/* =========================================================
   Adrevv TV Player — Frontend Styles v1.4.2
   ========================================================= */

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

/* ── Variables ── */
.adrevv-tv-wrap {
    --atv-font:             'DM Sans', system-ui, sans-serif;
    --atv-font-mono:        'DM Mono', monospace;
    --atv-player-bg:        #0a0a0f;
    --atv-sched-bg:         #111318;
    --atv-sched-item-bg:    #1c2030;
    --atv-sched-item-hover: #242840;
    --atv-sched-item-now:   #1a3a5c;
    --atv-sched-border:     rgba(255,255,255,.07);
    --atv-sched-text:       #ffffff;
    --atv-sched-subtext:    rgba(255,255,255,.55);
    --atv-sched-radius:     3px;

    /* Frame + chrome (themable: dark by default, overridden by .is-light) */
    --atv-frame-bg:         #1a1c22;
    --atv-chrome-strong:    rgba(255,255,255,.45);
    --atv-chrome-faint:     rgba(255,255,255,.35);
    --atv-divider:          rgba(255,255,255,.07);
    --atv-scrollbar:        #3a3d48;

    --atv-accent:           #2563eb;
    --atv-accent-light:     #3b82f6;
    --atv-live-red:         #ef4444;
    --atv-sidebar-w:        240px;
    --player-height:        520px;

    /* Button settings — overridden per-instance by admin settings */
    --atv-btn-inactive-bg:     #2a2d35;
    --atv-btn-inactive-border: #d1d5db;
    --atv-btn-active-bg:       #ef4444;
    --atv-btn-active-border:   #374151;
    --atv-btn-hover-bg:        #ef4444;
    --atv-btn-hover-border:    #374151;
    --atv-btn-text-color:      #ffffff;
    --atv-btn-font-size:       14px;
    --atv-btn-font-weight:     500;

    font-family: var(--atv-font);
    box-sizing: border-box;
}
.adrevv-tv-wrap *, .adrevv-tv-wrap *::before, .adrevv-tv-wrap *::after {
    box-sizing: inherit;
}

/* ── Outer Shell ── */
.adrevv-tv-wrap {
    display: flex;
    flex-direction: row;
    width: 100%;
    background: var(--atv-frame-bg);
    border-radius: 3px;
    min-height: 480px;
    position: relative;
    overflow: hidden;
    transition: background-color .25s ease;
}

/* ────────────────────────────────────────────
   CHANNEL SIDEBAR
──────────────────────────────────────────── */
.adrevv-tv-channels {
    width: var(--atv-sidebar-w);
    flex-shrink: 0;
    align-self: flex-start;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 10px 0 0;
    background: var(--atv-frame-bg);
    border-right: 1px solid var(--atv-divider);
    transition: background-color .25s ease, border-color .25s ease;
}

.adrevv-tv-channels-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px 12px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--atv-chrome-strong);
    border-bottom: 1px solid var(--atv-divider);
    flex-shrink: 0;
}
.adrevv-tv-channels-header > span:first-child { margin-right: auto; }

/* ── Light / Dark toggle ── */
.adrevv-tv-wrap .adrevv-tv-theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    flex-shrink: 0;
    border-radius: 3px;
    border: 1px solid var(--atv-divider);
    background: transparent;
    color: var(--atv-chrome-strong);
    cursor: pointer;
    transition: background-color .15s, color .15s, border-color .15s;
}
.adrevv-tv-wrap .adrevv-tv-theme-toggle:hover {
    color: var(--atv-sched-text);
    background: var(--atv-divider);
}
.adrevv-tv-theme-toggle svg { width: 16px; height: 16px; display: block; }
.adrevv-tv-theme-toggle .atv-icon-moon { display: none; }
.adrevv-tv-theme-toggle .atv-icon-sun  { display: block; }
.adrevv-tv-wrap.is-light .adrevv-tv-theme-toggle .atv-icon-moon { display: block; }
.adrevv-tv-wrap.is-light .adrevv-tv-theme-toggle .atv-icon-sun  { display: none; }

/* Scrollable channel list — fills the full frame height */
.adrevv-tv-channels-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scrollbar-width: thin;
    scrollbar-color: var(--atv-scrollbar) transparent;
}
.adrevv-tv-channels-list::-webkit-scrollbar { width: 4px; }
.adrevv-tv-channels-list::-webkit-scrollbar-thumb { background: var(--atv-scrollbar); border-radius: 4px; }

/* ── Category Label ── */
.adrevv-tv-category-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--atv-chrome-faint);
    padding: 10px 4px 4px;
    margin-top: 2px;
    border-top: 1px solid var(--atv-divider);
    flex-shrink: 0;
}
.adrevv-tv-category-label:first-child {
    margin-top: 0;
    border-top: none;
    padding-top: 2px;
}

