/* Modern Live TV Streaming Styles */
:root {
    --primary-color: #2563eb;
    --secondary-color: #1e40af;
    --accent-color: #dc2626;
    --success-color: #16a34a;
    --background-color: #0f172a;
    --surface-color: #1e293b;
    --card-color: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --border-color: #475569;
    --hover-color: #3b82f6;
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-live: linear-gradient(90deg, #ff0000, #ff4500, #ff0000);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --blur-bg: rgba(15, 23, 42, 0.8);
}

/* Theme Overrides */
[data-theme="dark"] {
    --background-color: #000000;
    --surface-color: #111827;
    --card-color: #1f2937;
    --border-color: #374151;
}

[data-theme="blue"] {
    --primary-color: #3b82f6;
    --secondary-color: #1d4ed8;
    --background-color: #0c1425;
    --surface-color: #1e293b;
    --card-color: #334155;
}

/* Global Styles */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--background-color);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Header Styles */
.header {
    background: var(--blur-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: all 0.3s ease;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Channel Cards */
.channel-card {
    background: var(--surface-color);
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    transform: translateY(0);
}

.channel-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.channel-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-live);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.channel-card:hover::before {
    opacity: 1;
}

/* Channel Card Buttons */
.channel-card button {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: inherit;
}

.channel-card button:hover {
    background: var(--hover-color);
    transform: scale(1.05);
}

.channel-card button:active {
    transform: scale(0.98);
}

/* Video Player Section */
#player-section {
    background: var(--surface-color);
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    margin-bottom: 3rem;
}

/* YouTube Player Container */
.video-container {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

#youtube-player {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 12px;
}

/* Player Controls */
.player-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
}

.player-controls button {
    background: var(--surface-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    font-size: 0.875rem;
}

.player-controls button:hover {
    background: var(--border-color);
    transform: translateY(-2px);
}

.player-controls button:active {
    transform: translateY(0);
}

#close-player {
    background: var(--accent-color) !important;
    color: white !important;
    border: none !important;
}

#close-player:hover {
    background: #b91c1c !important;
}

/* Scroll to Top Button */
#scroll-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    z-index: 1000;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-lg);
    font-size: 1.1rem;
}

#scroll-top:hover {
    background: var(--hover-color);
    transform: translateY(-3px);
    box-shadow: 0 25px 30px -5px rgba(0, 0, 0, 0.15);
}

/* Live Indicator Animation */
@keyframes pulse {
    0%, 100% { 
        opacity: 1; 
        transform: scale(1); 
    }
    50% { 
        opacity: 0.7; 
        transform: scale(1.1); 
    }
}

.live-indicator {
    animation: pulse 2s infinite;
}

/* Responsive Grid */
#channels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Footer Styles */
footer {
    background: var(--surface-color);
    border-top: 1px solid var(--border-color);
    padding: 2rem 0;
    margin-top: 3rem;
}

footer a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.3s ease;
}

footer a:hover {
    color: var(--primary-color);
}

/* Theme Selector */
#themeSelect {
    background: var(--surface-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem;
    font-size: 0.875rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s ease;
}

#themeSelect:hover {
    border-color: var(--primary-color);
}

#themeSelect:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .container {
        padding: 0 0.75rem;
    }
    
    #channels-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .channel-card {
        padding: 1rem;
    }
    
    #player-section {
        padding: 1rem;
        margin: 0 -0.75rem 2rem -0.75rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    
    .player-controls {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .player-controls button {
        width: 100%;
        justify-content: center;
    }
    
    #scroll-top {
        bottom: 1rem;
        right: 1rem;
        width: 45px;
        height: 45px;
    }
    
    .header h1 {
        font-size: 1.25rem !important;
    }
    
    .header .nav-controls {
        gap: 0.5rem;
    }
    
    #themeSelect {
        font-size: 0.8rem;
        padding: 0.4rem;
    }
}

@media (max-width: 480px) {
    .channel-card {
        padding: 0.75rem;
    }
    
    .channel-card h3 {
        font-size: 1rem !important;
    }
    
    .channel-card button {
        padding: 0.5rem 1rem !important;
        font-size: 0.8rem !important;
    }
    
    #player-section {
        padding: 0.75rem;
    }
    
    .video-container {
        border-radius: 8px;
    }
    
    #youtube-player {
        border-radius: 8px;
    }
}

/* High Performance Optimizations */
.channel-card,
.player-controls button,
#scroll-top {
    will-change: transform;
}

/* Preload optimizations */
iframe[src*="youtube.com"] {
    loading: lazy;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Focus styles for accessibility */
.channel-card:focus,
button:focus,
select:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .header,
    #scroll-top,
    .player-controls {
        display: none;
    }
    
    body {
        background: white;
        color: black;
    }
}
.cards-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(160px,1fr));gap:1rem}
.channel-btn{display:flex;flex-direction:column;align-items:center;border:none;background:transparent;cursor:pointer;transition:transform .2s;padding:.5rem;border-radius:12px}
.channel-btn:hover{transform:scale(1.05)}
.channel-btn img{width:64px;height:64px;object-fit:contain}
.live-dot{display:block;width:8px;height:8px;margin:4px auto;border-radius:50%;background:#ff0000;animation:pulse 1.5s infinite}
.channel-btn:focus{outline:2px solid var(--primary-color);outline-offset:2px}
.player-sticky-top,.player-sticky-bottom{position:sticky;width:100%;background:var(--theme-bg, var(--surface-color));border-bottom:1px solid var(--theme-border, var(--border-color));z-index:999}
.player-sticky-bottom{bottom:0;border-top:1px solid var(--theme-border, var(--border-color))}
.player-hidden{display:none}
#live-player{width:100%;aspect-ratio:16/9;border:0;max-height:506px}
#player-title{font-size:1.1rem;padding:.5rem 1rem;color:var(--theme-text, var(--text-color))}
.channel-card{display:flex;flex-direction:column;align-items:center;gap:.5rem;padding:1rem;border:1px solid var(--border-color);border-radius:12px;background:var(--surface-color)}
.channel-card .channel-icon{width:64px;height:64px;object-fit:contain}
.channel-card .channel-name{font-weight:600;text-align:center}
.channel-card .watch-btn{background:var(--primary-color);color:#fff;border:0;border-radius:8px;padding:.4rem .8rem;cursor:pointer}
.channel-card .watch-btn:hover{filter:brightness(1.05)}
.player-loading{display:flex;align-items:center;gap:.5rem;padding:.5rem 1rem;color:var(--theme-text, var(--text-color))}
.player-status{padding:.25rem 1rem;color:var(--theme-text, var(--text-color))}
.live-pill{color:#ef4444;font-weight:700}
.cards-grid .channel-card{gap:.25rem}