@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

/* ==========================================
   MATTE PASTEL THEME VARIABLES (LIGHT & DARK)
========================================== */
:root {
    --pixel-per-minute: 6px;
    --channel-width: 150px;          /* Way bigger square channel block width */
    --time-header-height: 52px;     /* Slightly taller header for badge positioning */
    --row-height: 110px;              /* Substantially larger row height for prominent display */
    
    /* Solid Palette (Light Mode) */
    --bg-main: #353c4f;              /* Solid matte slate-blue background */
    --bg-matte: #ffffff;             /* Solid white */
    --bg-surface: #f8fafc;
    --surface-hover: #f1f5f9;
    
    /* Vivid Pastel Accents & Gradients */
    --border-subtle: #cbd5e1;
    --border-accent: #94a3b8;
    --blue-accent: #3b82f6;          /* sky blue */
    --blue-glow: none;
    --rose-glow: none;
    --spotlight-color-1: none;
    --spotlight-color-2: none;
    --primary-red: #3b82f6;          /* Blue "Now" line */
    
    /* Live Show Red/Pinkish Palette */
    --live-bg: #fef2f2;
    --live-border: #ef4444;
    --live-glow: none;
    --live-title-color: #991b1b;
    --live-time-color: #b91c1c;
    
    /* Grid Cell Gradients (Translucent for glassmorphic blur) */
    --program-bg: #f1f5f9; /* Soft off-white program block background */
    --program-hover-bg: #e2e8f0;
    
    /* Typography */
    --text-primary: #1e293b;
    --text-muted: #64748b;

    /* Background Flares (Light) */
    --flare-1-color: rgba(168, 85, 247, 0.55);
    --flare-1-mid: rgba(192, 132, 252, 0.2);
    --flare-1-fade: rgba(241, 243, 249, 0);

    --flare-2-color: rgba(251, 146, 60, 0.50);
    --flare-2-mid: rgba(244, 63, 94, 0.25);
    --flare-2-fade: rgba(241, 243, 249, 0);

    --flare-3-color: rgba(56, 189, 248, 0.45);
    --flare-3-mid: rgba(168, 85, 247, 0.15);
    --flare-3-fade: rgba(241, 243, 249, 0);

    --flare-4-color: rgba(0, 204, 214, 0.40);
    --flare-4-mid: rgba(0, 204, 214, 0.15);
    --flare-4-fade: rgba(241, 243, 249, 0);

    /* Elements Borders, Shadows & Backgrounds (Light) */
    --container-border: #cbd5e1;
    --container-shadow: 0 20px 50px rgba(0, 0, 0, 0.08);

    --grid-border: #cbd5e1;
    --grid-bg: #e2e8f0; /* Solid light grey grid background */
    --grid-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);

    --timeline-bg: #1e293b; /* Dark timeline matching screenshot */
    --channel-column-bg: #cbd5e1; /* Soft light grey channel column */
    --channel-logo-bg: #cbd5e1;

    --program-border: #e2e8f0;
    --program-shadow: none;

    --scrollbar-track: #e2e8f0;
    --scrollbar-thumb: #cbd5e1;
    --scrollbar-thumb-hover: #94a3b8;

    --row-grid-line: #cbd5e1;

    /* Hover cards & Modal structures (Light) */
    --hover-card-bg: rgba(255, 255, 255, 0.88);
    --hover-card-border: rgba(139, 92, 246, 0.45); /* Accentuated light violet border */
    --hover-card-shadow: 0 20px 40px -10px rgba(139, 92, 246, 0.3), 0 10px 20px -5px rgba(244, 63, 94, 0.15), 0 0 0 1px rgba(192, 132, 252, 0.4);
    --hover-card-overlay-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0.80) 40%, rgba(255, 255, 255, 0.95) 100%);
    
    --modal-overlay-bg: rgba(15, 23, 42, 0.35);
    --modal-bg: rgba(255, 255, 255, 0.95);
    --modal-border: rgba(255, 255, 255, 0.9);
    --modal-shadow: 0 30px 60px -12px rgba(139, 92, 246, 0.25), 0 18px 36px -18px rgba(0, 0, 0, 0.1);
    --modal-overlay-gradient: linear-gradient(0deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.3) 60%, rgba(0, 0, 0, 0.1) 100%);
    --modal-close-bg: rgba(255, 255, 255, 0.85);
    --modal-credits-bg: rgba(248, 250, 252, 0.8);
    
    /* Category tags (Light) */
    --tag-category-bg: #e0f2fe;
    --tag-category-text: #0369a1;
    --tag-category-border: #bae6fd;
    --tag-category-shadow: rgba(56, 189, 248, 0.15);

    --tag-year-bg: #fef3c7;
    --tag-year-text: #92400e;
    --tag-year-border: #fde68a;
    --tag-year-shadow: rgba(251, 146, 60, 0.15);

    /* Episode tags (Light) */
    --tag-episode-bg: #f3e8ff;
    --tag-episode-text: #6b21a8;
    --tag-episode-border: #e9d5ff;
    --tag-episode-shadow: rgba(168, 85, 247, 0.15);
}

