:root {
    --background-color: #121212;
    --surface-color: #1e1e1e;
    --primary-color: #bb86fc;
    --text-color: #e0e0e0;
    --border-radius: 8px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding: 2rem;
    transition: background-color 0.3s ease;
    display: flex;
    justify-content: center;
    flex-direction: column;
    align-content: center;
    flex-wrap: wrap;
}

#recaptcha-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100vh;
}

#main-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    width: 100%;
    max-width: 1800px;
    flex-wrap: wrap;
    justify-content: center;
}

/* --- Player Open State --- */
body.player-open #main-content {
    /* Mobile First: Player on top */
    flex-direction: column;
    align-items: stretch;
}

#player-container {
    display: none; /* Hidden by default */
    position: relative;
    width: 100%;
    max-width: 1102px;
    flex-direction: column;
}

#video-player {
    width: 100%; /* Responsive width */
    height: auto; /* Maintain aspect ratio */
    aspect-ratio: 16 / 9;
    border-radius: var(--border-radius);
    background-color: #000;
}

#button-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    width: 100%;
}

body.player-open #button-container {
    /* On mobile, channel list is full width below player */
    display: flex;
    flex-direction: column;
    width: 100%;
    max-height: 70vh; /* Limit height on mobile */

}

/* --- Desktop Layout (Player on the left) --- */
@media (min-width: 1024px) {
    body.player-open #main-content {
        flex-direction: row;
        align-items: flex-start;
    }

    #player-container {
        flex-grow: 1; /* Player takes available space */
        flex-direction: column;
    }

    body.player-open #button-container {
        width: 320px; /* Fixed width for channel list on desktop */
        flex-shrink: 0;
        max-height: 90vh;
        padding-right: 1rem;
    }
    .stream-button {
        padding: 1.5rem!important;
    }
}

.stream-button {
    background-color: var(--surface-color);
    color: var(--text-color);
    border: 1px solid transparent;
    border-radius: var(--border-radius);
    padding: 2rem;
    font-size: 1.2rem;
    min-width: 330px;
    text-align: left;
    cursor: pointer;
    transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 1rem;
    justify-content: flex-start;
    align-content: center;
    flex-direction: row;
}

.channel-logo {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border-radius: 4px;
    flex-shrink: 0;
}

.channel-info {
    display: flex;
    flex-direction: column;
}

/* Toggle between channel lists */
#list-toggle {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin: 0.75rem 0 0.5rem;
    position: sticky;
    top: 0;
    z-index: 300; /* above player and lists */
    padding: 0.5rem 0.75rem;
}

.toggle-button {
    background: transparent;
    color: var(--text-color);
    border: 1px solid var(--primary-color);
    border-radius: var(--border-radius);
    padding: 0.4rem 0.9rem;
    cursor: pointer;
}

.toggle-button.active {
    background: var(--primary-color);
    color: var(--background-color);
}

/* Footer */
.site-footer {
    margin-top: 2rem;
    display: flex;
    justify-content: center;
}

.button-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

@media (min-width: 640px) {
    .button-container {
        grid-template-columns: 1fr;
    }
}

/* Alternate theme colors for list B */
#button-container-b .stream-button {
    background-color: rgba(255, 255, 255, 0.06);
    border-color: rgba(167, 100, 252, 0.35);
}
#button-container-b .stream-button:hover {
    background-color: rgba(255, 255, 255, 0.10);
    border-color: rgba(167, 100, 252, 0.7);
}

#schedule-button {
    display: none; /* Hide by default */
    margin: 1rem auto 0;
    background-color: var(--surface-color);
    color: var(--text-color);
    border: 1px solid var(--primary-color);
    border-radius: var(--border-radius);
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    cursor: pointer;
}

/* Currently playing channel indicator */
.stream-button.playing {
    border-color: rgba(16, 93, 48, 0.51); /* green-ish */
    box-shadow: 0 0 10px rgba(73, 167, 113, 0.36), inset 0 0 2px rgba(47, 143, 87, 0.36);
}

#schedule-button:hover {
    background-color: var(--primary-color);
    color: var(--background-color);
}

/* Hide seek/progress controls in WebKit/Blink */
#video-player::-webkit-media-controls-timeline {
    display: none !important;
}
#video-player::-webkit-media-controls-seek-back-button,
#video-player::-webkit-media-controls-seek-forward-button {
    display: none !important;
}
#video-player::-webkit-media-controls-current-time-display,
#video-player::-webkit-media-controls-time-remaining-display {
    display: none !important;
}

.stream-button:hover {
    transform: translateY(-5px);
    background-color: rgba(255, 255, 255, 0.05);
    border-color: var(--primary-color);
}


.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.8);
    padding-top: 60px;
}

.modal-content {
    background-color: var(--surface-color);
    margin: 5% auto;
    padding: 2rem;
    border: 1px solid #888;
    width: 80%;
    max-width: 600px;
    border-radius: var(--border-radius);
    color: var(--text-color);
}

.modal .close-button {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.modal .close-button:hover,
.modal .close-button:focus {
    color: white;
    text-decoration: none;
    cursor: pointer;
}

#schedule-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

#schedule-table th, #schedule-table td {
    border: 1px solid #ddd;
    padding: 8px;
}

#schedule-table th {
    padding-top: 12px;
    padding-bottom: 12px;
    text-align: left;
    background-color: var(--primary-color);
    color: var(--background-color);
}

.channel-name {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.program-guide {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
    font-style: italic;
}

.control-button {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background-color: rgba(0, 0, 0, 0.5);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.2s ease;
}

#player-container:hover .control-button {
    opacity: 1;
}

/* Fullscreen sizing: ensure video fits screen without cropping on narrow monitors */
#video-player:fullscreen,
#video-player:-webkit-full-screen,
#video-player:-ms-fullscreen {
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    object-fit: contain !important;
    background: #000;
    border-radius: 0;
    aspect-ratio: auto;
}

#player-container:fullscreen #video-player,
#player-container:-webkit-full-screen #video-player,
#player-container:-ms-fullscreen #video-player {
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    object-fit: contain !important;
    border-radius: 0;
    aspect-ratio: auto;
}