/* Basic Setup */
:root {
    --primary-color: #e50914;
    /* Netflix-like red for accents */
    --bg-color: #f4f4f4;
    --text-color: #333;
    --sidebar-bg: #eebcbd;
    /* Light pinkish background from screenshot sidebar */
    --header-bg: #fff;
    --controls-bg: #444;
    /* Dark grey for controls */
    --controls-text: #fff;
    --border-color: #ddd;
    --header-height: 80px;
    --footer-height: 60px;
}

/* Visibility Utilities */
.mobile-only {
    display: none !important;
}

/* Base resets */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    height: 100dvh;
    /* Dynamic viewport height for mobile browsers */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Prevent body scroll, use inner scrolling */
}

/* App Container */
/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    overflow: hidden;
    /* Ensure no scroll on container itself */
}

/* Header */
.channels-header {
    background-color: var(--header-bg);
    height: auto;
    min-height: var(--header-height);
    display: flex;
    align-items: center;
    border-bottom: 2px solid var(--primary-color);
    padding: 10px 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 10;
    flex-wrap: wrap;
    /* Allow wrapping on very small screens */
    gap: 10px;
}

.header-title {
    font-weight: 700;
    font-size: 1.2rem;
    margin-right: 20px;
    text-transform: uppercase;
    position: relative;
    white-space: nowrap;
}

.header-title::after {
    content: '';
    position: absolute;
    bottom: -15px;
    left: 0;
    width: 60px;
    height: 3px;
    background-color: var(--primary-color);
}

.menu-toggle-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-color);
    margin-right: 15px;
    display: none;
    /* Hidden on desktop */
}

.channel-list {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    scrollbar-width: none;
    /* Hide scrollbar for standard look */
    align-items: center;
    flex: 1;
    /* Take available width */
    min-width: 0;
    /* Allow flex item to shrink below content size */
}

.channel-list::-webkit-scrollbar {
    display: none;
}

.channel-item {
    border: 1px solid #ccc;
    border-radius: 5px;
    padding: 5px 10px;
    cursor: pointer;
    transition: all 0.3s;
    background: white;
    flex-shrink: 0;
    /* Don't shrink channel items */
}

.channel-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.channel-item.active {
    border-color: var(--primary-color);
    box-shadow: 0 0 5px rgba(229, 9, 20, 0.4);
    background-color: #fff0f0;
}

.channel-item img {
    height: auto;
    max-height: 60px;
    /* Constrain max height in list to keep header tidy */
    width: auto;
    object-fit: contain;
    display: block;
}

/* Specific override for user requested large logo if needed, 
   but for the list standardizing is better. 
   If user really wants BIG logo in header, we can increase max-height */
.channel-item[data-channel="nv"] img {
    max-height: 80px;
    /* Slightly larger for NV if desired */
}


/* Header Right Section */
.header-right {
    margin-left: auto;
    /* Push to the right */
    display: flex;
    align-items: center;
    gap: 15px;
    padding-left: 15px;
    /* Spacing from channel list */
    border-left: 1px solid #eee;
}

.header-separator {
    width: 1px;
    height: 20px;
    background-color: #ddd;
    display: block;
}

.social-media {
    display: flex;
    gap: 10px;
}

.social-media a {
    color: var(--text-color);
    font-size: 1rem;
    transition: color 0.2s;
    display: flex;
    align-items: center;
}

.social-media a:hover {
    color: var(--primary-color);
}

.viewer-count-widget {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-color);
    white-space: nowrap;
}

.viewer-count-widget i {
    color: var(--primary-color);
    /* Red eye icon */
}

.address-display {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-color);
    white-space: nowrap;
}

.address-display i {
    color: var(--primary-color);
}

.support-link,
.website-link {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: color 0.2s;
    white-space: nowrap;
}

.support-link:hover,
.website-link:hover {
    color: var(--primary-color);
}

.language-selector select {
    padding: 5px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: white;
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    outline: none;
}

.language-selector select:focus {
    border-color: var(--primary-color);
}

/* Main Content Area */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
    /* Height handled by flex parent */
    min-height: 0;
    /* Important for nested flex scroll */
}

/* Sidebar */
.program-guide {
    width: 250px;
    min-width: 250px;
    background-color: #f0f0f0;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    height: 100%;
}

.guide-header {
    padding: 15px;
    font-weight: 500;
    border-bottom: 1px solid #ccc;
    background-color: #e9e9e9;
}

.program-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
}

.program-item {
    padding: 12px 15px;
    border-bottom: 1px solid #e0e0e0;
    font-size: 0.9rem;
    color: #555;
    cursor: pointer;
    transition: all 0.2s;
}

