/* ===========================================================
   Hi-POS — Playground Board (TV display)
   -----------------------------------------------------------
   Mengikuti design system Hi-POS (lihat syspos-bo-demo):
     primary  hsl(217 93% 55%)  -> #2273F7
     font     Inter
   Produk SaaS: nama venue & logo di-white-label lewat
   CONFIG.brand di app.js — CSS ini tidak mengunci ke 1 customer.
   Kanvas tetap 1920x1080, scale-to-fit (lihat app.js: fit()).
   =========================================================== */
:root {
  /* Brand Hi-POS (diambil dari logo + token Back Office) */
  --brand: #2273f7; /* primary */
  --brand-dark: #123a8f; /* navy pada logo */
  --brand-deep: #0b2a6b;
  --cyan: #22c3d6; /* aksen cyan pada logo */
  --lime: #8dc63f; /* aksen hijau pada logo */

  /* Semantik status (tidak ikut berubah saat accent diganti) */
  --ok: #2273f7; /* "aman" — dikonfigurasi via CONFIG.accent */
  --warn: #f59e0b; /* <= thresholdMin */
  --crit: #ef4444; /* <= criticalMin  */

  /* Netral */
  --ink: #0f172a;
  --ink-soft: #64748b;
  --card: #ffffff;
  --line: #dce7fa;
  --line-soft: #edf3fe;
}
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html,
body {
  width: 100%;
  height: 100%;
  background: #0b2a6b;
  overflow: hidden;
}
body {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family:
    "Inter",
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

#stage {
  width: 1920px;
  height: 1080px;
  flex: 0 0 auto;
  position: relative;
  transform-origin: center center;
  background:
    radial-gradient(
      1200px 720px at 86% -14%,
      rgba(34, 195, 214, 0.22) 0%,
      rgba(34, 195, 214, 0) 62%
    ),
    radial-gradient(
      1080px 660px at 4% 112%,
      rgba(34, 115, 247, 0.18) 0%,
      rgba(34, 115, 247, 0) 58%
    ),
    linear-gradient(180deg, #f7faff 0%, #e9f1fe 100%);
  overflow: hidden;
}
/* Grid pattern halus — mengutip .bg-grid-pattern di globals.css Back Office. */
#stage::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(34, 115, 247, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 115, 247, 0.05) 1px, transparent 1px);
  background-size: 60px 60px;
}

.wrap {
  position: absolute;
  inset: 0;
  padding: 34px 44px 26px;
  display: flex;
  flex-direction: column;
}

/* ---------- App bar (topbar ala Hi-POS Back Office) ---------- */
.appbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 22px;
  padding: 16px 26px 16px 20px;
  margin-bottom: 24px;
  box-shadow: 0 10px 26px rgba(11, 42, 107, 0.08);
  position: relative;
  overflow: hidden;
}
/* Strip gradien brand di sisi kiri app bar */
.appbar::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 8px;
  background: linear-gradient(
    180deg,
    var(--brand-dark) 0%,
    var(--brand) 55%,
    var(--cyan) 100%
  );
}

.brand {
  display: flex;
  align-items: center;
  gap: 18px;
}
.mark {
  width: 84px;
  height: 84px;
  border-radius: 20px;
  flex: none;
  background: #fff;
  border: 2px solid var(--line-soft);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 18px rgba(34, 115, 247, 0.16);
}
.mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.brand-txt {
  display: flex;
  flex-direction: column;
  line-height: 1;
}
.brand-txt .name {
  font-weight: 800;
  font-size: 38px;
  color: var(--ink);
  letter-spacing: -0.6px;
}
.brand-txt .tag {
  font-weight: 800;
  font-size: 15px;
  color: var(--brand);
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-top: 8px;
}

.head-right {
  display: flex;
  align-items: center;
  gap: 20px;
}
.head-sep {
  width: 2px;
  height: 46px;
  background: var(--line);
  border-radius: 2px;
}
.clock {
  text-align: right;
  line-height: 1;
}
.clock .time {
  font-weight: 800;
  font-size: 48px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
}
.clock .date {
  font-weight: 600;
  font-size: 17px;
  color: var(--ink-soft);
  margin-top: 8px;
}

.sound-btn {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  border: 2px solid var(--line);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink-soft);
  transition: 0.2s;
}
.sound-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
}
.sound-btn.on {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: 0 6px 16px rgba(34, 115, 247, 0.35);
}

/* Tombol uji coba suara (sembunyikan di produksi: CONFIG.showTestButton=false) */
.test-btn {
  height: 58px;
  padding: 0 22px;
  border-radius: 16px;
  border: 2px solid var(--line);
  background: #fff;
  cursor: pointer;
  color: var(--ink);
  font-family: inherit;
  font-weight: 700;
  font-size: 16px;
  transition: 0.2s;
  white-space: nowrap;
}
.test-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
}
.test-btn:active {
  transform: scale(0.96);
}

