/* TAIVISIT kiosk — Atlassian/Jira-inspired design system, scaled up for a
   touch kiosk (large targets, but clean neutrals, small radii, subtle shadows). */

:root {
  --blue: #0C66E4; --blue-hover: #0055CC; --blue-light: #E9F2FF;
  --green: #1F845A; --green-hover: #216E4E; --green-bg: #DCFFF1; --green-ink: #216E4E;
  --ink: #172B4D; --ink-soft: #44546F; --muted: #626F86;
  --line: #DFE1E6; --line-soft: #EBECF0;
  --bg: #F7F8F9; --card: #FFFFFF;
  --danger: #C9372C; --danger-ink: #AE2E24; --danger-bg: #FFECEB;
  --amber-bg: #FFF7D6; --amber-ink: #7F5F01;
  --accent: #0C66E4; --accent-tint: #E9F2FF; --ok: #1F845A;
  --radius: 3px; --radius-md: 6px; --radius-lg: 8px;
  --shadow: 0 1px 1px rgba(9,30,66,.25), 0 0 1px rgba(9,30,66,.31);
  --shadow-card: 0 1px 2px rgba(9,30,66,.15);
  --shadow-raise: 0 4px 8px -2px rgba(9,30,66,.2), 0 0 1px rgba(9,30,66,.31);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang TC",
    "Microsoft JhengHei", Helvetica, Arial, sans-serif;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

#app { min-height: 100%; display: flex; flex-direction: column; }

/* Bilingual (中文 mode) stacks English over Chinese via a newline — render it. */
.welcome-title, .btn, .section-title, h1.screen-title, .field label, .field .hint,
.privacy, .type-row .seg, .host-item, .list-empty, .form-error, .welcome-back,
.terms-meta, .sig-label, .autoreturn, .done-details div, .qr-prompt, .status-banner,
.net-banner, .emergency-btn, .emg-title, .emg-sub { white-space: pre-line; }

/* ---------- Header ---------- */
.kiosk-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  gap: 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.kiosk-header img.logo { height: 44px; width: auto; }

.lang-switch {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card);
}
.lang-switch .lang-opt {
  border: none;
  background: transparent;
  font-size: 1rem;
  font-weight: 600;
  padding: 8px 18px;
  min-height: 44px;
  color: var(--ink-soft);
  cursor: pointer;
}
.lang-switch .lang-opt.active { background: var(--blue); color: #fff; }

/* ---------- Offline banner ---------- */
.net-banner {
  display: none;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 600;
  padding: 10px 16px;
}
.net-banner.show { display: block; }
.net-banner.offline { background: var(--amber-bg); color: var(--amber-ink); }
.net-banner.online { background: var(--green-bg); color: var(--green-ink); }

/* ---------- Screens ---------- */
.screen { display: none; flex: 1 1 auto; flex-direction: column; padding: 20px 28px 32px; }
.screen.active { display: flex; }
.screen-body {
  flex: 1 1 auto;
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
h1.screen-title { font-size: 1.9rem; font-weight: 600; letter-spacing: -.01em; margin: 4px 0 26px; text-align: center; }

/* ---------- Buttons ---------- */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 60px;
  font-size: 1.2rem;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: #fff;
  background: var(--blue);
  cursor: pointer;
  padding: 12px 22px;
  transition: background .1s, box-shadow .1s;
}
.btn:active { filter: brightness(.94); }
.btn.primary { background: var(--green); }
.btn.primary:active { background: var(--green-hover); }
.btn.secondary { background: var(--line-soft); color: var(--ink); }
.btn.secondary:active { background: #D5D9E0; }
.btn.ghost {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn.ghost:active { background: var(--bg); }
.btn.big { min-height: 104px; font-size: 1.6rem; border-radius: var(--radius-lg); }
.btn[disabled] { opacity: 0.45; cursor: default; }

.btn-row { display: flex; gap: 14px; margin-top: 24px; }
.btn-row .btn { flex: 1; }

.welcome-title { font-size: 2.6rem; font-weight: 700; letter-spacing: -.02em; text-align: center; color: var(--ink); margin: 0 0 34px; line-height: 1.2; }
.welcome-actions { display: flex; flex-direction: column; gap: 16px; margin-top: 8px; }
@media (min-width: 720px) and (orientation: landscape) {
  .welcome-actions { flex-direction: row; }
}

.privacy {
  text-align: center;
  color: var(--muted);
  font-size: 1rem;
  max-width: 620px;
  margin: 30px auto 0;
  line-height: 1.55;
}

/* ---------- Single-page form ---------- */
.form-page { justify-content: flex-start; max-width: 820px; padding-top: 4px; }
.section {
  margin-bottom: 24px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 22px 24px;
}
.section-title { font-size: 1.3rem; font-weight: 600; letter-spacing: -.01em; margin: 0 0 16px; }
.type-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 720px) { .type-row { grid-template-columns: repeat(4, 1fr); } }
.type-row .seg {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: 18px 10px; font-size: 1.1rem; font-weight: 600; color: var(--ink);
  cursor: pointer; text-align: center; transition: border-color .1s, background .1s, box-shadow .1s;
}
.type-row .seg:active { background: var(--bg); }
.type-row .seg .emoji { font-size: 2rem; display: block; margin-bottom: 8px; }
.type-row .seg.selected { border-color: var(--blue); background: var(--blue-light); color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); }
.section.invalid { border-color: var(--danger); }
.section.invalid .section-title { color: var(--danger-ink); }

/* ---------- Fields ---------- */
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-size: 1.05rem; font-weight: 600; margin-bottom: 8px; }
.field .hint { font-size: .95rem; color: var(--muted); margin-top: 6px; font-weight: 400; }
.field .req { color: var(--danger); }
.field input {
  width: 100%;
  font-size: 1.25rem;
  padding: 15px 16px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}
