:root {
    --bg-main: #060913;
    --bg-card: rgba(17, 24, 39, 0.6);
    --bg-sidebar: rgba(10, 15, 30, 0.95);
    --border-color: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(99, 102, 241, 0.3);
    
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    
    --accent: #6366f1;
    --accent-light: #8b5cf6;
    --accent-glow: rgba(99, 102, 241, 0.25);
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    
    --success: #10b981;
    --danger: #ef4444;
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Plyr custom styles overrides */
    --plyr-color-main: #6366f1;
    --plyr-video-background: #000;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    position: fixed;
    width: 100%;
    touch-action: none;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-sans);
    background-image: 
        radial-gradient(circle at 5% 5%, rgba(99, 102, 241, 0.08) 0%, transparent 35%),
        radial-gradient(circle at 95% 95%, rgba(139, 92, 246, 0.08) 0%, transparent 35%);
    background-attachment: fixed;
}

/* Main Layout */
.app-layout {
    display: grid;
    grid-template-columns: 1fr 360px;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

.main-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    padding: 1.25rem;
    gap: 1.25rem;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    padding: 0.85rem 1.5rem;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 1.6rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 8px var(--accent-glow));
}

.logo h1 {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.badge {
    background: var(--accent-gradient);
    font-size: 0.65rem;
    font-weight: 800;
    padding: 0.2rem 0.5rem;
    border-radius: 20px;
    letter-spacing: 0.5px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.sidebar-toggle {
    display: none;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 0.5rem 0.9rem;
    border-radius: 10px;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    transition: var(--transition);
}

.sidebar-toggle:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--accent);
}

/* Video Player Wrapper */
.player-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 0.85rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    min-height: 0; /* Ensures flex container can shrink properly */
}

.video-container {
    position: relative;
    width: 100%;
    flex-grow: 1;
    min-height: 0;
    background: #000;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

/* Plyr Custom Sizing */
.plyr {
    width: 100% !important;
    height: 100% !important;
    border-radius: 16px;
}
.plyr__video-wrapper {
    height: 100% !important;
}

/* Placeholder Screen Overlay */
.player-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(7, 9, 15, 0.96);
    z-index: 10;
    transition: opacity 0.4s ease;
}

.player-placeholder.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Hide Plyr overlays and controls when custom placeholder is active */
.video-container:has(#player-placeholder:not(.hidden)) .plyr__control--overlaid,
.video-container:has(#player-placeholder:not(.hidden)) .plyr__controls {
    opacity: 0 !important;
    pointer-events: none !important;
}

.placeholder-content {
    text-align: center;
    max-width: 420px;
    padding: 2rem;
}

.play-pulse-btn {
    font-size: 4.8rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    cursor: pointer;
    transition: var(--transition);
    filter: drop-shadow(0 0 15px var(--accent-glow));
    margin-bottom: 1.5rem;
    animation: btnPulse 2s infinite ease-in-out;
    display: inline-block;
}

.play-pulse-btn:hover {
    transform: scale(1.12);
}

@keyframes btnPulse {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 0 10px var(--accent-glow)); }
    50% { transform: scale(1.06); filter: drop-shadow(0 0 20px rgba(99, 102, 241, 0.5)); }
}

.placeholder-content h2 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.placeholder-content p {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Recovery Signal Banner */
.recovery-banner {
    position: absolute;
    top: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(239, 68, 68, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    padding: 0.65rem 1.3rem;
    border-radius: 30px;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    z-index: 5;
    backdrop-filter: blur(8px);
    animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideDown {
    from { top: -50px; opacity: 0; }
    to { top: 1.25rem; opacity: 1; }
}

.recovery-banner.hidden {
    display: none !important;
}

.channel-info-footer {
    padding: 0.85rem 0.5rem 0.2rem 0.5rem;
}

.channel-info-footer h2 {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.text-accent {
    color: var(--accent-light);
}

/* Top 10 Channels Section */
.top-channels-section {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 1rem 1.25rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    height: auto;
    flex-shrink: 0; /* Ensures it maintains size */
}

.section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-header h3 {
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-secondary);
}

.text-danger {
    color: var(--danger);
}

/* Responsive grid replacing horizontal scroll */
.top-channels-carousel {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 0.75rem;
    width: 100%;
}

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

@media (max-width: 600px) {
    .top-channels-carousel {
        grid-template-columns: repeat(4, 1fr);
    }
}

.loader-placeholder {
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 1.5rem;
    width: 100%;
    text-align: center;
}

/* Top Channel Card Item (Vertical alignment) */
.top-card-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 14px;
    padding: 0.65rem 0.4rem;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    text-align: center;
    width: 100%;
}

/* Modern bottom border indicator instead of left vertical line */
.top-card-item::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 3px;
    border-radius: 3px 3px 0 0;
    background: var(--accent-gradient);
    opacity: 0;
    transition: var(--transition);
}

.top-card-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-hover);
    transform: translateY(-2px);
}

.top-card-item:hover::before {
    opacity: 1;
    width: 50%;
}

.top-card-item.active {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--accent);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.15);
}

.top-card-item.active::before {
    opacity: 1;
    width: 50%;
}

