:root {
    /* Base Colors - Deep Dark Theme */
    --bg-main: #0a0a0e;
    --bg-sidebar: #12121a;
    --bg-card: rgba(255, 255, 255, 0.03);
    --bg-card-hover: rgba(255, 255, 255, 0.08);
    --bg-overlay: rgba(0, 0, 0, 0.7);
    
    /* Accents - Vibrant Red & Purple for TV vibe */
    --accent-red: #e50914;
    --accent-red-hover: #b80710;
    --accent-purple: #8338ec;
    
    /* Text */
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --text-muted: #6c6c7d;
    
    /* Borders & Shadows */
    --border-light: rgba(255, 255, 255, 0.08);
    --shadow-sm: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 10px 20px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 15px rgba(229, 9, 20, 0.3);
    
    /* Layout */
    --sidebar-width: 250px;
    --header-height: 70px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    overflow-x: hidden;
    line-height: 1.5;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ==================
   Sidebar
   ================== */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    padding: 24px 0;
    flex-shrink: 0;
    z-index: 100;
}

.logo-container {
    display: flex;
    align-items: center;
    padding: 0 24px 30px;
    gap: 12px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent-red), var(--accent-purple));
    border-radius: var(--radius-sm);
    position: relative;
    box-shadow: var(--shadow-glow);
}

.logo-icon::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-40%, -50%);
    border-top: 8px solid transparent;
    border-left: 12px solid white;
    border-bottom: 8px solid transparent;
}

.logo-container h1 {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: 1px;
    background: linear-gradient(135deg, #fff, #ccc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-section {
    flex: 1;
    padding: 0 16px;
}

.nav-section h2 {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 1.5px;
    margin-bottom: 12px;
    padding-left: 16px;
}

.nav-list {
    list-style: none;
}

.nav-list li {
    padding: 12px 16px;
    margin-bottom: 6px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
}

.nav-list li:hover {
    background-color: var(--bg-card);
    color: var(--text-primary);
    transform: translateX(4px);
}

.nav-list li.active {
    background: linear-gradient(90deg, rgba(229, 9, 20, 0.15) 0%, transparent 100%);
    color: var(--accent-red);
    border-left: 3px solid var(--accent-red);
}

.footer-info {
    padding: 24px;
    color: var(--text-muted);
    font-size: 12px;
    border-top: 1px solid var(--border-light);
}

/* ==================
   Main Content
   ================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: radial-gradient(circle at top right, rgba(131, 56, 236, 0.05), transparent 40%),
                radial-gradient(circle at top left, rgba(229, 9, 20, 0.05), transparent 40%);
}

.top-nav {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    position: sticky;
    top: 0;
    background-color: rgba(10, 10, 14, 0.8);
    backdrop-filter: blur(10px);
    z-index: 50;
    border-bottom: 1px solid var(--border-light);
}

.search-bar input {
    background-color: var(--bg-card);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    padding: 10px 20px;
    border-radius: 20px;
    width: 300px;
    font-family: inherit;
    font-size: 14px;
    transition: all 0.3s ease;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--accent-purple);
    background-color: rgba(255, 255, 255, 0.05);
    width: 350px;
    box-shadow: 0 0 10px rgba(131, 56, 236, 0.2);
}

.avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #2b2b36, #1a1a24);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--text-primary);
    border: 2px solid var(--border-light);
    cursor: pointer;
    transition: border-color 0.2s;
}

.avatar:hover {
    border-color: var(--accent-red);
}

.content-wrapper {
    padding: 30px 40px;
    display: flex;
    flex-direction: column;
    gap: 40px;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

/* ==================
   Player Section
   ================== */
.player-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
    animation: fadeIn 0.6s ease-out;
    position: sticky;
    top: calc(var(--header-height) + 10px);
    z-index: 40;
}

.video-container {
    width: 100%;
    aspect-ratio: 16 / 9;
    background-color: #000;
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
}

video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.player-overlay, .error-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-overlay);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    backdrop-filter: blur(5px);
    transition: opacity 0.3s ease;
}

