/* ===================================================
   Perfect Opticals – Premium Search Bar
   =================================================== */

/* ── Container ── */
.header-search {
    position: relative;
    width: 360px;
    flex-shrink: 0;
    z-index: 2100;
}

/* ── Input Wrapper ── */
.search-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    background: #1a1e2e;
    border: 1px solid rgba(201, 168, 108, 0.22);
    border-radius: 40px;
    padding: 0 14px;
    height: 42px;
    gap: 8px;
    transition: border-color 0.25s, box-shadow 0.25s;
}

.search-input-wrap:focus-within {
    border-color: #c9a86c;
    box-shadow: 0 0 0 3px rgba(201, 168, 108, 0.12);
}

.search-icon {
    color: #6b7280;
    font-size: 14px;
    flex-shrink: 0;
    pointer-events: none;
    transition: color 0.25s;
}

.search-input-wrap:focus-within .search-icon {
    color: #c9a86c;
}

.search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #e8e8e8;
    font-family: var(--font-body, 'Lato', sans-serif);
    font-size: 13.5px;
    font-weight: 400;
    letter-spacing: 0.2px;
    min-width: 0;
    caret-color: #c9a86c;
}

.search-input::placeholder {
    color: #4b5568;
    font-weight: 400;
}

/* Clear button */
.search-clear-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: #6b7280;
    font-size: 13px;
    padding: 2px 4px;
    border-radius: 50%;
    line-height: 1;
    transition: color 0.2s, background 0.2s;
    flex-shrink: 0;
}

.search-clear-btn:hover {
    color: #c9a86c;
    background: rgba(201, 168, 108, 0.1);
}

.search-clear-btn.visible {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Dropdown ── */
.search-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    right: 0;
    background: #161b27;
    border: 1px solid rgba(201, 168, 108, 0.15);
    border-radius: 14px;
    box-shadow:
        0 24px 60px rgba(0, 0, 0, 0.6),
        0 6px 20px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(201, 168, 108, 0.06);
    z-index: 3000;
    max-height: 440px;
    display: flex;
    flex-direction: column;
    overflow: hidden;

    /* Hidden by default */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px) scale(0.99);
    transform-origin: top center;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
    pointer-events: none;
}

.search-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ── Dropdown inner scroll area ── */
.search-results-list {
    overflow-y: auto;
    flex: 1;
    padding: 6px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(201, 168, 108, 0.2) transparent;
}

.search-results-list::-webkit-scrollbar {
    width: 4px;
}

.search-results-list::-webkit-scrollbar-track {
    background: transparent;
}

.search-results-list::-webkit-scrollbar-thumb {
    background: rgba(201, 168, 108, 0.25);
    border-radius: 4px;
}

/* ── Single Result Item ── */
.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.18s;
    border-radius: 0;
    position: relative;
}

.search-result-item:hover,
.search-result-item.focused {
    background: rgba(201, 168, 108, 0.07);
    outline: none;
}

.search-result-item:hover .search-item-name,
.search-result-item.focused .search-item-name {
    color: #c9a86c;
}

/* Product image */
.search-item-img-wrap {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    background: #1d2130;
    border: 1px solid rgba(201, 168, 108, 0.1);
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-item-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.25s;
}

.search-result-item:hover .search-item-img {
    transform: scale(1.06);
}

.search-item-img-placeholder {
    color: #374151;
    font-size: 22px;
}

/* Text info */
.search-item-info {
    flex: 1;
    min-width: 0;
}

.search-item-name {
    font-family: var(--font-heading, 'Oswald', sans-serif);
    font-size: 13px;
    font-weight: 600;
    color: #e5e7eb;
    letter-spacing: 0.3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.18s;
    margin-bottom: 3px;
}

.search-item-meta {
    font-family: var(--font-body, 'Lato', sans-serif);
    font-size: 11.5px;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-item-meta-sep {
    margin: 0 4px;
    color: #374151;
}

/* Price + badge area */
.search-item-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.search-item-price {
    font-family: var(--font-body, 'Lato', sans-serif);
    font-size: 13px;
    font-weight: 600;
    color: #c9a86c;
    white-space: nowrap;
}

.search-oos-badge {
    font-family: var(--font-body, 'Lato', sans-serif);
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.6px;
    color: #f87171;
    background: rgba(248, 113, 113, 0.12);
    border: 1px solid rgba(248, 113, 113, 0.25);
    padding: 2px 7px;
    border-radius: 20px;
    text-transform: uppercase;
    white-space: nowrap;
}

/* ── Text Highlight ── */
.search-highlight {
    background: transparent;
    color: #c9a86c;
    font-weight: 700;
    border-radius: 2px;
    padding: 0;
}

/* ── Divider between items ── */
.search-result-divider {
    height: 1px;
    background: rgba(201, 168, 108, 0.06);
    margin: 0 14px;
}

/* ── Loading State ── */
.search-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 28px 20px;
    gap: 10px;
}

