/* ===== Layar TV: fullscreen dinamis =====
 * --u  = satuan skala (1% tinggi kanvas 16:9). Berubah otomatis mengikuti rasio layar.
 * Angka utama & video memakai container query sehingga selalu mengisi ruang yang tersedia.
 */
.display-page {
  --u: min(1vh, 0.5625vw);
  --gap: calc(var(--u) * 1.6);
  --radius-lg: calc(var(--u) * 2);
  --history-min: calc(var(--u) * 22);
  --card-shadow: 0 calc(var(--u) * 1) calc(var(--u) * 3) calc(var(--u) * -1.2) rgba(15, 23, 42, .32);
  overflow: hidden;
  background: radial-gradient(circle at 20% 0%, #e6f6f4 0, var(--slate-100) 45%, #e8eef6 100%);
  user-select: none;
}
.display-page.hide-cursor, .display-page.hide-cursor * { cursor: none !important; }

.tv {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

/* ---------- Header ---------- */
.tv-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: calc(var(--u) * 3);
  min-height: calc(var(--u) * 11);
  padding: calc(var(--u) * 1) calc(var(--u) * 2.5);
  color: #fff;
  background: linear-gradient(100deg, var(--navy-800) 0%, var(--navy-700) 45%, var(--teal-700) 100%);
  box-shadow: 0 calc(var(--u) * .4) calc(var(--u) * 2) rgba(7, 29, 58, .25);
  position: relative;
  z-index: 2;
}
.brand { display: flex; align-items: center; gap: calc(var(--u) * 1.8); min-width: 0; }
.brand-logo {
  height: calc(var(--u) * 9); width: auto; flex: none; object-fit: contain;
  filter: drop-shadow(0 calc(var(--u) * .3) calc(var(--u) * .8) rgba(0, 0, 0, .3));
}
.brand-text { min-width: 0; }
.brand-text h1 {
  margin: 0; font-size: calc(var(--u) * 4.4); font-weight: 800; letter-spacing: -.01em; line-height: 1.05;
  white-space: nowrap;
}
.brand-text p {
  margin: calc(var(--u) * .5) 0 0; font-size: calc(var(--u) * 1.75); font-weight: 500; opacity: .9;
  line-height: 1.3; max-width: calc(var(--u) * 115);
}
.clock { text-align: right; flex: none; }
.clock-time { font-size: calc(var(--u) * 5.4); font-weight: 800; line-height: 1; letter-spacing: .02em; }
.clock-date { font-size: calc(var(--u) * 2); font-weight: 600; margin-top: calc(var(--u) * .4); opacity: .95; white-space: nowrap; }
.clock .conn { font-size: calc(var(--u) * 1.3); margin-top: calc(var(--u) * .4); opacity: .85; justify-content: flex-end; }
.clock .conn-dot { width: calc(var(--u) * .9); height: calc(var(--u) * .9); }
.clock .conn[data-status="live"] { opacity: .55; }

/* ---------- Area utama ---------- */
.tv-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.6fr);
  grid-template-rows: minmax(0, 1fr);
  gap: var(--gap);
  padding: var(--gap) calc(var(--u) * 2);
  min-height: 0;
}

.loket-a { --c: var(--loket-a); --c-dark: var(--loket-a-dark); --soft: var(--loket-a-soft); --glow: 20, 184, 166; }
.loket-b { --c: var(--loket-b); --c-dark: var(--loket-b-dark); --soft: var(--loket-b-soft); --glow: 37, 112, 200; }

