/* Enhanced Search Layout CSS with Live Search Results */

/* Base Reset */
* {
    box-sizing: border-box;
}

/* Enhanced Search Bar Styles */
.search-bar-container {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #18122b;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    padding: 1rem;
    margin-bottom: 1.5rem;
    border-radius: 0 0 12px 12px;
    border: 1px solid #393053;
    border-top: none;
}

.search-wrapper {
    position: relative;
    max-width: 600px;
    margin: 0 auto;
}

.search-bar {
    width: 100%;
    background: #393053;
    border: 2px solid #635985;
    border-radius: 12px;
    padding: 1rem 3rem 1rem 3rem;
    font-size: 1rem;
    color: #f7f7f7;
    transition: all 0.3s ease;
}

.search-bar:focus {
    outline: none;
    border-color: #a3c9a8;
    box-shadow: 0 0 0 3px #a3c9a833;
    background: #393053;
}

.search-bar::placeholder {
    color: rgba(156, 163, 175, 0.8);
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(156, 163, 175, 0.8);
    pointer-events: none;
}

.search-results-count {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #b8b8d1;
    font-size: 0.875rem;
    pointer-events: none;
}

/* NEW: Search Results Container (Above Player) */
.search-results-container {
    background: #18122b;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid #393053;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 8px 32px #63598533;
}

.search-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.search-result-card {
    background: #39305366;
    border: 2px solid #63598566;
    border-radius: 10px;
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    text-align: center;
}

.search-result-card:hover {
    background: #635985;
    border-color: #a3c9a8;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px #a3c9a833;
}

.search-result-icon {
    width: 100%;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 0.75rem;
    background: #635985;
}

.search-result-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: #f7f7f7;
    margin-bottom: 0.5rem;
    line-height: 1.2;
    text-align: center;
}

.search-result-quality {
    font-size: 0.75rem;
    color: #b8b8d1;
    background: #a3c9a8;
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    display: inline-block;
}

.search-no-results {
    text-align: center;
    padding: 3rem 1rem;
    color: rgba(156, 163, 175, 0.8);
}

.search-no-results svg {
    width: 3rem;
    height: 3rem;
    margin: 0 auto 1rem;
    opacity: 0.5;
}