.channel-logo-wrapper {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.channel-logo-img {
    width: 90%;
    height: 90%;
    object-fit: contain;
}

.channel-logo-placeholder {
    font-size: 1.25rem;
    color: var(--text-muted);
}

/* Channel name below the icon */
.top-card-item .top-name {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 0.15rem;
}

.top-card-item:hover .top-name {
    color: var(--text-primary);
}

/* Sidebar Styling */
.sidebar {
    display: flex;
    flex-direction: column;
    height: 100%;
    border-left: 1px solid var(--border-color);
    background: var(--bg-sidebar);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    overflow: hidden;
    box-shadow: -5px 0 25px rgba(0,0,0,0.15);
}

.sidebar-header {
    padding: 1.25rem 1rem 0.75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.search-box {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 0.9rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    pointer-events: none;
    transition: var(--transition);
}

.search-box input {
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0.75rem 2.25rem 0.75rem 2.25rem;
    border-radius: 12px;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    color: var(--text-primary);
    outline: none;
    transition: var(--transition);
}

.search-box input:focus {
    background: rgba(255, 255, 255, 0.07);
    border-color: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
}

.search-box input:focus + .search-icon {
    color: var(--accent);
}

.clear-btn {
    position: absolute;
    right: 0.8rem;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.95rem;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

.clear-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

.clear-btn.hidden {
    display: none;
}

/* Channels List Scroll Container */
.channels-list-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0.75rem;
    position: relative;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
}

.channels-list-container::-webkit-scrollbar {
    width: 5px;
}
.channels-list-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 10px;
}
.channels-list-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.12);
}

.channels-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

/* Channel Selector List Item */
.channel-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid rgba(255, 255, 255, 0.03);
    padding: 0.75rem 0.9rem;
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.channel-list-item:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--border-hover);
    transform: translateX(3px);
}

.channel-list-item.active {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.12);
}

.channel-item-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.item-logo-wrapper {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.03);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.item-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.item-logo-placeholder {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.channel-item-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.channel-item-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.channel-item-group {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 0.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-indicator-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
    flex-shrink: 0;
    margin-left: 0.5rem;
}

/* Loader, Empty, No results styling */
.list-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.25rem 0.5rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
}

.list-loader.hidden, .no-results.hidden {
    display: none !important;
}

.no-results {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}

.no-results i {
    font-size: 2.2rem;
    margin-bottom: 0.75rem;
    color: rgba(255,255,255,0.06);
}

.no-results p {
    font-size: 0.85rem;
}

/* Animations */
.animate-pulse {
    animation: beaconPulse 2s infinite ease-in-out;
}

@keyframes beaconPulse {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.1); }
}

/* Mobile Sidebar Drawer and Responsiveness */
@media (max-width: 900px) {
    .app-layout {
        display: flex;
        flex-direction: column;
        height: 100%;
        overflow: hidden;
    }
    
    .sidebar-toggle {
        display: none !important;
    }
    
    .sidebar {
        position: relative;
        transform: none;
        transition: none;
        width: 100%;
        height: auto;
        flex-grow: 1;
        min-height: 0;
        border-left: none;
        border-top: 1px solid var(--border-color);
        box-shadow: none;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    
    .sidebar-overlay {
        display: none !important;
    }
    
    .main-content {
        padding: 0.75rem;
        gap: 0.5rem;
        flex-grow: 0;
        flex-shrink: 0;
        height: auto;
        overflow: hidden;
    }
    
    .player-wrapper {
        border-radius: 16px;
        padding: 0.5rem;
        flex-grow: 0;
        height: auto;
    }
    
    .video-container {
        aspect-ratio: 16 / 9;
        flex-grow: 0;
        height: auto;
    }
    
    .top-channels-section {
        display: none !important;
    }
}

@media (max-width: 500px) {
    .app-header {
        padding: 0.75rem 1rem;
    }
    .logo h1 {
        font-size: 1.1rem;
    }
    .badge {
        display: none;
    }
}

/* Mobile Top Channels Accordion */
.mobile-top-channels-accordion {
    display: none;
}

@media (max-width: 900px) {
    .mobile-top-channels-accordion {
        display: block;
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    }
    
    .top-channels-section {
        display: none !important;
    }
    
    /* Accordion styles */
    .accordion-header {
        width: 100%;
        background: rgba(255, 255, 255, 0.02);
        border: none;
        padding: 1rem 1.25rem;
        display: flex;
        justify-content: space-between;
        align-items: center;
        color: var(--text-primary);
        font-family: var(--font-sans);
        font-size: 0.85rem;
        font-weight: 700;
        letter-spacing: 0.5px;
        cursor: pointer;
        transition: var(--transition);
        outline: none;
    }
    
    .accordion-header:hover {
        background: rgba(255, 255, 255, 0.04);
    }
    
    .accordion-header span {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }
    
    .accordion-arrow {
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        color: var(--text-muted);
    }
    
    .accordion-header.active .accordion-arrow {
        transform: rotate(180deg);
        color: var(--accent);
    }
    
    .accordion-content {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        background: rgba(0, 0, 0, 0.15);
        touch-action: pan-y;
        -webkit-overflow-scrolling: touch;
    }
    
    .accordion-content.open {
        max-height: 500px;
        overflow-y: auto;
    }
    
    .accordion-content .top-channels-carousel {
        padding: 1rem 1.25rem;
        grid-template-columns: repeat(4, 1fr);
        gap: 0.5rem;
    }
}

/* Hide Google reCAPTCHA v3 floating badge */
.grecaptcha-badge {
    visibility: hidden !important;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    text-align: center;
    background: rgba(0, 0, 0, 0.1);
}

.sidebar-footer span {
    font-size: 0.65rem;
    color: var(--text-muted);
    line-height: 1.3;
    display: block;
}

.sidebar-footer a {
    color: var(--accent);
    text-decoration: none;
    transition: var(--transition);
}

.sidebar-footer a:hover {
    text-decoration: underline;
}
