/* ===========================================================================
   IPTV for Samsung Tizen TV
   Designed for 1920x1080, viewed from a distance with a D-pad remote.
   =========================================================================== */

:root {
    --bg:            #0b0f17;
    --bg-elev:       #141a26;
    --bg-elev-2:     #1d2533;
    --accent:        #2f6df6;
    --accent-soft:   rgba(47, 109, 246, 0.18);
    --text:          #f2f5fa;
    --text-dim:      #9aa7bd;
    --text-faint:    #5c6883;
    --focus:         #ffffff;
    --good:          #34d399;
    --bad:           #f87171;
    --fav:           #fbbf24;

    --red:    #e5484d;
    --green:  #46a758;
    --yellow: #f5d90a;
    --blue:   #3b82f6;
}

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

html, body {
    width: 1920px;
    height: 1080px;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: "Tizen Sans", "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 24px;
    -webkit-user-select: none;
    user-select: none;
    cursor: none;
}

.hidden { display: none !important; }

.screen {
    position: absolute;
    inset: 0;
    width: 1920px;
    height: 1080px;
}

.key {
    display: inline-block;
    min-width: 36px;
    padding: 2px 10px;
    border-radius: 6px;
    background: var(--bg-elev-2);
    border: 1px solid var(--text-faint);
    font-size: 18px;
    text-align: center;
}
.key-red, .key-green, .key-yellow, .key-blue {
    display: inline-block;
    width: 16px; height: 16px;
    border-radius: 50%;
    vertical-align: middle;
    margin-right: 4px;
}
.key-red    { background: var(--red); }
.key-green  { background: var(--green); }
.key-yellow { background: var(--yellow); }
.key-blue   { background: var(--blue); }

/* ===== Splash ===== */
.splash {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 50% 40%, #16203a 0%, var(--bg) 70%);
}
.splash-logo {
    font-size: 120px;
    font-weight: 800;
    letter-spacing: 8px;
    background: linear-gradient(90deg, #5b8cff, #7ad1ff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.splash-status {
    margin-top: 28px;
    font-size: 28px;
    color: var(--text-dim);
}

/* ===== Browser ===== */
.browser-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 96px;
    padding: 0 56px;
    background: var(--bg-elev);
    border-bottom: 1px solid #222b3b;
}
.brand {
    font-size: 40px;
    font-weight: 800;
    letter-spacing: 3px;
    color: var(--accent);
}
.browser-meta { display: flex; gap: 36px; align-items: center; color: var(--text-dim); }
.channel-count { font-size: 22px; }
.clock { font-size: 28px; font-variant-numeric: tabular-nums; color: var(--text); }

.browser-body {
    display: flex;
    height: calc(1080px - 96px - 72px);
}

