/* ===== RESET & BASE ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #1a73e8;
    --primary-dark: #1557b0;
    --primary-light: #4a9af5;
    --accent: #0d47a1;
    --bg-dark: #0a1628;
    --bg-card: #111d33;
    --bg-surface: #152238;
    --bg-sidebar: #0d1b2e;
    --text-primary: #ffffff;
    --text-secondary: #a8b8d0;
    --text-muted: #6b7f99;
    --border: #1e3a5f;
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-player: 0 8px 40px rgba(26, 115, 232, 0.15);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.2s ease;
    --navbar-h: 60px;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

.container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ===== NAVBAR ===== */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(10, 22, 40, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    height: var(--navbar-h);
}

.navbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.logo-icon {
    font-size: 24px;
}

.logo-text {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.logo-accent {
    color: var(--primary);
}

.nav-links {
    display: flex;
    gap: 4px;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
}

.nav-link:hover,
.nav-link.active {
    color: var(--text-primary);
    background: rgba(26, 115, 232, 0.1);
}

.nav-link.active {
    color: var(--primary-light);
}

.nav-actions {
    display: flex;
    align-items: center;
}

.search-box {
    position: relative;
}

.search-box input {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 7px 14px 7px 36px;
    color: var(--text-primary);
    font-size: 13px;
    width: 200px;
    outline: none;
    transition: var(--transition);
}

.search-box input:focus {
    border-color: var(--primary);
    width: 260px;
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 15px;
    height: 15px;
    color: var(--text-muted);
}

/* ===== MAIN CONTENT ===== */
.main-content {
    padding-top: var(--navbar-h);
    min-height: 100vh;
}

.main-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 0;
    height: calc(100vh - var(--navbar-h));
}

/* ===== PLAYER SECTION ===== */
.player-section {
    display: flex;
    flex-direction: column;
    padding: 20px 20px 20px 0;
    overflow: hidden;
}

.player-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-player);
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.player-container video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.player-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    gap: 16px;
}

.play-button {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 20px rgba(26, 115, 232, 0.4);
}

.play-button:hover {
    transform: scale(1.1);
    background: var(--primary-light);
}

.play-button svg {
    width: 32px;
    height: 32px;
    margin-left: 4px;
}

.player-hint {
    color: var(--text-secondary);
    font-size: 14px;
}

.player-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.8);
    gap: 12px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.player-loading p,
.player-error p {
    color: var(--text-secondary);
    font-size: 13px;
}

.player-error {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    gap: 10px;
    color: var(--text-secondary);
}

.player-error svg {
    width: 40px;
    height: 40px;
    color: #ef5350;
}

.btn-retry {
    margin-top: 6px;
    padding: 7px 20px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-retry:hover {
    background: var(--primary-light);
}

/* Now Playing */
.now-playing {
    margin-top: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.now-playing-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.live-badge {
    background: #e53935;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    animation: pulse-live 2s infinite;
}

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

#currentChannel {
    font-size: 16px;
    font-weight: 600;
}

.channel-category {
    color: var(--text-muted);
    font-size: 12px;
    background: var(--bg-surface);
    padding: 2px 8px;
    border-radius: 4px;
}

.player-controls {
    display: flex;
    gap: 8px;
}

.ctrl-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.ctrl-btn:hover {
    border-color: var(--primary);
    color: var(--primary-light);
}

.ctrl-btn svg {
    width: 18px;
    height: 18px;
}

/* ===== CHANNEL SIDEBAR ===== */
.channel-sidebar {
    background: var(--bg-sidebar);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--navbar-h));
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h3 {
    font-size: 14px;
    font-weight: 700;
}

.channel-count {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-surface);
    padding: 2px 8px;
    border-radius: 10px;
}

/* Category Filter in Sidebar */
.category-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
}

.cat-btn {
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: transparent;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition);
}

.cat-btn:hover {
    border-color: var(--primary);
    color: var(--primary-light);
}

.cat-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* Channel List */
.channel-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.channel-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
}

.channel-item:hover {
    background: var(--bg-surface);
    border-color: var(--border);
}

.channel-item.active {
    background: rgba(26, 115, 232, 0.1);
    border-color: var(--primary);
}

.channel-item-logo {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    overflow: hidden;
}

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

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

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

.channel-item-tag {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 2px;
}

.channel-item-live {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4caf50;
    flex-shrink: 0;
    opacity: 0;
    transition: var(--transition);
}

.channel-item.active .channel-item-live {
    opacity: 1;
    animation: pulse-dot 1.5s infinite;
}

@keyframes pulse-dot {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

/* Empty state */
.channel-list-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 13px;
}

/* ===== FOOTER ===== */
.footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 16px 0;
}

.footer-bottom {
    text-align: center;
}

.footer-bottom p {
    color: var(--text-muted);
    font-size: 11px;
}

.footer-bottom a {
    color: var(--primary-light);
    text-decoration: none;
}

/* ===== MOBILE TOGGLE ===== */
.mobile-channel-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--primary);
    border: none;
    color: white;
    cursor: pointer;
    z-index: 999;
    box-shadow: 0 4px 16px rgba(26, 115, 232, 0.4);
    align-items: center;
    justify-content: center;
}

.mobile-channel-toggle svg {
    width: 24px;
    height: 24px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
    .main-grid {
        grid-template-columns: 1fr;
        height: auto;
    }

    .player-section {
        padding: 16px;
    }

    .channel-sidebar {
        position: fixed;
        top: var(--navbar-h);
        right: -360px;
        width: 320px;
        height: calc(100vh - var(--navbar-h));
        z-index: 900;
        transition: right 0.3s ease;
        box-shadow: -4px 0 20px rgba(0,0,0,0.5);
    }

    .channel-sidebar.open {
        right: 0;
    }

    .mobile-channel-toggle {
        display: flex;
    }

    .nav-links {
        display: none;
    }

    .footer {
        display: none;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 12px;
    }

    .player-section {
        padding: 12px;
    }

    .player-container {
        border-radius: 8px;
    }

    .now-playing {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .search-box input {
        width: 140px;
    }

    .search-box input:focus {
        width: 180px;
    }

    .channel-sidebar {
        width: 280px;
    }
}

/* ===== SCROLLBAR ===== */
.channel-list::-webkit-scrollbar {
    width: 6px;
}

.channel-list::-webkit-scrollbar-track {
    background: transparent;
}

.channel-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.channel-list::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}
