/* ===========================================================
   Scheduled Media Player — dark, TV/kiosk friendly
   =========================================================== */

:root {
  --bg: #060a10;
  --bg-soft: #0b121b;
  --card: #101a26;
  --card-2: #16222f;
  --line: #1e2d3d;
  --text: #e8eef7;
  --muted: #8ba0b6;
  --accent: #34d399;
  --accent-2: #38bdf8;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 18px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  color: var(--text);
  background: radial-gradient(1200px 800px at 18% -10%, #10202e 0%, var(--bg) 58%) fixed, var(--bg);
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.is-hidden { display: none !important; }

/* ---------------- Layout ---------------- */

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(340px, 0.85fr);
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "top top"
    "stage timeline";
  gap: clamp(14px, 1.8vw, 28px);
  padding: clamp(16px, 2.2vw, 36px);
}

.topbar {
  grid-area: top;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.stage {
  grid-area: stage;
  display: flex;
  min-height: 0;
}

.timeline-wrap {
  grid-area: timeline;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: linear-gradient(180deg, rgba(22, 34, 47, 0.65), rgba(11, 18, 27, 0.65));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(14px, 1.6vw, 22px);
  overflow: hidden;
}

@media (max-width: 1020px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    grid-template-areas: "top" "stage" "timeline";
  }
  .timeline-wrap { max-height: 60vh; }
}

/* ---------------- Clock ---------------- */

.clock {
  font-size: clamp(2.4rem, 5.4vw, 4.6rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #ffffff 20%, #9dc3d8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.clock-meta {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: clamp(0.85rem, 1.1vw, 1rem);
  letter-spacing: 0.01em;
}

.clock-meta .sep { opacity: 0.5; }

.sim-badge {
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #0b121b;
  background: var(--warn);
}

/* ---------------- Buttons ---------------- */

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.btn:hover:not(:disabled) { background: #1d2b3b; }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(180deg, #3ee2a4, #26b982);
  border-color: transparent;
  color: #04150f;
}
.btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, #4df0b3, #2ecb90); }

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
  padding: 8px 12px;
  font-size: 1.05rem;
  line-height: 1;
}
.btn-ghost:hover:not(:disabled) { color: var(--text); background: rgba(255, 255, 255, 0.05); }

.btn-lg { padding: 15px 34px; font-size: 1.1rem; border-radius: 14px; }
.btn-mini { padding: 5px 10px; font-size: 0.78rem; border-radius: 9px; }
.btn-danger { color: var(--danger); border-color: rgba(248, 113, 113, 0.35); }
.btn-danger:hover { background: rgba(248, 113, 113, 0.12); }

.top-actions { display: flex; gap: 8px; }

/* ---------------- Now card ---------------- */

.now-card {
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  padding: clamp(22px, 2.6vw, 40px);
  border-radius: calc(var(--radius) + 6px);
  border: 1px solid var(--line);
  background:
    radial-gradient(900px 320px at 0% 0%, rgba(52, 211, 153, 0.10), transparent 60%),
    linear-gradient(160deg, rgba(22, 34, 47, 0.9), rgba(8, 13, 20, 0.9));
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.45);
}

.now-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.pill-idle {
  background: rgba(139, 160, 182, 0.12);
  color: var(--muted);
  border: 1px solid var(--line);
}

.pill-live {
  background: rgba(52, 211, 153, 0.14);
  color: var(--accent);
  border: 1px solid rgba(52, 211, 153, 0.35);
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.25); }
  50% { box-shadow: 0 0 0 8px rgba(52, 211, 153, 0); }
}

