/**
 * Smart Search Styles for Wave Movies
 * Netflix-style search with fuzzy matching
 */

/* ===== SEARCH INPUT STYLES ===== */
.smart-search-input {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    background: rgba(26, 26, 46, 0.8);
    color: #fff;
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
}

.smart-search-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.smart-search-input:hover {
    border-color: rgba(229, 9, 20, 0.3);
    background: rgba(26, 26, 46, 0.95);
}

.smart-search-input:focus {
    outline: none;
    border-color: #e50914;
    box-shadow: 
        0 0 0 3px rgba(229, 9, 20, 0.15),
        0 4px 20px rgba(229, 9, 20, 0.1);
    background: rgba(26, 26, 46, 1);
}

.smart-search-input.searching {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24'%3E%3Cpath fill='%23e50914' d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 18px;
}

/* ===== SEARCH RESULTS CONTAINER ===== */
.smart-search-results,
.search-results-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 0.75rem;
    background: linear-gradient(145deg, #1a1a2e 0%, #16213e 100%);
    border: 1px solid rgba(229, 9, 20, 0.2);
    border-radius: 12px;
    max-height: 450px;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 10000;
    display: none;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(255, 255, 255, 0.05);
    animation: fadeInUp 0.2s ease-out;
}

.smart-search-results.active,
.search-results-dropdown.active {
    display: block;
}

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

/* Scrollbar styling */
.smart-search-results::-webkit-scrollbar,
.search-results-dropdown::-webkit-scrollbar {
    width: 6px;
}

.smart-search-results::-webkit-scrollbar-track,
.search-results-dropdown::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 3px;
}

.smart-search-results::-webkit-scrollbar-thumb,
.search-results-dropdown::-webkit-scrollbar-thumb {
    background: rgba(229, 9, 20, 0.3);
    border-radius: 3px;
}

.smart-search-results::-webkit-scrollbar-thumb:hover,
.search-results-dropdown::-webkit-scrollbar-thumb:hover {
    background: rgba(229, 9, 20, 0.5);
}

/* ===== SEARCH RESULT ITEMS ===== */
.search-results-list,
.search-list {
    padding: 0.75rem;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem;
    text-decoration: none;
    color: #fff;
    transition: all 0.2s ease;
    border-radius: 10px;
    margin-bottom: 0.5rem;
    border: 1px solid transparent;
    position: relative;
    overflow: hidden;
}

.search-result-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #e50914;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.search-result-item:hover,
.search-result-item.selected {
    background: rgba(229, 9, 20, 0.1);
    border-color: rgba(229, 9, 20, 0.2);
    transform: translateX(3px);
}

.search-result-item:hover::before,
.search-result-item.selected::before {
    opacity: 1;
}

.search-result-item.first {
    background: linear-gradient(90deg, rgba(229, 9, 20, 0.15) 0%, transparent 100%);
    border-left: 3px solid #e50914;
}

/* Movie vs TV styling */
.search-result-item.movie {
    --type-color: #2ecc71;
}

.search-result-item.tv {
    --type-color: #e74c3c;
}

/* Thumbnail */
.result-thumb {
    flex-shrink: 0;
    width: 55px;
    height: 80px;
    border-radius: 6px;
    overflow: hidden;
    background: linear-gradient(135deg, #2c3e50 0%, #1a1a2e 100%);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    position: relative;
}

.result-thumb::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, transparent 60%, rgba(0,0,0,0.5));
    pointer-events: none;
}

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

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

/* Result Info */
.result-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

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

.result-title mark {
    background: linear-gradient(135deg, #e50914 0%, #ff6b6b 100%);
    color: #fff;
    padding: 1px 4px;
    border-radius: 3px;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(229, 9, 20, 0.3);
}

/* Meta badges */
.result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    font-size: 0.75rem;
}

.type-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.type-badge.movie {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    color: #fff;
}

.type-badge.tv {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: #fff;
}

.rating {
    color: #f1c40f;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.quality-badge {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    color: #fff;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 700;
}

.year {
    color: rgba(255, 255, 255, 0.5);
}

.score {
    color: #2ecc71;
    font-weight: 700;
    font-size: 0.7rem;
}