.loader {
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid var(--accent-red);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

.player-overlay p {
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: 1px;
}

.error-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.error-overlay button {
    margin-top: 20px;
    padding: 10px 24px;
    background-color: var(--accent-red);
    color: white;
    border: none;
    border-radius: 20px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.error-overlay button:hover {
    background-color: var(--accent-red-hover);
}

.now-playing-info {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-card);
    padding: 20px 24px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    backdrop-filter: blur(10px);
}

.channel-badge {
    background-color: rgba(255, 255, 255, 0.1);
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 1px;
}

.now-playing-info h2 {
    font-size: 24px;
    font-weight: 600;
    flex: 1;
}

.status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #ff3333;
    letter-spacing: 1px;
}

.live-dot {
    width: 10px;
    height: 10px;
    background-color: #ff3333;
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

/* ==================
   Channels Grid
   ================== */
.section-header h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 20px;
    position: relative;
    display: inline-block;
}

.section-header h3::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 0;
    width: 40px;
    height: 3px;
    background-color: var(--accent-red);
    border-radius: 2px;
}

.channels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.channel-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    overflow: hidden;
}

.channel-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255,255,255,0.05) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s;
}

.channel-card:hover {
    transform: translateY(-5px);
    background: var(--bg-card-hover);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: var(--shadow-md);
}

.channel-card:hover::before {
    opacity: 1;
}

.channel-card.active {
    border-color: var(--accent-red);
    box-shadow: var(--shadow-glow);
}

.channel-logo-wrapper {
    width: 80px;
    height: 80px;
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
    padding: 10px;
    transition: transform 0.3s;
}

.channel-card:hover .channel-logo-wrapper {
    transform: scale(1.05);
}

.channel-logo-wrapper img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Fallback letter for logo */
.channel-logo-wrapper .fallback-logo {
    font-size: 32px;
    font-weight: 800;
    color: #1a1a24;
}

.channel-info {
    text-align: center;
    width: 100%;
}

.channel-name {
    font-weight: 600;
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.channel-category {
    font-size: 12px;
    color: var(--text-secondary);
    background-color: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 10px;
    display: inline-block;
}

/* Playing Indicator */
.playing-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    display: none;
    gap: 2px;
    align-items: flex-end;
    height: 12px;
}

.channel-card.active .playing-indicator {
    display: flex;
}

.bar {
    width: 3px;
    background-color: var(--accent-red);
    animation: equalize 1s infinite;
}

.bar:nth-child(1) { height: 12px; animation-delay: 0.1s; }
.bar:nth-child(2) { height: 8px; animation-delay: 0.3s; }
.bar:nth-child(3) { height: 10px; animation-delay: 0.5s; }

/* ==================
   Animations
   ================== */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulse {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes equalize {
    0% { height: 4px; }
    50% { height: 12px; }
    100% { height: 4px; }
}

/* ==================
   Responsive
   ================== */
@media (max-width: 1024px) {
    .content-wrapper {
        padding: 24px;
    }
    .channels-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
}

@media (max-width: 768px) {
    .player-section {
        position: sticky;
        top: 60px; /* 70px header minus some if header shrinks, actually top-nav is not sticky on some setups? */
        z-index: 50;
        background: var(--bg-main);
        padding-top: 10px;
        padding-bottom: 10px;
        margin-top: -10px;
    }

    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        padding: 16px 20px;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        border-right: none;
        border-bottom: 1px solid var(--border-light);
    }
    
    .logo-container {
        padding: 0;
        margin-bottom: 0;
    }
    
    .nav-section, .footer-info {
        display: none; /* Hide sidebar nav on mobile, could implement a hamburger menu */
    }
    
    .top-nav {
        padding: 0 20px;
    }
    
    .search-bar input {
        width: 200px;
    }
    
    .search-bar input:focus {
        width: 240px;
    }
    
    .content-wrapper {
        padding: 16px;
        gap: 24px;
    }
    
    .now-playing-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
}


/* Desktop layout - Video Left, Channels Right */
@media (min-width: 1025px) {
    .content-wrapper {
        flex-direction: row;
        align-items: flex-start;
    }
    .player-section {
        flex: 1;
        /* Sticky works well here since parent is row and align-items: flex-start is set */
        top: calc(var(--header-height) + 20px);
    }
    .channels-section {
        width: 320px;
        flex-shrink: 0;
    }
    .channels-grid {
        grid-template-columns: 1fr;
    }
}