/* ==========================================
   MATTE BLACK THEME VARIABLE OVERRIDES
========================================== */
body.dark-mode {
    /* Premium Plex Warm Charcoal & Amber Gold Palette */
    --bg-main: #353c4f;              /* Keep body background color the same */
    --bg-matte: rgba(24, 24, 33, 0.95); /* Matte dark glass */
    --bg-surface: #181821;           /* Lighter dark blue-slate background (#181821) */
    --surface-hover: #2a2a3a; 
    
    /* Subtle Accents */
    --border-subtle: #2a2a3a;        
    --border-accent: #3d3d56;        
    --blue-accent: #3b82f6;          
    --blue-glow: rgba(59, 130, 246, 0.15);
    --rose-glow: rgba(244, 63, 94, 0.15);
    --spotlight-color-1: rgba(229, 169, 59, 0.16);
    --spotlight-color-2: rgba(251, 146, 60, 0.06);
    --primary-red: #ef4444;          
    
    /* Live Show Red/Pinkish Palette */
    --live-bg: linear-gradient(135deg, rgba(50, 24, 30, 0.98) 0%, rgba(42, 20, 26, 0.95) 100%);
    --live-border: #fda4af;          
    --live-glow: rgba(253, 164, 175, 0.25);
    --live-title-color: #ffe4e6;     
    --live-time-color: #fecdd3;      
    
    /* Grid Cell Colors */
    --program-bg: #181821;           /* Solid EPG grid block background */
    --program-hover-bg: #2a2a3a;     /* Hover state background */
    
    /* Typography */
    --text-primary: #f4f4f5;         
    --text-muted: #a1a1aa;           
    
    /* Background Flares (Plex Warm Amber and Gold Vignette) */
    --flare-1-color: rgba(229, 169, 59, 0.28);
    --flare-1-mid: rgba(229, 169, 59, 0.08);
    --flare-1-fade: rgba(18, 19, 23, 0);

    --flare-2-color: rgba(244, 63, 94, 0.18);
    --flare-2-mid: rgba(244, 63, 94, 0.05);
    --flare-2-fade: rgba(18, 19, 23, 0);

    --flare-3-color: rgba(251, 146, 60, 0.20);
    --flare-3-mid: rgba(251, 146, 60, 0.08);
    --flare-3-fade: rgba(18, 19, 23, 0);

    --flare-4-color: rgba(0, 204, 214, 0.22);
    --flare-4-mid: rgba(0, 204, 214, 0.08);
    --flare-4-fade: rgba(18, 19, 23, 0);

    /* Elements Borders, Shadows & Backgrounds */
    --container-border: #2a2a3a;
    --container-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);

    --grid-border: #2a2a3a;
    --grid-bg: #1b202c;              
    --grid-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);

    --timeline-bg: #1b202c;          
    --channel-column-bg: #121620;    /* Darker to differ from program blocks grid */
    --channel-logo-bg: #121620;

    --program-border: #2a2a3a;
    --program-shadow: none;

    --scrollbar-track: #1b202c;
    --scrollbar-thumb: #2a2a3a;
    --scrollbar-thumb-hover: #3d3d56;

    --row-grid-line: #2a2a3a;

    /* Hover cards & Modal structures (Zinc Matte Theme) */
    --hover-card-bg: #27272a;
    --hover-card-border: #3f3f46;
    --hover-card-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
    --hover-card-overlay-bg: linear-gradient(180deg, rgba(39, 39, 42, 0.15) 0%, rgba(39, 39, 42, 0.70) 50%, rgba(39, 39, 42, 0.98) 100%);
    
    --modal-overlay-bg: rgba(0, 0, 0, 0.75);
    --modal-bg: #27272a;
    --modal-border: #3f3f46;
    --modal-shadow: 0 30px 60px rgba(0, 0, 0, 0.7);
    --modal-overlay-gradient: linear-gradient(0deg, rgba(39, 39, 42, 0.96) 0%, rgba(39, 39, 42, 0.4) 60%, rgba(0, 0, 0, 0.3) 100%);
    --modal-close-bg: rgba(63, 63, 70, 0.85);
    --modal-credits-bg: rgba(24, 24, 27, 0.8);
    
    /* Category tags (Dark) */
    --tag-category-bg: rgba(56, 189, 248, 0.15);
    --tag-category-text: var(--blue-accent);
    --tag-category-border: rgba(56, 189, 248, 0.3);
    --tag-category-shadow: rgba(56, 189, 248, 0.1);

    --tag-year-bg: rgba(251, 146, 60, 0.15);
    --tag-year-text: #e28a2b;
    --tag-year-border: rgba(251, 146, 60, 0.3);
    --tag-year-shadow: rgba(251, 146, 60, 0.1);

    /* Episode tags (Dark) */
    --tag-episode-bg: rgba(168, 85, 247, 0.15);
    --tag-episode-text: #c084fc;
    --tag-episode-border: rgba(168, 85, 247, 0.3);
    --tag-episode-shadow: rgba(168, 85, 247, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    padding: 10px 0 30px 0; /* Reduced top padding to push logo higher */
    position: relative;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

body.grid-page {
    background-color: var(--bg-main);
    background-image: none !important;
}

/* ==========================================
   MATTE CONTAINER
========================================== */
#epg-container {
    width: 92%; /* Reduced slightly for balanced margin spacing */
    max-width: 2500px; /* Massive max-width for widescreen layouts */
    margin: 10px auto 60px auto;
    position: relative;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: none;
    box-shadow: none;
    z-index: 1;
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}


/* ==========================================
   CONTROLS BAR, DATE SELECT & SEARCH BAR
========================================== */
/* Centered Logo block */
.logo-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px 0 16px 0;
    width: 100%;
}
.controls-bar-logo {
    height: 105px !important; /* Made logo bigger */
    width: auto;
    filter: none !important; /* Remove glow filters */
}

.controls-bar {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    height: 48px;
    margin-bottom: 0; /* Set flush against the grid */
    padding: 0;
    position: relative;
    z-index: 2;
    background: var(--grid-bg);
    border: 1px solid var(--border-subtle);
    border-bottom: 2px solid var(--border-subtle); /* Thin divider between controls and day blocks */
    border-radius: 0;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    width: 100%;
    box-sizing: border-box;
}

.right-country {
    display: flex;
    align-items: stretch;
    height: 100%;
    gap: 0 !important;
}

/* Base style for control blocks to match day tabs */
.right-country #country-select,
.btn-favorites,
.btn-backdrop,
.btn-primetime {
    height: 100% !important;
    width: 150px !important; /* Uniform width matching channel column */
    border: none !important;
    border-right: 1px solid var(--border-subtle) !important;
    border-radius: 0 !important;
    background: #f8fafc !important; /* Soft off-white */
    color: #475569 !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    font-size: 11px !important;
    letter-spacing: 0.8px !important;
    padding: 0 !important; /* Reset padding to align centered on uniform width */
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    box-sizing: border-box !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
    outline: none !important;
    box-shadow: none !important;
    appearance: none !important;
    -webkit-appearance: none !important;
}

/* Hover effect */
.right-country #country-select:hover,
.btn-favorites:hover,
.btn-backdrop:hover,
.btn-primetime:hover {
    background: #f8fafc !important;
}

/* Active highlights & Live button formatting */
.btn-live {
    position: sticky !important;
    right: 66px !important; /* Adjusted for smaller button width */
    margin-left: auto !important;
    top: 14px !important; /* Positioned at the exact same top level as the timeline hours */
    transform: none !important;
    z-index: 300 !important;
    height: 18px !important;
    line-height: 18px !important;
    padding: 0 8px !important;
    border-radius: 0 !important; /* Sharp corners/square edges */
    font-size: 8.5px !important;
    font-weight: 700 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border: none !important;
    background: #ef4444 !important;
    color: #ffffff !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    text-transform: uppercase !important;
    letter-spacing: 0.8px !important;
    animation: live-button-pulse 2s infinite ease-in-out;
}
.btn-live:hover {
    background: #dc2626 !important;
    animation: none; /* Pause pulse on hover */
}

@keyframes live-button-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

.btn-favorites.active {
    background: #f59e0b !important; /* Keep gold active color */
    color: #ffffff !important;
}
.btn-favorites.active:hover {
    background: #d97706 !important;
}

body.enable-backdrop .btn-backdrop {
    background: #3b82f6 !important; /* Keep blue active color */
    color: #ffffff !important;
}

/* Search Box Container & Input override to match blocks */
.search-container {
    display: flex !important;
    align-items: stretch !important;
    padding: 0 !important;
    width: 350px !important;
    max-width: 350px !important;
    border: none !important;
    border-left: 1px solid var(--border-subtle) !important;
    background: #f8fafc !important; /* Soft off-white */
    height: 100% !important;
}

