/* Samsung 取機叫號系統 — 共用樣式
   品牌色以 Samsung Blue #1428A0 為基準，
   顯示頁在深色底上改用提亮版本，才能在大螢幕與遠距下維持對比。 */

:root {
  --samsung-blue: #1428a0;
  --samsung-blue-bright: #2f6bff;
  --samsung-blue-glow: #5b8cff;

  --ink: #0a0d18;
  --ink-soft: #4a5169;
  --paper: #f4f6fb;
  --line: #dfe4f0;
  --white: #ffffff;

  --ok: #12a150;
  --warn: #d97706;
  --danger: #dc2626;

  --font: 'Inter', 'SamsungOne', -apple-system, BlinkMacSystemFont, 'Segoe UI',
    'PingFang TC', 'Noto Sans TC', 'Microsoft JhengHei', sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ══════════════════════════════════════════ 顯示頁（現場大螢幕） */

body.display {
  background: radial-gradient(ellipse at 50% 0%, #16224d 0%, #070a16 55%, #04060e 100%);
  color: var(--white);
  overflow: hidden;
  cursor: default;
  user-select: none;
}

.stage {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 3vh 4vw;
  position: relative;
  z-index: 1;
}

/* 號碼更新時整個畫面掃過一道藍光，遠距離也能察覺「換號了」 */
.flash {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(91, 140, 255, 0.5), transparent 65%);
  opacity: 0;
  pointer-events: none;
  z-index: 5;
}

.flash.fire {
  animation: flash 900ms ease-out;
}

@keyframes flash {
  0% {
    opacity: 0;
  }
  12% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.brandbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2vw;
}

/* 用 center 而非 baseline：標誌是圖片，baseline 對齊會讓它相對說明文字浮高 */
.brand {
  display: flex;
  align-items: center;
  gap: 1.2vw;
}

/* 官方標誌。深色底上直接反白，避免另外準備一份白色版。
   高度跟著視窗縮放，現場不論投影機或大電視都不會過大過小。 */
.brand .logo {
  height: clamp(22px, 2.4vw, 44px);
  width: auto;
  display: block;
  filter: brightness(0) invert(1);
}

/* 官方標誌不存在時的替代文字。
   注意：Samsung wordmark 是客製標誌，這個文字版永遠不會與官方一致，僅供開發階段佔位。 */
.brand .wordmark {
  font-size: clamp(20px, 2.6vw, 46px);
  font-weight: 800;
  letter-spacing: 0.16em;
  color: var(--white);
}

.brand .wordmark[hidden] {
  display: none;
}

.brand .event {
  font-size: clamp(13px, 1.5vw, 26px);
  font-weight: 500;
  letter-spacing: 0.24em;
  color: rgba(255, 255, 255, 0.6);
}

.status {
  display: flex;
  align-items: center;
  gap: 0.8vw;
  font-size: clamp(12px, 1.1vw, 20px);
  color: rgba(255, 255, 255, 0.45);
  font-variant-numeric: tabular-nums;
}

.dot {
  width: 0.85em;
  height: 0.85em;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 12px currentColor;
  transition: background 200ms;
}

.dot.offline {
  background: var(--danger);
  animation: pulse 1.2s ease-in-out infinite;
}

.dot.stale {
  background: var(--warn);
}

@keyframes pulse {
  50% {
    opacity: 0.25;
  }
}

.main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1vh;
  min-height: 0;
}

.label {
  font-size: clamp(18px, 2.6vw, 48px);
  font-weight: 500;
  letter-spacing: 0.4em;
  text-indent: 0.4em;
  color: rgba(255, 255, 255, 0.55);
}

.number {
  font-size: min(46vh, 34vw);
  line-height: 0.92;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--white);
  text-shadow: 0 0 0.28em rgba(91, 140, 255, 0.55);
}

.number.idle {
  color: rgba(255, 255, 255, 0.3);
  text-shadow: none;
  font-size: min(22vh, 16vw);
  letter-spacing: 0.06em;
}

.number.enter {
  animation: numberIn 620ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes numberIn {
  0% {
    transform: scale(0.72);
    opacity: 0;
    filter: blur(14px);
  }
  100% {
    transform: scale(1);
    opacity: 1;
    filter: blur(0);
  }
}

.history {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.2vw;
  flex-wrap: wrap;
  min-height: 8vh;
}

.history-label {
  font-size: clamp(12px, 1.2vw, 22px);
  letter-spacing: 0.2em;
  color: rgba(255, 255, 255, 0.35);
}

.chip {
  font-size: clamp(18px, 2.4vw, 44px);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 0.24em 0.7em;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.62);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.chip:first-of-type {
  color: rgba(255, 255, 255, 0.85);
  border-color: rgba(91, 140, 255, 0.5);
  background: rgba(47, 107, 255, 0.16);
}

/* 進入展示模式的覆蓋層。
   瀏覽器要求全螢幕與音效都必須由使用者手勢觸發，
   所以現場開機後必然需要這一下點擊；順手一起解決 Wake Lock。 */
.enter-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2.4vh;
  background: rgba(4, 6, 14, 0.92);
  backdrop-filter: blur(8px);
  border: 0;
  color: var(--white);
  font-family: var(--font);
  cursor: pointer;
}

