/**
 * Road Diamond Product Search - Frontend Styles
 *
 * @package Road_Diamond_Product_Search
 */

/* ==========================================================================
   Container Layout - Force Full Width in Elementor
   ========================================================================== */

/* Target the Elementor widget wrapper - force it to take full available width */
.elementor-widget-rdps-product-search {
    width: 100% !important;
    max-width: none !important;
    flex: 1 1 100% !important;
    flex-grow: 1 !important;
    flex-shrink: 0 !important;
    flex-basis: 100% !important;
    min-width: 0 !important;
    align-self: stretch !important;
}

/* When widget is inside an Elementor flex container (e-con) */
.e-con>.e-con-inner>.elementor-widget-rdps-product-search,
.e-con .elementor-widget-rdps-product-search {
    width: 100% !important;
    flex: 1 1 100% !important;
}

/* Ensure the inner widget container also takes full width */
.elementor-widget-rdps-product-search .elementor-widget-container {
    width: 100% !important;
    max-width: none !important;
}

/* The main search container */
.rdps-search-container {
    width: 100% !important;
    max-width: none !important;
    box-sizing: border-box;
    display: block;
}

.rdps-search-container * {
    box-sizing: border-box;
}

/* No items message styling */
.rdps-no-items {
    color: #999 !important;
    font-style: italic;
    cursor: default !important;
}

.rdps-no-items:hover {
    background-color: transparent !important;
}

.rdps-search-row {
    display: flex;
    gap: 0;
    margin-bottom: 15px;
    width: 100%;
}

.rdps-filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    width: 100%;
}

/* ==========================================================================
   Search Input
   ========================================================================== */

.rdps-search-input {
    flex: 1;
    min-width: 200px;
    padding: 12px 15px;
    font-size: 14px;
    line-height: 1.5;
    border: 1px solid #ddd;
    border-right: none;
    border-radius: 4px 0 0 4px;
    background-color: #fff;
    color: #333;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.rdps-search-input:focus {
    outline: none;
    border-color: #20b2aa;
    box-shadow: 0 0 0 1px #20b2aa;
}

.rdps-search-input::placeholder {
    color: #999;
}

/* ==========================================================================
   Search Button
   ========================================================================== */

.rdps-search-button {
    padding: 12px 30px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.5;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
    border-radius: 0 4px 4px 0;
    background-color: #20b2aa;
    color: #fff;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    white-space: nowrap;
}

.rdps-search-button:hover {
    background-color: #1a9a92;
}

.rdps-search-button:active {
    transform: scale(0.98);
}

/* ==========================================================================
   Dropdown Container
   ========================================================================== */

.rdps-dropdown {
    position: relative;
    display: inline-block;
    flex: 1;
    min-width: 200px;
}

/* ==========================================================================
   Dropdown Toggle Button
   ========================================================================== */

.rdps-dropdown-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
    text-align: left;
    border: none;
    border-radius: 4px;
    background-color: #20b2aa;
    color: #fff;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.rdps-dropdown-toggle:hover {
    background-color: #1a9a92;
}

.rdps-dropdown.active .rdps-dropdown-toggle {
    background-color: #178a83;
    border-radius: 4px 4px 0 0;
}

.rdps-dropdown-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rdps-dropdown-arrow {
    display: flex;
    align-items: center;
    margin-left: 10px;
    transition: transform 0.2s ease;
}

.rdps-dropdown.active .rdps-dropdown-arrow {
    transform: rotate(180deg);
}

/* ==========================================================================
   Dropdown Menu
   ========================================================================== */

.rdps-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    display: none;
    max-height: 300px;
    overflow-y: auto;
    background-color: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.rdps-dropdown.active .rdps-dropdown-menu {
    display: block;
    animation: rdps-slideDown 0.2s ease;
}

@keyframes rdps-slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   Dropdown Menu Items
   ========================================================================== */

.rdps-dropdown-menu label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    margin: 0;
    font-size: 14px;
    font-weight: normal;
    line-height: 1.4;
    color: #333;
    cursor: pointer;
    transition: background-color 0.15s ease;
    border-bottom: 1px solid #f0f0f0;
}

.rdps-dropdown-menu label:last-child {
    border-bottom: none;
}

.rdps-dropdown-menu label:hover {
    background-color: #f5f5f5;
}

.rdps-dropdown-menu label.selected {
    background-color: #e8f8f7;
}