/* ── Channel Card ── */
.adrevv-tv-wrap .adrevv-tv-channel-card {
    display: flex;
    align-items: center;
    padding: 0 12px;
    height: 36px;
    flex-shrink: 0;
    background: var(--atv-btn-inactive-bg) !important;
    border: 2px solid var(--atv-btn-inactive-border) !important;
    border-radius: 3px;
    cursor: pointer;
    text-align: left;
    width: 100%;
    overflow: hidden;
    transition: background .15s, border-color .15s;
}
.adrevv-tv-wrap .adrevv-tv-channel-card:hover {
    background: var(--atv-btn-hover-bg) !important;
    border-color: var(--atv-btn-hover-border) !important;
}
.adrevv-tv-wrap .adrevv-tv-channel-card.is-active {
    background: var(--atv-btn-active-bg) !important;
    border-color: var(--atv-btn-active-border) !important;
}
.adrevv-tv-wrap .adrevv-tv-channel-card .adrevv-tv-channel-name {
    display: block;
    font-size: var(--atv-btn-font-size);
    font-weight: var(--atv-btn-font-weight);
    color: var(--atv-btn-text-color) !important;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

/* ────────────────────────────────────────────
   MAIN AREA
──────────────────────────────────────────── */
.adrevv-tv-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--atv-player-bg);
    padding: 10px;
    transition: background-color .25s ease;
}

/* ── Player (16:9 video area) ── */
.adrevv-tv-player-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    overflow: hidden;
    border-radius: 3px;
    flex-shrink: 0;
}
.adrevv-tv-video {
    width: 100%;
    height: 100%;
    display: block;
    background: #000;
    object-fit: contain;
    object-position: center top;
}

.adrevv-tv-overlay {
    position: absolute;
    top: 0; left: 0;
    padding: 9px 11px;
    pointer-events: none;
    opacity: 1;
    z-index: 4;
    border-radius: 3px 0 0 0;
    background: linear-gradient(135deg, rgba(0,0,0,.6) 0%, rgba(0,0,0,.28) 45%, rgba(0,0,0,0) 80%);
    transition: opacity .3s;
}
.adrevv-tv-player-wrap:hover .adrevv-tv-overlay { opacity: 0; }
.adrevv-tv-overlay-inner { display: flex; align-items: center; gap: 8px; }
.adrevv-tv-overlay-badge {
    font-size: 10px; font-weight: 700; letter-spacing: .1em;
    color: #fff; background: var(--atv-live-red);
    padding: 2px 7px; border-radius: 3px;
}
.adrevv-tv-overlay-title {
    font-size: 13px; font-weight: 600;
    color: rgba(255,255,255,.9);
    text-shadow: 0 1px 4px rgba(0,0,0,.6);
}

/* ── Spinner ── */
.adrevv-tv-spinner {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,.55);
    opacity: 0; pointer-events: none; transition: opacity .25s;
}
.adrevv-tv-spinner.is-visible { opacity: 1; }
.adrevv-tv-spinner-ring {
    width: 40px; height: 40px;
    border: 3px solid rgba(255,255,255,.15);
    border-top-color: #fff;
    border-radius: 50%;
    animation: adrevv-spin .75s linear infinite;
}
@keyframes adrevv-spin { to { transform: rotate(360deg); } }

/* ── Tap for sound overlay (covers the video area) ── */
.adrevv-tv-sound-prompt {
    position: absolute;
    inset: 0;
    width: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    background: rgba(0,0,0,.4);
    color: #fff;
    font-family: var(--atv-font);
    cursor: pointer;
    z-index: 5;
    transition: background-color .2s;
}
.adrevv-tv-sound-prompt.is-visible { display: flex; }
.adrevv-tv-sound-prompt:hover { background: rgba(0,0,0,.5); }
.adrevv-tv-sound-prompt .atv-sound-badge {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 11px 18px;
    border-radius: 3px;
    background: rgba(0,0,0,.55);
    border: 1px solid rgba(255,255,255,.22);
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    box-shadow: 0 4px 16px rgba(0,0,0,.4);
}
.adrevv-tv-sound-prompt svg { width: 20px; height: 20px; flex-shrink: 0; }

/* ────────────────────────────────────────────
   SCHEDULE BAR
──────────────────────────────────────────── */
.adrevv-tv-schedule-wrap {
    background: var(--atv-sched-bg);
    flex-shrink: 0;
    margin-top: 10px;
    border-radius: 3px;
    transition: background-color .25s ease;
}
.adrevv-tv-schedule-header {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 16px 8px;
    border-bottom: 1px solid var(--atv-sched-border);
    color: var(--atv-sched-subtext);
}
.adrevv-tv-schedule-header svg { flex-shrink: 0; }
.adrevv-tv-schedule-channel-name { font-size: 12px; font-weight: 600; color: var(--atv-sched-text); }
.adrevv-tv-schedule-date { font-size: 11px; margin-left: auto; font-family: var(--atv-font-mono); color: var(--atv-sched-subtext); }