.now-window {
  font-size: 0.85rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.now-title {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.now-sub {
  margin: 0;
  color: var(--muted);
  font-size: clamp(0.9rem, 1.15vw, 1.05rem);
  min-height: 1.4em;
}

.progress {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.35s linear;
}

.now-times {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  margin-top: -6px;
}

.now-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.volume {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.volume-icon { font-size: 1rem; opacity: 0.75; }

input[type="range"] {
  appearance: none;
  width: 150px;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #06121a;
  box-shadow: 0 0 0 1px rgba(52, 211, 153, 0.6);
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #06121a;
}

.next-up {
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.next-up strong { color: var(--text); font-weight: 600; }

/* ---------------- Timeline ---------------- */

.section-title {
  margin: 0 0 12px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 700;
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0 4px 0 0;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scrollbar-width: thin;
}

.timeline::-webkit-scrollbar { width: 8px; }
.timeline::-webkit-scrollbar-thumb { background: #24384b; border-radius: 99px; }

.tl {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 12px;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.tl-time {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--muted);
  padding-top: 1px;
}

.tl-title {
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tl-sub {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}

.tl-state {
  grid-column: 2;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.badge {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent-2);
  border: 1px solid rgba(56, 189, 248, 0.25);
  white-space: nowrap;
}

.tl.status-live {
  background: rgba(52, 211, 153, 0.09);
  border-color: rgba(52, 211, 153, 0.3);
}
.tl.status-live .tl-time,
.tl.status-live .tl-state { color: var(--accent); }

.tl.status-due {
  background: rgba(251, 191, 36, 0.08);
  border-color: rgba(251, 191, 36, 0.25);
}
.tl.status-due .tl-state { color: var(--warn); }

.tl.status-done { opacity: 0.45; }
.tl.status-missed { opacity: 0.5; }
.tl.status-missed .tl-state { color: var(--danger); }
.tl.is-offday { opacity: 0.28; }
.tl.is-disabled { opacity: 0.32; text-decoration: line-through; }

.timeline-note {
  margin: 10px 0 0;
  font-size: 0.7rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.dot-badge {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-left: 6px;
}
.dot-badge:first-child { margin-left: 0; }
.dot-badge.status-live { background: var(--accent); }
.dot-badge.status-done { background: var(--muted); opacity: 0.4; }
.dot-badge.status-upcoming { background: #2b3f54; }

/* ---------------- YouTube player shell ---------------- */

.player-shell {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 2px;
  height: 2px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  z-index: 40;
  background: #000;
}

body.show-video .player-shell {
  width: min(40vw, 560px);
  height: auto;
  aspect-ratio: 16 / 9;
  opacity: 1;
  pointer-events: auto;
  border-radius: 14px;
  border: 1px solid var(--line);
  box-shadow: 0 22px 55px rgba(0, 0, 0, 0.65);
}

.yt-player, .yt-player iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* ---------------- Boot overlay ---------------- */

.boot {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 8, 13, 0.86);
  backdrop-filter: blur(10px);
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.boot.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.boot-card {
  width: min(560px, 100%);
  text-align: center;
  background: linear-gradient(165deg, rgba(22, 34, 47, 0.95), rgba(9, 14, 21, 0.95));
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: clamp(28px, 4vw, 48px);
  box-shadow: 0 40px 90px rgba(0, 0, 0, 0.6);
}

.boot-kicker {
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 14px;
}

.boot-card h1 {
  margin: 0 0 14px;
  font-size: clamp(1.6rem, 3.4vw, 2.3rem);
  letter-spacing: -0.02em;
}

.boot-card p {
  color: var(--muted);
  line-height: 1.65;
  font-size: 0.95rem;
  margin: 0 0 24px;
}

.boot-note { font-size: 0.8rem !important; margin: 18px 0 0 !important; }
.boot-error { color: var(--danger) !important; }

/* ---------------- Settings dialog ---------------- */

.settings-dialog {
  width: min(940px, 94vw);
  max-height: 90vh;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--bg-soft);
  color: var(--text);
  overflow: hidden;
}

.settings-dialog[open] { display: flex; flex-direction: column; }

.settings-dialog::backdrop {
  background: rgba(3, 7, 12, 0.78);
  backdrop-filter: blur(6px);
}

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.settings-head h2 { margin: 0; font-size: 1.1rem; letter-spacing: -0.01em; }

.settings-body {
  padding: 20px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
  flex: 1 1 auto;
  /* Wajib: tanpa ini, flex item menolak mengecil dan menutupi footer. */
  min-height: 0;
}

.settings-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: rgba(8, 13, 20, 0.7);
  flex: 0 0 auto;
  flex-wrap: wrap;
}

.settings-foot .spacer { flex: 1; }

.set-block h3 {
  margin: 0 0 10px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.hint { font-size: 0.78rem; color: var(--muted); margin: 0 0 10px; line-height: 1.5; }
.hint-inline { font-size: 0.7rem; text-transform: none; letter-spacing: 0; color: #55697d; font-weight: 500; }

.day-toggles, .ev-days {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.day-chip {
  appearance: none;
  font-family: inherit;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.day-chip.is-on {
  background: rgba(52, 211, 153, 0.16);
  border-color: rgba(52, 211, 153, 0.45);
  color: var(--accent);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
}

.field input[type="number"],
.field input[type="time"],
.field input[type="text"],
.field select,
.ev-title,
.media-row input,
#sim-time {
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: #0a121b;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  outline: none;
  width: 100%;
}

.field input:focus,
.ev-title:focus,
.media-row input:focus,
#sim-time:focus {
  border-color: rgba(56, 189, 248, 0.55);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12);
}

.field-check {
  flex-direction: row;
  align-items: center;
  gap: 9px;
  font-size: 0.85rem;
  color: var(--text);
  font-weight: 500;
}

.field-check input { accent-color: var(--accent); width: 16px; height: 16px; }
.field input[type="range"] { width: 100%; }

.event-list { display: flex; flex-direction: column; gap: 12px; }

.event-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: rgba(16, 26, 38, 0.7);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.event-card.is-off { opacity: 0.55; }

.ev-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.ev-title { flex: 1 1 220px; font-weight: 600; }

.ev-prio {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}

.ev-prio input {
  width: 62px;
  background: #0a121b;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 6px 8px;
  font-family: inherit;
  font-size: 0.85rem;
}

.ev-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  align-items: end;
}

.media-list { display: flex; flex-direction: column; gap: 8px; }

.media-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}

.media-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px auto;
  gap: 8px;
  align-items: center;
}

.media-row input[data-mfield="startSeconds"] { text-align: center; }

.switch { position: relative; display: inline-flex; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span {
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: #24384b;
  position: relative;
  transition: background 0.2s ease;
  display: block;
}
.switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #7d93a8;
  transition: transform 0.2s ease, background 0.2s ease;
}
.switch input:checked + span { background: rgba(52, 211, 153, 0.35); }
.switch input:checked + span::after { transform: translateX(18px); background: var(--accent); }

.sim-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sim-row #sim-time { width: 130px; }
.sim-status { font-size: 0.78rem; color: var(--warn); font-variant-numeric: tabular-nums; }

/* ---------------- Toast ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 20px);
  background: rgba(16, 26, 38, 0.96);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 11px 20px;
  border-radius: 12px;
  font-size: 0.88rem;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 120;
  max-width: 90vw;
}

.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