.search-input-wrapper {
    height: 100% !important;
    width: 100% !important;
    display: flex !important;
    align-items: stretch !important;
    position: relative !important;
}

.search-input {
    height: 100% !important;
    width: 100% !important;
    background: #f8fafc !important; /* Soft off-white */
    color: #353c4f !important; /* Match timeline background color */
    border: none !important;
    border-radius: 0 !important;
    padding: 0 16px 0 38px !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.8px !important;
    box-sizing: border-box !important;
}

/* Position search icon relative to input */
.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    pointer-events: none;
    z-index: 10;
    color: #353c4f !important; /* Match timeline background color */
}

.animated-placeholder {
    left: 36px !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.8px !important;
    color: #353c4f !important; /* Match timeline background color */
}

/* Dark Mode overrides */
body.dark-mode .right-country #country-select,
body.dark-mode .btn-favorites,
body.dark-mode .btn-live,
body.dark-mode .btn-backdrop,
body.dark-mode .btn-primetime,
body.dark-mode .search-container,
body.dark-mode .search-input {
    background: #181821 !important;
    color: #a1a1aa !important;
    border-right: 1px solid var(--border-subtle) !important;
}

body.dark-mode .right-country #country-select:hover,
body.dark-mode .btn-favorites:hover,
body.dark-mode .btn-live:hover,
body.dark-mode .btn-backdrop:hover,
body.dark-mode .btn-primetime:hover,
body.dark-mode .search-container:hover,
body.dark-mode .search-input:hover {
    background: #2a2a3a !important;
}

/* Dark mode search input text and icon color adjustments */
body.dark-mode .search-input {
    color: #f4f4f5 !important; /* Brighter text when typing */
}
body.dark-mode .animated-placeholder {
    color: #a1a1aa !important; /* Zinc-400 for placeholder */
}
body.dark-mode .search-icon {
    color: #a1a1aa !important; /* Zinc-400 for search icon */
}

body.dark-mode .btn-live {
    background: #dc2626 !important;
    color: #ffffff !important;
}
body.dark-mode .btn-favorites.active {
    background: #d97706 !important;
    color: #ffffff !important;
}
body.dark-mode.enable-backdrop .btn-backdrop {
    background: #2563eb !important;
    color: #ffffff !important;
}

/* ==========================================
   DAYS OF THE WEEK TAB BAR
========================================== */
#days-tab-bar {
    display: flex;
    height: 48px;
    background: var(--grid-bg);
    border: 1px solid var(--border-subtle);
    border-top: none;
    border-bottom: 2px solid var(--border-subtle); /* Thin divider line between days and timeline */
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
}

.day-tab {
    flex: 1;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.8px;
    cursor: pointer;
    border-right: 1px solid var(--border-subtle);
    background: #f1f5f9; /* Soft light grey */
    color: #475569;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.day-tab:last-child {
    border-right: none;
}

.day-tab.active {
    background: #3b82f6 !important; /* sky blue active */
    color: #ffffff !important;
}

.day-tab:not(.active) {
    background: #ffffff;
    color: #334155;
}

.day-tab:hover:not(.active) {
    background: #f8fafc;
}

/* Dark Mode overrides for Days Tab Bar */
body.dark-mode #days-tab-bar {
    background: var(--grid-bg);
}

body.dark-mode .day-tab {
    border-right: 1px solid var(--border-subtle);
    background: #181821;
    color: #a1a1aa;
}

body.dark-mode .day-tab.active {
    background: #3b82f6 !important; /* Active blue indicator */
    color: #ffffff !important;
}

body.dark-mode .day-tab:not(.active) {
    background: #181821;
    color: #a1a1aa;
}

body.dark-mode .day-tab:hover:not(.active) {
    background: #2a2a3a;
}

/* DATE PICKER STYLES */
.date-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
}

.calendar-icon {
    width: 20px;
    height: 20px;
    color: #00ccd6; /* Aquatic cyan/teal color */
    flex-shrink: 0;
}

#date-select {
    background-color: var(--bg-surface);
    color: var(--text-primary);
    border: none; /* Borderless select box */
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
    appearance: none;          /* Remove native browser dropdown arrow */
    -webkit-appearance: none;   /* Safari/Chrome */
    -moz-appearance: none;      /* Firefox */
}

#date-select:hover, #date-select:focus {
    background-color: var(--surface-hover);
    box-shadow: 0 0 16px var(--blue-glow);
    outline: none;
}

/* CENTER CHANNEL SEARCH BOX */
.search-container {
    flex: 0 0 auto;      /* no flex grow */
    margin: 0 0 0 auto;  /* push it to the right */
}

.search-input-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
}

.search-input {
    width: 100%;
    background-color: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    padding: 10.5px 16px 10.5px 40px;
    border-radius: 20px;
    font-size: 13.5px;
    font-weight: 500;
    outline: none;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.animated-placeholder {
    position: absolute;
    left: 40px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--text-muted);
    font-size: 13.5px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5px;
    opacity: 0.6;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

/* Hide custom animated placeholder when input is focused or has content */
.search-input:focus ~ .animated-placeholder,
.search-input:not(:placeholder-shown) ~ .animated-placeholder {
    opacity: 0;
    visibility: hidden;
}

.animated-placeholder .dot {
    display: inline-block;
    animation: dot-bounce 1.4s infinite ease-in-out both;
}

.animated-placeholder .dot:nth-child(1) {
    animation-delay: 0s;
}

.animated-placeholder .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.animated-placeholder .dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dot-bounce {
    0%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-4px);
    }
}

.search-input:hover {
    border-color: var(--border-accent);
}

.search-input:focus {
    border-color: var(--blue-accent);
    box-shadow: 0 0 0 3px var(--blue-glow);
}

.search-icon {
    display: none !important;
}

/* Dynamic Context Backdrop Container and Layer System */
.backdrop-container {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
    transition: backdrop-filter 0.3s ease, background-color 0.3s ease;
}

body.enable-backdrop .backdrop-container {
    backdrop-filter: blur(70px) saturate(1.4);
    -webkit-backdrop-filter: blur(70px) saturate(1.4);
    background: rgba(255, 255, 255, 0.48); /* Brightened frosted light overlay for light mode */
}

body.enable-backdrop.dark-mode .backdrop-container {
    background: rgba(18, 19, 23, 0.18); /* Brighter (0.18 opacity) warm charcoal vignette overlay for dark mode */
}

.backdrop-layer {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
    filter: blur(8px) brightness(0.65) saturate(0.8);
    -webkit-filter: blur(8px) brightness(0.65) saturate(0.8);
    transition: opacity 1.8s ease-in-out;
}

body.enable-backdrop .backdrop-layer.active {
    opacity: 0.50; /* Highly visible in dark theme */
}