.field input:focus { outline: none; border-color: var(--blue); }
.hidden { display: none !important; }
.welcome-back {
  background: var(--blue-light);
  color: var(--blue);
  font-weight: 600;
  font-size: 1.1rem;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  text-align: center;
}
.form-error { color: var(--danger-ink); font-weight: 600; font-size: 1.05rem; margin-top: 6px; min-height: 1.3em; }

/* ---------- Host dropdown ---------- */
.host-select {
  width: 100%;
  font-size: 1.25rem;
  padding: 16px 44px 16px 16px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: #fff url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23626F86' stroke-width='2'><path d='M6 9l6 6 6-6'/></svg>") no-repeat right 14px center;
  color: var(--ink);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}
.host-select:focus { outline: none; border-color: var(--blue); }

/* ---------- Host list (used by the sign-out screen) ---------- */
.host-search {
  width: 100%; font-size: 1.2rem; padding: 15px 16px;
  border: 2px solid var(--line); border-radius: var(--radius); margin-bottom: 14px;
}
.host-search:focus { outline: none; border-color: var(--blue); }
.host-list { overflow-y: auto; -webkit-overflow-scrolling: touch; max-height: 48vh; }
.host-item {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: 18px 20px; font-size: 1.2rem; font-weight: 600; margin-bottom: 10px; cursor: pointer;
}
.host-item .sub { font-size: .95rem; color: var(--muted); font-weight: 400; margin-top: 3px; }
.host-item:active, .host-item.selected { border-color: var(--blue); background: var(--blue-light); }
.list-empty { color: var(--muted); font-size: 1.1rem; text-align: center; padding: 22px; }

/* ---------- Terms + signature ---------- */
.terms-box {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; font-size: 1.05rem; line-height: 1.6; color: var(--ink-soft);
  height: 34vh; overflow-y: auto; -webkit-overflow-scrolling: touch; white-space: pre-wrap;
}
.terms-meta { display: flex; justify-content: space-between; align-items: center; margin: 12px 2px; color: var(--muted); font-size: .95rem; gap: 12px; }
.scroll-hint { color: var(--amber-ink); font-weight: 600; }
.sig-wrap { margin-top: 10px; }
.sig-label { font-size: 1.05rem; font-weight: 600; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sig-clear { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 16px; font-size: .95rem; font-weight: 600; color: var(--ink-soft); cursor: pointer; }
canvas.sigpad {
  width: 100%; height: 190px; background: #fff;
  border: 2px dashed var(--line); border-radius: var(--radius); touch-action: none; display: block;
}

/* ---------- Done ---------- */
.done-wrap { text-align: center; }
.done-check { font-size: 3.6rem; }
.done-details {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 8px 22px; margin: 22px auto; max-width: 520px; text-align: left;
}
.done-details div { font-size: 1.1rem; padding: 12px 0; display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line-soft); }
.done-details div:last-child { border-bottom: none; }
.done-details .k { color: var(--muted); }
.done-details .v { font-weight: 600; text-align: right; }
#qrcode { display: inline-block; padding: 16px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); margin: 6px auto; }
#qrcode img, #qrcode canvas { display: block; }
.qr-prompt { font-size: 1.05rem; color: var(--ink-soft); max-width: 520px; margin: 16px auto 0; line-height: 1.55; }
.qr-offline { color: var(--amber-ink); font-weight: 600; }
.autoreturn { color: var(--muted); margin-top: 18px; font-size: 1rem; }

