/* playlists.css — "កញ្ចប់មេរៀន" (public/js/playlists.js) — ប្រើ Variable របស់ Site (តាម Dark/Light ដោយខ្លួនឯង) */
.pl-panel { margin: 0 0 22px; }
.pl-panel.hidden { display: none; }
.pl-head { margin: 0 0 12px; }
.pl-heading { font-size: 1.1rem; font-weight: 700; color: var(--cream, #f1f1f1); line-height: 1.5; }
.pl-sub { font-size: 0.85rem; color: var(--muted, #aaa); }
.pl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }

.pl-card {
  display: flex; flex-direction: column; padding: 0; overflow: hidden; text-align: left; cursor: pointer;
  border: 1px solid var(--border, #303030); border-radius: var(--radius, 14px); background: var(--bg-raised, #212121);
  color: var(--cream, #f1f1f1); font: inherit; box-shadow: var(--shadow, none); transition: transform 0.15s ease, border-color 0.15s ease;
}
.pl-card:hover { border-color: var(--gold, #3ea6ff); transform: translateY(-2px); }
.pl-card:active { transform: scale(0.99); }
.pl-thumb { position: relative; aspect-ratio: 16 / 9; background: var(--bg, #0f0f0f); }
.pl-thumb img, .pl-hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pl-cat {
  position: absolute; top: 10px; left: 10px; padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 700;
  background: var(--gold, #3ea6ff); color: #04121f;
}
:root[data-theme="light"] .pl-cat { color: #fff; }
.pl-count { position: absolute; right: 10px; bottom: 10px; padding: 3px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; background: rgba(0, 0, 0, 0.72); color: #fff; }
.pl-owned { position: absolute; top: 10px; right: 10px; padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; background: #16a34a; color: #fff; }
.pl-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 4px; }
.pl-title { font-weight: 700; font-size: 1rem; line-height: 1.5; overflow-wrap: anywhere; }
.pl-meta { font-size: 0.82rem; color: var(--muted, #aaa); }
.pl-center { text-align: center; }
.pl-price { margin-top: 4px; font-size: 1.15rem; font-weight: 800; color: var(--gold, #3ea6ff); }
.pl-price.is-owned { color: #16a34a; font-size: 0.95rem; }

/* Bottom sheet */
.pl-overlay {
  position: fixed; inset: 0; z-index: 1500; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(8, 10, 14, 0); -webkit-backdrop-filter: blur(0); backdrop-filter: blur(0);
  transition: background 0.25s ease, backdrop-filter 0.25s ease, -webkit-backdrop-filter 0.25s ease;
}
.pl-overlay.is-open { background: rgba(8, 10, 14, 0.55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.pl-sheet {
  position: relative; width: 100%; min-width: 0; max-width: 560px; max-height: 92%; overflow-x: hidden; overflow-y: auto;
  box-sizing: border-box; padding: 10px 18px calc(18px + max(env(safe-area-inset-bottom, 0px), var(--tg-bottom, 0px)));
  border-radius: 24px 24px 0 0; background: var(--bg-raised, #212121); color: var(--cream, #f1f1f1);
  box-shadow: 0 -16px 48px rgba(0, 0, 0, 0.35); transform: translateY(100%); transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}
.pl-overlay.is-open .pl-sheet { transform: translateY(0); }
@media (min-width: 640px) { .pl-overlay { align-items: center; } .pl-sheet { border-radius: 24px; max-height: 88vh; } }
.pl-grabber { width: 40px; height: 4px; margin: 2px auto 12px; border-radius: 4px; background: var(--border, #444); }
.pl-x {
  position: absolute; top: 12px; right: 14px; z-index: 2; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 15px; cursor: pointer;
}
.pl-hero { position: relative; aspect-ratio: 16 / 9; margin: 0 0 14px; overflow: hidden; border-radius: 16px; background: var(--bg, #0f0f0f); }
.pl-sheet-title { font-size: 1.2rem; font-weight: 700; line-height: 1.5; text-align: center; overflow-wrap: anywhere; }
.pl-desc { margin: 10px 0 0; font-size: 0.92rem; line-height: 1.65; color: var(--muted, #aaa); text-align: center; overflow-wrap: anywhere; }
.pl-loading { padding: 40px 0; text-align: center; color: var(--muted, #aaa); }
.pl-videos { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.pl-video-btn {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; text-align: left; cursor: pointer;
  border: 1px solid var(--border, #303030); border-radius: 12px; background: var(--gold-tint, rgba(62, 166, 255, 0.12)); color: inherit; font: inherit;
}
.pl-video.is-locked .pl-video-btn { opacity: 0.75; background: transparent; }
.pl-video-num { flex: 0 0 auto; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--gold, #3ea6ff); color: #04121f; font-size: 0.85rem; font-weight: 800; }
:root[data-theme="light"] .pl-video-num { color: #fff; }
.pl-video-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pl-video-title { font-size: 0.95rem; line-height: 1.5; overflow-wrap: anywhere; }
.pl-video-dur { font-size: 0.78rem; color: var(--muted, #aaa); }
.pl-video-state { flex: 0 0 auto; font-size: 0.95rem; }
.pl-foot { position: sticky; bottom: 0; margin: 16px -18px calc(-1 * max(env(safe-area-inset-bottom, 0px), var(--tg-bottom, 0px))); padding: 12px 18px 4px; background: var(--bg-raised, #212121); }
.pl-buy {
  display: block; width: 100%; min-height: 52px; padding: 0 18px; border: 0; border-radius: 16px; background: var(--gold, #3ea6ff); color: #04121f;
  font: inherit; font-size: 1.05rem; font-weight: 800; cursor: pointer;
}
:root[data-theme="light"] .pl-buy { color: #fff; }
.pl-buy:disabled, .pl-btn-ghost:disabled { opacity: 0.6; cursor: default; }
.pl-note { margin-top: 8px; font-size: 0.8rem; color: var(--muted, #aaa); text-align: center; }
.pl-owned-note { padding: 10px 0; font-size: 0.9rem; color: #16a34a; text-align: center; font-weight: 700; }
.pl-confirm { text-align: center; }
.pl-confirm-title { font-weight: 700; font-size: 1.05rem; }
.pl-confirm-line { margin-top: 4px; font-size: 1.3rem; font-weight: 800; color: var(--gold, #3ea6ff); }
.pl-confirm-bal { margin-top: 2px; font-size: 0.85rem; color: var(--muted, #aaa); min-height: 1.4em; }
.pl-error { min-height: 1.3em; margin: 4px 0 8px; font-size: 0.85rem; color: #ef4444; }
.pl-actions { display: flex; gap: 10px; }
.pl-actions .pl-buy { flex: 1; }
.pl-btn-ghost { flex: 0 0 auto; min-height: 52px; padding: 0 18px; border: 1.5px solid var(--border, #444); border-radius: 16px; background: transparent; color: inherit; font: inherit; font-weight: 700; cursor: pointer; }
html.pl-lock, html.pl-lock body { overflow: hidden; }
.pl-toast {
  position: fixed; left: 50%; bottom: calc(90px + max(env(safe-area-inset-bottom, 0px), var(--tg-bottom, 0px))); z-index: 2100; transform: translate(-50%, 12px);
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 12px; background: rgba(30, 30, 30, 0.96); color: #f1f1f1; font-size: 0.88rem; opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease; pointer-events: none; text-align: center;
}
.pl-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { .pl-card, .pl-overlay, .pl-sheet, .pl-toast { transition: none; } }

.pl-freechip { align-self: flex-start; margin-top: 2px; padding: 2px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; background: rgba(22, 163, 74, 0.16); color: #16a34a; }
.pl-free-badge { flex: 0 0 auto; padding: 2px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 800; background: #16a34a; color: #fff; }

/* ---------- Video Modal៖ កុំឲ្យ Player ធំហួសអេក្រង់ពេលគ្មាន Sidebar ----------
   ពេលគ្មាន "រឿងផ្សេងទៀត" (ឧ. មានមេរៀនតែ ១ វីដេអូ → .vm-sidebar មិនលេច) .vm-main ពង្រីកពេញ .vm-layout (≤1500px) ធ្វើឲ្យ
   Player 16:9 ខ្ពស់លើសអេក្រង់ (Desktop) ត្រូវរំកិលចុះមើល។ កំណត់ទទឹងអតិបរមាតាមកម្ពស់អេក្រង់ (គិត Top bar+គម្លាត ~150px) ហើយតម្រង់កណ្តាល។
   ប៉ះតែ Desktop (≥768px) ពេលគ្មាន .vm-sidebar — ករណីមាន Sidebar (Layout ធម្មតា) មិនប្តូរ */
@media (min-width: 768px) {
  .vm-layout:not(:has(.vm-sidebar)) .vm-main {
    width: 100%;
    max-width: min(100%, calc((100vh - 150px) * 16 / 9));
    margin-inline: auto;
  }
}

#video-grid.pl-empty-hidden { display: none; }

/* ---------- ទំព័រមើលវីដេអូ៖ Sidebar Playlist + អេក្រង់សោ "ទិញកញ្ចប់" + ផ្ទាំងជូនដំណឹង ---------- */
.pl-side-head { padding: 4px 4px 12px; }
.pl-side-kicker { font-size: 0.78rem; font-weight: 700; color: var(--gold, #3ea6ff); letter-spacing: 0.02em; }
.pl-side-title { font-size: 1.05rem; font-weight: 700; line-height: 1.5; color: var(--cream, #f1f1f1); overflow-wrap: anywhere; }
.pl-side-buy { margin-top: 10px; min-height: 46px; font-size: 0.98rem; }
.pl-side .pl-owned-note { padding: 8px 0 0; text-align: left; }
.pl-side-item { display: flex; gap: 10px; cursor: pointer; border-radius: 8px; padding: 6px 6px 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.06); transition: background 0.15s ease; }
:root[data-theme="light"] .pl-side-item { border-bottom-color: rgba(13, 148, 136, 0.12); }
.pl-side-item:hover { background: var(--bg-card, #181818); }
.pl-side-item.is-current { background: var(--gold-tint, rgba(62, 166, 255, 0.15)); cursor: default; }
.pl-side-item.is-locked img { filter: brightness(0.55) saturate(0.8); }
.pl-side-item.is-locked .t { opacity: 0.85; }
.pl-side-lock { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; background: rgba(0, 0, 0, 0.25); }
.pl-side-item .t { display: block; font-size: 0.9rem; line-height: 1.45; overflow-wrap: anywhere; }
.pl-side-item .m { display: block; font-size: 0.76rem; color: var(--muted, #aaa); }

.pl-gate { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 6px 12px 0; text-align: center; max-width: 360px; margin: 0 auto; }
.pl-gate-title { font-size: 1.05rem; font-weight: 800; color: #fff; line-height: 1.5; }
.pl-gate-sub { font-size: 0.85rem; color: rgba(255, 255, 255, 0.8); }
.pl-gate .pl-buy { max-width: 300px; min-height: 46px; }
.pl-linkbtn { margin: 4px 0 0; padding: 8px 12px; border: 0; background: none; color: var(--gold, #3ea6ff); font: inherit; font-size: 0.9rem; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.vm-lock-overlay .pl-linkbtn { color: #9ad0ff; }

.pl-notice { text-align: center; padding-top: 6px; }
.pl-notice-icon { font-size: 2.4rem; line-height: 1.2; }
.pl-notice-price { margin: 8px 0 0; font-size: 1.9rem; font-weight: 800; color: var(--gold, #3ea6ff); }
.pl-notice .pl-foot { position: static; margin: 14px 0 0; padding: 0; background: none; }
.pl-notice-links { display: flex; flex-direction: column; align-items: center; margin-top: 4px; }

/* រូបសោ SVG (ជំនួស Emoji) */
.pl-lock-ico { display: inline-flex; align-items: center; justify-content: center; line-height: 0; }
.pl-lock-ico svg { width: 1em; height: 1em; display: block; }
.pl-video-state .pl-lock-ico { font-size: 1.15rem; color: var(--muted, #aaa); }
.pl-lock-sm { font-size: 0.9em; vertical-align: -0.12em; }
.pl-lock-sm svg { display: inline-block; }
.pl-side-lock .pl-lock-ico { font-size: 1.6rem; color: #fff; filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.6)); }
.pl-notice-icon { color: var(--gold, #3ea6ff); }
.pl-notice-icon .pl-lock-ico { font-size: 2.6rem; }