/* ==========================================================================
   Checkbox Styling
   ========================================================================== */

.rdps-dropdown-menu input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    flex-shrink: 0;
    accent-color: #20b2aa;
    cursor: pointer;
}

/* Custom checkbox for better cross-browser support */
.rdps-dropdown-menu input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid #ccc;
    border-radius: 3px;
    background-color: #fff;
    position: relative;
    transition: all 0.15s ease;
}

.rdps-dropdown-menu input[type="checkbox"]:hover {
    border-color: #20b2aa;
}

.rdps-dropdown-menu input[type="checkbox"]:checked {
    background-color: #20b2aa;
    border-color: #20b2aa;
}

.rdps-dropdown-menu input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* ==========================================================================
   Loading State
   ========================================================================== */

.rdps-search-container.loading {
    pointer-events: none;
    opacity: 0.7;
}

.rdps-search-container.loading .rdps-search-button::after {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-left: 8px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: rdps-spin 0.8s linear infinite;
}

@keyframes rdps-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==========================================================================
   Product Grid Filtering
   ========================================================================== */

.rdps-product-hidden {
    display: none !important;
}

.rdps-product-fade-in {
    animation: rdps-fadeIn 0.3s ease;
}

@keyframes rdps-fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ==========================================================================
   No Results Message
   ========================================================================== */

.rdps-no-results {
    padding: 40px 20px;
    text-align: center;
    color: #666;
    font-size: 16px;
    background-color: #f9f9f9;
    border-radius: 4px;
    margin-top: 20px;
}

.rdps-no-results strong {
    display: block;
    margin-bottom: 10px;
    font-size: 18px;
    color: #333;
}

/* ==========================================================================
   AI Correction Banner
   ========================================================================== */

.rdps-ai-correction {
    padding: 12px 18px;
    margin-bottom: 16px;
    font-size: 18px;
    line-height: 1.5;
    letter-spacing: 0.5px;
    color: #1a5c57;
    background: linear-gradient(135deg, #e8f8f7, #d0f0ee);
    border: 1px solid #b8e8e4;
    border-left: 4px solid #20b2aa;
    border-radius: 4px;
    animation: rdps-slideInBanner 0.3s ease;
}

.rdps-ai-icon {
    font-size: 20px;
    margin-right: 4px;
}

.rdps-ai-correction strong {
    color: #0d4a45;
}

.rdps-ai-original {
    color: #6b9e9a;
    font-size: 13px;
}

@keyframes rdps-slideInBanner {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   Selection Badge
   ========================================================================== */

.rdps-selection-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    margin-left: 8px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    color: #20b2aa;
    background-color: #fff;
    border-radius: 10px;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
    .rdps-search-row {
        flex-direction: column;
    }

    .rdps-search-input {
        border-right: 1px solid #ddd;
        border-radius: 4px;
        margin-bottom: 10px;
    }

    .rdps-search-button {
        border-radius: 4px;
        width: 100%;
    }

    .rdps-filters-row {
        flex-direction: column;
    }

    .rdps-dropdown {
        width: 100%;
        min-width: unset;
    }
}

@media (max-width: 480px) {
    .rdps-dropdown-toggle {
        padding: 10px 15px;
        font-size: 13px;
    }

    .rdps-dropdown-menu label {
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* ==========================================================================
   Scrollbar Styling
   ========================================================================== */

.rdps-dropdown-menu::-webkit-scrollbar {
    width: 6px;
}

.rdps-dropdown-menu::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.rdps-dropdown-menu::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.rdps-dropdown-menu::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .rdps-search-container {
        display: none;
    }
}

/* ==========================================================================
   Single/Few Results - Prevent Thin Product Cards
   ========================================================================== */

/* Single result - make product card larger and centered */
ul.products.rdps-single-result {
    justify-content: center !important;
}

ul.products.rdps-single-result li.product:not(.rdps-product-hidden) {
    width: 350px !important;
    max-width: 100% !important;
    flex: 0 0 350px !important;
}

/* Few results (2-3) - reasonable sizing */
ul.products.rdps-few-results li.product:not(.rdps-product-hidden) {
    width: 280px !important;
    flex: 0 0 280px !important;
    max-width: 100% !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {

    ul.products.rdps-single-result li.product:not(.rdps-product-hidden),
    ul.products.rdps-few-results li.product:not(.rdps-product-hidden) {
        width: 100% !important;
        max-width: 300px !important;
        flex: 0 0 100% !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }
}