.enter-overlay[hidden] {
  display: none;
}

.enter-overlay .icon {
  font-size: clamp(40px, 6vw, 96px);
}

.enter-overlay .title {
  font-size: clamp(24px, 3.4vw, 60px);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.enter-overlay .hint {
  font-size: clamp(13px, 1.4vw, 24px);
  color: rgba(255, 255, 255, 0.55);
  line-height: 1.9;
  text-align: center;
  max-width: 34em;
}

.offline-banner {
  position: fixed;
  left: 50%;
  bottom: 3vh;
  transform: translateX(-50%);
  z-index: 8;
  padding: 0.7em 1.6em;
  border-radius: 999px;
  background: rgba(220, 38, 38, 0.92);
  color: var(--white);
  font-size: clamp(13px, 1.3vw, 22px);
  font-weight: 600;
  letter-spacing: 0.05em;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.offline-banner[hidden] {
  display: none;
}

/* ══════════════════════════════════════════ 控制端 / 管理端 */

body.panel {
  background: var(--paper);
  color: var(--ink);
  min-height: 100%;
  display: flex;
  justify-content: center;
  padding: 24px 16px 64px;
}

.panel-wrap {
  width: 100%;
  max-width: 520px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.panel-head h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0;
}

.panel-head .role {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--samsung-blue);
  color: var(--white);
}

.panel-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 16px;
}

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(10, 13, 24, 0.05);
}

.card h2 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
  margin: 0 0 14px;
}

.current-readout {
  text-align: center;
  padding: 8px 0 18px;
}

.current-readout .cap {
  font-size: 13px;
  letter-spacing: 0.2em;
  color: var(--ink-soft);
}

.current-readout .val {
  font-size: 88px;
  line-height: 1.05;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--samsung-blue);
  margin-top: 4px;
}

.current-readout .val.idle {
  font-size: 40px;
  color: var(--ink-soft);
}

button {
  font-family: var(--font);
  cursor: pointer;
  border: 0;
  border-radius: 14px;
  transition: transform 80ms ease, filter 140ms ease, background 140ms ease;
}

button:active:not(:disabled) {
  transform: scale(0.985);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  width: 100%;
  padding: 30px 20px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--white);
  background: var(--samsung-blue);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.12);
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.btn-secondary {
  flex: 1;
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
}

.btn-secondary:hover:not(:disabled) {
  background: #e9edf7;
}

.btn-danger {
  color: var(--danger);
  border-color: #f3c9c9;
  background: #fdf3f3;
}

.btn-danger:hover:not(:disabled) {
  background: #fbe8e8;
}

.field {
  display: flex;
  gap: 10px;
}

input[type='text'],
input[type='number'],
input[type='password'] {
  flex: 1;
  width: 100%;
  padding: 14px 16px;
  font-family: var(--font);
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  transition: border-color 140ms;
}

input:focus {
  border-color: var(--samsung-blue-bright);
  box-shadow: 0 0 0 3px rgba(47, 107, 255, 0.14);
}

.field button {
  padding: 0 22px;
  font-size: 15px;
  font-weight: 600;
  color: var(--white);
  background: var(--samsung-blue);
  white-space: nowrap;
}

.hint {
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--ink-soft);
  margin: 10px 0 0;
}

.history-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.history-list span {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
}

.history-list .empty {
  border: 0;
  background: none;
  font-weight: 400;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(8px);
  padding: 12px 22px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--white);
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms, transform 200ms;
  z-index: 20;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  background: var(--danger);
}

/* 登入卡片 */
.gate {
  max-width: 380px;
  margin: 12vh auto 0;
}

.gate h1 {
  font-size: 22px;
  margin: 0 0 6px;
}

.gate p {
  font-size: 14px;
  color: var(--ink-soft);
  margin: 0 0 20px;
}

/* ══════════════════════════════════════════ 首頁 */

.home {
  max-width: 520px;
  margin: 10vh auto;
}

.home .links {
  display: grid;
  gap: 12px;
}

.home a {
  display: block;
  padding: 20px 22px;
  border-radius: 16px;
  background: var(--white);
  border: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
  transition: border-color 140ms, transform 80ms;
}

.home a:hover {
  border-color: var(--samsung-blue-bright);
}

.home a strong {
  display: block;
  font-size: 17px;
  margin-bottom: 4px;
}

.home a span {
  font-size: 13px;
  color: var(--ink-soft);
}
