/* ============================= */
/* SEARCH OVERLAY WRAPPER */
/* ============================= */

#search-overlay-ui {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;

    display: flex;
    justify-content: center;
    align-items: flex-start;

    padding-top: 100px;

    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(6px);

    opacity: 0;
    visibility: hidden;
    transition: all .3s ease;

    z-index: 9999;
    pointer-events: none;
}

/* Active */
#search-overlay-ui.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Fix for heading visibility - override transparent text */
.banner-small-heading {
    -webkit-text-fill-color: initial !important;
    background-clip: initial !important;
    color: #fff !important;
}

/* ============================= */
/* SEARCH BOX */
/* ============================= */

#search-overlay-ui .search-box {
    width: 900px;
    max-width: 95%;
    background: #0f0f0f;
    border-radius: 16px;
    padding: 25px;
    box-shadow: 0 20px 60px rgba(0,0,0,.9);
}

/* ============================= */
/* INPUT WRAPPER */
/* ============================= */


.search-input-wrapper {
    position: relative;
    width: 100%;
    max-width:900px;   /* limit width */
    margin: 0 auto;     /* center it */
}

.search-input-wrapper input {
    width: 100%;
    box-sizing: border-box;  /* VERY IMPORTANT */
    padding: 16px 60px 16px 45px;
    font-size: 16px;
    background: #1a1a1a;
    border: 2px solid #222;
    border-radius: 12px;
    color: #fff;
    outline: none;
    transition: border-color 0.3s ease;
}

.search-input-wrapper input:focus {
    border-color: #E50914;
}


/* SEARCH ICON */

.search-input-wrapper .search-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: #888;
}

/* CLEAR */

.search-input-wrapper .clear-text {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    color: #aaa;
    cursor: pointer;
    display: none;
}

.search-input-wrapper .clear-text:hover {
    color: #fff;
}

/* ============================= */
/* RESULTS */
/* ============================= */

#search-results {
    margin-top: 20px;
    max-height: 60vh;
    overflow-y: auto;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Remove empty check that might cause issues */
#search-results {
    min-height: 50px;
}

/* Force all children to display */
#search-results > * {
    display: block !important;
}

/* Scrollbar */

#search-results::-webkit-scrollbar {
    width: 6px;
}
#search-results::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
}

/* ============================= */
/* TEXT SUGGESTIONS */
/* ============================= */

.search-suggestions-section {
    margin-bottom: 20px;
}

.search-suggestion-header {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #666;
    margin-bottom: 10px;
    padding-left: 4px;
}

.search-suggestion-items {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.search-suggestion-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 8px;
    color: #ccc;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.search-suggestion-item:hover {
    background: #252525;
    border-color: #444;
    color: #fff;
}

.search-suggestion-item svg {
    color: #666;
}

.search-suggestion-item.recent {
    padding: 8px 14px;
}

.search-suggestion-item.browse-items {
    background: transparent;
    border: none;
    padding: 0;
}

.search-suggestion-item.category {
    background: #1a1a1a;
    border: 1px solid #333;
    padding: 8px 16px;
}

.search-suggestion-item.category:hover {
    border-color: #E50914;
    color: #E50914;
}

/* ============================= */
/* CONTENT SECTIONS */
/* ============================= */

.search-content-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #222;
}

.search-content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
}

.search-content-title {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
}

.search-content-count {
    font-size: 12px;
    color: #666;
    background: #222;
    padding: 4px 10px;
    border-radius: 20px;
}

.search-content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.search-content-card {
    cursor: pointer;
    transition: transform 0.2s ease;
}

.search-content-card:hover {
    transform: translateY(-4px);
}

.search-content-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: 10px;
    overflow: hidden;
    background: #1a1a1a;
}

.search-content-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.search-content-card:hover .search-content-thumb img {
    transform: scale(1.05);
}

.search-content-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.search-content-card:hover .search-content-overlay {
    opacity: 1;
}