.result-genre {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== LOADING STATE ===== */
.search-loading,
#searchLoading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
}

.search-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid rgba(229, 9, 20, 0.2);
    border-top-color: #e50914;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ===== NO RESULTS / ERROR STATES ===== */
.search-no-results,
.search-error,
#searchNoResults {
    padding: 2.5rem 1.5rem;
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
}

.search-no-results svg,
#searchNoResults svg {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.search-no-results p,
#searchNoResults p {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.7);
}

.search-no-results small {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.4);
}

.search-error {
    color: #e74c3c;
}

/* ===== VIEW ALL / MORE RESULTS ===== */
.search-more {
    padding: 1rem;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.view-all {
    color: #e50914;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    padding: 0.5rem 1rem;
    border-radius: 6px;
}

.view-all:hover {
    background: rgba(229, 9, 20, 0.1);
    text-decoration: none;
}

/* ===== MOBILE SEARCH ===== */
.mobile-search-section {
    padding: 1rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 0.5rem;
}

.smart-search-input.mobile {
    background: rgba(0, 0, 0, 0.3);
}

.mobile-search-results {
    position: relative;
    top: 0;
    margin-top: 0.5rem;
    max-height: 300px;
}

/* ===== HEADER INTEGRATION ===== */
.header-search {
    position: relative;
    flex: 1;
    max-width: 500px;
    margin: 0 1.5rem;
}

.search-box {
    position: relative;
}

.search-box .search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: rgba(255, 255, 255, 0.4);
    pointer-events: none;
    transition: color 0.2s ease;
}

#searchInput {
    padding-left: 2.75rem;
}

#searchInput:focus + .search-icon,
.search-box:focus-within .search-icon {
    color: #e50914;
}

.search-clear {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    border-radius: 50%;
    width: 24px;
    height: 24px;
}

#searchInput:not(:placeholder-shown) + .search-clear {
    opacity: 1;
    visibility: visible;
}

.search-clear:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.search-clear svg {
    width: 16px;
    height: 16px;
}

/* ===== MOBILE SEARCH ITEMS ===== */
.mobile-search-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    text-decoration: none;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.2s ease;
}

.mobile-search-item:hover,
.mobile-search-item:active {
    background: rgba(229, 9, 20, 0.1);
}

.mobile-search-item img {
    width: 45px;
    height: 65px;
    border-radius: 4px;
    object-fit: cover;
    background: #2c3e50;
}

.mobile-item-info {
    flex: 1;
    min-width: 0;
}

.mobile-item-title {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.25rem;
}

.mobile-item-meta {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
}

.mobile-no-results {
    padding: 1.5rem;
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.85rem;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1024px) {
    .header-search {
        max-width: 400px;
    }
}

@media (max-width: 768px) {
    .header-search {
        display: none;
    }

    .smart-search-results {
        position: fixed;
        top: 70px;
        left: 1rem;
        right: 1rem;
        max-height: calc(100vh - 100px);
        margin-top: 0;
    }

    .result-thumb {
        width: 50px;
        height: 70px;
    }

    .result-title {
        font-size: 0.9rem;
    }

    .result-meta {
        font-size: 0.7rem;
    }
}

@media (max-width: 480px) {
    .smart-search-results {
        left: 0.5rem;
        right: 0.5rem;
        border-radius: 8px;
    }

    .search-result-item {
        padding: 0.625rem;
        gap: 0.75rem;
    }

    .result-thumb {
        width: 45px;
        height: 60px;
    }

    .result-genre {
        display: none;
    }
}

/* ===== ANIMATIONS ===== */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.searching {
    animation: pulse 1.5s ease-in-out infinite;
}

/* ===== UTILITY CLASSES ===== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .smart-search-input {
        border-color: #fff;
    }

    .smart-search-input:focus {
        border-color: #e50914;
        box-shadow: 0 0 0 3px #e50914;
    }

    .search-result-item:hover,
    .search-result-item.selected {
        border-color: #e50914;
        outline: 2px solid #e50914;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .smart-search-input,
    .search-result-item,
    .view-all,
    .search-spinner {
        transition: none;
        animation: none;
    }

    .smart-search-results {
        animation: none;
    }
}