/* Slightly brighter overlay for light mode readability */
body.enable-backdrop:not(.dark-mode) .backdrop-layer.active {
    opacity: 0.50; /* Highly visible in light theme */
    filter: blur(8px) brightness(0.9) saturate(0.8);
    -webkit-filter: blur(8px) brightness(0.9) saturate(0.8);
}

/* Force high visibility color backdrop on welcome splash page always */
body.splash-page .backdrop-layer.active {
    opacity: 0.68 !important;
}

/* Splash-specific adjustments */
.splash-page {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

/* Force the container to be centered regardless of other styles */
.splash-container {
    margin: 0 !important; 
    width: 90% !important;
    max-width: 500px !important;
    padding: 40px !important;
    display: flex;
    flex-direction: column;
    align-items: center;    /* Centers the H1, P, and Dropdown inside the card */
    text-align: center;
    background: var(--bg-matte); /* Maintains your matte aesthetic */
}

/* Splash landing page spacing */
.splash-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    width: 100%;
}

/* Ensure the body is a full-screen flex container */
body.splash-page {
    display: flex !important;
    justify-content: center !important; /* Centers horizontally */
    align-items: center !important;     /* Centers vertically */
    background-color: var(--bg-main);
    overflow: hidden; /* Prevents scrollbars */
}

/* 1. Style the select element itself */
#country-select {
    width: 100%;
    display: block;
    padding: 10px 20px;          /* match date-select */
    border-radius: 20px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-size: 13.5px;           /* match date-select */
    font-weight: 600;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;       /* Added Firefox coverage */
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    text-align: center;
}

/* 2. Add a custom modern arrow */
.dropdown-wrapper {
    position: relative;
    width: 100%;
    max-width: 300px;
}

/* 3. Hover and Focus effects to match your grid */
#country-select:hover {
    background-color: var(--surface-hover);
    border-color: var(--blue-accent);
}

#country-select:focus {
    outline: none;
    border-color: var(--blue-accent);
    box-shadow: 0 0 0 3px var(--blue-glow);
}

/* Ensure dropdown options have solid backgrounds to prevent browser contrast bugs */
select option {
    background-color: #ffffff !important;
    color: #1e293b !important;
}

body.dark-mode select option {
    background-color: #1e293b !important;
    color: #f8fafc !important;
}

/* Force the container to respect the flex parent and remove the grid margin */
#epg-container.splash-container {
    margin: 0 !important; 
    top: auto !important;
    left: auto !important;
    position: relative !important;
    width: 90% !important;
    max-width: 620px !important; /* Stretched from 500px to keep tagline on one line */
}

.selection-area {
    margin-top: 30px;
    display: flex;
    gap: 15px;
    justify-content: center;
}

.splash-container button {
    padding: 12px 24px;
    border-radius: 20px;
    border: none;
    background: var(--blue-accent);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}

.splash-container button:hover {
    transform: scale(1.05);
}

/* ==========================================
   EPG CANVAS GRID WRAPPER (MATTE STYLED)
========================================== */
#grid-wrapper {
    display: grid;
    grid-template-columns: var(--channel-width) 1fr;
    grid-template-rows: var(--time-header-height) auto;
    overflow-x: auto;
    overflow-y: visible; /* Extended to follow full page scroll */
    max-height: none;    /* Allow height to grow dynamically */
    position: relative;
    width: 100%;
    border: 1px solid var(--border-subtle);
    border-top: none;
    border-radius: 0;
    background: var(--grid-bg);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* Custom Scrollbar */
#grid-wrapper::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
#grid-wrapper::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}
#grid-wrapper::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 4px;
}
#grid-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* ==========================================
   TIMELINE HEADER (STICKY)
========================================== */
#timeline-corner {
    grid-column: 1;
    grid-row: 1;
    position: sticky;
    top: 0;
    left: 0;
    z-index: 250 !important; /* Increased to stay on top of scrolling timeline segments */
    background-color: #353c4f; /* Matte slate-blue matching page background */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    display: flex !important;
    align-items: stretch !important;
    justify-content: stretch !important;
    overflow: hidden;
}

#timeline {
    grid-column: 2;
    grid-row: 1;
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--time-header-height);
    background-color: #353c4f; /* Matte slate-blue matching page background */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transition: background-color 0.3s ease;
    display: flex !important;
    align-items: center !important;
}

.timeline-segment {
    position: absolute;
    top: 16px;
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #f8fafc; /* Crisp off-white text */
    transform: translateX(-50%);
}

.timeline-segment::after {
    content: '';
    position: absolute;
    bottom: -16px;
    left: 50%;
    width: 1px;
    height: 6px;
    background-color: rgba(255, 255, 255, 0.3); /* Translucent white ticks */
}

/* ==========================================
   STICKY DIRECTV-STYLE CHANNEL COLUMN
========================================== */
#channel-column {
    grid-column: 1;
    grid-row: 2;
    position: sticky;
    left: 0;
    z-index: 200;
    width: var(--channel-width);
    flex-shrink: 0;
    background-color: transparent; /* Clear background so gaps expose page theme */
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.channel {
    height: var(--row-height); /* Full vertical height matching row */
    min-height: var(--row-height);
    max-height: var(--row-height);
    margin-top: 0; /* Remove vertical gap */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 6px 10px;
    border: 1px solid var(--border-accent); /* Enhanced solid border */
    color: var(--text-primary);
    background-color: var(--channel-column-bg); /* Solid channel card background */
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
}

.btn-favorite {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--text-muted);
    opacity: 0.4;
    transition: all 0.2s ease-in-out;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-favorite:hover {
    color: #f59e0b;
    opacity: 1;
    transform: scale(1.15);
}

.btn-favorite.is-favorite {
    color: #f59e0b;
    opacity: 1;
}

.channel .btn-favorite {
    position: absolute;
    top: 4px;
    right: 4px;
    z-index: 10;
}

.channel-logo-hulu {
    width: 110px; /* Upscaled uniform width */
    height: 65px; /* Upscaled uniform height */
    object-fit: contain;
    margin-bottom: 8px;
    display: block;
    transition: transform 0.2s ease;
}

.channel-logo-hulu:hover {
    transform: scale(1.05);
}

.channel-name-under {
    font-size: 9px;
    font-weight: 600;
    opacity: 0.80;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    white-space: normal; /* Allow wrapping */
    word-wrap: break-word;
    overflow-wrap: break-word;
    width: 100%;
    line-height: 1.25;
    margin-top: 2px;
}

.channel-name-only {
    font-size: 13px;
    font-weight: 700;
    line-height: 1.25;
    word-wrap: break-word;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    max-width: 95%;
}

/* ==========================================
   GRID CANVAS & PROGRAM BLOCKS
========================================== */
#grid {
    grid-column: 2;
    grid-row: 2;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: visible;              /* Allows Now line to project into the timeline header */
}

.row {
    position: relative;
    height: var(--row-height);
    min-height: var(--row-height);
    max-height: var(--row-height);
    border-bottom: none; /* Removed horizontal dividing line */
    transition: border-color 0.3s ease;
}