.loket-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: #fff;
  border-radius: var(--radius-lg);
  border: calc(var(--u) * .4) solid transparent;
  box-shadow: var(--card-shadow);
  overflow: hidden;
  transition: border-color .3s ease;
}
.loket-head {
  background: linear-gradient(135deg, var(--c) 0%, var(--c-dark) 100%);
  color: #fff;
  text-align: center;
  padding: calc(var(--u) * 1.2) calc(var(--u) * 1.4) calc(var(--u) * 1.1);
}
.loket-head h2 {
  margin: 0; font-size: calc(var(--u) * 4.2); font-weight: 800; letter-spacing: .06em; line-height: 1.05;
}
.loket-head h2 span { font-weight: 700; opacity: .9; }
.loket-head h2 strong { font-size: 1.25em; }
.loket-desc {
  margin: calc(var(--u) * .4) 0 0; font-size: calc(var(--u) * 2); font-weight: 600; opacity: .95;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.caption {
  font-size: calc(var(--u) * 2); font-weight: 800; letter-spacing: .14em; text-transform: uppercase;
  color: var(--slate-500); white-space: nowrap;
}
.loket-now {
  flex: 1; min-height: 0;
  container-type: size;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: calc(var(--u) * .4);
  padding: calc(var(--u) * .8) calc(var(--u) * 1.2);
}
.now-number {
  font-size: calc(var(--u) * 16); font-weight: 800; line-height: 1; letter-spacing: -.02em;
  color: var(--c-dark); white-space: nowrap;
}
.now-number.long { font-size: calc(var(--u) * 12); }
/* Ukuran angka mengikuti ruang kartu (lebar & tinggi), jadi selalu penuh dan rapi */
@supports (font-size: 1cqw) {
  /* JS (fitNumber) mengecilkan lagi bila glyph font lebih lebar dari perkiraan */
  .now-number { font-size: min(46cqw, 66cqh); }
  .now-number.long { font-size: min(36cqw, 60cqh); }
}
.now-number.empty { color: var(--slate-300); }

.loket-foot {
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--soft);
  border-top: calc(var(--u) * .25) dashed rgba(var(--glow), .35);
}
.foot-block { padding: calc(var(--u) * 1.1) calc(var(--u) * 1); text-align: center; min-width: 0; }
.foot-wait { border-left: calc(var(--u) * .2) solid rgba(var(--glow), .2); }
.foot-block .caption { font-size: calc(var(--u) * 1.6); }
.next-number, .wait-count {
  font-size: calc(var(--u) * 5.2); font-weight: 800; color: var(--slate-800); line-height: 1.1; white-space: nowrap;
}
.next-number.muted { color: var(--slate-400); }
.wait-count small { font-size: calc(var(--u) * 1.9); font-weight: 700; color: var(--slate-500); margin-left: calc(var(--u) * .5); }

/* Efek pemanggilan: glow berdenyut + border berkedip halus */
.loket-card.calling {
  border-color: var(--c);
  animation: card-glow 1.1s ease-in-out infinite;
}
.loket-card.calling .now-number { animation: number-blink 1.1s ease-in-out infinite; }
.loket-card.calling .loket-head { animation: head-shine 1.1s ease-in-out infinite; }
.now-number.pop { animation: number-pop .7s cubic-bezier(.2, 1.4, .4, 1); }

