/* --- Premium Expanding Search Bar --- */
.search-box-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    width: 38px; /* Initial icon width */
    height: 38px;
    overflow: visible; /* Allow dropdown to show outside wrapper bounds */
}

/* Active State (Expanded) */
.search-input-wrapper.active {
    width: 340px;
    background: #141414;
    border-color: #333;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    overflow: visible; /* Keep visible so dropdown shows */
}

.search-input {
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    color: #fff;
    padding: 0 40px 0 16px; /* Space for icons */
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.search-input-wrapper.active .search-input {
    opacity: 1;
    pointer-events: auto;
}

.search-input:focus {
    outline: none;
}

.search-icon-btn, .search-close-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: color 0.2s;
}

.search-icon-btn {
    right: 8px; /* Icon stays on right */
    width: 24px;
    height: 24px;
    z-index: 2;
}

.search-input-wrapper.active .search-icon-btn {
    color: #e50914; /* Red icon when active */
}

.search-close-btn {
    right: 60px; /* Moved left — mic now sits to its right */
    font-size: 18px;
    color: #aaa;
    z-index: 3;
    width: 24px;
    height: 24px;
}

.search-mic-btn {
    position: absolute;
    top: 58%;
    transform: translateY(-50%);
    right: 36px; /* Now sits between close btn and search icon */
    width: 26px;
    height: 26px;
    border: none;
    background: transparent;
    color: #aaa;
    font-size: 20px;
    cursor: pointer;
    z-index: 3;
    display: none; /* JS will enable if supported */
    transition: color 0.2s;
}

.search-mic-btn:hover {
    color: #e50914;
}

.search-mic-btn.listening {
    color: #e50914;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: translateY(-50%) scale(1); opacity: 1; }
    50% { transform: translateY(-50%) scale(1.2); opacity: 0.8; }
    100% { transform: translateY(-50%) scale(1); opacity: 1; }
}

.search-close-btn:hover {
    color: #fff;
}

/* Suggestions Dropdown */
.search-suggestions {
    position: absolute;
    top: 100%;
    right: 0;
    width: 280px; /* Matches Expanded Input */
    background: #141414;
    border: 1px solid #333;
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    z-index: 1000;
    margin-top: 4px;
    overflow: hidden;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
}

.premium-search-header {
    padding: 10px 16px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #e50914;
    background: #1a1a1a;
    border-bottom: 1px solid #2a2a2a;
}

.premium-search-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid #222;
    text-decoration: none !important;
    transition: background 0.2s;
}

.premium-search-item:hover {
    background: #2a2a2a;
}

.search-poster {
    width: 32px;
    height: 44px;
    border-radius: 3px;
    object-fit: cover;
    margin-right: 12px;
    background: #333;
}

.search-info h6 {
    font-size: 13px;
    margin: 0;
    color: #fff;
    line-height: 1.2;
}

.search-info span {
    font-size: 11px;
    color: #999;
}

.search-empty {
    padding: 20px;
    text-align: center;
    font-size: 13px;
    color: #777;
}
 /* Premium OTT Search Dropdown Styles */
#search-suggestions {
    background: #141414;
    border: 1px solid #333;
    border-top: none;
    box-shadow: 0 15px 40px rgba(0,0,0,0.7);
    backdrop-filter: blur(10px);
    border-radius: 0 0 12px 12px;
    width: 340px;
    left: auto;
    right: 0;
    overflow: hidden;
    margin-top: 2px;
    z-index: 1060;
    display: flex;
    flex-direction: column;
    max-height: 480px; /* Cap dropdown height */
}

/* Scrollable results area inside the dropdown */
#search-suggestions .search-scroll-area {
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 400px; /* Hard cap — scroll kicks in after this */
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: #e50914 #1a1a1a;
    scroll-behavior: smooth;
}