.program {
    position: absolute;
    top: 0; /* Remove vertical gap */
    height: 100%; /* Full height matching row */
    background: var(--program-bg);
    border: 1px solid var(--border-accent); /* Enhanced solid border */
    border-radius: 0; /* Sharp corners */
    padding: 8px 12px;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    overflow: hidden;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    cursor: pointer;
}



/* Background dynamic color glows animation keyframes */
@keyframes slow-glow-1 {
    0%, 100% {
        transform: translate(0, 0) scale(1) rotate(0deg);
        filter: hue-rotate(0deg);
    }
    33% {
        transform: translate(120px, 80px) scale(1.15) rotate(120deg);
        filter: hue-rotate(90deg);
    }
    66% {
        transform: translate(-60px, 140px) scale(0.92) rotate(240deg);
        filter: hue-rotate(180deg);
    }
}

@keyframes slow-glow-2 {
    0%, 100% {
        transform: translate(0, 0) scale(1) rotate(0deg);
        filter: hue-rotate(0deg);
    }
    33% {
        transform: translate(-100px, 120px) scale(1.12) rotate(-120deg);
        filter: hue-rotate(-60deg);
    }
    66% {
        transform: translate(80px, -80px) scale(0.95) rotate(-240deg);
        filter: hue-rotate(120deg);
    }
}

@keyframes slow-glow-3 {
    0%, 100% {
        transform: translate(0, 0) scale(1) rotate(0deg);
        filter: hue-rotate(0deg);
    }
    50% {
        transform: translate(140px, -90px) scale(1.2) rotate(180deg);
        filter: hue-rotate(240deg);
    }
}

@keyframes slow-glow-4 {
    0%, 100% {
        transform: translate(0, 0) scale(1) rotate(0deg);
        filter: hue-rotate(0deg);
    }
    50% {
        transform: translate(-120px, 100px) scale(1.18) rotate(-180deg);
        filter: hue-rotate(-180deg);
    }
}

.program-title {
    font-size: 13.5px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    line-height: 1.2;
    color: var(--text-primary);
}

.program-time {
    font-size: 11px;
    font-weight: 700;
    color: var(--primary-red);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.program:hover {
    background: var(--program-hover-bg);
    border-color: var(--border-accent);
    z-index: 10;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

/* ==========================================
   CURRENTLY PLAYING (LIVE) SHOW - PURPLE THEME
========================================== */
/* Live styling removed to match reference pic layout */

/* ==========================================
   ACCENTUATED PREVIEW CARD & SHOW ICON
========================================== */
#programme-hover-card {
    position: fixed;
    display: none;
    z-index: 9999;
    width: 340px;
    border-radius: 20px;
    overflow: hidden;
    color: var(--text-primary);
    background: var(--hover-card-bg);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: 1.5px solid var(--hover-card-border) !important; /* Clearly defined, not too thick border */
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28) !important;
    pointer-events: none !important; /* Disable all mouse interactions */
    opacity: 0;
    transform: scale(0.95); /* Start slightly smaller for subtle zoom entrance */
    transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.3s ease, border-color 0.3s ease;
}

#programme-hover-card.visible {
    opacity: 1;
    transform: scale(1);
}

#programme-hover-card * {
    pointer-events: none !important; /* Ensure children cannot intercept mouse events */
}

#programme-hover-card .card-bg-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 1;
    transform: scale(1);
    transition: transform 8s cubic-bezier(0.1, 0.8, 0.3, 1);
}

@keyframes hover-card-zoom {
    0% {
        transform: scale(1);
    }
    100% {
        transform: scale(1.08);
    }
}

#programme-hover-card.visible .card-bg-image {
    transform: scale(1.06); /* Slow, premium zoom to match the index page's Ken Burns style */
    transition: transform 8s cubic-bezier(0.1, 0.8, 0.3, 1);
}

.hover-card-art, .hover-card-icon {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 8px 20px rgba(139, 92, 246, 0.25);
    margin-bottom: 8px;
}

.hover-card-overlay {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--hover-card-overlay-bg);
    margin-top: -10px;
    position: relative;
    z-index: 2;
    transition: background 0.3s ease;
    border-radius: 0 0 19px 19px; /* Force bottom corners to clip inside parent borders */
}

.hover-card-overlay .card-channel {
    font-size: 11px;
    font-weight: 800;
    color: var(--blue-accent);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.hover-card-overlay .card-title {
    font-size: 17px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.25;
}

.hover-card-overlay .card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
}

.hover-card-overlay .card-desc {
    font-size: 12px;
    color: var(--text-primary);
    line-height: 1.45;
    margin-top: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hover-card-overlay .card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.hover-card-overlay .tag-category {
    background-color: var(--tag-category-bg);
    color: var(--tag-category-text);
    border: 1px solid var(--tag-category-border);
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 8px;
    box-shadow: 0 2px 6px var(--tag-category-shadow);
    transition: all 0.3s ease;
}

.hover-card-overlay .tag-year {
    background-color: var(--tag-year-bg);
    color: var(--tag-year-text);
    border: 1px solid var(--tag-year-border);
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 8px;
    box-shadow: 0 2px 6px var(--tag-year-shadow);
    transition: all 0.3s ease;
}

.hover-card-overlay .tag-episode {
    background-color: var(--tag-episode-bg);
    color: var(--tag-episode-text);
    border: 1px solid var(--tag-episode-border);
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 8px;
    box-shadow: 0 2px 6px var(--tag-episode-shadow);
    transition: all 0.3s ease;
}

/* ==========================================
   PROGRAMME DETAIL MODAL & ACTORS GRID
========================================== */
#programme-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background-color: var(--modal-overlay-bg);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.3s ease;
}

#programme-modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background-color: var(--modal-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--modal-border);
    border-radius: 8px;
    width: 100%;
    max-width: 680px;
    max-height: 88vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--modal-shadow);
    transform: scale(0.95);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

#programme-modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-header-art {
    width: 100%;
    height: 280px;
    background-size: cover;
    background-position: center top;
    position: relative;
    background-color: var(--bg-main);
    overflow: hidden;
    -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 1) 70%, rgba(0, 0, 0, 0) 100%);
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 1) 70%, rgba(0, 0, 0, 0) 100%);
}

.modal-header-overlay {
    position: absolute;
    inset: 0;
    background: var(--modal-overlay-gradient);
    display: flex;
    align-items: flex-end;
    padding: 24px;
    transition: background 0.3s ease;
    z-index: 1;
}

.modal-close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 10;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--modal-close-bg);
    backdrop-filter: blur(6px);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease, background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.modal-close-btn:hover {
    background-color: var(--primary-red);
    color: #ffffff;
    border-color: var(--primary-red);
    transform: scale(1.05);
}

