/* Design System & Light Theme (default) */
:root {
    --bg-gradient: linear-gradient(135deg, #f0f2f8 0%, #e8eaf6 50%, #f5f5ff 100%);
    --panel-bg: rgba(255, 255, 255, 0.85);
    --panel-border: rgba(0, 0, 0, 0.07);
    --sidebar-bg: linear-gradient(180deg, #ffffff 0%, #f8f8ff 100%);
    --main-bg: linear-gradient(135deg, #f0f2f8 0%, #e8eaf6 100%);
    --header-bg: rgba(255, 255, 255, 0.7);
    --overlay-bg: rgba(240, 242, 248, 0.92);
    --input-bg: rgba(0, 0, 0, 0.04);
    --input-focus-bg: #ffffff;
    --btn-bg: rgba(0, 0, 0, 0.04);
    --btn-bg-hover: rgba(124, 58, 237, 0.07);
    --badge-bg: rgba(0, 0, 0, 0.08);
    --footer-bg: rgba(0, 0, 0, 0.02);
    --icon-color: var(--text-primary);
    --modal-bg: rgba(255, 255, 255, 0.98);
    --modal-border: rgba(0, 0, 0, 0.08);
    --modal-input-bg: rgba(0, 0, 0, 0.03);
    --modal-input-focus: rgba(0, 0, 0, 0.06);
    --modal-table-bg: rgba(0, 0, 0, 0.04);
    --modal-footer-bg: rgba(0, 0, 0, 0.04);
    --modal-text: var(--text-primary);
    --modal-muted: var(--text-muted);
    --accent: #7c3aed;
    --accent-glow: rgba(124, 58, 237, 0.25);
    --accent-secondary: #0ea5e9;
    --accent-secondary-glow: rgba(14, 165, 233, 0.2);
    --text-primary: #1a1a2e;
    --text-muted: #64748b;
    --card-hover: rgba(124, 58, 237, 0.05);
    --card-active: rgba(124, 58, 237, 0.08);
    --error: #ef4444;
    --success: #10b981;
    --font-family: 'Poppins', 'Inter', system-ui, -apple-system, sans-serif;
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Dark Theme */
[data-theme="dark"] {
    --bg-gradient: linear-gradient(135deg, #0e0a1c 0%, #171232 50%, #0d0d1f 100%);
    --panel-bg: rgba(23, 16, 45, 0.92);
    --panel-border: rgba(255, 255, 255, 0.09);
    --sidebar-bg: linear-gradient(180deg, #141022 0%, #1a1330 100%);
    --main-bg: linear-gradient(135deg, #0e0a1c 0%, #151031 100%);
    --header-bg: rgba(17, 12, 32, 0.7);
    --overlay-bg: rgba(13, 9, 26, 0.92);
    --input-bg: rgba(255, 255, 255, 0.05);
    --input-focus-bg: rgba(255, 255, 255, 0.08);
    --btn-bg: rgba(255, 255, 255, 0.06);
    --btn-bg-hover: rgba(124, 58, 237, 0.15);
    --badge-bg: rgba(255, 255, 255, 0.12);
    --footer-bg: rgba(10, 5, 28, 0.5);
    --icon-color: #ffffff;
    --modal-bg: rgba(20, 14, 44, 0.97);
    --modal-border: rgba(255, 255, 255, 0.08);
    --modal-input-bg: rgba(255, 255, 255, 0.06);
    --modal-input-focus: rgba(255, 255, 255, 0.1);
    --modal-table-bg: rgba(0, 0, 0, 0.3);
    --modal-footer-bg: rgba(0, 0, 0, 0.2);
    --modal-text: #ffffff;
    --modal-muted: #9b93b8;
    --text-primary: #e8e6f5;
    --text-muted: #9b93b8;
    --card-hover: rgba(124, 58, 237, 0.12);
    --card-active: rgba(124, 58, 237, 0.18);
}

/* Reset & Basics */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) transparent;
}

body {
    font-family: var(--font-family);
    background: var(--bg-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.04);
}
::-webkit-scrollbar-thumb {
    background: rgba(124, 58, 237, 0.25);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* Layout */
.app-container {
    display: grid;
    grid-template-columns: 350px 1fr;
    height: 100vh;
    overflow: hidden;
    transition: grid-template-columns 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.app-container.sidebar-collapsed {
    grid-template-columns: 0px 1fr;
}

/* Sidebar Styling */
.sidebar {
    background: var(--sidebar-bg);
    border-right: 1px solid rgba(124, 58, 237, 0.1);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    display: flex;
    flex-direction: column;
    height: 100%;
    z-index: 10;
    overflow: hidden;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.06);
}

/* Brand header */
.brand {
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(124, 58, 237, 0.08);
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.04) 0%, transparent 60%);
    position: relative;
    flex-shrink: 0;
}

.brand::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 20px;
    right: 20px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(124, 58, 237, 0.25), transparent);
}

.brand-icon {
    width: auto;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.brand-icon svg {
    width: 22px;
    height: 22px;
    fill: #fff;
}

.brand-logo-img {
    display: block;
}

.brand-title {
    font-size: 19px;
    font-weight: 800;
    letter-spacing: 0.5px;
    background: linear-gradient(90deg, #fff 40%, var(--accent-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.search-box {
    padding: 14px 16px;
    position: relative;
    flex-shrink: 0;
}

.search-input {
    width: 100%;
    padding: 10px 16px 10px 44px;
    background: var(--input-bg);
    border: 1px solid var(--panel-border);
    border-radius: 50px;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 13px;
    transition: var(--transition);
}

.search-input::placeholder {
    color: rgba(100, 116, 139, 0.6);
}

.search-input:focus {
    outline: none;
    border-color: rgba(124, 58, 237, 0.4);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.08);
    background: var(--input-focus-bg);
}

.search-icon {
    position: absolute;
    left: 30px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    opacity: 0.5;
}

/* Tabs */
.tabs-container {
    display: flex;
    padding: 0 16px 12px;
    gap: 6px;
    border-bottom: 1px solid var(--panel-border);
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    flex-shrink: 0;
}

.tabs-container::-webkit-scrollbar {
    height: 3px;
}

.tab-btn {
    flex: 0 0 auto;
    padding: 7px 13px;
    border: 1px solid var(--panel-border);
    background: var(--input-bg);
    color: var(--text-muted);
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 12px;
    border-radius: 50px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 5px;
}

.tab-btn:hover {
    color: var(--accent);
    background: rgba(124, 58, 237, 0.06);
    border-color: rgba(124, 58, 237, 0.2);
}

.tab-btn.active {
    color: #fff;
    background: linear-gradient(135deg, var(--accent) 0%, #9333ea 100%);
    border-color: transparent;
    box-shadow: 0 2px 10px rgba(124, 58, 237, 0.3);
}

.tab-badge {
    background: var(--badge-bg);
    color: var(--text-muted);
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 10px;
}

.tab-btn.active .tab-badge {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

/* Channel Listing */
.channel-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: transparent;
}

.channel-card {
    display: flex;
    align-items: center;
    gap: 14px;
    height: 80px;
    padding: 0 14px 0 10px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.channel-card:hover {
    background: rgba(124, 58, 237, 0.05);
    border-color: rgba(124, 58, 237, 0.15);
}

.channel-card.active {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.08) 0%, rgba(14, 165, 233, 0.04) 100%);
    border-color: rgba(124, 58, 237, 0.3);
    box-shadow: 0 2px 16px rgba(124, 58, 237, 0.1);
}

.channel-card.active::after {
    content: '';
    position: absolute;
    left: 0;
    top: 14px;
    bottom: 14px;
    width: 3px;
    border-radius: 0 2px 2px 0;
    background: linear-gradient(to bottom, var(--accent), var(--accent-secondary));
    box-shadow: 0 0 6px var(--accent-glow);
}

/* Channel number index (rendered by JS) */
.channel-number {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    opacity: 0.45;
    width: 20px;
    text-align: right;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.channel-logo-container {
    width: 58px;
    height: 58px;
    flex-shrink: 0;
    border-radius: 10px;
    background: var(--input-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid var(--panel-border);
    position: relative;
    transition: var(--transition);
}

.channel-card:hover .channel-logo-container {
    border-color: rgba(14, 165, 233, 0.4);
    box-shadow: 0 0 8px rgba(14, 165, 233, 0.1);
}

.channel-card.active .channel-logo-container {
    border-color: rgba(124, 58, 237, 0.4);
    box-shadow: 0 0 10px rgba(124, 58, 237, 0.15);
}

.channel-logo {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.channel-card:hover .channel-logo {
    transform: scale(1.08);
}

/* Fallback Logo Avatar */
.channel-avatar {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 22px;
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: #fff;
    letter-spacing: -0.5px;
}

.channel-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

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

.channel-card.active .channel-name {
    color: var(--accent);
}

.channel-group {
    display: none;
}

/* Right side: favorite + live badge inline */
.channel-side {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.favorite-btn {
    background: none;
    border: none;
    color: rgba(100, 116, 139, 0.3);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    z-index: 2;
}

.favorite-btn:hover {
    color: var(--accent-secondary);
    transform: scale(1.15);
}

.favorite-btn.active {
    color: #f59e0b;
    filter: drop-shadow(0 0 4px rgba(245, 158, 11, 0.4));
}

/* Sidebar Footer Stats */
.sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 12px 16px;
    border-top: 1px solid var(--panel-border);
    background: var(--footer-bg);
    flex-shrink: 0;
}

.stats-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.stats-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    opacity: 0.7;
}

.stats-value {
    font-size: 16px;
    font-weight: 800;
    background: linear-gradient(90deg, var(--accent) 0%, var(--accent-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.reset-favorites-btn {
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 7px 12px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    cursor: pointer;
    color: var(--text-muted);
    background: transparent;
    transition: all 0.2s ease;
}

.reset-favorites-btn:hover {
    color: #fff;
    border-color: #e74c3c;
    background: #e74c3c;
}

.reset-favorites-btn:active {
    transform: scale(0.95);
}

/* Main Stream Dashboard Area */
.main-content {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background: var(--main-bg);
}

.dashboard-header {
    height: 70px;
    padding: 0 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--panel-border);
    background: var(--header-bg);
    backdrop-filter: blur(12px);
}

.live-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--success);
    box-shadow: 0 0 10px var(--success);
    animation: pulse 1.8s infinite;
}

.header-status {
    font-size: 13px;
    color: var(--text-muted);
}

/* Player Center Layout */
.player-section {
    flex: 1;
    display: flex;
    justify-content: center;
    padding: 40px;
    overflow-y: auto;
}

.player-container {
    width: 100%;
    max-width: 960px;
    margin: auto 0;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 20px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.1), 0 2px 8px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.video-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
}

.video-wrapper:fullscreen,
.video-wrapper:-webkit-full-screen {
    aspect-ratio: auto;
    width: 100%;
    height: 100%;
    background: #000;
}

video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    opacity: 0;
    pointer-events: none;
}

/* Canvas that renders the video + logo watermark */
.video-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    z-index: 1;
    background: #000;
}

/* Player Overlay Message States (Error, Loading, Prompt) */
.player-overlay {
    position: absolute;
    inset: 0;
    background: var(--overlay-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    text-align: center;
    z-index: 5;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.player-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Custom video controls (native controls are hidden behind the canvas) */
.video-controls {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 8;
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: clamp(6px, 1.5vw, 12px);
    padding: clamp(6px, 1vw, 10px) clamp(8px, 1.6vw, 14px);
    padding-bottom: calc(clamp(6px, 1vw, 10px) + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0));
    opacity: 1;
    transition: opacity 0.3s ease;
    pointer-events: auto;
    box-sizing: border-box;
}

.video-controls.hidden {
    opacity: 0;
    pointer-events: none;
}

.ctrl-btn {
    flex: 0 0 auto;
    width: clamp(34px, 3.4vw, 44px);
    height: clamp(34px, 3.4vw, 44px);
    min-width: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    cursor: pointer;
    transition: background 0.2s ease;
    touch-action: manipulation;
}

.ctrl-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.ctrl-btn svg {
    flex: 0 0 auto;
    width: clamp(18px, 2vw, 22px);
    height: clamp(18px, 2vw, 22px);
    fill: currentColor;
}

.ctrl-btn .icon-pause,
.ctrl-btn .icon-muted {
    display: none;
}

.ctrl-btn.playing .icon-play,
.ctrl-btn.playing .icon-pause {
    display: none;
}

.ctrl-btn.playing .icon-pause {
    display: inline-block;
}

.ctrl-btn.muted .icon-vol,
.ctrl-btn.muted .icon-muted {
    display: none;
}

.ctrl-btn.muted .icon-muted {
    display: inline-block;
}

.ctrl-btn.fs-active {
    background: rgba(255, 255, 255, 0.28);
}

.ctrl-volume {
    flex: 1 1 100px;
    min-width: 44px;
    max-width: 140px;
    height: 4px;
    appearance: none;
    -webkit-appearance: none;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.3);
    outline: none;
    cursor: pointer;
    touch-action: none;
}

.ctrl-volume::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.ctrl-volume::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border: none;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.ctrl-time {
    flex: 0 0 auto;
    font-size: clamp(11px, 1.2vw, 13px);
    color: rgba(255, 255, 255, 0.9);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.ctrl-spacer {
    flex: 1 1 auto;
    min-width: 0;
}

/* Touch devices: bigger tap targets and slider thumb */
@media (pointer: coarse) {
    .ctrl-btn {
        width: 44px;
        height: 44px;
        border-radius: 10px;
    }

    .ctrl-volume {
        height: 5px;
    }

    .ctrl-volume::-webkit-slider-thumb {
        width: 18px;
        height: 18px;
    }

    .ctrl-volume::-moz-range-thumb {
        width: 18px;
        height: 18px;
    }
}

/* Tablets / small windows */
@media (max-width: 768px) {
    .video-controls {
        gap: 8px;
        padding: 6px 10px;
        padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
    }

    .ctrl-btn {
        width: 38px;
        height: 38px;
    }

    .ctrl-volume {
        max-width: 110px;
        min-width: 40px;
    }
}

/* Phones / narrow windows */
@media (max-width: 480px) {
    .ctrl-btn {
        width: 36px;
        height: 36px;
    }

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

    .ctrl-volume {
        flex-basis: 56px;
        min-width: 36px;
        max-width: 90px;
    }

    .ctrl-time {
        font-size: 11px;
    }
}

.overlay-icon {
    font-size: 48px;
    margin-bottom: 16px;
    animation: float 3s ease-in-out infinite;
}

.overlay-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.overlay-desc {
    font-size: 14px;
    color: var(--text-muted);
    max-width: 400px;
    line-height: 1.5;
}

/* Loading Spinner */
.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(124, 58, 237, 0.1);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

/* Metadata Bar under Player */
.player-meta {
    padding: 20px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--panel-bg);
    border-top: 1px solid var(--panel-border);
}

.meta-channel-info {
    display: flex;
    align-items: center;
    gap: 18px;
}

.meta-logo {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    background: var(--input-bg);
    border: 1px solid var(--panel-border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

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

.meta-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.meta-subtitle {
    font-size: 13px;
    color: var(--text-muted);
}

.meta-actions {
    display: flex;
    gap: 12px;
}

.btn-secondary {
    background: var(--btn-bg);
    color: var(--text-primary);
    border: 1px solid var(--panel-border);
    padding: 10px 20px;
    border-radius: 10px;
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.btn-secondary:hover {
    background: var(--btn-bg-hover);
    border-color: rgba(124, 58, 237, 0.25);
    color: var(--accent);
}

.player-nav {
    display: flex;
    gap: clamp(8px, 1.5vw, 14px);
    padding: 12px 28px;
    background: var(--panel-bg);
    border-top: 1px solid var(--panel-border);
}

.player-nav-btn {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    padding: 12px 16px;
    background: var(--input-bg);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    font-family: var(--font-family);
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    transition: var(--transition);
}

.player-nav-btn:hover {
    background: var(--btn-bg-hover);
    border-color: rgba(124, 58, 237, 0.25);
}

.player-nav-btn:active {
    transform: scale(0.98);
}

.player-nav-btn svg {
    flex: none;
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.player-nav-btn:last-child {
    text-align: right;
    flex-direction: row-reverse;
}

.player-nav-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.player-nav-btn:last-child .player-nav-text {
    align-items: flex-end;
}

.player-nav-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.player-nav-name {
    font-size: clamp(13px, 1.4vw, 15px);
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    color: var(--accent);
}

/* Animations */
@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(0, 230, 118, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 10px rgba(0, 230, 118, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(0, 230, 118, 0);
    }
}

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

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-8px); }
    100% { transform: translateY(0px); }
}

/* Center Footer Credit */
.app-footer {
    text-align: center;
    padding: 14px 20px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-muted);
    border-top: 1px solid var(--panel-border);
    background: var(--header-bg);
    flex-shrink: 0;
    letter-spacing: 0.3px;
}

.footer-credit-name {
    font-weight: 700;
    background: linear-gradient(90deg, var(--accent) 0%, var(--accent-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Empty states */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 32px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* Sidebar Backdrop for mobile/tablet overlay */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(4, 2, 10, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 85;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.app-container.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
}

/* Responsive Grid & Drawer Layout Overrides */
@media (max-width: 1024px) {
    .app-container {
        grid-template-columns: 1fr !important;
    }
    
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 320px;
        height: 100vh;
        z-index: 90;
        transform: translateX(-100%);
        border-right: 1px solid var(--panel-border);
        box-shadow: none;
        transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    }
    
    .app-container.sidebar-open .sidebar {
        transform: translateX(0);
        box-shadow: 15px 0 40px rgba(0, 0, 0, 0.6);
    }

    .btn-sidebar-toggle {
        display: flex !important;
    }
    
    .dashboard-header {
        padding: 0 24px;
    }
    
    .player-section {
        padding: 24px;
    }
}

@media (max-width: 768px) {
    .dashboard-header {
        padding: 0 16px;
        height: 64px;
    }

    .live-indicator span {
        display: none; /* Hide 'LIVE TV STREAM' text on very small screens to save space */
    }

    .player-section {
        padding: 12px;
    }

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

    .player-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
        padding: 16px;
    }

    .player-nav {
        flex-direction: column;
        padding: 12px 16px;
    }

    .player-nav-btn:last-child {
        flex-direction: row;
        text-align: left;
    }

    .player-nav-btn:last-child .player-nav-text {
        align-items: flex-start;
    }

    .meta-actions {
        width: 100%;
    }

    .btn-secondary {
        flex: 1;
        justify-content: center;
        width: 100%;
    }
    
    .header-controls {
        gap: 12px;
    }
    
    .header-status {
        display: none; /* Hide status details text on tiny screens */
    }
}

/* Header Controls & Admin Button */
.header-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-user-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--accent-secondary);
    background: rgba(0, 242, 254, 0.1);
    border: 1px solid var(--panel-border);
    padding: 5px 12px;
    border-radius: 20px;
    white-space: nowrap;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent) 0%, rgba(188, 60, 242, 0.8) 100%);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(188, 60, 242, 0.5);
    background: linear-gradient(135deg, #c74bfb 0%, var(--accent) 100%);
}

