/* ================================================================
   Vidira IPTV Player — style.css
   ================================================================ */

:root {
    --bg: #0d0d12;
    --surface: #16161f;
    --surface2: #1e1e2a;
    --surface3: #252533;
    --primary: #7c3aed;
    --primary2: #9333ea;
    --accent: #a855f7;
    --accent-glow: rgba(124,58,237,.35);
    --text: #f0f0f5;
    --muted: #6b6b80;
    --live-red: #ef4444;
    --radius: 10px;
    --topbar-h: 54px;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; background: var(--bg); color: var(--text); }
#app { display: flex; flex-direction: column; height: 100%; }

/* ════ LOADING ════ */
#loading {
    position: fixed; inset: 0; background: rgba(13,13,18,.95);
    display: none; flex-direction: column; justify-content: center; align-items: center;
    z-index: 999; gap: 16px;
}
.spinner {
    width: 40px; height: 40px;
    border: 3px solid rgba(124,58,237,.2);
    border-top-color: var(--accent);
    border-radius: 50%; animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#load-txt { font-size: 13px; color: var(--muted); }

/* ════ LOGIN ════ */
#login-screen {
    display: flex; flex-direction: column; justify-content: center;
    align-items: center; height: 100%; padding: 32px 24px; text-align: center;
    background: radial-gradient(ellipse at 50% 0%, rgba(124,58,237,.12) 0%, transparent 70%);
}
.login-logo-wrap { margin-bottom: 28px; }
.login-logo-wrap img { height: 44px; object-fit: contain; }
.login-logo-text {
    font-size: 26px; font-weight: 800; color: white;
    display: flex; align-items: center; gap: 8px;
}
.login-logo-text span { color: var(--accent); }
.login-sub { font-size: 13px; color: var(--muted); margin-bottom: 32px; line-height: 1.5; }

.login-card {
    width: 100%; max-width: 420px;
    background: var(--surface); border: 1px solid rgba(124,58,237,.2);
    border-radius: 16px; padding: 24px; margin-bottom: 0;
}
.login-label { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; margin-bottom: 8px; display: block; }
.login-input {
    width: 100%; padding: 13px 16px;
    border-radius: var(--radius); border: 1.5px solid rgba(255,255,255,.08);
    background: var(--surface2); color: white; font-size: 14px; outline: none;
    margin-bottom: 16px; transition: border-color .2s; display: block;
}
.login-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--accent-glow); }
.login-btn {
    width: 100%; padding: 14px;
    border: none; border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary), var(--primary2));
    color: white; font-size: 15px; font-weight: 700; cursor: pointer;
    box-shadow: 0 4px 24px var(--accent-glow); transition: opacity .2s; display: block;
    letter-spacing: .3px;
}
.login-btn:active { opacity: .8; }

/* Upload section di login */
.login-divider {
    display: flex; align-items: center; gap: 10px;
    margin: 16px 0; color: var(--muted); font-size: 12px;
}
.login-divider::before, .login-divider::after {
    content: ''; flex: 1; height: 1px; background: rgba(255,255,255,.08);
}
.login-upload-btn {
    width: 100%; padding: 13px;
    border: 1.5px dashed rgba(124,58,237,.4); border-radius: var(--radius);
    background: transparent; color: var(--muted); font-size: 13px;
    cursor: pointer; transition: all .2s; display: flex; align-items: center;
    justify-content: center; gap: 8px;
}
.login-upload-btn:hover, .login-upload-btn:active { border-color: var(--accent); color: var(--accent); background: rgba(124,58,237,.06); }
#playlist-file { display: none; }
.login-err { color: #f87171; font-size: 13px; margin-top: 12px; display: none; text-align: center; }

/* ════ MAIN ════ */
#main-screen { display: none; flex-direction: column; height: 100%; overflow: hidden; }

/* ════ TOPBAR ════ */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--surface); height: var(--topbar-h);
    padding: 0 16px; flex-shrink: 0; z-index: 20;
    border-bottom: 1px solid rgba(255,255,255,.05);
    box-shadow: 0 2px 16px rgba(0,0,0,.5);
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-brand { display: flex; align-items: center; gap: 8px; }
.topbar-brand img { height: 30px; object-fit: contain; }
.topbar-brand-text { font-size: 17px; font-weight: 800; color: white; letter-spacing: -.3px; }
.topbar-brand-text span { color: var(--accent); }
.hamburger-btn {
    background: none; border: none; color: var(--text); cursor: pointer;
    font-size: 20px; padding: 6px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; transition: background .15s; flex-shrink: 0;
}
.hamburger-btn:active { background: rgba(255,255,255,.08); }
.hamburger-icon { display: flex; flex-direction: column; gap: 5px; width: 20px; }
.hamburger-icon span { display: block; height: 2px; background: var(--text); border-radius: 2px; }
.hamburger-icon span:nth-child(2) { width: 14px; }