.adrevv-tv-schedule-track {
    overflow-x: auto; padding: 10px 14px 12px;
    scrollbar-width: thin; scrollbar-color: #2a2f42 transparent;
}
.adrevv-tv-schedule-track::-webkit-scrollbar { height: 3px; }
.adrevv-tv-schedule-track::-webkit-scrollbar-thumb { background: #2a2f42; border-radius: 3px; }

.adrevv-tv-schedule-items { display: flex; gap: 8px; min-width: max-content; }
.adrevv-tv-schedule-empty { font-size: 12px; color: var(--atv-sched-subtext); padding: 10px 4px; font-style: italic; }

.adrevv-tv-sched-item {
    display: flex; flex-direction: column; gap: 3px;
    background: var(--atv-sched-item-bg);
    border: 1px solid var(--atv-sched-border);
    border-radius: var(--atv-sched-radius);
    padding: 8px 14px 9px; min-width: 120px;
    cursor: default; transition: background .15s; position: relative;
}
.adrevv-tv-sched-item:hover { background: var(--atv-sched-item-hover); }
.adrevv-tv-sched-item.is-now { background: var(--atv-sched-item-now); border-color: rgba(59,130,246,.4); }
.adrevv-tv-sched-item.is-now::before {
    content: ''; position: absolute; top: 0; left: 0;
    width: 3px; height: 100%;
    background: var(--atv-accent-light);
    border-radius: 3px 0 0 3px;
}
.adrevv-tv-sched-time { font-family: var(--atv-font-mono); font-size: 10px; font-weight: 500; color: var(--atv-accent-light); text-transform: uppercase; letter-spacing: .04em; }
.adrevv-tv-sched-item.is-now .adrevv-tv-sched-time { color: #93c5fd; }
.adrevv-tv-sched-show { font-size: 12px; font-weight: 600; color: var(--atv-sched-text); line-height: 1.3; white-space: nowrap; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.adrevv-tv-sched-duration { font-size: 10px; color: var(--atv-sched-subtext); }

/* ────────────────────────────────────────────
   LIGHT THEME  (dark text on light surfaces)
   Reuses the existing accent/red palette.
──────────────────────────────────────────── */
.adrevv-tv-wrap.is-light {
    --atv-player-bg:        #dfe2e9;
    --atv-sched-bg:         #ffffff;
    --atv-sched-item-bg:    #f1f3f7;
    --atv-sched-item-hover: #e6e9f1;
    --atv-sched-item-now:   #dbeafe;
    --atv-sched-border:     rgba(0,0,0,.08);
    --atv-sched-text:       #15171c;
    --atv-sched-subtext:    rgba(0,0,0,.55);

    --atv-frame-bg:         #e9ebf0;
    --atv-chrome-strong:    rgba(0,0,0,.55);
    --atv-chrome-faint:     rgba(0,0,0,.40);
    --atv-divider:          rgba(0,0,0,.09);
    --atv-scrollbar:        #c2c7d0;
}
/* Keep the "on now" accent readable on a light pill */
.adrevv-tv-wrap.is-light .adrevv-tv-sched-item.is-now .adrevv-tv-sched-time { color: #1d4ed8; }
.adrevv-tv-wrap.is-light .adrevv-tv-sched-time { color: var(--atv-accent); }

/* ────────────────────────────────────────────
   TABLET
──────────────────────────────────────────── */
@media (max-width: 1024px) and (min-width: 769px) {
    .adrevv-tv-wrap { --atv-sidebar-w: 180px; }
}

/* ────────────────────────────────────────────
   MOBILE — player top, channels below
──────────────────────────────────────────── */
@media (max-width: 768px) {
    .adrevv-tv-wrap { flex-direction: column; border-radius: 3px; min-height: unset; }

    .adrevv-tv-channels {
        width: 100%;
        height: auto !important;   /* override JS-synced desktop height */
        align-self: stretch;
        padding: 8px 0;
        border-right: none;
        border-top: 1px solid var(--atv-divider);
        order: 2;
    }
    .adrevv-tv-channels-list {
        flex: 0 1 auto;
        flex-direction: column;
        overflow-y: auto; overflow-x: hidden;
        max-height: calc( (36px + 6px) * 5 + 16px );
        padding: 8px;
    }
    .adrevv-tv-channel-card { width: 100%; flex-shrink: 0; }

    .adrevv-tv-main { order: 1; padding: 8px 8px 0; }
    .adrevv-tv-player-wrap { border-radius: 3px; }
    .adrevv-tv-schedule-wrap { margin-top: 8px; border-radius: 3px; }
    .adrevv-tv-sound-prompt .atv-sound-badge { font-size: 13px; padding: 9px 14px; }
}

/* ── Empty State ── */
.adrevv-tv-empty { padding: 24px; color: #6b7280; font-family: var(--atv-font); font-size: 14px; text-align: center; }