/* Indikator koneksi data */
.conn {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 15px;
  color: var(--ink-soft);
  background: #f4f7fd;
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 9px 16px 9px 13px;
}
.conn-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--ink-soft);
}
.conn.live {
  color: #0e9f6e;
  border-color: #bbebd8;
  background: #eefbf5;
}
.conn.live .conn-dot {
  background: #0e9f6e;
  box-shadow: 0 0 10px #0e9f6e;
}
.conn.demo {
  color: #b45309;
  border-color: #fbd9a2;
  background: #fff8ec;
}
.conn.demo .conn-dot {
  background: var(--warn);
  box-shadow: 0 0 10px var(--warn);
}
.conn.down {
  color: #b91c1c;
  border-color: #f6c6c6;
  background: #fef2f2;
}
.conn.down .conn-dot {
  background: var(--crit);
  box-shadow: 0 0 10px var(--crit);
}

/* Location Badge */
.loc-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 15px;
  color: var(--brand);
  background: linear-gradient(135deg, rgba(34, 115, 247, 0.08), rgba(34, 195, 214, 0.12));
  border: 2px solid rgba(34, 115, 247, 0.2);
  border-radius: 999px;
  padding: 9px 16px 9px 13px;
  letter-spacing: 0.5px;
}
.loc-badge svg {
  color: var(--brand);
}

/* ---------- Kolom ---------- */
.cols {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 480px;
  gap: 26px;
  min-height: 0;
}
/* Kedua kolom pakai wadah yang sama: judul ikut di DALAM panel,
   background senada dgn kanvas (kartu putih di atasnya tetap menonjol). */
.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: linear-gradient(180deg, #fbfdff 0%, #f1f6fe 100%);
  border: 2px solid var(--line);
  border-radius: 24px;
  padding: 22px 20px;
  box-shadow: 0 10px 26px rgba(11, 42, 107, 0.07);
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 18px;
  flex-wrap: nowrap;
  white-space: nowrap;
}
.panel-head h2 {
  font-weight: 800;
  font-size: 32px;
  color: var(--ink);
  letter-spacing: -0.5px;
}
.head-ico {
  color: var(--brand);
  flex: none;
  display: inline-flex;
}
.count-badge {
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
  color: #fff;
  font-weight: 800;
  font-size: 20px;
  min-width: 46px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 13px;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 6px 14px rgba(34, 115, 247, 0.28);
}

/* ---------- Kartu anak ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 20px;
  flex: 1;
  min-height: 0;
}
.card {
  background: var(--card);
  border-radius: 22px;
  padding: 26px 16px 20px;
  box-shadow: 0 8px 22px rgba(11, 42, 107, 0.08);
  border: 2px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 13px;
  position: relative;
  overflow: hidden;
}
/* Strip status di atas kartu */
.card::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 6px;
  background: var(--ok);
  opacity: 0.9;
}
.avatar {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  flex: none;
  color: #fff;
  font-weight: 800;
  font-size: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 -4px 10px rgba(0, 0, 0, 0.14);
}
.who {
  text-align: center;
}
.who .nm {
  font-weight: 700;
  font-size: 30px;
  color: var(--ink);
  line-height: 1;
  white-space: nowrap;
  letter-spacing: -0.4px;
}
.chips {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 11px;
}
.chip {
  font-weight: 700;
  font-size: 14px;
  padding: 5px 11px;
  border-radius: 8px;
  white-space: nowrap;
}
.chip.gate {
  background: #e8f1fe;
  color: #1d63d8;
}
.chip.dur {
  background: #e4f8fb;
  color: #0e8fa0;
}
.cd {
  font-weight: 800;
  font-size: 52px;
  font-variant-numeric: tabular-nums;
  color: var(--ok);
  line-height: 1;
  margin-top: auto;
  letter-spacing: -1.5px;
}
.cdlbl {
  font-weight: 700;
  font-size: 12px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-top: -2px;
}
.bar {
  width: 100%;
  height: 10px;
  border-radius: 6px;
  background: #eaf0fa;
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  border-radius: 6px;
  background: var(--ok);
  transition: width 1s linear;
}

.card[data-state="warning"] {
  border-color: #fbd9a2;
  background: #fffcf5;
}
.card[data-state="warning"]::before,
.card[data-state="warning"] .bar > i {
  background: var(--warn);
}
.card[data-state="warning"] .cd {
  color: var(--warn);
}
.card[data-state="critical"] {
  border-color: var(--crit);
  background: #fff6f6;
  animation: pulseCard 1.6s ease-in-out infinite;
}
.card[data-state="critical"]::before,
.card[data-state="critical"] .bar > i {
  background: var(--crit);
}
.card[data-state="critical"] .cd {
  color: var(--crit);
}
@keyframes pulseCard {
  0%,
  100% {
    box-shadow: 0 8px 22px rgba(239, 68, 68, 0.14);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(239, 68, 68, 0.2);
  }
}