.modal-body {
    padding: 0 28px 28px 28px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.modal-title {
    font-size: 26px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

.modal-meta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.modal-badge {
    background-color: rgba(139, 92, 246, 0.12);
    color: var(--blue-accent);
    border: 1px solid rgba(139, 92, 246, 0.25);
    padding: 3px 10px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
}

.modal-section-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--blue-accent);
    margin-bottom: 8px;
}

.modal-description {
    font-size: 14.5px;
    line-height: 1.6;
    color: var(--text-primary);
}

.modal-credits-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px 20px;
    background-color: var(--modal-credits-bg);
    border: 1px solid var(--border-subtle);
    padding: 20px;
    border-radius: 14px;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.actor-card {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.actor-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.actor-role {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    line-height: 1.2;
}

/* ==========================================
   DYNAMIC RED "NOW" LINE & TIME PILL
========================================== */
#now-line {
    position: absolute;
    top: calc(-1 * var(--time-header-height)); /* Projects into timeline header */
    height: calc(100% + var(--time-header-height));
    width: 2px;
    background-color: var(--primary-red);
    z-index: 300;                            /* Renders over header and grid */
    pointer-events: none;
    box-shadow: none !important;
}

/* DirecTV-style Pill Badge inside the Sticky Header */
.now-time-badge {
    position: absolute;
    top: 12px;                               /* Aligns with segment hours */
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--primary-red);
    color: #ffffff;
    font-size: 11.5px;
    font-weight: 800;
    padding: 3px 10px;
    border-radius: 14px;
    letter-spacing: 0.5px;
    box-shadow: none !important;
    white-space: nowrap;
}

/* Constrain the new dropdown width */
.dropdown-wrapper.country-nav {
    width: 200px;
}

/* Ensure the select inside the nav matches the header feel */
.dropdown-wrapper.country-nav #country-select {
    padding: 10px 16px;
    font-size: 13px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    border-radius: 20px;
    cursor: pointer;
    width: 100%;
}

.dropdown-wrapper.country-nav #country-select:hover {
    border-color: var(--blue-accent);
}

.floating-search {
    position: absolute;
    top: 20px;
    right: 40px;
    z-index: 999;
}

.floating-search input {
    padding: 10px 16px;
    border-radius: 20px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.right-country {
    display: flex;
    align-items: stretch;
    gap: 0 !important;
    flex: 0 0 auto;
}

.right-country select {
    padding: 10px 16px;
    border-radius: 20px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.btn-live {
    background: #ef4444;
    border: 1px solid #ef4444;
    color: #ffffff;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 700;
    font-size: 13px;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0; 
}

.btn-live:hover {
    background: #dc2626;
    border-color: #dc2626;
    color: #ffffff;
}

.btn-backdrop {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 700;
    font-size: 13px;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0; 
}

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

/* Active toggle style when backdrop is turned ON */
body.enable-backdrop .btn-backdrop {
    background: #3b82f6 !important;
    color: #ffffff !important;
    border: none !important;
    border-right: 1px solid var(--border-subtle) !important;
    box-shadow: none !important;
}

/* ==========================================
   THEME TOGGLE BUTTON STYLES
========================================== */
.theme-toggle-btn {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    cursor: pointer;
    padding: 10px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.theme-toggle-btn:hover {
    border-color: var(--blue-accent);
    transform: scale(1.1);
    box-shadow: 0 0 12px var(--blue-glow);
}

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

body.dark-mode .theme-toggle-btn .sun-icon {
    display: block;
}
body.dark-mode .theme-toggle-btn .moon-icon {
    display: none;
}

/* Float style for splash screen */
.floating-theme-toggle {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 1000;
}

/* ==========================================
   MOBILE & TABLET RESPONSIVENESS (MEDIA QUERIES)
========================================== */
@media (max-width: 768px) {
    :root {
        --channel-width: 120px;          /* Slimmer channel column on mobile */
        --row-height: 62px;              /* More compact rows on mobile */
        --time-header-height: 46px;      /* Slightly shorter header */
        --pixel-per-minute: 5px;         /* Squeezed EPG timeline horizontal pixels */
    }

    body.dark-mode {
        --channel-width: 120px;
        --row-height: 62px;
        --time-header-height: 46px;
        --pixel-per-minute: 5px;
    }

    /* Controls wrap adjustments - integrated into grid borders */
    .controls-bar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0 !important;
        padding: 0 !important;
        height: auto !important;
        background: var(--grid-bg) !important;
        box-shadow: none !important;
        border: 1px solid var(--border-subtle) !important;
        border-bottom: none !important;
    }

    .right-country {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0 !important;
        width: 100% !important;
    }

    .right-country #country-select,
    .right-country .btn-favorites,
    .right-country .btn-backdrop,
    .right-country .btn-primetime {
        width: 100% !important;
        height: 42px !important;
        border: none !important;
        border-right: 1px solid var(--border-subtle) !important;
        border-bottom: 1px solid var(--border-subtle) !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }

    /* Remove right borders for the 2nd column items on mobile */
    .right-country .btn-favorites,
    .right-country .btn-primetime {
        border-right: none !important;
    }

    /* Day tabs scrollbar-less horizontal scroll for mobile */
    #days-tab-bar {
        overflow-x: auto !important;
        display: flex !important;
        scrollbar-width: none;
        border: 1px solid var(--border-subtle) !important;
        border-top: none !important;
        border-bottom: 2px solid var(--border-subtle) !important;
    }
    #days-tab-bar::-webkit-scrollbar {
        display: none;
    }
    .day-tab {
        flex: 0 0 80px !important;
        min-width: 80px !important;
    }

    /* Mobile Search Box - matching other action boxes in dimensions and style */
    .search-container {
        width: 100% !important;
        max-width: 100% !important;
        height: 42px !important;
        border: none !important;
        border-bottom: 1px solid var(--border-subtle) !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        box-sizing: border-box !important;
        position: relative !important;
        overflow: hidden !important;
        background: #f8fafc !important;
    }
    body.dark-mode .search-container {
        background: #181821 !important;
    }
    .search-input {
        background: transparent !important;
        border-radius: 0 !important;
        height: 100% !important;
    }

    /* Mobile Channel Cards */
    .channel {
        padding: 6px 8px !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        text-align: center !important;
    }

    /* Hide the channel text name completely on mobile if logo is successfully loaded */
    .channel-name-under {
        display: none !important;
    }

    .channel-logo-hulu {
        width: auto !important;
        max-width: 80px !important;
        height: auto !important;
        max-height: 40px !important;
        margin: 0 auto !important;
        display: block !important;
    }

    .channel-name-only {
        font-size: 10px !important;
        font-weight: 700 !important;
        line-height: 1.2 !important;
        max-width: 100% !important;
        display: block !important;
    }

    /* Smaller Timeline Segments & Live button on mobile */
    .timeline-segment {
        font-size: 11px !important;
    }
    
    .btn-live {
        height: 18px !important;
        line-height: 18px !important;
        padding: 0 8px !important;
        font-size: 8.5px !important;
        right: 60px !important;
    }

    /* Splash/Welcome page overrides */
    .splash-container {
        width: 92% !important;
        padding: 24px !important;
        margin: 16px !important;
    }

    .splash-content h1 {
        font-size: 24px !important;
    }

    /* Detail Modal mobile adaptations */
    .modal-content {
        width: 100% !important;
        margin: 10px !important;
        max-height: 90vh !important;
    }

    .modal-header-art {
        height: 180px !important;
    }

    .modal-title {
        font-size: 20px !important;
    }
}