/* Webkit custom scrollbar */
#search-suggestions .search-scroll-area::-webkit-scrollbar {
    width: 4px;
}
#search-suggestions .search-scroll-area::-webkit-scrollbar-track {
    background: #1a1a1a;
}
#search-suggestions .search-scroll-area::-webkit-scrollbar-thumb {
    background: #e50914;
    border-radius: 2px;
}
#search-suggestions .search-scroll-area::-webkit-scrollbar-thumb:hover {
    background: #ff1a1a;
}

/* Sticky section header */
#search-suggestions .premium-search-header {
    position: sticky;
    top: 0;
    z-index: 10;
}

/* View-all footer link */
.search-view-all {
    display: block;
    text-align: center;
    padding: 10px 16px;
    font-size: 12px;
    font-weight: 600;
    color: #e50914;
    background: #1a1a1a;
    border-top: 1px solid #2a2a2a;
    text-decoration: none !important;
    letter-spacing: 0.5px;
    transition: background 0.2s, color 0.2s;
    flex-shrink: 0;
}
.search-view-all:hover {
    background: #222;
    color: #ff4444;
}

.search-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 18px 16px;
    font-size: 13px;
    color: #aaa;
}

.search-loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(229, 9, 20, 0.25);
    border-top-color: #e50914;
    border-radius: 50%;
    animation: searchSpin 0.7s linear infinite;
    flex-shrink: 0;
}

@keyframes searchSpin {
    to { transform: rotate(360deg); }
}

.search-hint-label {
    padding: 8px 16px 4px;
    font-size: 11px;
    color: #888;
    letter-spacing: 0.3px;
}

.premium-search-item.is-active,
.premium-search-item:focus-visible {
    background: #252525;
    outline: none;
}

.premium-search-item.is-active .search-title,
.premium-search-item:hover .search-title {
    color: #e50914;
}

.search-title mark {
    background: rgba(229, 9, 20, 0.35);
    color: #fff;
    padding: 0 1px;
    border-radius: 2px;
}

.search-poster-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #e50914;
    font-size: 18px;
    background: #222;
}

.search-poster-container {
    position: relative;
    flex-shrink: 0;
    margin-right: 12px;
    width: 40px;
    height: 56px;
}

.search-poster-container .search-poster {
    width: 40px;
    height: 56px;
    object-fit: cover;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
    background-color: #333;
}

.search-poster-container .search-poster-fallback {
    width: 40px;
    height: 56px;
    border-radius: 4px;
}

/* Style the input field to match the dark theme */
.search-input-wrapper .search-input,
#search-query {
    background-color: transparent !important;
    border: none !important;
    color: #fff !important;
    box-shadow: none !important;
    height: 100% !important;
    padding-left: 15px;
    border-radius: 4px;
}

.search-input-wrapper.active .search-input,
.search-input-wrapper.active #search-query {
    background-color: transparent !important;
}

#search-query:focus,
.search-input-wrapper .search-input:focus {
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: #fff !important;
}

#search-query::placeholder,
.search-input-wrapper .search-input::placeholder {
    color: #888;
}

.premium-search-header {
    padding: 10px 16px;
    font-size: 0.7rem;
    font-weight: 800;
    color: #e50914; /* Brand Red */
    text-transform: uppercase;
    letter-spacing: 1.2px;
    background: #1a1a1a;
    border-bottom: 1px solid #2a2a2a;
}

.premium-search-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid #222;
    transition: all 0.2s ease;
    text-decoration: none !important;
    background: #141414;
    position: relative;
}

.premium-search-item:last-child {
    border-bottom: none;
}

.premium-search-item:hover {
    background: #1f1f1f;
    padding-left: 20px; /* Subtle slide effect */
}

.premium-search-item:hover .search-title {
    color: #e50914;
}

.search-poster-container {
    position: relative;
    flex-shrink: 0;
    margin-right: 12px;
}

.search-poster {
    width: 40px;
    height: 56px;
    object-fit: cover;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
    background-color: #333;
}