.search-state-icon {
    font-size: 28px;
    color: #374151;
}

.search-state-text {
    font-family: var(--font-body, 'Lato', sans-serif);
    font-size: 13px;
    color: #6b7280;
    text-align: center;
}

/* Spinner */
.search-spinner {
    width: 28px;
    height: 28px;
    border: 2.5px solid rgba(201, 168, 108, 0.12);
    border-top-color: #c9a86c;
    border-radius: 50%;
    animation: search-spin 0.75s linear infinite;
}

@keyframes search-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── Recent Searches ── */
.search-recent-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px 6px;
    border-bottom: 1px solid rgba(201, 168, 108, 0.06);
}

.search-recent-title {
    font-family: var(--font-heading, 'Oswald', sans-serif);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 1px;
    color: #6b7280;
    text-transform: uppercase;
}

.search-recent-clear {
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font-body, 'Lato', sans-serif);
    font-size: 11px;
    color: #4b5568;
    padding: 2px 6px;
    border-radius: 4px;
    transition: color 0.18s, background 0.18s;
}

.search-recent-clear:hover {
    color: #f87171;
    background: rgba(248, 113, 113, 0.08);
}

.search-recent-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    cursor: pointer;
    color: #9ca3af;
    font-family: var(--font-body, 'Lato', sans-serif);
    font-size: 13px;
    transition: background 0.18s, color 0.18s;
}

.search-recent-item:hover,
.search-recent-item.focused {
    background: rgba(201, 168, 108, 0.06);
    color: #e5e7eb;
}

.search-recent-item i {
    font-size: 12px;
    color: #4b5568;
    flex-shrink: 0;
    transition: color 0.18s;
}

.search-recent-item:hover i {
    color: #c9a86c;
}

/* ── View All Button ── */
.search-view-all-wrap {
    padding: 8px 10px;
    border-top: 1px solid rgba(201, 168, 108, 0.08);
    flex-shrink: 0;
}

.search-view-all {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    background: rgba(201, 168, 108, 0.08);
    border: 1px solid rgba(201, 168, 108, 0.2);
    border-radius: 8px;
    color: #c9a86c;
    font-family: var(--font-heading, 'Oswald', sans-serif);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.search-view-all:hover {
    background: rgba(201, 168, 108, 0.16);
    border-color: rgba(201, 168, 108, 0.45);
    color: #e8c87a;
}

/* ── RESPONSIVE ── */

/* 1200px */
@media (max-width: 1200px) {
    .header-search {
        width: 260px;
    }
}

@media (max-width: 1120px) and (min-width: 993px) {
    .header-search {
        width: 210px;
    }
}

/* 992px – hide from horizontal nav, move to mobile drawer or top */
@media (max-width: 992px) {
    .header-search {
        /* Hidden in standard header layout; shown via mobile search toggle */
        display: none;
    }

    .header-search.mobile-search-open {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        width: 100%;
        z-index: 3500;
        background: #0f1117;
        padding: 14px 16px;
        border-bottom: 1px solid rgba(201, 168, 108, 0.15);
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55);
    }

    .header-search.mobile-search-open .search-input-wrap {
        height: 46px;
    }

    .header-search.mobile-search-open .search-dropdown {
        position: fixed;
        top: 76px;
        left: 0;
        right: 0;
        border-radius: 0 0 14px 14px;
        max-height: calc(100dvh - 76px - 20px);
    }

    /* Mobile search toggle button */
    .search-mobile-btn {
        display: flex !important;
    }
}

/* Desktop: hide mobile toggle */
.search-mobile-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: #c8cdd8;
    font-size: 18px;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 50%;
    transition: color 0.25s, transform 0.2s;
    line-height: 1;
}

.search-mobile-btn:hover {
    color: #c9a86c;
    transform: translateY(-1px);
}

/* Mobile search close button inside the expanded panel */
.search-mobile-close {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: #6b7280;
    font-size: 20px;
    padding: 4px 8px;
    border-radius: 6px;
    line-height: 1;
    transition: color 0.2s;
    flex-shrink: 0;
    align-self: center;
}

@media (max-width: 992px) {
    .header-search.mobile-search-open .search-mobile-close {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .header-search.mobile-search-open .search-input-wrap {
        flex: 1;
    }

    .header-search.mobile-search-open>.search-input-row {
        display: flex;
        gap: 8px;
        width: 100%;
    }
}

/* Desktop 1200 container for item wrapping */
@media (max-width: 480px) {
    .search-item-img-wrap {
        width: 46px;
        height: 46px;
    }

    .search-item-name {
        font-size: 12px;
    }

    .search-item-meta {
        font-size: 10.5px;
    }

    .search-item-price {
        font-size: 12px;
    }
}