/* Past programming EPG timeline overlay styling */
#past-overlay {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    background-color: rgba(53, 60, 79, 0.32) !important; /* Lighter translucent version of timeline slate-blue (#353c4f) */
    pointer-events: none;
    z-index: 20 !important;
    transition: width 0.1s ease;
}

body.dark-mode #past-overlay {
    background-color: rgba(0, 0, 0, 0.45) !important; /* Neutral dark overlay to dim past items without color tinting */
}

/* Live program progress bar styles */
.program-progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background-color: rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

.program-progress-fill {
    height: 100%;
    background-color: #00ccd6; /* Aquatic cyan/teal */
}

body.dark-mode .program-progress-bar {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Animated Multicolor Logo Glow Keyframes */
@keyframes logo-glow {
    0% {
        filter: drop-shadow(0 0 3px rgba(0, 204, 214, 0.5)); /* Subtle Cyan */
    }
    25% {
        filter: drop-shadow(0 0 4px rgba(168, 85, 247, 0.6)); /* Subtle Purple */
    }
    50% {
        filter: drop-shadow(0 0 3px rgba(236, 72, 153, 0.5)); /* Subtle Pink */
    }
    75% {
        filter: drop-shadow(0 0 4px rgba(245, 158, 11, 0.6)); /* Subtle Gold */
    }
    100% {
        filter: drop-shadow(0 0 3px rgba(0, 204, 214, 0.5)); /* Back to Cyan */
    }
}

/* Inline Controls Bar Logo */
.controls-bar-logo {
    height: 10px; /* Note: inline style overrides this height, which is fine! */
    width: auto;
    object-fit: contain;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
    margin-right: 12px;
}

.controls-bar-logo:hover {
    transform: scale(1.08); /* Highlight pop on hover */
}

/* Adapt spacing on mobile */
@media (max-width: 768px) {
    .controls-bar-logo {
        height: 8px; /* Even smaller on mobile layouts */
        margin-right: 6px;
    }
}

/* Timeline Scroll Button (Right Square block) */
.btn-scroll-right {
    position: sticky !important;
    top: auto !important; /* Prevent vertical sticky offset calculations on page load */
    right: 0 !important;
    transform: none !important;
    z-index: 300;
    background: #3b82f6 !important; /* Blue color matching the day selector */
    color: #ffffff !important;
    border: none !important;
    border-radius: 0 !important; /* Sharp corners/square */
    width: var(--time-header-height) !important; /* Make it a square */
    height: 100% !important; /* Stretch to full height of flex container timeline */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer !important;
    box-shadow: none !important;
    transition: background-color 0.2s ease !important;
    pointer-events: auto !important;
    margin-left: auto !important;
}

.btn-scroll-right:hover {
    background: #2563eb !important;
}

body.dark-mode .btn-scroll-right {
    background: #2563eb !important;
}

body.dark-mode .btn-scroll-right:hover {
    background: #1d4ed8 !important;
}

/* Timeline Scroll Button (Left Square block) */
.btn-scroll-left {
    position: relative !important;
    transform: none !important;
    z-index: 300;
    background: #3b82f6 !important; /* Blue color matching the day selector */
    color: #ffffff !important;
    border: none !important;
    border-radius: 0 !important; /* Sharp corners/square */
    width: 100% !important; /* Fill the full width of the channel column corner (150px) */
    height: 100% !important; /* Stretch to full height of timeline corner */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer !important;
    box-shadow: none !important;
    transition: background-color 0.2s ease !important;
    pointer-events: auto !important;
}

.btn-scroll-left:hover {
    background: #2563eb !important;
}

body.dark-mode .btn-scroll-left {
    background: #2563eb !important;
}

body.dark-mode .btn-scroll-left:hover {
    background: #1d4ed8 !important;
}

.btn-scroll-right:active,
.btn-scroll-left:active {
    transform: scale(0.96) !important;
}

/* Favourites Filter Toggle Button */
.btn-favorites {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 700;
    font-size: 13px;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-favorites:hover {
    background: var(--bg-hover);
    border-color: var(--border-medium);
}

.btn-favorites.active {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); /* Gold premium gradient */
    border-color: #d97706;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
}

.btn-favorites.active:hover {
    background: linear-gradient(135deg, #fbbf24 0%, #d97706 100%);
    box-shadow: 0 6px 16px rgba(245, 158, 11, 0.5);
}

.btn-favorites.active svg {
    color: #ffffff;
}

.btn-favorites svg {
    color: #f59e0b; /* Golden star when not selected too */
    transition: color 0.2s ease;
}

/* Site Footer */
.site-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px; /* Compact spacing */
    padding: 30px 0 50px 0;
    width: 100%;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    clear: both;
}

.footer-tagline {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary); /* Changed to primary text for higher contrast */
    text-transform: none; /* Preserve tagline casing */
    letter-spacing: 0.6px;
    margin-bottom: 8px;
    text-align: center;
    opacity: 0.95; /* Increased opacity for light mode visibility */
}

.splash-tagline {
    font-size: 14.5px;
    font-weight: 500;
    color: var(--text-primary); /* Changed to primary text for higher contrast */
    margin-top: 10px;
    text-align: center;
    max-width: 580px; /* Stretched from 460px to keep tagline on one line */
    margin-left: auto;
    margin-right: auto;
    line-height: 1.5;
    opacity: 0.95; /* Increased opacity for light mode visibility */
}

.splash-logo {
    height: 170px; /* Schedula TV logo dimension */
    width: auto;
    object-fit: contain;
    margin-bottom: 20px;
    display: block;
    margin-left: auto;
    margin-right: auto;
    filter: none !important; /* Remove glow filters */
}