/* ════ SIDEBAR ════ */
.sidebar-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.65);
    z-index: 100; opacity: 0; pointer-events: none; transition: opacity .25s;
}
.sidebar-overlay.open { opacity: 1; pointer-events: all; }

.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 78vw; max-width: 290px;
    background: var(--surface); z-index: 101;
    transform: translateX(-100%); transition: transform .28s cubic-bezier(.4,0,.2,1);
    display: flex; flex-direction: column; overflow: hidden;
    border-right: 1px solid rgba(255,255,255,.05);
}
.sidebar.open { transform: translateX(0); }

.sidebar-header {
    display: flex; align-items: center; gap: 10px;
    padding: 18px 16px 14px;
    border-bottom: 1px solid rgba(255,255,255,.06);
    background: linear-gradient(135deg, rgba(124,58,237,.15), transparent);
    flex-shrink: 0;
}
.sidebar-header img { height: 24px; object-fit: contain; }
.sidebar-header-text { font-size: 15px; font-weight: 800; color: white; }
.sidebar-header-text span { color: var(--accent); }

.sidebar-section-title {
    font-size: 10px; font-weight: 700; color: var(--muted);
    letter-spacing: 1.4px; text-transform: uppercase;
    padding: 16px 16px 6px;
}
.sidebar-item {
    display: flex; align-items: center; gap: 11px;
    padding: 11px 16px; cursor: pointer;
    font-size: 13.5px; transition: background .15s; border-radius: 0;
    position: relative;
}
.sidebar-item:active { background: rgba(255,255,255,.05); }
.sidebar-item.active {
    background: rgba(124,58,237,.15); color: var(--accent);
}
.sidebar-item.active::before {
    content: ''; position: absolute; left: 0; top: 20%; bottom: 20%;
    width: 3px; background: var(--accent); border-radius: 0 3px 3px 0;
}
.sidebar-item .si-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-item .si-label { flex: 1; }
.sidebar-divider { height: 1px; background: rgba(255,255,255,.06); margin: 8px 0; }
.sidebar-action {
    display: flex; align-items: center; gap: 11px;
    padding: 11px 16px; cursor: pointer; font-size: 13.5px;
    transition: background .15s; color: var(--muted);
}
.sidebar-action:active { background: rgba(255,255,255,.05); }
.sidebar-action .si-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-cats { flex: 1; overflow-y: auto; }
.sidebar-cats::-webkit-scrollbar { width: 3px; }
.sidebar-cats::-webkit-scrollbar-thumb { background: rgba(124,58,237,.3); border-radius: 2px; }

/* ════ PLAYER WRAP ════ */
.player-wrap {
    position: relative; width: 100%; background: #000;
    flex-shrink: 0; overflow: hidden;
    aspect-ratio: 16 / 9;
    max-height: 32vh;
}
#video-el { width: 100%; height: 100%; display: block; background: #000; outline: none; object-fit: contain; }