/* Large Screens */
@media (min-width: 1600px) {
    .program-item {
        font-size: 1.1rem;
        padding: 15px 20px;
    }

    .live-status {
        font-size: 0.9rem;
        padding: 3px 8px;
    }
}

/* Small Mobile Screens */
@media (max-width: 480px) {
    .program-item {
        font-size: 0.8rem;
        padding: 10px 10px;
    }

    .program-item .time {
        width: 40px;
        /* Compress time width */
    }

    .live-status {
        font-size: 0.65rem;
        padding: 1px 4px;
    }
}

.program-item:hover {
    background-color: #e0e0e0;
}

.program-item.current {
    background-color: #ddd;
    color: #000;
    font-weight: 500;
    border-left: 4px solid var(--primary-color);
    animation: live-pulse 2s infinite;
    display: flex;
    /* Ensure flex alignment for badge */
    justify-content: space-between;
    /* Space out content */
    align-items: center;
}

/* Flashing Animation */
@keyframes live-pulse {
    0% {
        background-color: rgba(229, 9, 20, 0.1);
    }

    50% {
        background-color: rgba(229, 9, 20, 0.3);
    }

    100% {
        background-color: rgba(229, 9, 20, 0.1);
    }
}

.program-item .program-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.live-status {
    font-size: 0.75rem;
    color: white;
    background-color: var(--primary-color);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
    animation: text-flash 1.5s infinite;
    margin-left: auto;
    /* Push to right if not using space-between */
}

@keyframes text-flash {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }

    100% {
        opacity: 1;
    }
}


.program-item .time {
    display: inline-block;
    width: 50px;
    font-weight: bold;
    color: #333;
}

/* Video Player */
.video-player-container {
    flex: 1;
    background-color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    /* width: 100%; Removed to let flex handle it */
}

.video-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #000;
    /* Ensure black background when video hidden */
}

video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* Like TV not cropping */
    opacity: 0;
    /* Hidden by default to prevent error text flash */
    transition: opacity 0.5s ease-in;
}

video.video-active {
    opacity: 1;
    /* Fade in when playing */
}

/* Overlay for error/loading - hidden by default unless active */
.video-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: white;
    z-index: 5;
    pointer-events: none;
    /* Let clicks pass through to video */
    width: 100%;
    height: 100%;
    display: flex;
    /* Flexbox for centering children */
    justify-content: center;
    align-items: center;
}

.video-overlay>* {
    pointer-events: auto;
    /* Re-enable clicks for buttons */
}