/* ---------- Panel "Akan Habis" ----------
   Wadah & background diwarisi dari .panel (identik dgn "Sedang Bermain");
   di sini hanya aksen amber pada baris/lonceng yang membedakan. */
/* Head + sub dijaga setinggi head panel kiri supaya baris pertama
   "Akan Habis" sejajar dgn baris pertama kartu. */
.akan .panel-head {
  margin-bottom: 0;
}
.akan .panel-head h2 {
  font-size: 29px;
}
.akan .sub {
  font-weight: 700;
  font-size: 15px;
  line-height: 18px;
  color: lab(1.37% 0 0);
  margin: 0 0 0 41px;
}
.akan .count-badge {
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
  box-shadow: 0 6px 14px rgba(34, 115, 247, 0.28);
}
.akList {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: hidden;
  flex: 1;
}
.akRow {
  background: #fff;
  border-radius: 18px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 15px;
  border: 2px solid #fbd9a2;
  box-shadow: 0 6px 14px rgba(180, 83, 9, 0.09);
}
.akRow .avatar {
  width: 52px;
  height: 52px;
  font-size: 25px;
}
.akRow .who2 {
  flex: 1;
  min-width: 0;
}
.akRow .who2 .nm {
  font-weight: 700;
  font-size: 27px;
  color: var(--ink);
  line-height: 1;
  letter-spacing: -0.4px;
}
.akRow .who2 .meta {
  font-weight: 600;
  font-size: 14px;
  color: var(--ink-soft);
  margin-top: 6px;
}
.akRow .cd {
  font-size: 36px;
  margin-top: 0;
  color: var(--warn);
}
.bell {
  color: var(--warn);
  flex: none;
  display: inline-flex;
}
.akRow[data-state="warning"] {
  border-color: var(--warn);
}
.akRow[data-state="critical"] {
  border-color: var(--crit);
  background: #fff6f6;
  animation: softGlow 1.6s ease-in-out infinite;
}
.akRow[data-state="critical"] .cd,
.akRow[data-state="critical"] .bell {
  color: var(--crit);
}
/* Denyut halus (bukan kedip keras) — menarik perhatian tanpa melelahkan mata. */
@keyframes softGlow {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(239, 68, 68, 0.26);
  }
}

.empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: #0e9f6e;
  text-align: center;
}
.empty .big {
  font-weight: 800;
  font-size: 26px;
  letter-spacing: -0.4px;
}
.empty .sm {
  font-weight: 600;
  font-size: 16px;
  color: var(--ink-soft);
}

/* Hero brand saat belum ada anak bermain — pakai logo tenant (CONFIG.brand.logo). */
/* Menyatu dgn panel — tanpa background/border sendiri, sama seperti
   .empty di panel "Akan Habis". */
.brand-hero {
  grid-column: 1 / -1;
  grid-row: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}
.brand-hero img {
  width: min(34%, 300px);
  height: auto;
}
.brand-hero .big {
  font-weight: 800;
  font-size: 32px;
  color: var(--ink);
  letter-spacing: -0.5px;
}
.brand-hero .sm {
  font-weight: 600;
  font-size: 18px;
  color: var(--ink-soft);
}
/* Varian error: URL/kode lokasi tidak sah. Merah supaya jelas ini bukan
   kondisi normal "belum ada yang bermain". */
.brand-hero.fatal {
  color: var(--crit);
}
.brand-hero.fatal .big {
  color: var(--crit);
}
.brand-hero.fatal .sm b {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-weight: 700;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 2px 8px;
}

/* ---------- Footer: legenda status + powered by ---------- */
.footbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  height: 34px;
}
.legend {
  display: flex;
  align-items: center;
  gap: 26px;
}
.legend .lg {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 15px;
  color: var(--ink-soft);
}
.legend .lg em {
  font-style: normal;
  font-weight: 600;
  opacity: 0.8;
  margin-left: 4px;
}
.legend .dot {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  display: inline-block;
}
.legend .dot.ok {
  background: var(--ok);
}
.legend .dot.warn {
  background: var(--warn);
}
.legend .dot.crit {
  background: var(--crit);
}
.powered {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink-soft);
  opacity: 0.9;
}
.powered img {
  height: 30px;
  width: auto;
}
.powered strong {
  font-weight: 800;
  color: var(--brand-dark);
  font-size: 15px;
}

/* Aksesibilitas: nonaktifkan animasi bila user/sistem minta reduced-motion
   (direkomendasikan README untuk produksi). */
@media (prefers-reduced-motion: reduce) {
  .card[data-state="critical"],
  .akRow[data-state="critical"] {
    animation: none;
  }
}