.btn-primary svg {
    transition: transform 0.5s ease;
}

.btn-primary:hover svg {
    transform: rotate(45deg);
}

/* Admin Modal Styles */
.admin-modal {
    position: fixed;
    inset: 0;
    background: rgba(5, 3, 15, 0.85);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 20px;
}

.admin-modal.active {
    opacity: 1;
    pointer-events: auto;
}

.admin-modal-content {
    background: var(--modal-bg);
    border: 1px solid var(--modal-border);
    border-radius: 24px;
    width: 100%;
    max-width: 1050px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.6), 0 0 40px rgba(188, 60, 242, 0.1);
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    overflow: hidden;
}

.admin-modal.active .admin-modal-content {
    transform: scale(1);
}

/* Admin sub-tabs */
.admin-tabs {
    display: flex;
    gap: 4px;
    padding: 0 24px;
    border-bottom: 1px solid var(--modal-border);
    background: var(--modal-footer-bg);
    flex-shrink: 0;
}

.admin-tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 0.3px;
    padding: 14px 18px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: var(--transition);
    position: relative;
}

.admin-tab-btn:hover {
    color: var(--modal-text);
}

.admin-tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    text-shadow: 0 0 12px var(--accent-glow);
}

.admin-tab-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.admin-tab-panel {
    display: none;
}