.loading-spinner {
    font-size: 1.5rem;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.big-play-btn {
    background-color: rgba(229, 9, 20, 0.8);
    /* Red background */
    border: none;
    border-radius: 50%;
    width: 80px;
    height: 80px;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.big-play-btn:hover {
    transform: scale(1.1);
    background-color: rgba(229, 9, 20, 1);
}

.radio-visual {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background-color: #000;
    z-index: 4;
    /* Above video(0) */
    display: none;
}


/* Footer Controls */
.player-controls {
    background-color: var(--controls-bg);
    color: var(--controls-text);
    min-height: var(--footer-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 20px;
    font-family: monospace;
    flex-wrap: wrap;
    /* Auto wrap for smaller screens */
    gap: 10px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-btn {
    background: transparent;
    border: 1px solid #666;
    color: #ccc;
    padding: 5px 10px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.control-btn:hover {
    color: white;
    border-color: #999;
}

.control-btn.active {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.play-pause-btn {
    font-size: 1rem;
    width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.live-btn {
    border-color: var(--primary-color);
    color: var(--primary-color);
    font-weight: bold;
}

.live-btn:hover {
    background-color: var(--primary-color);
    color: white;
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 5px;
}

.volume-slider {
    width: 80px;
    height: 5px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

/* Responsive Design */
@media (max-width: 900px) {
    :root {
        --header-height: 60px;
        --footer-height: auto;
        /* Let it grow */
    }

    .menu-toggle-btn {
        display: block;
    }

    .header-title {
        display: none;
        /* Hide title on tablet/mobile to save space */
    }

    .program-guide {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 20;
        transform: translateX(-100%);
        box-shadow: 2px 0 5px rgba(0, 0, 0, 0.3);
        height: 100%;
        /* Full height overlay */
        background-color: #fff;
        /* Solid background for menu */
    }

    .program-guide.active {
        transform: translateX(0);
    }

    /* Show mobile elements */
    .mobile-only {
        display: block !important;
    }

    .desktop-only {
        display: none !important;
    }

    /* Mobile Menu Styling */
    .guide-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        background-color: var(--primary-color);
        color: white;
    }

    .close-menu-btn {
        background: none;
        border: none;
        color: white;
        font-size: 1.2rem;
        cursor: pointer;
    }

    .mobile-menu-content {
        padding: 15px;
        background-color: #f9f9f9;
        border-bottom: 1px solid #ddd;
    }

    .mobile-address {
        display: flex;
        gap: 10px;
        align-items: flex-start;
        font-size: 0.9rem;
        margin-bottom: 15px;
        color: #555;
    }

    .mobile-address i {
        color: var(--primary-color);
        margin-top: 3px;
    }

    .mobile-social {
        display: flex;
        gap: 20px;
        justify-content: center;
        margin-bottom: 15px;
        font-size: 1.2rem;
    }

    .mobile-links {
        display: flex;
        flex-direction: column;
        gap: 10px;
        margin-bottom: 15px;
    }

    .mobile-links a {
        text-decoration: none;
        color: #333;
        font-weight: 500;
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .mobile-language select {
        width: 100%;
        padding: 8px;
        border: 1px solid #ccc;
        border-radius: 4px;
    }

    .mobile-divider {
        border: 0;
        border-top: 1px solid #ddd;
        margin: 15px 0;
    }

    /* Channels Header specific adjustments for mobile */
    .channels-header {
        padding: 5px 10px;
    }

    .channel-item {
        padding: 3px 6px;
    }

    .channel-item img {
        max-height: 40px;
        /* Smaller icons on mobile */
    }

    /* Controls adjustments */
    .player-controls {
        flex-wrap: nowrap;
        /* Try to keep on one line if possible */
        padding: 10px;
        gap: 5px;
        overflow-x: auto;
        /* Scroll if absolutely necessary */
    }

    /* Hide less critical controls on mobile */
    .control-btn[title="-5 Dakika"],
    .control-btn[title="-1 Dakika"],
    .control-btn[title="+1 Dakika"],
    .control-btn[title="+5 Dakika"] {
        display: none !important;
    }

    .control-group.center {
        flex: 1;
        /* Take available space */
        justify-content: center;
        gap: 5px;
    }

    .control-btn {
        padding: 5px 8px;
        /* Smaller padding */
        font-size: 0.9rem;
        /* Readable icon size */
    }

    .time-display {
        font-size: 0.8rem;
    }

    /* Volume slider adjust */
    .volume-slider {
        width: 60px;
    }

    .header-right {
        gap: 10px;
        padding-left: 10px;
    }

    .menu-toggle-btn {
        display: none !important;
        /* Always visible on mobile now */
    }

    /* Stack Video -> Controls -> Guide on mobile */
    .app-container {
        height: auto;
        min-height: 100vh;
        overflow-y: auto;
        overflow-x: hidden;
        background-color: #000;
        display: flex;
        flex-direction: column;
    }

    /* Unwrap main-content to allow interleaving footer */
    .main-content {
        display: contents;
    }

    /* 1. Video on Top */
    .video-player-container {
        order: 1;
        width: 100%;
        height: auto;
        aspect-ratio: 16 / 9;
        background-color: #000;
        flex: none;
    }

    /* 2. Controls Below Video */
    .player-controls {
        order: 2;
        position: relative;
        width: 100%;
        z-index: 10;
        padding: 5px 10px;
        background-color: var(--controls-bg);
        justify-content: space-between;
        min-height: 50px;
        box-shadow: none;
        flex: none;
    }

    /* 3. Program Guide Fills Rest */
    .program-guide {
        order: 3;
        position: relative;
        top: auto;
        left: auto;
        transform: none;
        width: 100%;
        height: auto;
        z-index: 1;
        display: block;
        background-color: #f9f9f9;
        box-shadow: none;
        border-right: none;
        flex: 1 0 auto;
    }

    /* Hide close button as it's permanent now */
    .close-menu-btn {
        display: none !important;
    }

    .video-wrapper {
        position: relative;
        width: 100%;
        height: 100%;
    }

    video {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }

    /* Ensure secondary controls are hidden/shown correctly */
    .control-btn[title="-5 Dakika"],
    .control-btn[title="-1 Dakika"],
    .control-btn[title="+1 Dakika"],
    .control-btn[title="+5 Dakika"] {
        display: none !important;
    }
}

/* Very small screens */
@media (max-width: 480px) {
    .website-link {
        font-size: 0;
        /* Hide text, keep icon */
    }

    .website-link i {
        font-size: 1.2rem;
    }

    .language-selector select {
        padding: 3px;
        width: 50px;
    }
}