/* status banners (verify page / signed-out) */
.status-banner { border-radius: var(--radius-lg); padding: 20px; font-size: 1.5rem; font-weight: 700; color: #fff; text-align: center; }
.status-banner.on { background: var(--ok); }
.status-banner.off { background: var(--muted); }

/* ---------- Loading veil ---------- */
.veil {
  position: fixed; inset: 0; background: rgba(247,248,249,0.88);
  display: none; align-items: center; justify-content: center; font-size: 1.3rem; color: var(--ink-soft); z-index: 50;
}
.veil.show { display: flex; }
.spinner {
  width: 40px; height: 40px; border: 4px solid var(--line); border-top-color: var(--blue);
  border-radius: 50%; animation: spin 0.8s linear infinite; margin-right: 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Emergency: corner button + roll-call overlay ---------- */
#screen-welcome { position: relative; }
.emergency-btn {
  position: absolute; bottom: 12px; right: 12px; z-index: 5;
  background: var(--danger); color: #fff; border: none;
  border-radius: var(--radius-md); font-size: 1.05rem; font-weight: 700;
  padding: 14px 20px; cursor: pointer; box-shadow: var(--shadow-raise); text-align: center;
}
.emergency-btn:active { filter: brightness(.92); }

.emg-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: #7A0F0F; color: #fff;
  display: none; flex-direction: column;
}
.emg-overlay.show { display: flex; }
.emg-head { display: flex; align-items: center; gap: 16px; padding: 18px 24px; background: #5C0B0B; }
.emg-head-text { flex: 1; }
.emg-title { margin: 0; font-size: 1.6rem; font-weight: 700; }
.emg-sub { font-size: 1rem; opacity: .85; margin-top: 2px; }
.emg-count { font-size: 1.2rem; font-weight: 800; white-space: nowrap; }
.emg-head .btn, .emg-foot .btn { width: auto; min-height: 48px; font-size: 1rem; padding: 10px 20px; }
.emg-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 24px 28px; }
.eperson {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: rgba(255,255,255,.08); border: 2px solid rgba(255,255,255,.22);
  border-radius: var(--radius-lg); padding: 16px 20px; margin-bottom: 10px; cursor: pointer;
}
.eperson.ok { background: rgba(31,132,90,.42); border-color: #4BCE97; }
.ep-name { font-size: 1.5rem; font-weight: 800; }
.ep-meta { font-size: 1rem; opacity: .85; margin-top: 3px; }
.ep-mark { font-size: 1.7rem; font-weight: 800; }
.emg-empty { text-align: center; opacity: .85; font-size: 1.15rem; padding: 44px 20px; }
.emg-foot { padding: 14px 24px; background: #5C0B0B; display: flex; justify-content: flex-end; }

/* ---------- Mobile (phones) ---------- */
@media (max-width: 480px) {
  .kiosk-header { padding: 12px 16px; }
  .kiosk-header img.logo { height: 40px; }
  .lang-switch .lang-opt { padding: 8px 14px; font-size: .95rem; min-height: 42px; }
  .screen { padding: 16px; }
  h1.screen-title { font-size: 1.5rem; margin-bottom: 18px; }
  .section { padding: 18px 16px; margin-bottom: 16px; }
  .section-title { font-size: 1.2rem; }
  .welcome-title { font-size: 1.9rem; margin-bottom: 24px; }

  .btn { min-height: 56px; font-size: 1.1rem; }
  .btn.big { min-height: 84px; font-size: 1.35rem; }
  .btn-row { flex-direction: column; gap: 12px; }

  .type-row { gap: 8px; }
  .type-row .seg { padding: 14px 6px; font-size: .95rem; }
  .type-row .seg .emoji { font-size: 1.7rem; margin-bottom: 4px; }

  .field input, .host-select { font-size: 1.15rem; padding: 14px 14px; }
  .host-select { padding-right: 40px; }
  .field label { font-size: 1rem; }
  .host-item { padding: 15px 16px; font-size: 1.1rem; }
  .terms-box { height: 38vh; font-size: 1rem; }
  canvas.sigpad { height: 160px; }
  .done-details div { font-size: 1rem; }
}
