/* ========================================
   AmberTV - IPTV Streaming Application
   Modern Dark Theme with Amber Accents
   ======================================== */

:root {
    /* Color Palette - Dark Cinema Theme */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a25;
    --bg-card: #15151f;
    --bg-card-hover: #1e1e2a;
    
    /* Amber Accent Colors */
    --accent-primary: #f59e0b;
    --accent-secondary: #fbbf24;
    --accent-glow: rgba(245, 158, 11, 0.3);
    --accent-subtle: rgba(245, 158, 11, 0.1);
    
    /* Text Colors */
    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    
    /* Borders */
    --border-color: rgba(255, 255, 255, 0.06);
    --border-color-hover: rgba(255, 255, 255, 0.12);
    
    /* Status Colors */
    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px var(--accent-glow);
    
    /* Spacing */
    --sidebar-width: 280px;
    --header-height: 60px;
    
    /* Typography */
    --font-primary: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;
    
    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

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

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ========================================
   Layout
   ======================================== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ========================================
   Sidebar
   ======================================== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    overflow: hidden;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow);
}

.logo-icon svg {
    width: 24px;
    height: 24px;
    color: var(--bg-primary);
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

/* Source Selector */
.source-selector {
    padding: 16px 20px 8px;
}

.source-selector label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.source-selector select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition-fast);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.source-selector select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

.source-selector select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 8px;
}

.source-selector select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: var(--bg-secondary);
}

/* Search */
.search-container {
    padding: 8px 20px 16px;
    position: relative;
}

.search-icon {
    position: absolute;
    left: 32px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
}

#searchInput {
    width: 100%;
    padding: 12px 12px 12px 44px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 0.9rem;
    transition: var(--transition-fast);
}

#searchInput:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

#searchInput::placeholder {
    color: var(--text-muted);
}

/* Navigation */
.nav-menu {
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font-primary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    text-align: left;
    width: 100%;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-subtle);
    color: var(--accent-primary);
}

.nav-item.active svg {
    color: var(--accent-primary);
}

/* Categories */
.categories-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
    border-top: 1px solid var(--border-color);
    margin-top: 8px;
}

.categories-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    padding: 0 16px 12px;
}

.categories-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.category-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font-primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition-fast);
    text-align: left;
    width: 100%;
}

.category-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.category-item.active {
    background: var(--accent-subtle);
    color: var(--accent-primary);
}

.category-count {
    font-size: 0.75rem;
    font-family: var(--font-mono);
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
}

.category-item.active .category-count {
    background: var(--accent-primary);
    color: var(--bg-primary);
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.stats {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 8px;
}

.stats span {
    color: var(--accent-primary);
    font-weight: 600;
    font-family: var(--font-mono);
}

.cache-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.cache-status {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.cache-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
}

.cache-status.from-cache::before {
    background: var(--success);
}

.cache-status.from-network::before {
    background: var(--accent-primary);
}

.refresh-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.refresh-btn:hover {
    background: var(--bg-card-hover);
    color: var(--accent-primary);
}

.refresh-btn.loading svg {
    animation: spin 1s linear infinite;
}

.refresh-btn svg {
    width: 14px;
    height: 14px;
}

/* ========================================
   Main Content
   ======================================== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Player Section */
.player-section {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.player-wrapper {
    position: relative;
    width: 100%;
    max-height: 60vh;
    aspect-ratio: 16 / 9;
    background: #000;
    overflow: hidden;
}

#videoPlayer {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.player-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(10, 10, 15, 0.95), rgba(18, 18, 26, 0.9));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 10;
}

.player-overlay.hidden {
    display: none;
}

.play-button {
    width: 80px;
    height: 80px;
    background: var(--accent-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow);
    animation: pulse 2s infinite;
}

.play-button svg {
    width: 32px;
    height: 32px;
    color: var(--bg-primary);
    margin-left: 4px;
}

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

.player-overlay p {
    color: var(--text-secondary);
    font-size: 1rem;
}

.player-overlay .error-icon {
    width: 80px;
    height: 80px;
    background: var(--error);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
}

.player-overlay .error-icon svg {
    width: 40px;
    height: 40px;
    color: white;
}

.player-overlay .error-hint {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 8px;
}

/* Loading Spinner */
.loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 15;
    display: none;
}

.loading-spinner.active {
    display: block;
}

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

.spinner.large {
    width: 50px;
    height: 50px;
    border-width: 4px;
}

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

/* Now Playing Bar */
.now-playing {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
}

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

.channel-logo-large {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    object-fit: contain;
    background: var(--bg-card);
    padding: 8px;
}

.channel-details h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.channel-category-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 4px 10px;
    background: var(--accent-subtle);
    color: var(--accent-primary);
    border-radius: var(--radius-sm);
}

.favorite-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.favorite-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.favorite-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: var(--bg-primary);
}

.favorite-btn.active svg {
    fill: var(--bg-primary);
}

