/* ============================================================
   Septona lobby signage — tuned for a 65" iiyama (1080p/4K)
   Uses viewport units + a JS auto-fit engine so nothing scrolls.
   ============================================================ */
:root {
  --bg: #0b1020;
  --bg2: #0e1428;
  --panel: #121a33;
  --panel2: #0f1730;
  --line: #223056;
  --ink: #eaf0ff;
  --ink-dim: #9fb0d6;
  --ink-faint: #6b7ba6;
  --accent: #ffb020;
  --s1: #ffb020;   /* shift 1 — amber */
  --s2: #3fa9f5;   /* shift 2 — blue  */
  --s3: #b07cff;   /* shift 3 — purple */
  --fs-base: 1vw;  /* driven by JS auto-fit */
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', system-ui, 'Segoe UI', sans-serif;
  background: radial-gradient(1200px 700px at 15% -10%, #16204a 0%, var(--bg) 55%) fixed;
  color: var(--ink);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
#app { display: flex; flex-direction: column; height: 100vh; padding: 1.1vh 1.1vw; gap: 0.9vh; }

/* ---------------- HEADER ---------------- */
.topbar {
  display: flex; align-items: center; gap: 1.4vw;
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  border: 1px solid var(--line); border-radius: 14px;
  padding: 0.9vh 1.2vw; flex: 0 0 auto;
}
.brand { display: flex; align-items: center; gap: 0.9vw; min-width: 0; }
.brand-title { font-weight: 900; font-size: 1.55vw; line-height: 1.05; color: #fff; }
.brand-sub { font-size: 0.78vw; color: var(--ink-dim); letter-spacing: 0.22em; margin-top: 0.25vh; }

.period-chip {
  font-weight: 700; font-size: 0.95vw; color: var(--accent);
  border: 1px solid var(--line); border-radius: 999px; padding: 0.5vh 1vw;
  background: rgba(255,176,32,0.06); white-space: nowrap;
}

.shift-totals { display: flex; gap: 0.7vw; margin-left: auto; }
.st {
  display: flex; align-items: center; gap: 0.4vw;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 0.45vh 0.9vw; font-weight: 700; font-size: 0.95vw;
  background: var(--panel2);
}
.st .dot { width: 0.7vw; height: 0.7vw; border-radius: 50%; }
.st .n { font-size: 1.15vw; font-weight: 900; }
.st .lbl { color: var(--ink-dim); font-size: 0.72vw; }
.st.total { background: #16224a; border-color: #33477e; }
.st.total .n { color: #fff; }

.clock-wrap { display: flex; align-items: center; gap: 0.9vw; }
.current-shift {
  text-align: right; border: 1px solid var(--accent); border-radius: 10px;
  padding: 0.4vh 0.8vw; background: rgba(255,176,32,0.08);
}
.cs-label { font-size: 0.62vw; color: var(--accent); letter-spacing: 0.15em; }
.cs-value { font-size: 1.1vw; font-weight: 900; }
.cs-count { font-size: 0.68vw; color: var(--ink-dim); }
.clock { text-align: right; }
.clock-time { font-size: 1.9vw; font-weight: 900; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.clock-date { font-size: 0.78vw; color: var(--ink-dim); }

/* ---------------- TABS ---------------- */
.tabs { display: flex; gap: 0.6vw; flex: 0 0 auto; flex-wrap: wrap; }
.tab {
  cursor: pointer; user-select: none;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 0.6vh 1.1vw; font-weight: 700; font-size: 0.92vw;
  color: var(--ink-dim); background: var(--panel2);
  display: flex; align-items: center; gap: 0.5vw;
}
.tab .badge { font-size: 0.72vw; background: #22315a; border-radius: 999px; padding: 0.1vh 0.5vw; color: var(--ink); }
.tab.active { color: #0b1020; background: var(--accent); border-color: var(--accent); }
.tab.active .badge { background: rgba(0,0,0,0.18); color: #0b1020; }

/* ---------------- BOARD (dashboard) ---------------- */
.board { flex: 1 1 auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.9vw; min-height: 0; }
.col {
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  border: 1px solid var(--line); border-radius: 14px;
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
  transition: opacity .6s ease, box-shadow .6s ease, filter .6s ease;
}
/* Auto-highlight the current shift: brighten the active column, dim the others. */
.col-now {
  box-shadow: 0 0 0 2px var(--accent), 0 0 34px rgba(255,176,32,0.18);
  border-color: var(--accent);
}
.col-dim { opacity: 0.5; filter: saturate(0.75); }
.col-head {
  display: flex; align-items: center; gap: 0.6vw;
  padding: 0.8vh 1vw; border-bottom: 1px solid var(--line); flex: 0 0 auto;
}
.col-head .cdot { width: 0.9vw; height: 0.9vw; border-radius: 50%; }
.col-head .ctitle { font-weight: 900; font-size: 1.15vw; }
.col-head .ctime { font-size: 0.72vw; color: var(--ink-dim); margin-left: 0.3vw; }
.col-head .ccount { margin-left: auto; text-align: right; }
.col-head .ccount .big { font-size: 1.7vw; font-weight: 900; }
.col-head .ccount .small { font-size: 0.6vw; color: var(--ink-dim); letter-spacing: 0.12em; }
.col-head.now { box-shadow: inset 0 0 0 2px var(--accent); }
.col-head .live {
  font-size: 0.6vw; font-weight: 800; color: #0b1020; background: var(--accent);
  border-radius: 999px; padding: 0.1vh 0.5vw; letter-spacing: 0.1em;
}

/* col-body is a fixed-height viewport; the .workers track inside may be taller
   and is auto-scrolled by JS when it overflows. */
.col-body { flex: 1 1 auto; min-height: 0; padding: 0.5vh 0.5vw; overflow: hidden; position: relative; }
.workers {
  display: grid; grid-auto-flow: column;
  grid-template-rows: repeat(var(--rows, 20), auto);
  grid-auto-columns: 1fr;
  gap: 0.25vh 0.5vw;
  will-change: transform;
}
.worker {
  display: flex; align-items: center; gap: 0.45vw;
  padding: 0.22vh 0.45vw; border-radius: 7px; min-width: 0;
  background: rgba(255,255,255,0.02);
}
/* subtle fade at the top/bottom edges — only shown when the column actually
   scrolls, so short lists are never covered by shadow. */
.col-body.scrolls::before, .col-body.scrolls::after {
  content: ""; position: absolute; left: 0; right: 0; height: 2vh; z-index: 2; pointer-events: none;
}
.col-body.scrolls::before { top: 0; background: linear-gradient(180deg, var(--panel) 0%, rgba(18,26,51,0) 100%); }
.col-body.scrolls::after { bottom: 0; background: linear-gradient(0deg, var(--panel2) 0%, rgba(15,23,48,0) 100%); }
.worker .num {
  font-size: 0.8vw; font-weight: 900; color: #0b1020;
  border-radius: 50%; width: 1.35vw; height: 1.35vw;
  display: flex; align-items: center; justify-content: center;
  text-align: center; font-variant-numeric: tabular-nums; flex: 0 0 auto;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.28);
}
.worker .meta { min-width: 0; }
.worker .wname { font-weight: 700; font-size: 0.74vw; line-height: 1.05; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.worker .wloc { font-size: 0.54vw; color: var(--ink-faint); line-height: 1.05; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------------- GRID (faithful colored) ---------------- */
.grid-view { flex: 1 1 auto; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.gsec-title {
  font-weight: 900; font-size: 1.1vw; color: var(--accent);
  padding: 0.4vh 0; border-bottom: 2px solid var(--accent); margin-bottom: 0.4vh;
}
.gcols { display: flex; gap: 0.7vw; flex: 1 1 auto; min-height: 0; align-items: stretch; }
.gcol { display: flex; flex-direction: column; min-height: 0; flex: var(--f, 1) 1 0; }
.gcol-head { font-weight: 800; font-size: 0.9vw; padding: 0.3vh 0.5vw; color: var(--ink-dim); border-bottom: 1px solid var(--line); white-space: nowrap; }
.grows { display: grid; grid-auto-flow: column; grid-template-rows: repeat(var(--grows, 24), 1fr); grid-auto-columns: 1fr; gap: 2px 0.4vw; flex: 1 1 auto; min-height: 0; padding-top: 0.3vh; }
.grow {
  display: flex; align-items: center; gap: 0.4vw; padding: 0.1vh 0.4vw;
  color: #14181f; font-weight: 600; font-size: 0.82vw; border-radius: 3px;
  white-space: nowrap; overflow: hidden; line-height: 1;
}
.grow .gnum { font-weight: 800; min-width: 1.4vw; font-variant-numeric: tabular-nums; }
.grow .gname { overflow: hidden; text-overflow: ellipsis; }
.grow .gloc { margin-left: auto; font-size: 0.62vw; opacity: 0.7; overflow: hidden; text-overflow: ellipsis; max-width: 40%; }

/* ---------------- FOOTER ---------------- */
.footer {
  flex: 0 0 auto; display: flex; align-items: center; gap: 1vw;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 12px;
  padding: 0.55vh 1vw;
}
.legend { display: flex; gap: 0.9vw; flex-wrap: wrap; align-items: center; }
.legend .li { display: flex; align-items: center; gap: 0.4vw; font-size: 0.8vw; color: var(--ink-dim); }
.legend .sw { width: 1.1vw; height: 1.1vw; border-radius: 4px; border: 1px solid rgba(255,255,255,0.25); }
.legend .sw-num {
  width: 1.4vw; height: 1.4vw; border-radius: 50%; border: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85vw; font-weight: 900; font-variant-numeric: tabular-nums;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.28);
}
.foot-right { margin-left: auto; font-size: 0.72vw; color: var(--ink-faint); display: flex; align-items: center; gap: 1vw; }
.qr-box { display: flex; flex-direction: column; align-items: center; gap: 0.25vh; }
.qr-img { background: #fff; padding: 0.35vh; border-radius: 6px; line-height: 0; }
.qr-img img { width: 4.6vw; height: 4.6vw; display: block; image-rendering: pixelated; }
.qr-cap { font-size: 0.6vw; color: var(--ink-dim); letter-spacing: 0.04em; }

/* ---------------- CONTROLS ---------------- */
.controls { position: fixed; right: 1vw; bottom: 1vh; display: flex; gap: 0.5vw; z-index: 50; opacity: 0.25; transition: opacity .2s; }
.controls:hover { opacity: 1; }
.ctrl {
  cursor: pointer; border: 1px solid var(--line); background: var(--panel);
  color: var(--ink); border-radius: 8px; padding: 0.6vh 1vw; font-weight: 700;
  font-size: 0.85vw; text-decoration: none; font-family: inherit;
}
.ctrl.active { background: var(--accent); color: #0b1020; border-color: var(--accent); }
body[data-kiosk="1"] .controls { display: none; }

/* ---------------- EMPTY ---------------- */
[hidden] { display: none !important; }
.empty-state { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; background: var(--bg); z-index: 100; }
.empty-state h1 { font-size: 3vw; margin-bottom: 1vh; }
.empty-state p { font-size: 1.3vw; color: var(--ink-dim); }
.empty-state a { color: var(--accent); }

/* ================= MESSAGES ================= */

/* --- Banner / ticker (bottom strip) --- */
.msg-ticker {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: flex; align-items: center; height: 5.2vh; min-height: 44px;
  background: linear-gradient(90deg, #12203f, #0b1020);
  border-top: 2px solid var(--tag, #3fa9f5);
  box-shadow: 0 -6px 20px rgba(0,0,0,0.45);
}
.ticker-tag {
  flex: 0 0 auto; align-self: stretch; display: flex; align-items: center;
  padding: 0 1.4vw; font-weight: 900; font-size: 1.15vw; letter-spacing: .08em;
  color: #0b1020; background: var(--tag, #3fa9f5); text-transform: uppercase;
}
.ticker-viewport { flex: 1 1 auto; overflow: hidden; white-space: nowrap; }
.ticker-track {
  display: inline-block; white-space: nowrap; padding-left: 100%;
  animation: ticker-scroll var(--tickdur, 30s) linear infinite;
  font-size: 1.5vw; font-weight: 700; color: #eaf0ff; line-height: 5.2vh;
}
.ticker-track .tk-item { display: inline-block; margin-right: 4vw; }
.ticker-track .tk-dot { display: inline-block; width: 0.7vw; height: 0.7vw; border-radius: 50%; margin-right: 0.7vw; vertical-align: middle; }
@keyframes ticker-scroll { 0% { transform: translateX(0); } 100% { transform: translateX(-100%); } }
/* nudge footer up when ticker present */
body[data-ticker="1"] .footer { margin-bottom: 5.2vh; }

/* --- Full-screen message slide --- */
.msg-slide {
  position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 700px at 50% 30%, #16224a, #0b1020 70%);
  animation: fade-in .4s ease;
}
.slide-card {
  width: 82vw; max-width: 82vw; max-height: 84vh; border-radius: 1.4vw;
  background: linear-gradient(180deg, #141d38, #0f1730);
  border: 2px solid var(--tag, #3fa9f5); box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  padding: 3vh 3vw; display: flex; flex-direction: column; gap: 2.2vh;
}
.slide-badge {
  align-self: flex-start; font-weight: 900; font-size: 1.3vw; letter-spacing: .1em;
  color: #0b1020; background: var(--tag, #3fa9f5); padding: 0.7vh 1.4vw; border-radius: 999px;
  text-transform: uppercase;
}
.slide-body { display: flex; gap: 3vw; align-items: center; flex: 1 1 auto; min-height: 0; }
.slide-img { max-width: 42%; max-height: 58vh; border-radius: 1vw; object-fit: contain; border: 1px solid rgba(255,255,255,.12); }
.slide-text { flex: 1 1 auto; min-width: 0; }
.slide-title { font-size: 4vw; font-weight: 900; line-height: 1.05; margin-bottom: 2vh; color: #fff; }
.slide-msg { font-size: 2.3vw; font-weight: 500; line-height: 1.35; color: #d5deff; white-space: pre-wrap; }
.slide-foot { align-self: flex-end; font-size: 1vw; color: var(--ink-faint); }

/* --- Urgent takeover --- */
.msg-takeover {
  position: fixed; inset: 0; z-index: 120; display: flex; align-items: center; justify-content: center; text-align: center;
  background: repeating-linear-gradient(135deg, #7a0d0d, #7a0d0d 40px, #6a0b0b 40px, #6a0b0b 80px);
  animation: fade-in .3s ease, pulse-bg 2s ease-in-out infinite alternate;
}
@keyframes pulse-bg { from { filter: brightness(1); } to { filter: brightness(1.18); } }
.takeover-inner { max-width: 86vw; padding: 4vh 4vw; }
.takeover-badge {
  display: inline-block; font-weight: 900; font-size: 2vw; letter-spacing: .12em;
  background: #fff; color: #b30000; padding: 1vh 2.4vw; border-radius: 999px; margin-bottom: 3vh;
  animation: blink 1.1s step-start infinite;
}
@keyframes blink { 50% { opacity: 0.45; } }
.takeover-img { max-width: 44vw; max-height: 40vh; border-radius: 1vw; margin: 0 auto 3vh; display: block; object-fit: contain; border: 3px solid #fff; }
.takeover-title { font-size: 6vw; font-weight: 900; line-height: 1.02; color: #fff; margin-bottom: 2.5vh; text-shadow: 0 4px 20px rgba(0,0,0,.4); }
.takeover-msg { font-size: 3vw; font-weight: 600; line-height: 1.3; color: #ffe9e9; white-space: pre-wrap; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