.search-content-overlay svg {
    color: #fff;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.search-content-info {
    padding: 10px 4px;
}

.search-content-name {
    font-size: 13px;
    font-weight: 500;
    color: #ddd;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.search-content-meta {
    font-size: 11px;
    color: #666;
    display: flex;
    gap: 8px;
}

.search-content-meta span {
    background: #1a1a1a;
    padding: 2px 8px;
    border-radius: 4px;
}

/* ============================= */
/* LOADING & NO RESULTS */
/* ============================= */

.search-loading,
.search-error,
.search-no-results {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-size: 14px;
}

.search-loading {
    color: #E50914;
}

.search-error {
    color: #ff4444;
}

/* ============================= */
/* RESULT GRID (LEGACY) */
/* ============================= */

.search-result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
}

/* CARD */

.search-result-card {
    background: #1c1c1c;
    border-radius: 12px;
    padding: 10px;
    cursor: pointer;
    transition: .25s ease;
    text-align: center;
}

.search-result-card:hover {
    background: #262626;
    transform: translateY(-4px);
}

.search-result-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 10px;
}

.search-result-card .title {
    font-size: 14px;
    margin-top: 8px;
    color: #ddd;
}

/* ============================= */
/* MOBILE ADJUSTMENTS */
/* ============================= */

@media (max-width: 768px) {

    #search-overlay-ui {
        padding-top: 110px;
    }

    #search-overlay-ui .search-box {
        padding: 18px;
        border-radius: 12px;
    }

    .search-input-wrapper input {
        font-size: 15px;
        padding: 14px 80px 14px 45px;
    }

    .search-content-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    
    .search-suggestion-items {
        gap: 8px;
    }
    
    .search-suggestion-item {
        padding: 8px 12px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .search-content-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================= */
/* NEW ENHANCED STYLES */
/* ============================= */

/* Clear all button */
.search-suggestion-header .clear-all {
    font-size: 11px;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    color: #E50914;
    cursor: pointer;
    float: right;
    transition: color 0.2s ease;
}

.search-suggestion-header .clear-all:hover {
    color: #ff6b6b;
}

/* Trending searches */
.search-suggestion-item.trending {
    background: linear-gradient(135deg, #1a1a1a 0%, #252525 100%);
    border-color: #333;
}

.search-suggestion-item.trending svg {
    color: #E50914;
}

.search-suggestion-item.trending:hover {
    border-color: #E50914;
    background: linear-gradient(135deg, #252525 0%, #2a2a2a 100%);
}

/* Category header */
.search-suggestion-header.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    margin-bottom: 8px;
}

.search-suggestion-header .count {
    font-size: 11px;
    color: #888;
    background: #222;
    padding: 2px 8px;
    border-radius: 10px;
}

/* Selected item (keyboard navigation) */
.search-suggestion-item.selected {
    background: #E50914 !important;
    border-color: #E50914 !important;
    color: #fff !important;
}

.search-suggestion-item.selected svg {
    color: #fff !important;
}

/* Highlighted text */
.search-suggestion-item strong {
    color: #E50914;
    font-weight: 700;
}

/* Empty state */
.search-empty-state {
    text-align: center;
    padding: 50px 20px;
    color: #666;
}

.search-empty-state svg {
    color: #333;
    margin-bottom: 20px;
}

.search-empty-state p {
    font-size: 16px;
    color: #888;
    margin-bottom: 25px;
}

.search-tips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.search-tips .tip-label {
    color: #555;
    font-size: 13px;
}

.search-tips .tip-item {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    color: #ccc;
    cursor: pointer;
    transition: all 0.2s ease;
}

.search-tips .tip-item:hover {
    background: #E50914;
    border-color: #E50914;
    color: #fff;
}

/* No results */
.search-no-results .suggestion-text {
    color: #555;
    font-size: 13px;
    margin-top: 10px;
}

/* ============================= */
/* API GENERATED CARD STYLES */
/* ============================= */

/* Cards wrapper */
.search-suggestion-cards {
    margin-top: 20px;
}

/* Category section */
.search-card-section {
    margin-bottom: 24px;
}

.search-card-section:last-child {
    margin-bottom: 0;
}

/* Category header */
.search-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding: 0 4px;
}

.search-card-header span:first-child {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    text-transform: capitalize;
}

.search-card-header .count {
    font-size: 11px;
    color: #888;
    background: #222;
    padding: 2px 8px;
    border-radius: 10px;
}

/* Card grid */
.search-card-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
}