/* FULLSCREEN */
.player-wrap:fullscreen,
.player-wrap:-webkit-full-screen {
    width: 100vw; height: 100vh; max-height: none; aspect-ratio: auto;
    display: flex; flex-direction: column; justify-content: flex-end;
}
.player-wrap:fullscreen #video-el,
.player-wrap:-webkit-full-screen #video-el {
    max-height: none; width: 100%; height: 100%;
    position: absolute; top: 0; left: 0; object-fit: contain;
}
.player-wrap:fullscreen .ctrl-overlay,
.player-wrap:-webkit-full-screen .ctrl-overlay { position: absolute; bottom: 0; left: 0; right: 0; }
.player-wrap:fullscreen .watermark,
.player-wrap:-webkit-full-screen .watermark,
.player-wrap:fullscreen .live-badge,
.player-wrap:-webkit-full-screen .live-badge,
.player-wrap:fullscreen .seek-flash,
.player-wrap:-webkit-full-screen .seek-flash,
.player-wrap:fullscreen .tap-area,
.player-wrap:-webkit-full-screen .tap-area,
.player-wrap:fullscreen .center-play-btn,
.player-wrap:-webkit-full-screen .center-play-btn { position: absolute; }
.player-wrap:fullscreen .tap-area,
.player-wrap:-webkit-full-screen .tap-area { inset: 0; }

/* WATERMARK */
.watermark {
    position: absolute; bottom: 10px; right: 10px; z-index: 3;
    pointer-events: none;
    display: flex; align-items: center; opacity: .55;
    max-width: 28%; max-height: 14%;
}
.watermark img { height: 100%; max-height: 22px; width: auto; object-fit: contain; display: block; }

/* LIVE BADGE */
.live-badge {
    position: absolute; top: 10px; left: 10px; z-index: 5;
    display: flex; align-items: center; gap: 6px;
    color: white; font-size: 12px; font-weight: 800; letter-spacing: .5px;
    pointer-events: none;
    background: rgba(0,0,0,.45); padding: 4px 10px; border-radius: 20px;
}
.live-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--live-red); display: inline-block; flex-shrink: 0; box-shadow: 0 0 6px rgba(239,68,68,.8); }
@keyframes livePulse { 0%,100%{opacity:1} 50%{opacity:.2} }
.live-badge.pulsing .live-dot { animation: livePulse 1.2s ease-in-out infinite; }
.live-badge.hidden-badge { display: none; }
.live-badge { transition: opacity .25s ease; }
/* Sembunyikan otomatis bareng kontrol bawah */
.player-wrap.ctrls-hidden .live-badge:not(.hidden-badge) { opacity: 0; }

/* CENTER PLAY BUTTON */
.center-play-btn {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 80px; height: 80px; border-radius: 50%;
    background: var(--primary); color: white;
    display: flex; align-items: center; justify-content: center;
    font-size: 30px; z-index: 6; pointer-events: none;
    opacity: 0; transition: opacity .25s ease;
    box-shadow: 0 4px 32px rgba(124,58,237,.7);
}
.center-play-btn.show { opacity: 1; }

/* BUFFERING / LOADING OVERLAY */
.buffer-overlay {
    position: absolute; inset: 0; z-index: 7;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 10px; background: rgba(0,0,0,.35);
    opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.buffer-overlay.show { opacity: 1; }
.buffer-spinner {
    width: 42px; height: 42px;
    border: 3px solid rgba(255,255,255,.25);
    border-top-color: var(--accent);
    border-radius: 50%; animation: spin .75s linear infinite;
}
.buffer-speed {
    font-size: 11px; color: #d7d7e6; background: rgba(0,0,0,.4);
    padding: 3px 10px; border-radius: 20px; font-weight: 600;
    min-height: 18px; white-space: nowrap;
}

/* SEEK FLASH */
.seek-flash {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
    background: rgba(0,0,0,.7); color: white; font-size: 13px; font-weight: 700;
    padding: 7px 16px; border-radius: 20px;
    opacity: 0; transition: opacity .15s; z-index: 6; pointer-events: none;
    white-space: nowrap;
}
.seek-flash.show { opacity: 1; }

/* TAP AREA */
.tap-area { position: absolute; inset: 0; z-index: 3; }

/* ════ CONTROL BAR ════ */
.ctrl-overlay {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,.88));
    padding: 20px 12px 10px;
    transition: opacity .25s ease; z-index: 4;
}
.ctrl-overlay.hidden { opacity: 0; pointer-events: none; }

