/* =====================================================================
   Player v2
   ===================================================================== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background: #000;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    color: #fff;
}

#app {
    position: fixed; inset: 0;
    display: flex; flex-direction: column;
    background: #000;
    width: 100%; height: 100dvh; min-height: 100dvh;
}

.player-area {
    position: relative; flex: 1; min-height: 0;
    display: flex; align-items: center; justify-content: center;
    width: 100%; height: 100%; background: #000;
}

/* ---------- Loading ---------- */
.loading-overlay {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,0.92); z-index: 30;
}
.loading-overlay.hidden { display: none; }
.spinner {
    width: 2.2rem; height: 2.2rem; margin: 0 auto 0.85rem;
    border: 2px solid rgba(255,255,255,0.25); border-top-color: #fff;
    border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 0.875rem; color: #a1a1aa; text-align: center; }

/* ---------- Error ---------- */
.error-box {
    text-align: center; padding: 28px 22px; max-width: 420px;
    color: #e4e4e7;
}
.error-icon { font-size: 2.2rem; margin-bottom: 10px; color: #f87171; }
.error-box h2 { font-size: 1.15rem; font-weight: 600; margin-bottom: 8px; color: #fff; }
.error-box p { font-size: 0.9rem; color: #a1a1aa; line-height: 1.6; }
.retry-btn {
    margin-top: 16px; padding: 9px 20px; border-radius: 8px;
    background: var(--plyr-color-main, #0ea5e9); color: #fff;
    border: none; font-size: 0.875rem; font-weight: 500; cursor: pointer;
}
.retry-btn:hover { filter: brightness(1.12); }

/* ---------- Klik play dulu (poster gate) ---------- */
.poster-gate {
    position: absolute; inset: 0; z-index: 35;
    display: flex; align-items: center; justify-content: center;
    background: #000; cursor: pointer; overflow: hidden;
}
.poster-gate.hidden { display: none; }
.poster-gate-img {
    position: absolute; inset: 0; width: 100%; height: 100%;
    object-fit: cover; transition: filter 0.3s ease, transform 6s ease;
}
.poster-gate:hover .poster-gate-img { filter: brightness(0.65) blur(1px); transform: scale(1.03); }
.poster-gate-play {
    position: relative; z-index: 1;
    width: 4.5rem; height: 4.5rem; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,0.55); border: 1px solid rgba(255,255,255,0.25);
    transition: background 0.25s ease, transform 0.25s ease;
}
.poster-gate-play svg { width: 2rem; height: 2rem; fill: #fff; margin-left: 3px; }
.poster-gate:hover .poster-gate-play { background: var(--plyr-color-main, #0ea5e9); transform: scale(1.08); }
.poster-gate-title {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 1;
    padding: 1rem 1.1rem 0.9rem;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    font-size: 0.9rem; font-weight: 500; color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- Video ---------- */
.video-wrapper {
    width: 100%; height: 100%; min-height: 0;
    display: flex; align-items: center; justify-content: center;
}
.video-wrapper.hidden { display: none !important; }
.video-wrapper .plyr,
.video-wrapper .plyr__video-wrapper { width: 100% !important; height: 100% !important; min-height: 0 !important; }
#video_player { max-height: 100%; max-width: 100%; width: 100%; object-fit: contain; }

/* ---------- Iframe embed ---------- */
#iframe_player { position: absolute; inset: 0; width: 100%; height: 100%; }
#iframe_player.hidden { display: none; }
#iframe_player iframe { width: 100%; height: 100%; border: 0; }

/* ---------- Kontrol pojok atas ---------- */
.top-controls {
    position: absolute; top: 0.75rem; right: 0.75rem;
    z-index: 50; display: flex; align-items: flex-start; gap: 0.5rem;
}

.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 2rem; height: 2rem; border-radius: 0.5rem;
    background: rgba(0,0,0,0.65); backdrop-filter: blur(6px);
    border: 1px solid rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.9); cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.icon-btn:hover { background: rgba(0,0,0,0.85); color: #fff; }
.icon-btn svg { width: 1rem; height: 1rem; }
.icon-btn.hidden { display: none; }

/* ---------- Pilih server ---------- */
#server_switch { position: relative; }
#server_switch.hidden { display: none; }

.server-btn {
    display: flex; align-items: center; gap: 0.375rem;
    padding: 0.4rem 0.7rem; border-radius: 0.5rem;
    background: rgba(0,0,0,0.65); backdrop-filter: blur(6px);
    color: rgba(255,255,255,0.9); border: 1px solid rgba(255,255,255,0.12);
    font-size: 0.75rem; font-weight: 500; cursor: pointer; transition: all 0.2s;
    max-width: 11rem;
}
.server-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-btn:hover { background: rgba(0,0,0,0.85); color: #fff; }
.server-btn svg { width: 0.8rem; height: 0.8rem; flex-shrink: 0; color: #a1a1aa; transition: transform 0.2s; }
.server-btn.open svg { transform: rotate(180deg); }

.server-dropdown {
    position: absolute; right: 0; top: 2.4rem; z-index: 51;
    width: 12.5rem; padding: 0.35rem 0; border-radius: 0.7rem;
    background: rgba(24,24,27,0.97); backdrop-filter: blur(12px);
    box-shadow: 0 20px 40px -10px rgba(0,0,0,0.6);
    border: 1px solid rgba(255,255,255,0.1);
    max-height: 60vh; overflow-y: auto;
}
.server-dropdown.hidden { display: none; }
.server-dropdown-title {
    padding: 0.35rem 0.75rem; font-size: 10px; font-weight: 500;
    text-transform: uppercase; letter-spacing: 0.05em; color: #71717a;
}
.server-option {
    display: flex; width: 100%; align-items: center; gap: 0.5rem;
    padding: 0.5rem 0.75rem; text-align: left; font-size: 0.85rem;
    background: none; border: none; color: #a1a1aa; cursor: pointer;
    transition: background 0.2s, color 0.2s; text-decoration: none;
}
.server-option span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-option:hover { background: rgba(255,255,255,0.06); color: #e4e4e7; }
.server-option.active { background: rgba(255,255,255,0.1); color: #fff; font-weight: 500; }
.server-option .dot { width: 0.35rem; height: 0.35rem; border-radius: 50%; flex-shrink: 0; }
.server-option .dot.active { background: #34d399; }
.server-option .dot.inactive { background: #71717a; }

/* ---------- Watermark ---------- */
.watermark {
    position: absolute; z-index: 45; pointer-events: none;
    display: flex; align-items: center; gap: 6px;
    font-size: 0.8rem; font-weight: 600; color: #fff;
    text-shadow: 0 1px 4px rgba(0,0,0,0.9);
    transition: opacity 0.3s;
}
.watermark.hidden { display: none; }
.watermark a { pointer-events: auto; color: inherit; text-decoration: none; display: flex; align-items: center; gap: 6px; }
.watermark img { max-height: 34px; max-width: 130px; object-fit: contain; }
.watermark.pos-top-left     { top: 0.85rem; left: 0.85rem; }
.watermark.pos-top-right    { top: 0.85rem; right: 0.85rem; }
.watermark.pos-bottom-left  { bottom: 4.2rem; left: 0.85rem; }
.watermark.pos-bottom-right { bottom: 4.2rem; right: 0.85rem; }

/* Watermark pojok kanan atas jangan tabrakan dengan tombol server */
.watermark.pos-top-right { top: 3.2rem; }

/* ---------- Judul ---------- */
.title-bar {
    position: absolute; top: 0; left: 0; right: 0; z-index: 40;
    padding: 0.85rem 1rem 2.2rem;
    background: linear-gradient(to bottom, rgba(0,0,0,0.75), transparent);
    font-size: 0.9rem; font-weight: 500; color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    opacity: 0; transform: translateY(-6px);
    transition: opacity 0.25s, transform 0.25s;
    pointer-events: none;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    padding-right: 13rem;
}
.title-bar.show { opacity: 1; transform: translateY(0); }

/* ---------- Toast lanjut menonton ---------- */
.resume-toast {
    position: absolute; bottom: 4.5rem; left: 50%; transform: translateX(-50%);
    z-index: 55; display: flex; align-items: center; gap: 0.6rem;
    padding: 0.65rem 0.9rem; border-radius: 0.75rem;
    background: rgba(24,24,27,0.96); backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow: 0 12px 30px rgba(0,0,0,0.5);
    font-size: 0.83rem; color: #e4e4e7;
    max-width: calc(100% - 2rem);
}
.resume-toast.hidden { display: none; }
.resume-toast button {
    padding: 0.35rem 0.7rem; border-radius: 0.4rem; border: none;
    font-size: 0.78rem; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.resume-toast button#resume_yes { background: var(--plyr-color-main, #0ea5e9); color: #fff; }
.resume-toast button#resume_no  { background: rgba(255,255,255,0.1); color: #a1a1aa; }
.resume-toast button:hover { filter: brightness(1.15); }

/* ---------- Plyr ---------- */
.plyr {
    --plyr-color-main: #0ea5e9;
    --plyr-video-control-color: #fff;
    --plyr-menu-background: rgba(24,24,27,0.97);
    --plyr-menu-color: #e4e4e7;
}
.plyr__control--overlaid { background: rgba(14,165,233,0.85); }
.plyr__menu__container { border-radius: 0.6rem; }

/* =====================================================================
   Gaya tampilan (diatur dari Admin -> Pengaturan -> Player)
   ===================================================================== */

/* ---------- Netflix: judul besar, kontrol bulat gelap, aksen merah ---------- */
body.theme-netflix .title-bar {
    padding: 1.3rem 1.2rem 3rem;
    font-size: 1.15rem; font-weight: 700; letter-spacing: 0.01em;
    background: linear-gradient(to bottom, rgba(0,0,0,0.85), transparent);
}
body.theme-netflix .poster-gate-title {
    font-size: 1.25rem; font-weight: 700; padding: 1.5rem 1.3rem 1.2rem;
}
body.theme-netflix .poster-gate-play {
    width: 5.5rem; height: 5.5rem; background: rgba(20,20,20,0.7); border-color: rgba(255,255,255,0.15);
}
body.theme-netflix .poster-gate:hover .poster-gate-play { background: #e50914; border-color: #e50914; }
body.theme-netflix .server-btn,
body.theme-netflix .icon-btn { border-radius: 0.3rem; background: rgba(20,20,20,0.75); }
body.theme-netflix .server-dropdown { border-radius: 0.35rem; background: rgba(20,20,20,0.98); }
body.theme-netflix .server-option.active { background: rgba(229,9,20,0.18); }
body.theme-netflix .server-option .dot.active { background: #e50914; }
body.theme-netflix .resume-toast button#resume_yes { background: #e50914; }
body.theme-netflix .plyr__control--overlaid { background: rgba(229,9,20,0.85); }

/* ---------- Minimalis ala JW Player: flat, kotak tipis, tanpa blur ---------- */
body.theme-minimal .icon-btn,
body.theme-minimal .server-btn {
    border-radius: 0.2rem; background: rgba(0,0,0,0.8); backdrop-filter: none;
    border: 1px solid rgba(255,255,255,0.2);
}
body.theme-minimal .server-dropdown {
    border-radius: 0.2rem; background: rgba(15,15,15,0.98); backdrop-filter: none;
    box-shadow: 0 6px 16px rgba(0,0,0,0.5);
}
body.theme-minimal .title-bar {
    background: rgba(0,0,0,0.55); font-size: 0.82rem; font-weight: 400;
    padding: 0.6rem 0.9rem;
}
body.theme-minimal .poster-gate-play {
    border-radius: 0.3rem; width: 4rem; height: 3.2rem;
    background: rgba(0,0,0,0.7); border: 1px solid rgba(255,255,255,0.25);
}
body.theme-minimal .poster-gate:hover .poster-gate-play { background: rgba(0,0,0,0.9); transform: none; }
body.theme-minimal .resume-toast { border-radius: 0.2rem; backdrop-filter: none; }
body.theme-minimal .resume-toast button { border-radius: 0.15rem; }
body.theme-minimal .plyr__menu__container { border-radius: 0.2rem; }

/* ---------- Layar kecil ---------- */
@media (max-width: 640px) {
    .title-bar { font-size: 0.82rem; padding-right: 9rem; }
    .server-btn { max-width: 7.5rem; font-size: 0.7rem; }
    .server-dropdown { width: 11rem; }
    .watermark img { max-height: 26px; max-width: 100px; }
    .watermark { font-size: 0.72rem; }
    .resume-toast { font-size: 0.78rem; padding: 0.55rem 0.7rem; gap: 0.4rem; }
}