/* Live Search Results Dropdown (Legacy - for reference) */
.search-results-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    background: #18122b;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid #393053;
    border-radius: 12px;
    box-shadow: 0 20px 40px #63598599;
    max-height: 60vh;
    overflow-y: auto;
    z-index: 1000;
    transform: translateY(-10px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.search-results-dropdown.show {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}

.search-results-header {
    padding: 1rem;
    border-bottom: 1px solid rgba(55, 65, 81, 0.5);
    font-size: 0.875rem;
    color: #b8b8d1;
    font-weight: 600;
}

/* Clear Search Button */
.clear-search-btn {
    position: absolute;
    right: 3rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #a3c9a8;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 50%;
    transition: all 0.3s ease;
    display: none;
}

.clear-search-btn.show {
    display: block;
}

.clear-search-btn:hover {
    color: #f7f7f7;
    background: #635985;
}

/* Video Player Container */
.player-container {
    margin-bottom: 2rem;
    display: none;
}

.player-container.show {
    display: block;
}

.video-container {
    position: relative;
    width: 100%;
    background: #18122b;
    aspect-ratio: 16/9;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.video-container iframe,
.video-container video,
.video-container > div {
    border: none;
    width: 100% !important;
    height: 100% !important;
    position: absolute;
    top: 0;
    left: 0;
    object-fit: contain;
    border-radius: 12px;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

/* Player Info */
.player-info {
    padding: 1.5rem;
    background: #18122b;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 0 0 12px 12px;
    margin-top: -1px;
}

/* Channel Grid (when not searching) */
.channels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    padding: 2rem;
    width: 100vw;
    min-height: 100vh;
    margin: 0;
    box-sizing: border-box;
}

.channel-card {
    position: relative;
    background: #393053;
    border: 2px solid #635985;
    border-radius: 12px;
    padding: 1rem;
    transition: all 0.3s ease;
    cursor: pointer;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.channel-card:hover {
    transform: translateY(-4px);
    border-color: #a3c9a8;
    box-shadow: 0 12px 32px #a3c9a833;
}

.channel-card.active {
    border-color: #a3c9a8;
    background: #a3c9a822;
    box-shadow: 0 8px 24px #a3c9a833;
}

.channel-icon {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    background: rgba(55, 65, 81, 0.5);
}

.channel-name {
    font-size: 1rem;
    font-weight: 600;
    color: #f7f7f7;
    margin-bottom: 0.5rem;
    text-align: center;
}

.channel-quality {
    font-size: 0.75rem;
    color: #b8b8d1;
    text-align: center;
    padding: 0.25rem 0.5rem;
    background: #a3c9a8;
    border-radius: 4px;
    display: inline-block;
}

/* Favorites Button */
.favorite-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: #635985;
    border: none;
    border-radius: 50%;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #f7f7f7;
    z-index: 10;
}

.favorite-btn:hover {
    background: #a3c9a8;
    transform: scale(1.1);
}

.favorite-btn.active {
    color: #a3c9a8;
}

/* Glass Effects */
.glass-effect {
    background: #18122b;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid #393053;
}

/* Navigation Links */
.nav-link {
    transition: all 0.3s ease;
}

/* Loading State */
.loading-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
    padding: 1rem 0;
}

.loading-card {
    background: #393053;
    border: 2px solid #635985;
    border-radius: 12px;
    padding: 1rem;
    animation: pulse 2s infinite;
}

.loading-placeholder {
    height: 120px;
    background: linear-gradient(90deg, #393053 25%, #635985 50%, #393053 75%);
    background-size: 200% 100%;
    animation: loading 2s infinite;
    border-radius: 8px;
    margin-bottom: 0.75rem;
}

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

@keyframes pulse {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

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

.search-results-dropdown::-webkit-scrollbar-track,
.search-results-grid::-webkit-scrollbar-track {
    background: #393053;
    border-radius: 3px;
}

.search-results-dropdown::-webkit-scrollbar-thumb,
.search-results-grid::-webkit-scrollbar-thumb {
    background: #a3c9a8;
    border-radius: 3px;
}

.search-results-dropdown::-webkit-scrollbar-thumb:hover,
.search-results-grid::-webkit-scrollbar-thumb:hover {
    background: #a3c9a8;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .search-bar-container {
        margin: 0;
        margin-bottom: 1rem;
        padding: 0.75rem;
        border-radius: 0 0 8px 8px;
    }

    .search-bar {
        padding: 0.875rem 2.5rem 0.875rem 2.5rem;
        font-size: 0.875rem;
        background: #393053;
        border: 2px solid #635985;
        color: #f7f7f7;
    }

    .search-results-container {
        padding: 1rem;
        margin-bottom: 1.5rem;
        background: #18122b;
        border: 1px solid #393053;
    }

    .search-results-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 0.75rem;
    }

    .search-result-card {
        padding: 0.5rem;
        background: #39305366;
        border: 2px solid #63598566;
    }

    .search-result-icon {
        height: 60px;
        background: #635985;
    }

    .search-result-name {
        font-size: 0.75rem;
        color: #f7f7f7;
    }

    .search-result-quality {
        font-size: 0.625rem;
        padding: 0.125rem 0.375rem;
        background: #a3c9a8;
        color: #393053;
    }

    .channels-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        gap: 0.5rem;
        padding: 0;
        width: 100vw;
        min-height: 100vh;
        margin: 0;
        box-sizing: border-box;
    }

    .channel-card {
        padding: 0.75rem;
        background: #393053;
        border: 2px solid #635985;
    }

    .channel-icon {
        height: 100px;
        background: #635985;
    }

    .channel-name {
        font-size: 0.875rem;
        color: #f7f7f7;
    }

    .video-container {
        margin: 0 0.75rem;
        border-radius: 8px;
        background: #18122b;
    }

    .player-info {
        margin: 0 0.75rem;
        border-radius: 0 0 8px 8px;
        padding: 1rem;
        background: #18122b;
    }

    /* Remove hover effects on mobile */
    .channel-card:hover,
    .search-result-card:hover {
        transform: none;
        border-color: rgba(55, 65, 81, 0.5);
        box-shadow: none;
    }

    .channel-card:active,
    .search-result-card:active {
        transform: scale(0.98);
    }

    .favorite-btn:hover {
        background: rgba(0, 0, 0, 0.7);
        transform: none;
    }

    .favorite-btn {
        width: 1.75rem;
        height: 1.75rem;
        background: #635985;
        color: #f7f7f7;
    }
}

@media (max-width: 480px) {
    .search-bar-container {
        padding: 0.5rem;
    }

    .search-bar {
        padding: 0.75rem 2rem 0.75rem 2rem;
        font-size: 0.8125rem;
        background: #393053;
        border: 2px solid #635985;
        color: #f7f7f7;
    }

    .search-results-container {
        padding: 0.75rem;
        margin-bottom: 1rem;
        background: #18122b;
        border: 1px solid #393053;
    }

    .search-results-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 0.5rem;
    }

    .search-result-icon {
        height: 50px;
        background: #635985;
    }

    .search-result-name {
        font-size: 0.6875rem;
        color: #f7f7f7;
    }

    .channels-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 0.25rem;
        padding: 0;
        width: 100vw;
        min-height: 100vh;
        margin: 0;
        box-sizing: border-box;
    }

    .channel-icon {
        height: 70px;
        background: #635985;
    }

    .favorite-btn {
        width: 1.5rem;
        height: 1.5rem;
        background: #635985;
        color: #f7f7f7;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .channel-card:hover,
    .search-result-card:hover {
        transform: none;
        border-color: rgba(55, 65, 81, 0.5);
        box-shadow: none;
    }

    .favorite-btn:hover {
        background: rgba(0, 0, 0, 0.7);
        transform: none;
    }
}

/* High DPI screens */
@media (-webkit-min-device-pixel-ratio: 2) {
    .channel-icon,
    .search-result-icon {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}