/* Progress bar */
.progress-wrap {
    width: 100%; height: 3px; background: rgba(255,255,255,.2);
    border-radius: 2px; margin-bottom: 10px; cursor: pointer; position: relative;
}
.progress-fill { height: 100%; background: var(--accent); border-radius: 2px; width: 0%; pointer-events: none; transition: width .4s linear; }

/* Control row */
.ctrl-row { display: flex; align-items: center; gap: 8px; }

/* Play/Pause pill */
.ctrl-play-pill {
    background: var(--primary); border: none; color: white;
    min-width: 44px; height: 34px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; cursor: pointer; flex-shrink: 0;
    transition: background .15s;
    padding: 0 12px;
    box-shadow: 0 2px 10px rgba(124,58,237,.4);
    font-family: 'Segoe UI Symbol', 'Segoe UI', sans-serif;
    -webkit-text-fill-color: white;
}
.ctrl-play-pill:active { background: var(--primary2); }
.ctrl-play-pill, .ctrl-play-pill * { color: white !important; -webkit-text-fill-color: white !important; }

/* Seek + other pills */
.ctrl-seek, .ctrl-pill {
    background: rgba(255,255,255,.15); border: none; color: white;
    padding: 0 12px; height: 34px; border-radius: 10px;
    font-size: 12px; font-weight: 600;
    cursor: pointer; white-space: nowrap; flex-shrink: 0;
    transition: background .15s; display: flex; align-items: center;
}
.ctrl-seek:active, .ctrl-pill:active { background: rgba(255,255,255,.25); }

/* Spacer */
.ctrl-spacer { flex: 1; }

/* Resolution button */
.res-wrap { position: relative; flex-shrink: 0; }
.res-btn {
    background: rgba(255,255,255,.15); border: none; color: white;
    font-size: 12px; font-weight: 600; padding: 0 12px; height: 34px;
    border-radius: 10px; cursor: pointer; transition: background .15s; white-space: nowrap;
    display: flex; align-items: center;
}
.res-btn:active { background: rgba(255,255,255,.25); }

/* Res panel */
.res-panel {
    position: absolute; bottom: 44px; left: 50%; transform: translateX(-50%);
    background: #1a1a24; border-radius: 10px; overflow: hidden; display: none;
    min-width: 100px; box-shadow: 0 6px 28px rgba(0,0,0,.85); z-index: 20;
}
.res-panel.open { display: block; }
.res-panel-title {
    padding: 6px 12px 5px; font-size: 9px; font-weight: 700;
    color: var(--muted); letter-spacing: 1.2px; text-transform: uppercase;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.res-option {
    padding: 7px 12px; font-size: 12px; font-weight: 500; cursor: pointer;
    color: var(--text); transition: background .15s;
    display: flex; align-items: center; gap: 8px;
}
.res-option:active { background: rgba(255,255,255,.05); }
.res-option .res-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex-shrink: 0; visibility: hidden; }
.res-option.active { color: var(--accent); }
.res-option.active .res-dot { visibility: visible; }

/* Live indicator di control bar */
.ctrl-live-indicator {
    display: flex; align-items: center; gap: 6px;
    color: white; font-size: 12px; font-weight: 800; letter-spacing: .5px;
    padding: 0 10px; height: 34px; border-radius: 10px;
    background: rgba(239,68,68,.15);
    flex-shrink: 0;
}
.ctrl-live-dot {
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--live-red); display: inline-block; flex-shrink: 0;
    box-shadow: 0 0 6px rgba(239,68,68,.9);
    animation: livePulse 1.2s ease-in-out infinite;
}
.ctrl-live-indicator.hidden-badge { display: none; }

/* Fullscreen button */
.ctrl-fs {
    background: rgba(255,255,255,.15); border: none; color: white;
    width: 34px; height: 34px; border-radius: 10px;
    font-size: 15px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: background .15s;
}
.ctrl-fs:active { background: rgba(255,255,255,.25); }