.footer-row-top {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.footer-row-bottom {
    margin-top: 4px;
}

.footer-logo {
    height: 45px; /* Size for footer visibility */
    width: auto;
    object-fit: contain;
    opacity: 0.70; /* Increased opacity */
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.footer-logo:hover {
    opacity: 0.95;
    transform: scale(1.05);
}

.footer-text {
    opacity: 0.75; /* Increased opacity */
    color: var(--text-muted);
}

.footer-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.2px;
    transition: color 0.2s ease, text-shadow 0.2s ease;
    opacity: 0.80; /* Increased opacity */
    cursor: pointer;
}

.footer-link:hover {
    color: var(--blue-accent);
    opacity: 0.95;
    text-shadow: 0 0 8px rgba(0, 204, 214, 0.4);
}

/* Legal Modal Styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6); /* Translucent backdrop overlay */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.legal-modal-card {
    background: var(--hover-card-bg);
    border: 1px solid var(--hover-card-border);
    border-radius: 8px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    width: 90%;
    max-width: 650px;
    max-height: 75vh;
    padding: 32px;
    position: relative;
    transform: translateY(40px) scale(0.95);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

.modal-overlay.active .legal-modal-card {
    transform: translateY(0) scale(1);
}

.legal-modal-content {
    overflow-y: auto;
    padding-right: 12px;
    color: var(--text-primary);
}

.legal-modal-content h2 {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 6px;
    background: linear-gradient(135deg, #00ccd6 0%, #3b82f6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.legal-modal-content h3 {
    font-size: 14px;
    font-weight: 700;
    margin: 20px 0 8px 0;
    color: var(--blue-accent);
}

.legal-modal-content p, 
.legal-modal-content li {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.legal-modal-content ul {
    margin-left: 20px;
    margin-bottom: 12px;
}

.legal-modal-content li {
    margin-bottom: 6px;
}

.last-updated {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 16px;
}

.modal-close-btn {
    position: absolute;
    top: 24px;
    right: 24px;
    background: none;
    border: none;
    font-size: 28px;
    font-weight: 300;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s ease, transform 0.2s ease;
    line-height: 1;
}

.modal-close-btn:hover {
    color: var(--primary-red);
    transform: rotate(90deg);
}

/* Custom Scrollbar for scrollable legal content */
.legal-modal-content::-webkit-scrollbar {
    width: 6px;
}
.legal-modal-content::-webkit-scrollbar-track {
    background: transparent;
}
.legal-modal-content::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 3px;
}

/* Scroll to Top Button (Floating Page Viewport Corner) */
.btn-scroll-to-top {
    position: fixed !important;
    bottom: 30px !important;
    right: 30px !important; /* Floating at the far bottom-right page background corner */
    z-index: 999999 !important; /* High index to float on top of page background, grid, and backdrop */
    background: rgba(239, 68, 68, 0.95) !important; /* Vibrant Red */
    color: #ffffff !important;
    border: 2px solid #ffffff !important;
    border-radius: 50% !important;
    width: 40px !important;
    height: 40px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5) !important;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px) scale(0.9);
}

.btn-scroll-to-top.visible {
    opacity: 1 !important;
    pointer-events: auto !important;
    transform: translateY(0) scale(1) !important;
}

.btn-scroll-to-top:hover {
    background: #dc2626 !important;
    transform: scale(1.12) !important;
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.6) !important;
}

.btn-scroll-to-top:active {
    transform: scale(0.95) !important;
}

/* Green NEW Badge for Program Cards */
.new-badge-indicator {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background-color: #16a34a !important; /* Matte Green (No gradients) */
    color: #ffffff !important;
    font-size: 9px !important; /* Normalized font size */
    font-weight: 800 !important;
    padding: 3.5px 7px !important; /* Increased height and proportional width */
    border-radius: 3px !important; /* Defined rectangle corners */
    letter-spacing: 0.4px !important; /* Normalized to prevent horizontal stretch */
    line-height: 1.1 !important; /* Balanced line vertical spacing */
    z-index: 10 !important;
    text-transform: uppercase !important;
    pointer-events: none !important;
    box-shadow: none !important; /* No glows or reflections */
    border: none !important; /* Flat matte borderless design */
    display: inline-flex !important; /* Center alignment container */
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
}

/* Red LIVE Badge for Program Cards */
.live-badge-indicator {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background-color: #dc2626 !important; /* Matte Red (No gradients) */
    color: #ffffff !important;
    font-size: 9px !important;
    font-weight: 800 !important;
    padding: 3.5px 7px !important; /* Same size as NEW badge */
    border-radius: 3px !important; /* Same rectangular corners */
    letter-spacing: 0.4px !important;
    line-height: 1.1 !important;
    z-index: 10 !important;
    text-transform: uppercase !important;
    pointer-events: none !important;
    box-shadow: none !important; /* Flat matte design */
    border: none !important;
    display: inline-flex !important; /* Center alignment container */
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
}

/* Hover Preview Card Badge Size Overrides (Slightly smaller, not stretched) */
#programme-hover-card .new-badge-indicator,
#programme-hover-card .live-badge-indicator {
    font-size: 8px !important;
    padding: 1px 5px !important; /* Reduced height from 2px to 1px */
    line-height: 1 !important;
    display: inline-flex !important; /* Center text vertically and horizontally */
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
}

/* Country indicator badge for favorited channels lists */
.channel-country-badge {
    font-size: 8.5px;
    font-weight: 700;
    text-transform: uppercase;
    color: #f59e0b; /* Match golden favorite star */
    opacity: 0.90;
    letter-spacing: 0.8px;
    display: inline-block;
    margin-top: 2px;
}

/* Live Program Block Right-Aligned Rectangular Image (Adaptive sizing) */
.program-live-image {
    object-fit: cover !important;
    border-radius: 4px !important;
    margin-left: 8px !important;
    flex-shrink: 0 !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1) !important;
}
.program-live-image.size-large {
    width: 110px !important;
    height: 68px !important;
    border-radius: 6px !important;
    margin-left: 12px !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.15), 0 2px 4px -2px rgba(0, 0, 0, 0.15) !important;
}
.program-live-image.size-medium {
    width: 80px !important;
    height: 50px !important;
}
.program-live-image.size-small {
    width: 50px !important;
    height: 32px !important;
}

@media (max-width: 768px) {
    .program-live-image.size-large {
        width: 60px !important;
        height: 38px !important;
        margin-left: 6px !important;
        border-radius: 4px !important;
    }
    .program-live-image.size-medium {
        width: 45px !important;
        height: 28px !important;
        margin-left: 4px !important;
    }
    .program-live-image.size-small {
        width: 30px !important;
        height: 20px !important;
        margin-left: 4px !important;
        border: 0.5px solid rgba(255, 255, 255, 0.15) !important;
    }
}

/* Live EPG Program Block - Soft Desaturated Steel-Blue Matte Highlight */
.program.is-live {
    background: #dbeafe !important; /* Muted sky-blue tint (highly visible) */
    border: 1.5px solid #3b82f6 !important; /* Distinct blue border outline */
}

.program.is-live .program-title {
    color: #1e3a8a !important; /* Crisp dark navy title */
    font-weight: 700 !important;
}

.program.is-live .program-time {
    color: #1e40af !important; /* Navy timing text */
}

body.dark-mode .program.is-live {
    background: #242f41 !important; /* Muted matte steel-blue dark shade */
    border: 1px solid #3d4f68 !important; /* Muted border */
}

body.dark-mode .program.is-live .program-title {
    color: #f1f5f9 !important; /* Standard light slate title */
    text-shadow: none !important; /* No glowing neon effects */
}

body.dark-mode .program.is-live .program-time {
    color: #94a3b8 !important; /* Muted slate time */
}
