@font-face {
  font-family: "Jameel Noori Nastaleeq";
  src: url("../fonts/JameelNooriNastaleeq.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #0f172a;
  --panel: #111827;
  --panel-2: #1f2937;
  --text: #f8fafc;
  --muted: #cbd5e1;
  --border: rgba(255,255,255,.12);
  --accent: #38bdf8;
  --danger: #ef4444;
  --ok: #22c55e;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }

.site-wrap, .watch-wrap, .admin-wrap { width: min(1120px, calc(100% - 28px)); margin: 0 auto; padding: 28px 0; }
.topbar, .watch-head, .admin-topbar { display: flex; gap: 16px; justify-content: space-between; align-items: center; margin-bottom: 18px; }
h1, h2, h3 { margin: 0 0 12px; line-height: 1.2; }
p { color: var(--muted); }
.card { background: rgba(17, 24, 39, .88); border: 1px solid var(--border); border-radius: 20px; padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.22); margin-bottom: 18px; }
.notice { background: rgba(56,189,248,.12); border: 1px solid rgba(56,189,248,.3); color: #e0f2fe; padding: 12px 14px; border-radius: 14px; }
.error { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.36); color: #fecaca; padding: 12px 14px; border-radius: 14px; }
.success { background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.36); color: #bbf7d0; padding: 12px 14px; border-radius: 14px; }
.btn, button, input[type="submit"] { display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); min-height: 40px; padding: 9px 14px; border-radius: 12px; cursor: pointer; transition: transform .15s ease, border-color .15s ease; }
.btn:hover, button:hover, input[type="submit"]:hover { transform: translateY(-1px); border-color: rgba(56,189,248,.55); }
.btn-primary { background: var(--accent); color: #04111d; border-color: transparent; font-weight: 700; }
.btn-danger { background: var(--danger); color: white; border-color: transparent; }

.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.video-card { background: var(--panel-2); border: 1px solid var(--border); border-radius: 18px; overflow: hidden; display: grid; gap: 10px; padding-bottom: 14px; }
.video-card img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; }
.video-card strong, .video-card span { padding: 0 14px; }
.video-card span { color: var(--muted); font-size: 14px; }

.secure-player { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; overflow: hidden; border-radius: 22px; border: 1px solid var(--border); box-shadow: 0 28px 80px rgba(0,0,0,.35); }
.youtube-frame { position: absolute; inset: 0; width: 100%; height: 100%; }
.subtitle-layer { position: absolute; inset: 0; pointer-events: none; z-index: 5; display: flex; justify-content: center; padding-inline: 18px; }
.subtitle-box { display: none; width: fit-content; border-radius: 12px; padding: .28em .7em .38em; line-height: 1.65; text-align: center; white-space: pre-line; word-break: break-word; pointer-events: none; }
.player-controls { position: absolute; z-index: 8; left: 12px; bottom: 12px; display: flex; gap: 8px; direction: ltr; opacity: .88; }
.player-controls button { min-height: 34px; padding: 6px 10px; border-radius: 10px; background: rgba(15,23,42,.76); backdrop-filter: blur(8px); }
.description { line-height: 1.9; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-row { display: grid; gap: 7px; }
.form-row.full { grid-column: 1 / -1; }
label { color: #e2e8f0; font-weight: 650; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="color"], textarea, select { width: 100%; background: rgba(15,23,42,.72); color: var(--text); border: 1px solid var(--border); border-radius: 12px; padding: 11px 12px; outline: none; }
input[type="color"] { height: 46px; padding: 4px; }
textarea { min-height: 110px; resize: vertical; }
.help { color: var(--muted); font-size: 13px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; border-bottom: 1px solid var(--border); padding: 12px 10px; vertical-align: top; }
th { color: #bfdbfe; font-weight: 750; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.badge { display: inline-flex; padding: 4px 9px; border-radius: 999px; background: rgba(148,163,184,.16); color: #e2e8f0; font-size: 12px; }
.badge.published { background: rgba(34,197,94,.15); color: #bbf7d0; }
.badge.draft { background: rgba(251,191,36,.15); color: #fde68a; }

@media (max-width: 760px) {
  .form-grid { grid-template-columns: 1fr; }
  .topbar, .watch-head, .admin-topbar { align-items: flex-start; flex-direction: column; }
  .player-controls { transform: scale(.92); transform-origin: left bottom; }
  .subtitle-box { max-width: 94% !important; font-size: clamp(20px, 5vw, 34px) !important; }
}

/* Full custom YouTube shell player */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.custom-shell .youtube-frame,
.custom-shell .youtube-frame iframe {
  pointer-events: none;
}
.player-overlay {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background: rgba(2, 6, 23, .62);
  pointer-events: auto;
}
.player-overlay.is-visible { display: flex; }
.player-poster {
  background-size: cover;
  background-position: center;
}
.overlay-card {
  display: grid;
  justify-items: center;
  gap: 14px;
  max-width: min(760px, 92%);
  padding: 24px;
  border-radius: 24px;
  background: rgba(15, 23, 42, .48);
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 24px 80px rgba(0,0,0,.34);
  backdrop-filter: blur(10px);
}
.overlay-card.compact { padding: 20px 24px; }
.overlay-title {
  color: #fff;
  font-weight: 800;
  font-size: clamp(22px, 4vw, 44px);
  line-height: 1.2;
  text-wrap: balance;
  text-shadow: 0 4px 18px rgba(0,0,0,.62);
}
.overlay-hint {
  color: rgba(255,255,255,.78);
  font-size: 14px;
  letter-spacing: .02em;
}
.big-play {
  width: 76px;
  height: 76px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.22);
  background: rgba(56,189,248,.96);
  color: #04111d;
  font-size: 30px;
  font-weight: 900;
  box-shadow: 0 16px 44px rgba(56,189,248,.25);
}
.big-play.small { width: 60px; height: 60px; font-size: 26px; }
.custom-controls {
  position: absolute;
  z-index: 10;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: grid;
  grid-template-columns: auto auto 1fr auto auto auto auto minmax(70px, 110px) auto;
  gap: 8px;
  align-items: center;
  direction: ltr;
  padding: 8px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(15,23,42,.86), rgba(15,23,42,.70));
  backdrop-filter: blur(12px);
  opacity: .96;
}
.custom-shell:not(:hover) .custom-controls,
.custom-shell.is-playing:not(:hover) .custom-controls {
  opacity: .28;
}
.custom-shell .custom-controls:hover,
.custom-shell .custom-controls:focus-within {
  opacity: .98 !important;
}
.control-btn {
  min-height: 34px;
  min-width: 38px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(30,41,59,.86);
}
.control-btn.wide { min-width: 112px; }
.seek-bar,
.volume-slider {
  accent-color: var(--accent);
  min-width: 0;
}
.time-readout {
  color: rgba(255,255,255,.88);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  min-width: 38px;
  text-align: center;
}
.custom-shell .subtitle-layer { z-index: 6; }

@media (max-width: 860px) {
  .custom-controls {
    grid-template-columns: auto 1fr auto auto auto;
    gap: 6px;
  }
  .time-readout,
  .volume-slider,
  #duration-time { display: none; }
  .control-btn.wide { min-width: auto; }
}

@media (max-width: 520px) {
  .custom-controls {
    left: 8px;
    right: 8px;
    bottom: 8px;
    padding: 6px;
  }
  .control-btn { min-height: 32px; min-width: 34px; padding: 5px 8px; font-size: 13px; }
  .big-play { width: 62px; height: 62px; font-size: 25px; }
  .overlay-card { padding: 18px; }
}
.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: #e2e8f0;
}
.inline-check input { width: auto; }
@media (hover: none) {
  .custom-shell:not(:hover) .custom-controls,
  .custom-shell.is-playing:not(:hover) .custom-controls { opacity: .96; }
}


/* Professional custom-control YouTube shell override */
.secure-player.custom-shell {
  isolation: isolate;
  background: #000;
}
.youtube-viewport {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  background: #000;
}
.youtube-frame,
.youtube-frame iframe {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  border: 0 !important;
  pointer-events: none !important;
}
.youtube-frame iframe {
  transform: scale(1.018);
  transform-origin: center center;
}
.video-surface {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  cursor: pointer;
  box-shadow: none;
  transform: none !important;
}
.video-surface:hover,
.video-surface:focus {
  border-color: transparent;
  outline: none;
  transform: none !important;
}
.yt-ui-mask {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 4;
  pointer-events: none;
}
.yt-ui-mask-top {
  top: 0;
  height: clamp(42px, 9%, 78px);
  background: linear-gradient(180deg, rgba(0,0,0,.82), rgba(0,0,0,.36) 48%, rgba(0,0,0,0));
}
.yt-ui-mask-bottom {
  bottom: 0;
  height: clamp(72px, 16%, 124px);
  background: linear-gradient(0deg, rgba(0,0,0,.92), rgba(0,0,0,.44) 54%, rgba(0,0,0,0));
}
.custom-shell .subtitle-layer { z-index: 6; }
.custom-shell .player-overlay { z-index: 9; }
.custom-shell .custom-controls {
  z-index: 12;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity .18s ease, transform .18s ease;
}
.custom-shell.controls-visible .custom-controls,
.custom-shell:not(.is-playing) .custom-controls,
.custom-shell .custom-controls:hover,
.custom-shell .custom-controls:focus-within {
  opacity: .98 !important;
  pointer-events: auto;
  transform: translateY(0);
}
.custom-shell.has-overlay .custom-controls {
  opacity: .98 !important;
  pointer-events: auto;
  transform: translateY(0);
}
.custom-shell.is-playing:not(.controls-visible) .custom-controls {
  opacity: 0 !important;
  pointer-events: none;
}
.custom-shell .control-btn,
.custom-shell .seek-bar,
.custom-shell .volume-slider {
  position: relative;
  z-index: 13;
}
@media (hover: none) {
  .custom-shell.is-playing:not(.controls-visible) .custom-controls {
    opacity: .98 !important;
    pointer-events: auto;
    transform: translateY(0);
  }
  .yt-ui-mask-top { height: 44px; }
  .yt-ui-mask-bottom { height: 86px; }
}