.favorite-btn svg {
    width: 20px;
    height: 20px;
}

/* ========================================
   Channels Section
   ======================================== */
.channels-section {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

.channels-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.channels-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.view-toggles {
    display: flex;
    gap: 4px;
    background: var(--bg-tertiary);
    padding: 4px;
    border-radius: var(--radius-md);
}

.view-toggle {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.view-toggle:hover {
    color: var(--text-primary);
}

.view-toggle.active {
    background: var(--bg-card);
    color: var(--accent-primary);
}

.view-toggle svg {
    width: 18px;
    height: 18px;
}

/* Channels Grid */
.channels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.channels-grid.list-view {
    grid-template-columns: 1fr;
    gap: 8px;
}

/* Channel Card */
.channel-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    cursor: pointer;
    transition: var(--transition-normal);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
    position: relative;
    overflow: hidden;
}

.channel-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    transform: scaleX(0);
    transition: var(--transition-normal);
}

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

.channel-card:hover::before {
    transform: scaleX(1);
}

.channel-card.active {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 1px var(--accent-primary), var(--shadow-glow);
}

.channel-card.active::before {
    transform: scaleX(1);
}

.channel-logo {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-md);
    object-fit: contain;
    background: var(--bg-tertiary);
    padding: 8px;
}

.channel-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.channel-group {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
}

.channel-favorite-icon {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 20px;
    height: 20px;
    color: var(--accent-primary);
    opacity: 0;
    transition: var(--transition-fast);
}

.channel-card:hover .channel-favorite-icon,
.channel-card.is-favorite .channel-favorite-icon {
    opacity: 1;
}

.channel-card.is-favorite .channel-favorite-icon {
    fill: var(--accent-primary);
}

/* List View Styles */
.channels-grid.list-view .channel-card {
    flex-direction: row;
    text-align: left;
    padding: 12px 16px;
    gap: 16px;
}

.channels-grid.list-view .channel-logo {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

.channels-grid.list-view .channel-name {
    flex: 1;
}

.channels-grid.list-view .channel-favorite-icon {
    position: static;
    opacity: 0;
}

/* Loading State */
.channels-loading {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px;
    gap: 16px;
    color: var(--text-muted);
}

/* Empty State */
.empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px;
    gap: 16px;
    color: var(--text-muted);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    color: var(--text-muted);
    opacity: 0.5;
}

/* ========================================
   Toast Notifications
   ======================================== */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 20px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    box-shadow: var(--shadow-lg);
    transform: translateY(100px);
    opacity: 0;
    transition: var(--transition-normal);
    z-index: 1000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success {
    border-color: var(--success);
}

.toast.error {
    border-color: var(--error);
}

/* ========================================
   Keyboard Help
   ======================================== */
.keyboard-help {
    position: fixed;
    bottom: 24px;
    left: calc(var(--sidebar-width) + 24px);
    z-index: 1000;
}

.keyboard-help-toggle {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.keyboard-help-toggle:hover {
    background: var(--bg-card-hover);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.keyboard-help-toggle svg {
    width: 20px;
    height: 20px;
}

.keyboard-help-content {
    position: absolute;
    bottom: 54px;
    left: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: var(--transition-normal);
    box-shadow: var(--shadow-lg);
}

.keyboard-help.expanded .keyboard-help-content {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.keyboard-help.expanded .keyboard-help-toggle {
    background: var(--accent-primary);
    color: var(--bg-primary);
    border-color: var(--accent-primary);
}

.shortcut {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.shortcut:not(:last-child) {
    border-bottom: 1px solid var(--border-color);
}

kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-primary);
}

@media (max-width: 768px) {
    .keyboard-help {
        left: 24px;
    }
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 240px;
    }
    
    .channels-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: var(--transition-normal);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .player-wrapper {
        max-height: 40vh;
    }
    
    .channels-section {
        padding: 16px;
    }
    
    .channels-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
    }
    
    .channel-card {
        padding: 16px;
    }
    
    .channel-logo {
        width: 48px;
        height: 48px;
    }
}

/* ========================================
   Animations
   ======================================== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.channel-card {
    animation: fadeIn 0.3s ease backwards;
}

.channel-card:nth-child(1) { animation-delay: 0.02s; }
.channel-card:nth-child(2) { animation-delay: 0.04s; }
.channel-card:nth-child(3) { animation-delay: 0.06s; }
.channel-card:nth-child(4) { animation-delay: 0.08s; }
.channel-card:nth-child(5) { animation-delay: 0.1s; }
.channel-card:nth-child(6) { animation-delay: 0.12s; }
.channel-card:nth-child(7) { animation-delay: 0.14s; }
.channel-card:nth-child(8) { animation-delay: 0.16s; }
.channel-card:nth-child(9) { animation-delay: 0.18s; }
.channel-card:nth-child(10) { animation-delay: 0.2s; }