.search-info {
    flex-grow: 1;
    min-width: 0;
}

.search-title {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-meta {
    font-size: 0.7rem;
    color: #aaa;
    margin-top: 3px;
    display: flex;
    align-items: center;
    gap: 6px;
}

@media (max-width: 767.98px) {
    header .header-mobile-actions .search-box-container {
        display: flex;
        align-items: center;
    }

    header .header-mobile-actions .search-input-wrapper {
        width: 32px;
        height: 32px;
    }

    header .header-mobile-actions .search-icon-btn {
        width: 32px;
        height: 32px;
        right: 0;
    }
}

/* ── Mobile / tablet: full-width search panel ── */
@media (max-width: 1199.98px) {
    header .navbar .right-panel .search-box-container.search-panel-open,
    header .navbar .right-panel .search-box-container:has(.search-input-wrapper.active) {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1300;
        display: block;
        width: 100%;
        padding: 0.7rem 0.75rem 0.75rem;
        background: #0d0d0d;
        border-bottom: 1px solid #2a2a2a;
        box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
    }

    header .navbar .right-panel .search-box-container.search-panel-open .search-input-wrapper.active,
    header .navbar .right-panel .search-box-container:has(.search-input-wrapper.active) .search-input-wrapper.active {
        position: relative;
        top: auto;
        right: auto;
        left: auto;
        transform: none;
        width: 100% !important;
        max-width: none !important;
        height: 44px;
        border-radius: 8px;
        box-shadow: none;
    }

    .search-input-wrapper.active .search-input {
        padding: 0 92px 0 14px;
        font-size: 15px;
    }

    .search-input-wrapper.active .search-icon-btn {
        right: 10px;
    }

    .search-input-wrapper.active .search-mic-btn {
        right: 36px;
        top: 50%;
    }

    .search-input-wrapper.active .search-close-btn {
        right: 60px;
        display: flex !important;
    }

    header .navbar .right-panel .search-box-container.search-panel-open .search-suggestions,
    header .navbar .right-panel .search-box-container.search-panel-open #search-suggestions,
    header .navbar .right-panel .search-box-container:has(.search-input-wrapper.active) .search-suggestions,
    header .navbar .right-panel .search-box-container:has(.search-input-wrapper.active) #search-suggestions {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        width: 100% !important;
        max-width: none !important;
        max-height: min(62vh, 460px) !important;
        margin-top: 0.6rem !important;
        border-radius: 10px !important;
        border: 1px solid #2f2f2f !important;
        z-index: 1 !important;
        overflow: hidden;
    }

    #search-suggestions .search-scroll-area {
        max-height: min(50vh, 380px);
        scrollbar-color: #555 #1a1a1a;
    }

    #search-suggestions .search-scroll-area::-webkit-scrollbar-thumb {
        background: #555;
    }

    .premium-search-item {
        padding: 12px 14px;
        gap: 4px;
    }

    .premium-search-item:hover {
        padding-left: 14px;
    }

    .search-poster-container {
        margin-right: 12px;
    }

    .search-title {
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .search-hint-label {
        padding: 10px 14px 6px;
    }
}

@media (max-width: 575.98px) {
    header .navbar .right-panel .search-box-container.search-panel-open,
    header .navbar .right-panel .search-box-container:has(.search-input-wrapper.active) {
        padding: 0.6rem 0.6rem 0.65rem;
    }

    header .navbar .right-panel .search-box-container.search-panel-open .search-input-wrapper.active,
    header .navbar .right-panel .search-box-container:has(.search-input-wrapper.active) .search-input-wrapper.active {
        height: 42px;
    }

    #search-suggestions .search-scroll-area {
        max-height: min(48vh, 340px);
    }

    .search-poster-container,
    .search-poster-container .search-poster,
    .search-poster-container .search-poster-fallback {
        width: 36px;
        height: 50px;
    }

    .search-title {
        font-size: 0.85rem;
    }
}