.admin-tab-panel.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.admin-modal-header {
    padding: 24px 32px;
    border-bottom: 1px solid var(--panel-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.admin-title {
    font-size: 22px;
    font-weight: 800;
    background: linear-gradient(90deg, var(--modal-text) 0%, var(--accent-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.modal-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 32px;
    cursor: pointer;
    transition: var(--transition);
    line-height: 1;
}

.modal-close-btn:hover {
    color: var(--modal-text);
    transform: scale(1.1);
}

.admin-grid {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* Manage Users section */
.admin-users-section {
    padding: 24px 32px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.admin-users-section .list-section-header {
    margin-bottom: 14px;
}

.users-grid {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 24px;
    min-height: 0;
    flex: 1;
}

.users-form-pane {
    padding: 0;
    border-right: none;
    overflow: hidden;
}

.users-list-pane {
    padding: 0;
    overflow: hidden;
}

/* Sections */
.admin-form-section {
    padding: 32px;
    border-right: 1px solid var(--panel-border);
    overflow-y: auto;
}

.admin-list-section {
    padding: 32px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.section-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--modal-text);
    letter-spacing: 0.5px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    background: var(--modal-input-bg);
    border: 1px solid var(--modal-border);
    border-radius: 10px;
    color: var(--modal-text);
    font-family: var(--font-family);
    font-size: 14px;
    transition: var(--transition);
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 8px rgba(188, 60, 242, 0.3);
    background: var(--modal-input-focus);
}

.input-with-btn {
    display: flex;
    gap: 10px;
}

.input-with-btn input {
    flex: 1;
}

.btn-action {
    background: var(--modal-input-bg);
    border: 1px solid var(--modal-border);
    color: var(--modal-text);
    padding: 0 16px;
    border-radius: 10px;
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition);
}

.btn-action:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.test-status {
    display: block;
    font-size: 11px;
    margin-top: 6px;
    font-weight: 500;
}

.test-status.checking {
    color: var(--text-muted);
}

.test-status.success {
    color: var(--success);
}

.test-status.failed {
    color: var(--error);
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 28px;
}

.btn-submit {
    flex: 1.5;
    padding: 12px;
    background: linear-gradient(135deg, var(--accent) 0%, rgba(188, 60, 242, 0.8) 100%);
    border: none;
    border-radius: 10px;
    color: #fff;
    font-family: var(--font-family);
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(188, 60, 242, 0.5);
}

.btn-cancel {
    flex: 1;
    padding: 12px;
    background: var(--modal-input-bg);
    border: 1px solid var(--modal-border);
    border-radius: 10px;
    color: var(--modal-muted);
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-cancel:hover {
    background: var(--modal-input-focus);
    color: var(--modal-text);
}

/* Admin Manage List Table */
.list-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 16px;
}

.list-section-header .section-title {
    margin-bottom: 0;
}

.admin-search-input {
    width: 150px;
    padding: 8px 12px;
    background: var(--modal-input-bg);
    border: 1px solid var(--modal-border);
    border-radius: 8px;
    color: var(--modal-text);
    font-family: var(--font-family);
    font-size: 13px;
    transition: var(--transition);
}

.admin-search-input:focus {
    outline: none;
    border-color: var(--accent-secondary);
    width: 200px;
}

.admin-channel-table {
    flex: 1;
    overflow-y: auto;
    border: 1px solid var(--modal-border);
    border-radius: 12px;
    background: var(--modal-table-bg);
}

.admin-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    border-bottom: 1px solid var(--panel-border);
    transition: var(--transition);
}

.admin-item-row:last-child {
    border-bottom: none;
}

.admin-item-row:hover {
    background: var(--modal-input-bg);
}

.admin-item-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.admin-item-logo {
    width: 38px;
    height: 38px;
    border-radius: 6px;
    overflow: hidden;
    background: var(--modal-input-bg);
    border: 1px solid var(--modal-border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

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

.admin-item-details {
    min-width: 0;
}

.admin-item-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--modal-text);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-item-group {
    font-size: 11px;
    color: var(--text-muted);
}

.user-role-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--accent-secondary);
    background: rgba(0, 242, 254, 0.1);
    border: 1px solid rgba(0, 242, 254, 0.25);
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 8px;
    vertical-align: middle;
}

.admin-item-actions {
    display: flex;
    gap: 6px;
    margin-left: 12px;
}

.btn-icon {
    background: var(--modal-input-bg);
    border: 1px solid var(--modal-border);
    color: var(--modal-muted);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-icon:hover {
    background: var(--modal-input-focus);
    color: var(--modal-text);
}

.btn-icon.edit-btn:hover {
    border-color: var(--accent-secondary);
    color: var(--accent-secondary);
    box-shadow: 0 0 8px var(--accent-secondary-glow);
}

.btn-icon.delete-btn:hover {
    border-color: var(--error);
    color: var(--error);
    box-shadow: 0 0 8px rgba(255, 74, 90, 0.3);
}

/* Footer */
.admin-modal-footer {
    padding: 20px 32px;
    border-top: 1px solid var(--modal-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--modal-footer-bg);
}

.btn-danger {
    background: rgba(255, 74, 90, 0.1);
    color: var(--error);
    border: 1px solid rgba(255, 74, 90, 0.2);
    padding: 10px 18px;
    border-radius: 10px;
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-danger:hover {
    background: var(--error);
    color: #fff;
    box-shadow: 0 4px 12px rgba(255, 74, 90, 0.3);
}

/* Responsive Admin */
@media (max-width: 900px) {
    .admin-modal-content {
        overflow-y: auto;
    }
    .admin-tab-body {
        overflow: visible;
    }
    .admin-tab-panel.active {
        display: block;
        overflow: visible;
    }
    .admin-grid {
        grid-template-columns: 1fr;
        overflow-y: visible;
    }
    .admin-form-section {
        border-right: none;
        border-bottom: 1px solid var(--panel-border);
        overflow-y: visible;
        padding: 24px;
    }
    .admin-list-section {
        padding: 24px;
        height: 400px;
    }
    .admin-users-section {
        flex: 0 0 auto;
    }
    .users-grid {
        grid-template-columns: 1fr;
    }
    .users-form-pane {
        padding: 0;
    }
    .users-list-pane {
        height: 220px;
    }
}

/* Sidebar Toggle Controls */
.btn-sidebar-toggle {
    background: var(--btn-bg);
    border: 1px solid var(--panel-border);
    color: var(--icon-color);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    margin-right: 12px;
}

.btn-sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
}

.app-container.sidebar-collapsed .sidebar {
    pointer-events: none;
    opacity: 0;
    margin-left: -350px;
}

.sidebar {
    transition: opacity 0.3s ease, margin-left 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Sidebar Stats Footer */
.sidebar-footer {
    padding: 16px 24px;
    background: var(--footer-bg);
    border-top: 1px solid var(--panel-border);
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: auto;
}

.stats-item {
    flex: 1;
    background: var(--modal-input-bg);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stats-label {
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stats-value {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Tab Badge Count */
.tab-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 20px;
    background: var(--badge-bg);
    color: var(--text-muted);
    margin-left: 6px;
    transition: var(--transition);
}

.tab-btn.active .tab-badge {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* Equalizer active indicator animation */
.equalizer-container {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    width: 14px;
    height: 14px;
    margin-left: 10px;
    flex-shrink: 0;
}

.equalizer-bar {
    width: 3px;
    height: 100%;
    background-color: var(--accent-secondary);
    animation: bounce 0.8s ease-in-out infinite alternate;
    border-radius: 1px;
    transform-origin: bottom;
}

.equalizer-bar:nth-child(2) {
    animation-duration: 0.5s;
    animation-delay: -0.15s;
}

.equalizer-bar:nth-child(3) {
    animation-duration: 0.7s;
    animation-delay: -0.3s;
}

@keyframes bounce {
    0% { transform: scaleY(0.2); }
    100% { transform: scaleY(1.0); }
}

/* Search Highlights */
mark.search-highlight {
    background: rgba(0, 242, 254, 0.22);
    color: var(--accent-secondary);
    padding: 0 1px;
    border-radius: 3px;
    font-weight: 700;
}

/* Password modal styling */
.password-card {
    background: var(--modal-bg);
    border: 1px solid var(--modal-border);
    border-radius: 20px;
    width: 100%;
    max-width: 400px;
    padding: 30px;
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.6), 0 0 40px rgba(188, 60, 242, 0.1);
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    text-align: center;
}

.admin-modal.active .password-card {
    transform: scale(1);
}

.password-header {
    margin-bottom: 24px;
}

.security-badge {
    width: 54px;
    height: 54px;
    background: rgba(188, 60, 242, 0.1);
    border: 1px solid var(--accent);
    color: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    box-shadow: 0 0 15px var(--accent-glow);
}

.password-header h2 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--modal-text);
}

.password-header p {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
}

.password-error-label {
    display: block;
    color: var(--error);
    font-size: 11px;
    font-weight: 600;
    margin-top: 6px;
    text-align: left;
    min-height: 16px;
}

/* Shake Animation for incorrect password */
.shake {
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}

/* Category Accordion Header styles */
.category-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--modal-input-bg);
    border-left: 3px solid var(--accent-secondary);
    border-radius: 6px;
    margin: 18px 0 10px;
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
}

.category-group-header:hover {
    background: var(--btn-bg-hover);
    border-left-color: var(--accent);
}

.category-title-area {
    display: flex;
    align-items: center;
    gap: 8px;
}

.category-title-text {
    font-size: 11px;
    font-weight: 800;
    color: var(--modal-text);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.category-count-badge {
    font-size: 9px;
    font-weight: 700;
    background: rgba(0, 242, 254, 0.1);
    color: var(--accent-secondary);
    padding: 2px 6px;
    border-radius: 12px;
}

.category-chevron {
    transition: transform 0.3s ease;
    color: var(--text-muted);
}

.category-group-header.collapsed .category-chevron {
    transform: rotate(-90deg);
}

.category-channel-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: max-height 0.3s ease-out;
    overflow: hidden;
}

.category-channel-container.collapsed {
    display: none;
}

/* Thumbnail Badge indicator tags */
.thumbnail-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: linear-gradient(135deg, var(--accent) 0%, rgba(188, 60, 242, 0.8) 100%);
    color: #fff;
    font-size: 8px;
    font-weight: 800;
    padding: 1px 4px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 6px rgba(188, 60, 242, 0.3);
    z-index: 2;
    pointer-events: none;
}

.thumbnail-badge.live {
    background: linear-gradient(135deg, #ff0844 0%, #ffb199 100%);
    box-shadow: 0 2px 6px rgba(255, 8, 68, 0.3);
}

/* ==========================================
   Theme Toggle Button
   ========================================== */
.btn-icon-theme {
    background: var(--btn-bg);
    border: 1px solid var(--panel-border);
    color: var(--icon-color);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.btn-icon-theme:hover {
    background: var(--btn-bg-hover);
    border-color: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
}

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

.btn-icon-theme .icon-sun {
    display: none;
}

[data-theme="dark"] .btn-icon-theme .icon-moon {
    display: none;
}

[data-theme="dark"] .btn-icon-theme .icon-sun {
    display: block;
}

/* Smooth color transitions when switching themes */
body,
.main-content,
.dashboard-header,
.player-container,
.player-meta,
.player-overlay,
.sidebar-footer {
    transition: background 0.3s ease, background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