/* Individual card */
.search-card-item {
    cursor: pointer;
    transition: transform 0.2s ease;
}

.search-card-item:hover {
    transform: translateY(-4px);
}

/* Thumbnail */
.search-card-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: 8px;
    overflow: hidden;
    background: #1a1a1a;
}

.search-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.search-card-item:hover .search-card-thumb img {
    transform: scale(1.05);
}

/* Play overlay */
.search-card-thumb .play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.search-card-item:hover .play-overlay {
    opacity: 1;
}

.search-card-thumb .play-overlay svg {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

/* Card info */
.search-card-info {
    padding: 8px 4px;
}

.search-card-title {
    font-size: 13px;
    color: #ddd;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================= */
/* RESPONSIVE FOR CARDS */
/* ============================= */

@media (max-width: 1200px) {
    .search-card-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media (max-width: 992px) {
    .search-card-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 768px) {
    .search-card-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    
    .search-card-header {
        margin-bottom: 8px;
    }
    
    .search-card-header span:first-child {
        font-size: 13px;
    }
    
    .search-card-title {
        font-size: 12px;
    }
    
    .search-card-info {
        padding: 6px 2px;
    }
}

@media (max-width: 480px) {
    .search-card-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

/* ============================= */
/* SEARCH CATEGORY SECTION & FILTER */
/* ============================= */

.search-category-section {
    margin-bottom: 30px;
}

.search-category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 5px;
    flex-wrap: wrap;
    gap: 10px;
}

.search-category-header .banner-small-heading {
    margin: 0 !important;
    font-size: 20px !important;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.filter-dropdown {
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%) !important;
    color: #fff !important;
    border: 1px solid rgba(255,255,255,0.1) !important;
    padding: 8px 35px 8px 14px !important;
    border-radius: 25px !important;
    cursor: pointer !important;
    font-size: 13px !important;
    font-weight: 500;
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    transition: all 0.3s ease !important;
    min-width: 100px;
}

.filter-dropdown:hover {
    border-color: #E50914 !important;
    background: linear-gradient(135deg, #E50914 0%, #800108 100%) !important;
}

.filter-dropdown:focus {
    outline: none !important;
    border-color: #E50914 !important;
    box-shadow: 0 0 0 2px rgba(229, 9, 20, 0.3) !important;
}

.filter-dropdown option {
    background: linear-gradient(180deg, #E50914 0%, #800108 100%) !important;
    color: #fff !important;
    padding: 10px;
}

.filter-dropdown option:hover {
    background: #800108 !important;

    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: all 0.3s ease;
}

.filter-dropdown option {
    background: #1a1a1a !important;
    color: #fff !important;
    padding: 10px;
}

/* ============================= */
/* CUSTOM FILTER DROPDOWN */
/* ============================= */

.custom-filter-dropdown {
    position: relative;
    display: inline-block;
}

.custom-filter-dropdown .filter-selected {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px 30px 8px 14px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 100px;
    transition: all 0.3s ease;
}

.custom-filter-dropdown .filter-selected:hover {
    border-color: #E50914;
    background: black;
}

.custom-filter-dropdown .filter-arrow {
    transition: transform 0.3s ease;
    margin-left: 8px;
}

.custom-filter-dropdown.open .filter-arrow {
    transform: rotate(180deg);
}

.custom-filter-dropdown .filter-options {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 5px;
    background: black;
    border-radius: 10px;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 100;
    min-width: 120px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.custom-filter-dropdown.open .filter-options {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.custom-filter-dropdown .filter-option {
    padding: 10px 15px;
    color: #fff;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s ease;
}

.custom-filter-dropdown .filter-option:hover {
    background: rgba(255,255,255,0.2);
}

.custom-filter-dropdown .filter-option.selected {
    background: rgba(0,0,0,0.2);
    font-weight: 600;
}

/* ============================= */
/* SKELETON LOADING STATES */
/* ============================= */

.search-skeleton-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    padding: 15px 5px;
}

.skeleton-card {
    background: #1a1a1a;
    border-radius: 8px;
    overflow: hidden;
    padding: 0;
}

.skeleton-image {
    width: 100%;
    aspect-ratio: 16/9;
    background: linear-gradient(90deg, #1a1a1a 25%, #2d2d2d 50%, #1a1a1a 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.skeleton-text {
    height: 14px;
    margin: 10px 8px 5px;
    border-radius: 4px;
    background: linear-gradient(90deg, #1a1a1a 25%, #2d2d2d 50%, #1a1a1a 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    animation-delay: 0.1s;
}

.skeleton-text.short {
    width: 60%;
    margin-top: 5px;
    animation-delay: 0.2s;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Lazy load image states - base */
.search-category-grid .lazy-load {
    transition: all 0.3s ease;
}

/* Skeleton state - only when NOT loaded */
.search-category-grid .lazy-load:not(.loaded) {
    background: linear-gradient(90deg, rgba(30, 30, 30, 0.8) 25%, rgba(50, 50, 50, 0.8) 50%, rgba(30, 30, 30, 0.8) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
}

/* Type5/Type40/Type41 on search results - ALWAYS apply filter */
.search-category-grid .hovered .lazy-load,
.search-category-grid .hovered .posterimage,
.search-category-grid .prime-item .lazy-load,
.search-category-grid .rank-item .lazy-load {
    filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.35));
}

/* Loaded state - remove shimmer but keep filter */
.search-category-grid .lazy-load.loaded {
    background: transparent;
    animation: none;
    border: none;
    border-radius: 0;
}

/* ============================= */
/* RESPONSIVE STYLES */
/* ============================= */

@media (max-width: 768px) {
    .search-category-header {
        padding: 12px 5px;
        gap: 8px;
    }
    
    .search-category-header .banner-small-heading {
        font-size: 18px !important;
    }
    
    .custom-filter-dropdown .filter-selected {
        padding: 7px 25px 7px 12px;
        font-size: 12px;
        min-width: 85px;
        border-radius: 20px;
    }
    
    .custom-filter-dropdown .filter-options {
        min-width: 100px;
        border-radius: 8px;
    }
    
    .custom-filter-dropdown .filter-option {
        padding: 8px 12px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .search-category-header {
        padding: 10px 5px;
        gap: 8px;
    }
    
    .search-category-header .banner-small-heading {
        font-size: 16px !important;
    }
    
    .custom-filter-dropdown .filter-selected {
        padding: 6px 22px 6px 10px;
        font-size: 11px;
        min-width: 75px;
        border-radius: 18px;
    }
    
    .custom-filter-dropdown .filter-options {
        min-width: 90px;
        border-radius: 8px;
    }
    
    .custom-filter-dropdown .filter-option {
        padding: 7px 10px;
        font-size: 11px;
    }
}

/* ============================================
   INFINITE SCROLL STYLES
   Zero impact on existing UI
   ============================================ */

.lazy-item {
    display: none;
}

.lazy-item.visible {
    display: block;
    animation: fadeInLazy 0.4s ease-out;
}

@keyframes fadeInLazy {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.infinite-scroll-trigger {
    width: 100%;
    height: 1px;
    pointer-events: none;
}