@keyframes card-glow {
  0%   { box-shadow: 0 0 0 0 rgba(var(--glow), .75), 0 0 calc(var(--u) * 4) rgba(var(--glow), .45); }
  70%  { box-shadow: 0 0 0 calc(var(--u) * 2) rgba(var(--glow), 0), 0 0 calc(var(--u) * 6) rgba(var(--glow), .25); }
  100% { box-shadow: 0 0 0 0 rgba(var(--glow), 0), 0 0 calc(var(--u) * 4) rgba(var(--glow), .45); }
}
@keyframes number-blink {
  0%, 100% { transform: scale(1); color: var(--c-dark); }
  50%      { transform: scale(1.04); color: var(--c); }
}
@keyframes head-shine {
  0%, 100% { filter: brightness(1); }
  50%      { filter: brightness(1.18); }
}
@keyframes number-pop {
  0%   { transform: scale(.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* ---------- Video & riwayat ---------- */
.media-col {
  container-type: size;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-height: 0;
  min-width: 0;
}
.video-frame {
  position: relative;
  flex: none;
  align-self: center;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--navy-900);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--card-shadow);
}
/* Video sebesar mungkin dengan tetap menyisakan ruang riwayat panggilan */
@supports (width: 1cqh) {
  .video-frame { width: min(100cqw, (100cqh - var(--history-min) - var(--gap)) * 16 / 9); }
}
.video-stage, .video-stage .video-el, .video-stage iframe {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0;
}
.video-stage video { object-fit: contain; background: #000; }
.video-placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(var(--u) * 1.2);
  color: #fff; text-align: center; padding: calc(var(--u) * 3);
  background: linear-gradient(135deg, var(--navy-800), var(--teal-700));
}
.video-placeholder img {
  height: 42%; max-height: calc(var(--u) * 18); width: auto; object-fit: contain;
  filter: drop-shadow(0 calc(var(--u) * .5) calc(var(--u) * 1.2) rgba(0, 0, 0, .3));
}
.video-placeholder strong { font-size: calc(var(--u) * 3.6); font-weight: 800; }
.video-placeholder span { font-size: calc(var(--u) * 1.9); opacity: .85; }

.history {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: flex; flex-direction: column;
  background: #fff;
  border-radius: var(--radius-lg);
  padding: calc(var(--u) * 1.4) calc(var(--u) * 1.8);
  box-shadow: var(--card-shadow);
}
.history-title {
  font-size: calc(var(--u) * 2); font-weight: 800; letter-spacing: .12em; text-transform: uppercase;
  color: var(--slate-600); margin-bottom: calc(var(--u) * 1);
}
.history-list {
  list-style: none; margin: 0; padding: 0;
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: calc(var(--u) * 1);
}
.history-list li {
  display: flex; align-items: center; justify-content: space-between; gap: calc(var(--u) * 1);
  min-width: 0; min-height: 0; overflow: hidden;
  background: var(--soft);
  border-left: calc(var(--u) * .7) solid var(--c);
  border-radius: calc(var(--u) * 1.2);
  padding: calc(var(--u) * .6) calc(var(--u) * 1.3);
}
.history-list li.latest { background: linear-gradient(135deg, var(--c), var(--c-dark)); color: #fff; }
.history-list li.latest .h-num, .history-list li.latest .h-meta { color: #fff; }
.h-num { font-size: calc(var(--u) * 4.2); font-weight: 800; color: var(--c-dark); line-height: 1; white-space: nowrap; }
.h-meta { text-align: right; font-size: calc(var(--u) * 1.7); color: var(--slate-600); font-weight: 600; line-height: 1.25; white-space: nowrap; }
.h-meta strong { display: block; font-weight: 800; }
.history-list li.empty {
  grid-column: 1 / -1; grid-row: 1 / -1; justify-content: center;
  background: var(--slate-50); border-left: 0; color: var(--slate-400);
  font-size: calc(var(--u) * 2.3); font-weight: 700;
}

/* ---------- Running text ---------- */
.tv-ticker {
  display: flex;
  height: calc(var(--u) * 6.5);
  background: var(--navy-800);
  color: #fff;
  overflow: hidden;
}
.ticker-badge {
  flex: none;
  display: flex; align-items: center;
  padding: 0 calc(var(--u) * 4.5) 0 calc(var(--u) * 2.5);
  background: var(--teal-500);
  color: var(--navy-900);
  font-size: calc(var(--u) * 2.6); font-weight: 800; letter-spacing: .1em;
  clip-path: polygon(0 0, 100% 0, calc(100% - calc(var(--u) * 2)) 100%, 0 100%);
}
.ticker-viewport { position: relative; flex: 1; overflow: hidden; }
.ticker-track {
  position: absolute; top: 0; bottom: 0; left: 0;
  display: flex; align-items: center;
  white-space: nowrap;
  font-size: calc(var(--u) * 2.8); font-weight: 700;
  will-change: transform;
}

/* ---------- Rasio layar lebih kotak (4:3, 5:4, 3:2) ---------- */
@media (max-aspect-ratio: 3/2) {
  .display-page { --u: min(1vh, 0.72vw); --history-min: 0px; }
  .tv-main {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1.25fr) minmax(0, 1fr);
  }
  .media-col { grid-column: 1 / -1; flex-direction: row; }
  .video-frame { width: 58%; }
  @supports (width: 1cqh) {
    .video-frame { width: min(62cqw, 100cqh * 16 / 9); }
  }
  .history-list { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); }
}

/* ---------- Layar potret (TV diputar vertikal) ---------- */
@media (orientation: portrait) {
  .display-page { --u: min(0.62vh, 1.05vw); --history-min: calc(var(--u) * 26); }
  .brand-text h1 { white-space: normal; }
  .tv-main {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) minmax(0, 1.15fr);
  }
  .media-col { grid-column: 1 / -1; flex-direction: column; }
  .video-frame { width: 100%; }
  @supports (width: 1cqh) {
    .video-frame { width: min(100cqw, (100cqh - var(--history-min) - var(--gap)) * 16 / 9); }
  }
  .history-list { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Kontrol layar penuh ---------- */
/* Ditempatkan di dalam bar running text agar tidak menutupi informasi antrean */
.fs-toolbar {
  --s: max(12px, calc(var(--u) * 1.6));
  position: fixed;
  right: 0;
  bottom: 0;
  height: calc(var(--u) * 6.5);
  padding: 0 calc(var(--u) * 1.5) 0 calc(var(--u) * 5);
  background: linear-gradient(to right, rgba(11, 45, 87, 0), var(--navy-800) calc(var(--u) * 4));
  z-index: 60;
  display: flex; align-items: center; gap: calc(var(--s) * .7);
  font-size: var(--s);
  opacity: 0;
  transform: translateY(calc(var(--u) * 1));
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
.display-page.controls-visible .fs-toolbar,
.display-page.needs-fs .fs-toolbar { opacity: 1; transform: none; pointer-events: auto; }
.fs-hint {
  display: none;
  padding: .55em 1em; border-radius: 999px;
  background: var(--navy-700); color: #fff; font-weight: 600;
  border: 1px solid rgba(255, 255, 255, .25);
  backdrop-filter: blur(6px);
}
.display-page.needs-fs .fs-hint { display: inline-flex; align-items: center; gap: .4em; }
.fs-btn {
  display: inline-flex; align-items: center; gap: .55em;
  padding: .55em 1em; border: 0; border-radius: 999px;
  font-size: 1em; font-weight: 700; color: #fff; cursor: pointer;
  background: rgba(7, 29, 58, .85);
  box-shadow: 0 6px 20px rgba(7, 29, 58, .35);
  backdrop-filter: blur(6px);
  transition: background-color .15s ease, transform .1s ease;
}
.fs-btn:hover { background: var(--navy-700); }
.fs-btn:active { transform: scale(.97); }
.fs-btn:focus-visible { outline: 3px solid var(--amber-400); outline-offset: 2px; }
.fs-btn svg { width: 1.35em; height: 1.35em; flex: none; }
.fs-btn kbd { font-size: .78em; }
.display-page.needs-fs .fs-btn { background: var(--teal-600); animation: fs-pulse 2s ease-in-out infinite; }
@keyframes fs-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(20, 184, 166, .6), 0 6px 20px rgba(7, 29, 58, .35); }
  50%      { box-shadow: 0 0 0 10px rgba(20, 184, 166, 0), 0 6px 20px rgba(7, 29, 58, .35); }
}

/* ---------- Pop-up pemanggilan ---------- */
.call-overlay {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: rgba(7, 29, 58, .55);
  backdrop-filter: blur(4px);
  animation: fade-in .25s ease-out;
}
.call-box {
  min-width: min(calc(var(--u) * 90), 92vw);
  max-width: 94vw;
  text-align: center;
  background: #fff;
  border-radius: calc(var(--u) * 3);
  border-top: calc(var(--u) * 1.6) solid var(--c);
  padding: calc(var(--u) * 4) calc(var(--u) * 8) calc(var(--u) * 5);
  animation: box-in .45s cubic-bezier(.2, 1.3, .4, 1), card-glow 1.1s ease-in-out .45s infinite;
}
.call-caption {
  font-size: calc(var(--u) * 3.6); font-weight: 800; letter-spacing: .16em; text-transform: uppercase; color: var(--slate-600);
}
.call-number {
  font-size: min(calc(var(--u) * 26), 24vw); font-weight: 800; line-height: 1; color: var(--c-dark);
  margin: calc(var(--u) * 1) 0 calc(var(--u) * 2);
  animation: number-blink 1.1s ease-in-out infinite;
}
.call-dest { font-size: calc(var(--u) * 4.6); font-weight: 700; color: var(--slate-700); }
.call-dest strong { color: var(--c); font-weight: 800; }
.call-recall {
  display: inline-block; margin-top: calc(var(--u) * 2);
  padding: calc(var(--u) * .6) calc(var(--u) * 2.2); border-radius: 999px;
  background: #fef3c7; color: #92400e; font-weight: 800; font-size: calc(var(--u) * 2.4);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes box-in { from { opacity: 0; transform: scale(.7); } to { opacity: 1; transform: none; } }

/* ---------- Overlay mulai ---------- */
.start-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; padding: 24px;
  background: linear-gradient(135deg, rgba(11, 45, 87, .96), rgba(15, 118, 110, .96));
  cursor: pointer;
}
.start-card {
  width: min(640px, 100%);
  max-height: calc(100dvh - 48px);
  overflow: auto;
  background: #fff; border-radius: 20px; padding: 28px 32px;
  text-align: center; box-shadow: var(--shadow);
  user-select: text;
  cursor: default;
}
.start-logo { height: 96px; width: auto; object-fit: contain; margin: 0 auto 10px; }
.start-card h2 { margin: 0 0 8px; font-size: 26px; font-weight: 800; color: var(--navy-800); }
.start-card p { margin: 0 0 14px; color: var(--slate-600); line-height: 1.55; }
.voice-field { display: block; text-align: left; margin: 16px 0 8px; }
.voice-field span { display: block; font-weight: 700; font-size: 14px; margin-bottom: 6px; color: var(--slate-700); }
.voice-field select {
  width: 100%; padding: 12px; border-radius: 10px; border: 2px solid var(--slate-300); background: #fff;
}
.voice-warn { color: var(--red-600) !important; font-weight: 600; font-size: 14px; }
.check-field {
  display: flex; align-items: center; gap: 10px; text-align: left;
  margin: 12px 0 0; font-weight: 600; font-size: 15px; color: var(--slate-700); cursor: pointer;
}
.check-field input { width: 20px; height: 20px; flex: none; accent-color: var(--teal-600); }
.start-actions { display: flex; gap: 12px; justify-content: center; margin: 20px 0 14px; flex-wrap: wrap; }
.start-actions .btn { font-size: 18px; padding: 14px 26px; }
.start-hint { font-size: 13px; color: var(--slate-500) !important; margin: 0 !important; }