/* ════ EPG BAR ════ */
.epg-bar {
    background: rgba(13,13,18,.9); padding: 7px 14px;
    font-size: 12px; color: var(--muted);
    display: flex; align-items: center; gap: 8px;
    flex-shrink: 0; border-bottom: 1px solid rgba(255,255,255,.04);
    min-height: 34px; overflow: hidden;
    border-top: 1px solid rgba(124,58,237,.1);
}
.epg-bar .ch-name { color: var(--accent); font-weight: 700; white-space: nowrap; flex-shrink: 0; font-size: 12px; }
.epg-bar .sep { color: rgba(255,255,255,.1); flex-shrink: 0; }
.epg-bar .prog-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; font-size: 11px; }
.epg-bar .prog-time { white-space: nowrap; font-size: 10px; color: rgba(255,255,255,.25); flex-shrink: 0; }

/* ════ SEARCH ════ */
.search-wrap { padding: 10px 12px; background: var(--bg); flex-shrink: 0; position: relative; }
.search-icon { position: absolute; left: 22px; top: 50%; transform: translateY(-50%); font-size: 13px; pointer-events: none; color: var(--muted); }
.search-input {
    width: 100%; padding: 9px 14px 9px 36px;
    border-radius: 20px; border: 1.5px solid rgba(255,255,255,.07);
    background: var(--surface); color: white; font-size: 13.5px; outline: none;
    transition: border-color .2s;
}
.search-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--accent-glow); }
.search-input::placeholder { color: var(--muted); }

/* ════ CHANNEL LIST ════ */
.ch-list { flex: 1; overflow-y: auto; padding: 8px 10px; }
.ch-list::-webkit-scrollbar { width: 3px; }
.ch-list::-webkit-scrollbar-thumb { background: rgba(124,58,237,.3); border-radius: 2px; }

.ch-item {
    display: flex; align-items: center; padding: 10px 12px;
    background: var(--surface); margin-bottom: 6px;
    border-radius: var(--radius); cursor: pointer;
    transition: background .15s, border-color .15s;
    border: 1px solid rgba(255,255,255,.04);
}
.ch-item:active { background: var(--surface2); }
.ch-item.playing {
    border-color: var(--primary); background: rgba(124,58,237,.1);
    box-shadow: 0 0 0 1px rgba(124,58,237,.15);
}
.ch-logo { width: 44px; height: 44px; border-radius: 8px; object-fit: contain; background: #0a0a12; margin-right: 12px; flex-shrink: 0; border: 1px solid rgba(255,255,255,.06); }
.ch-logo-fb { width: 44px; height: 44px; border-radius: 8px; background: var(--surface2); margin-right: 12px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 20px; color: #444; border: 1px solid rgba(255,255,255,.05); }
.ch-info { flex: 1; overflow: hidden; }
.ch-name { font-size: 13.5px; font-weight: 700; margin-bottom: 3px; color: var(--text); }
.ch-epg { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-epg.live { color: #c084fc; }
.epg-badge { font-size: 10px; background: rgba(124,58,237,.18); color: var(--accent); padding: 2px 7px; border-radius: 10px; white-space: nowrap; flex-shrink: 0; margin-left: 8px; border: 1px solid rgba(124,58,237,.2); }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); font-size: 14px; }

/* ════ LOGIN UPLOAD BUTTON & DIVIDER ════ */
.login-divider {
    display: flex; align-items: center; gap: 12px;
    margin: 14px 0; color: var(--muted); font-size: 12px;
}
.login-divider::before,
.login-divider::after {
    content: ''; flex: 1; height: 1px; background: rgba(255,255,255,.07);
}
.login-btn-upload {
    width: 100%; padding: 12px;
    border: 1.5px dashed rgba(124,58,237,.35);
    border-radius: var(--radius);
    background: transparent; color: var(--muted);
    font-size: 14px; font-weight: 600; cursor: pointer;
    transition: border-color .2s, color .2s; display: block; text-align: center;
}
.login-btn-upload:active { border-color: var(--accent); color: var(--accent); }