.group-list {
    width: 460px;
    height: 100%;
    overflow: hidden;
    padding: 20px 0;
    background: var(--bg-elev);
    border-right: 1px solid #222b3b;
}
.group-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    margin: 4px 16px;
    padding: 0 24px;
    border-radius: 12px;
    font-size: 26px;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.group-item .group-badge {
    font-size: 18px;
    color: var(--text-faint);
    background: var(--bg-elev-2);
    border-radius: 20px;
    padding: 2px 12px;
}
.group-item.active { color: var(--text); }
.group-item.focused {
    background: var(--focus);
    color: #0b0f17;
}
.group-item.focused .group-badge { background: rgba(0,0,0,0.18); color: #0b0f17; }

.channel-pane {
    flex: 1;
    height: 100%;
    overflow: hidden;
    padding: 16px 40px;
    position: relative;
}
.channel-search {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 52px;
    margin-bottom: 8px;
    color: var(--text-dim);
}
.search-label { color: var(--text-faint); }
.search-term {
    color: var(--text);
    border-bottom: 2px solid var(--accent);
    min-width: 200px;
    padding-bottom: 2px;
}
.channel-list { list-style: none; height: 100%; overflow: hidden; }
.channel-item {
    display: flex;
    align-items: center;
    gap: 24px;
    height: 96px;
    padding: 0 28px;
    margin: 6px 0;
    border-radius: 14px;
    background: var(--bg-elev);
}
.channel-item.focused {
    background: var(--accent);
    box-shadow: 0 0 0 3px var(--focus);
}
.channel-item.playing { outline: 2px solid var(--good); }
.ch-number {
    width: 60px;
    font-size: 24px;
    color: var(--text-faint);
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.channel-item.focused .ch-number { color: rgba(255,255,255,0.8); }
.ch-logo-wrap {
    width: 96px; height: 60px;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-elev-2);
    border-radius: 8px;
    overflow: hidden;
    flex: 0 0 auto;
}
.ch-logo { max-width: 96px; max-height: 60px; object-fit: contain; }
.ch-logo-fallback { font-size: 26px; font-weight: 700; color: var(--text-dim); }
.ch-name {
    flex: 1;
    font-size: 30px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ch-fav { color: var(--fav); font-size: 28px; width: 32px; text-align: center; }

.channel-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    color: var(--text-faint);
}

.browser-footer, .settings-footer {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 72px;
    display: flex;
    align-items: center;
    gap: 44px;
    padding: 0 56px;
    background: var(--bg-elev);
    border-top: 1px solid #222b3b;
}
.hint { font-size: 22px; color: var(--text-dim); }

/* ===== Player ===== */
.player { background: #000; }
#av-player {
    position: absolute;
    inset: 0;
    width: 1920px;
    height: 1080px;
    background: #000;
}
.html5-player {
    position: absolute;
    inset: 0;
    width: 1920px;
    height: 1080px;
    background: #000;
    object-fit: contain;
}

.player-spinner {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}
.spinner {
    width: 84px; height: 84px;
    border: 8px solid rgba(255,255,255,0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-text { font-size: 26px; color: var(--text-dim); }

.player-osd {
    position: absolute;
    left: 56px; bottom: 64px;
    display: flex;
    align-items: center;
    gap: 28px;
    padding: 24px 36px;
    background: rgba(11, 15, 23, 0.82);
    border-radius: 18px;
    border: 1px solid rgba(255,255,255,0.08);
    max-width: 1100px;
    backdrop-filter: blur(6px);
}
.osd-logo-wrap {
    width: 140px; height: 90px;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-elev-2);
    border-radius: 10px;
    overflow: hidden;
    flex: 0 0 auto;
}
.osd-logo { max-width: 140px; max-height: 90px; object-fit: contain; }
.osd-number { font-size: 22px; color: var(--accent); font-weight: 700; }
.osd-name { font-size: 40px; font-weight: 700; margin: 2px 0; }
.osd-group { font-size: 24px; color: var(--text-dim); }
.osd-state { font-size: 22px; color: var(--good); margin-top: 6px; }

.zap-entry {
    position: absolute;
    top: 64px; right: 64px;
    padding: 18px 40px;
    font-size: 64px;
    font-weight: 800;
    letter-spacing: 8px;
    background: rgba(11, 15, 23, 0.85);
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.12);
}

.player-error {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    padding: 48px 64px;
    background: rgba(20, 10, 12, 0.9);
    border: 1px solid var(--bad);
    border-radius: 18px;
    max-width: 1200px;
}
.error-title { font-size: 40px; font-weight: 700; color: var(--bad); margin-bottom: 16px; }
.error-msg { font-size: 26px; color: var(--text-dim); margin-bottom: 24px; word-break: break-word; }
.error-hint { font-size: 22px; color: var(--text-faint); }

/* ===== Settings ===== */
.settings { padding: 64px 80px; }
.settings-title { font-size: 52px; font-weight: 800; margin-bottom: 48px; }
.settings-section { margin-bottom: 40px; max-width: 1400px; }
.settings-label { display: block; font-size: 24px; color: var(--text-dim); margin-bottom: 12px; }
.settings-field {
    font-size: 30px;
    padding: 24px 32px;
    background: var(--bg-elev);
    border-radius: 14px;
    border: 2px solid transparent;
    word-break: break-all;
}
.settings-field.focused {
    border-color: var(--focus);
    background: var(--bg-elev-2);
}
.settings-help { font-size: 20px; color: var(--text-faint); margin-top: 10px; }
.settings-about { color: var(--text-dim); font-size: 22px; margin-top: 64px; }
.settings-engine { color: var(--text-faint); margin-top: 8px; }

/* ===== Toast ===== */
.toast {
    position: absolute;
    bottom: 100px; left: 50%;
    transform: translateX(-50%);
    padding: 18px 40px;
    background: rgba(11, 15, 23, 0.95);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 14px;
    font-size: 26px;
    z-index: 50;
}

/* ===== On-screen keyboard ===== */
.osk {
    position: absolute;
    inset: 0;
    z-index: 60;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(5, 8, 14, 0.92);
}
.osk-title { font-size: 32px; color: var(--text-dim); margin-bottom: 20px; }
.osk-input {
    width: 1400px;
    min-height: 64px;
    padding: 16px 24px;
    margin-bottom: 28px;
    font-size: 30px;
    background: var(--bg-elev);
    border: 2px solid var(--accent);
    border-radius: 12px;
    word-break: break-all;
}
.osk-input::after { content: "|"; color: var(--accent); animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }
.osk-keys {
    display: grid;
    grid-template-columns: repeat(14, 92px);
    gap: 10px;
}
.osk-key {
    height: 78px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    background: var(--bg-elev);
    border-radius: 10px;
    color: var(--text);
}
.osk-key.wide { grid-column: span 2; }
.osk-key.xwide { grid-column: span 3; }
.osk-key.focused { background: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
