/* =============================================================
   BarangayCare - Shared Stylesheet (visual redesign)
   -------------------------------------------------------------
   Motif:   "banig" weave (woven Filipino mat) texture on headers
   Resident: a printed paper queue ticket
   Staff:    an LED-style "Now serving" display board
   Fonts:    Big Shoulders (signage typeface) for numbers/headings,
             Atkinson Hyperlegible (made for readability) for text
   Mobile-first: base styles target phones, then widen.
   ============================================================= */

/* ---------- Design tokens ---------- */
:root {
  --bg:             #ECF1EF;
  --surface:        #FFFFFF;
  --surface-2:      #F5F8F7;   /* inputs and unselected options */
  --ink:            #0F2A2E;
  --muted:          #566A6E;
  --line:           #D2DDD9;

  --primary:        #0B5D4F;   /* barangay green */
  --primary-dark:   #08463B;
  --primary-bright: #12866F;
  --primary-soft:   #DDEFE8;

  --marigold:       #F6B100;   /* ticket color */
  --marigold-dark:  #D99A00;
  --marigold-soft:  #FFF4D1;

  --danger:         #B42318;
  --danger-soft:    #FDECEA;

  --board:          #0E1F22;   /* staff display board */

  --font: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --font-display: "Big Shoulders", "Arial Narrow", "Roboto Condensed", "Segoe UI", sans-serif;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-1: 0 1px 2px rgba(15, 42, 46, 0.06), 0 4px 14px rgba(15, 42, 46, 0.06);
  --shadow-2: 0 14px 34px rgba(15, 42, 46, 0.16);

  /* Banig weave: two diagonal stripe layers crossing each other */
  --banig:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.07) 0 12px, transparent 12px 24px),
    repeating-linear-gradient(-45deg, rgba(0, 0, 0, 0.11) 0 12px, transparent 12px 24px);
}

/* One color per service, in database order (C, R, I, B, G).
   Used by the resident's service list and the staff queue tabs. */
.service-option:nth-child(5n+1), .queue-tab:nth-child(5n+1) { --accent: #12866F; }
.service-option:nth-child(5n+2), .queue-tab:nth-child(5n+2) { --accent: #2F6FB0; }
.service-option:nth-child(5n+3), .queue-tab:nth-child(5n+3) { --accent: #C2410C; }
.service-option:nth-child(5n+4), .queue-tab:nth-child(5n+4) { --accent: #7C4DBA; }
.service-option:nth-child(5n+5), .queue-tab:nth-child(5n+5) { --accent: #3E6A73; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}

.wrap {
  width: 100%;
  max-width: 36rem;
  margin: 0 auto;
  padding: 0 1.125rem;
}

/* Visible keyboard focus everywhere */
/* Two rings (dark inside, white outside) so the focus is clear on light AND dark panels. */
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; box-shadow: 0 0 0 6px #FFFFFF; }

/* Skip link: first thing a keyboard or screen-reader user reaches */
.skip-link {
  position: absolute;
  left: 0.75rem;
  top: -4rem;
  z-index: 100;
  padding: 0.75rem 1.125rem;
  border-radius: var(--radius-md);
  background: var(--ink);
  color: #FFFFFF;
  font-weight: 700;
  text-decoration: none;
}
.skip-link:focus { top: 0.75rem; }

/* Error text right under the field it belongs to */
.field-error { margin: -0.5rem 0 1rem; color: var(--danger); font-weight: 700; font-size: 0.9375rem; }
.field-error::before { content: "\26A0\FE0E  "; }

/* ---------- Logo mark (roof + ticket) ---------- */
.logo { flex: none; width: 2.75rem; height: 2.75rem; }

/* =============================================================
   CITIZEN PORTAL
   ============================================================= */

/* ---------- Header ---------- */
.site-header {
  background-color: var(--primary);
  background-image: var(--banig);
  color: #FFFFFF;
  padding: 1.25rem 0 3.75rem;
  border-bottom: 6px solid var(--marigold);
}
.brand-row { display: flex; align-items: center; gap: 0.75rem; }
.brand {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.01em;
}
.hall { margin: 0.125rem 0 0; font-size: 0.875rem; opacity: 0.85; }
.hero-title {
  margin: 1.75rem 0 0.625rem;
  max-width: 14ch;
  font-family: var(--font-display);
  font-size: clamp(2.75rem, 12vw, 3.75rem);
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: 0.005em;
}
.lede { margin: 0; max-width: 32rem; font-size: 1.0625rem; }
.lede.tl { margin-top: 0.375rem; font-size: 0.9375rem; opacity: 0.85; }
.quick-links { display: flex; flex-wrap: wrap; gap: 0.625rem; margin-top: 1.125rem; }

/* Tagalog helper text beside English labels */
.tl { display: block; font-weight: 400; font-size: 0.875rem; color: var(--muted); }
.site-header .tl { color: inherit; }

/* Content overlaps the header slightly, like cards laid on a counter */
main.wrap { position: relative; margin-top: -2.25rem; padding-bottom: 2.5rem; }

/* ---------- Form steps ---------- */
.step {
  margin: 0 0 1rem;
  padding: 1.375rem 1.25rem;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.step legend {
  float: left;
  width: 100%;
  margin-bottom: 1.125rem;
  padding: 0 0 0 2.875rem;
  position: relative;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.25;
}
.step legend + * { clear: both; }
.step-num {
  position: absolute;
  left: 0;
  top: -0.125rem;
  width: 2.125rem;
  height: 2.125rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--marigold);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 800;
}
.step-submit { padding: 0; background: transparent; box-shadow: none; }

/* ---------- Service choices ---------- */
.service-list { display: grid; gap: 0.625rem; }

.service-option {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  width: 100%;
  min-height: 4rem;
  padding: 0.75rem 0.875rem;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}
.service-option:hover { border-color: var(--accent); background: var(--surface); }
.service-option[aria-checked="true"] {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent);
}
/* Check mark on the chosen service */
.service-option[aria-checked="true"]::after {
  content: "✓";
  flex: none;
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--accent);
  color: #FFFFFF;
  font-weight: 700;
}
.service-prefix {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.875rem;
  height: 2.875rem;
  border-radius: 10px;
  background: var(--accent, var(--primary));
  color: #FFFFFF;
  font-family: var(--font-display);
  font-size: 1.625rem;
  font-weight: 800;
}
.service-text { flex: 1; display: flex; flex-direction: column; }
.service-name { font-weight: 700; line-height: 1.3; }
.service-desc { font-size: 0.9375rem; color: var(--muted); line-height: 1.4; }

.requirements {
  margin-top: 1rem;
  padding: 0.875rem 1rem;
  border-radius: var(--radius-md);
  background: var(--marigold-soft);
  border: 1px solid #F3DC92;
}
.requirements p { margin: 0; }
.requirements-title { font-weight: 700; margin-bottom: 0.25rem !important; }
.requirements-title .tl { display: inline; margin-left: 0.375rem; }

/* ---------- Text fields ---------- */
.field { display: block; margin-bottom: 1rem; }
.field-label { display: block; font-weight: 700; margin-bottom: 0.375rem; }
.field-label .tl { display: inline; margin-left: 0.375rem; }
.field input {
  width: 100%;
  min-height: 3.25rem;
  padding: 0.625rem 0.875rem;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  transition: border-color 0.15s, background-color 0.15s;
}
.field input::placeholder { color: #8A9A9D; }
.field input:focus { border-color: var(--primary); background: var(--surface); }
.field input[aria-invalid="true"] { border-color: var(--danger); background: var(--danger-soft); }

.privacy { margin: 0; font-size: 0.875rem; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  min-height: 3.25rem;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.15s, transform 0.05s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #FFFFFF; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-quiet { background: var(--surface); color: var(--primary); border-color: var(--primary); }
.btn-quiet:hover { background: var(--primary-soft); }
.btn-block {
  width: 100%;
  min-height: 3.75rem;
  font-size: 1.25rem;
  box-shadow: 0 8px 20px rgba(11, 93, 79, 0.28);
}
.btn:disabled { opacity: 0.65; cursor: wait; }
.btn-small { min-height: 2.75rem; padding: 0.375rem 0.875rem; font-size: 0.9375rem; }

.form-error {
  margin: 0 0 0.75rem;
  padding: 0.75rem 0.875rem;
  border-radius: var(--radius-md);
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 700;
}

/* ---------- The ticket ---------- */
.ticket {
  position: relative;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  overflow: hidden;
}
/* Comes out like a ticket from a printer when it first appears */
#ticketView:not([hidden]) .ticket { animation: ticket-print 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes ticket-print {
  from { clip-path: inset(0 0 100% 0); transform: translateY(-12px); }
  to   { clip-path: inset(0 0 0 0);    transform: translateY(0); }
}

.ticket-top {
  padding: 1.5rem 1.25rem 1.5rem;
  background-color: var(--marigold);
  background-image:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.16) 0 10px, transparent 10px 20px),
    repeating-linear-gradient(-45deg, rgba(0, 0, 0, 0.04) 0 10px, transparent 10px 20px);
  text-align: center;
  transition: background-color 0.4s;
}
.ticket-service {
  display: inline-block;
  margin: 0;
  padding: 0.25rem 0.875rem;
  border-radius: 999px;
  background: rgba(15, 42, 46, 0.12);
  font-weight: 700;
  font-size: 0.9375rem;
}
.ticket-label { margin: 1rem 0 0; font-size: 0.9375rem; font-weight: 700; }
.ticket-label .tl { color: inherit; opacity: 0.7; }
.ticket-code {
  margin: 0.25rem 0 0.375rem;
  font-family: var(--font-display);
  font-size: clamp(4.5rem, 25vw, 8.5rem);
  font-weight: 800;
  line-height: 0.88;
  letter-spacing: 0.01em;
  white-space: nowrap;          /* never split "C-005" across two lines */
  font-variant-numeric: tabular-nums;
}
.ticket-name { margin: 0; font-size: 1.125rem; font-weight: 700; }

/* Perforated tear line with two half-circle notches */
.ticket-stub {
  position: relative;
  padding: 1.5rem 1.25rem 1.25rem;
  border-top: 3px dashed var(--line);
  transition: background-color 0.4s;
}
.ticket-stub::before,
.ticket-stub::after {
  content: "";
  position: absolute;
  top: -0.9rem;
  width: 1.625rem;
  height: 1.625rem;
  border-radius: 50%;
  background: var(--bg);
}
.ticket-stub::before { left: -0.85rem; }
.ticket-stub::after  { right: -0.85rem; }

.ticket-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-size: 1.375rem;
  font-weight: 700;
}
/* Status dot before the title */
.ticket-status::before {
  content: "";
  flex: none;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  background: var(--marigold);
}
.ticket-status-text { margin: 0.25rem 0 1rem; color: var(--muted); }

.ticket-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 0.625rem; margin: 0; }
.ticket-facts div { padding: 0.75rem 0.875rem; border-radius: var(--radius-md); background: var(--surface-2); }
.ticket-facts dt { font-size: 0.875rem; color: var(--muted); }
.ticket-facts dd {
  margin: 0;
  font-family: var(--font-display);
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.ticket-facts dd.fact-empty { font-family: var(--font); font-size: 1.125rem; padding-top: 0.5rem; }

/* Decorative barcode strip, like a printed queue ticket */
.ticket-barcode {
  height: 2.25rem;
  margin-top: 1.25rem;
  border-radius: 2px;
  opacity: 0.75;
  background: repeating-linear-gradient(90deg,
    var(--ink) 0 2px, transparent 2px 4px,
    var(--ink) 4px 5px, transparent 5px 8px,
    var(--ink) 8px 11px, transparent 11px 12px,
    var(--ink) 12px 13px, transparent 13px 16px);
}

/* ---- Ticket states ---- */
/* It's your turn: the whole ticket turns green */
.ticket[data-status="serving"] .ticket-top { background-color: var(--primary-bright); color: #FFFFFF; }
.ticket[data-status="serving"] .ticket-service { background: rgba(255, 255, 255, 0.2); }
.ticket[data-status="serving"] .ticket-stub { background: var(--primary-soft); }
.ticket[data-status="serving"] .ticket-status { color: var(--primary); }
.ticket[data-status="serving"] .ticket-status::before { background: var(--primary-bright); animation: live-dot 1.2s ease-in-out infinite; }
.ticket[data-status="serving"] .ticket-code { animation: turn-pulse 1.2s ease-out 2; }

.ticket[data-status="completed"] .ticket-top,
.ticket[data-status="cancelled"] .ticket-top { background-color: #C9D5D1; }
.ticket[data-status="completed"] .ticket-status::before { background: var(--primary-bright); }
.ticket[data-status="skipped"] .ticket-status,
.ticket[data-status="cancelled"] .ticket-status { color: var(--danger); }
.ticket[data-status="skipped"] .ticket-status::before,
.ticket[data-status="cancelled"] .ticket-status::before { background: var(--danger); }

@keyframes turn-pulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.07); }
  100% { transform: scale(1); }
}
@keyframes live-dot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(18, 134, 111, 0.5); }
  50%      { box-shadow: 0 0 0 6px rgba(18, 134, 111, 0); }
}

.hint { margin: 1.125rem 0 0.75rem; color: var(--muted); }
.actions { display: grid; gap: 0.625rem; }

/* ---------- Footer ---------- */
.site-footer { padding: 0 0 6rem; color: var(--muted); font-size: 0.875rem; } /* room for the chat button */
.site-footer p { margin: 0; }

/* ---------- Helpers ---------- */
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
[hidden] { display: none !important; }

@media (min-width: 40rem) {
  .site-header { padding: 1.75rem 0 4.25rem; }
  .actions { grid-template-columns: 1fr 1fr; }
}

/* =============================================================
   STAFF DASHBOARD
   ============================================================= */
.staff-page { background: var(--bg); }

/* ---------- Sign in: brand panel + form ---------- */
.login-wrap { min-height: 100vh; display: grid; }
.login-art {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.5rem 1.25rem;
  background-color: var(--primary);
  background-image: var(--banig);
  color: #FFFFFF;
  border-bottom: 6px solid var(--marigold);
}
.login-art .brand-row { color: #FFFFFF; }
.login-headline {
  margin: 0;
  max-width: 12ch;
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 800;
  line-height: 0.95;
}
.login-board {
  display: none;               /* shown on wide screens only */
  align-self: flex-start;
  padding: 1rem 1.5rem 1.125rem;
  border-radius: var(--radius-md);
  background-color: var(--board);
  background-image: radial-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1.4px);
  background-size: 6px 6px;
}
.login-board-label { margin: 0; color: rgba(255, 255, 255, 0.7); font-size: 0.875rem; }
.login-board-code {
  margin: 0;
  font-family: var(--font-display);
  font-size: 4.5rem;
  font-weight: 800;
  line-height: 0.95;
  color: var(--marigold);
  text-shadow: 0 0 22px rgba(246, 177, 0, 0.35);
}
.login-side { display: grid; place-items: center; padding: 2rem 1.125rem; }
.login-card {
  width: 100%;
  max-width: 24rem;
  padding: 2rem 1.5rem 1.75rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-2);
}
.login-title {
  margin: 0 0 0.25rem;
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1;
}
.login-sub { margin: 0 0 1.5rem; color: var(--muted); }

@media (min-width: 56rem) {
  .login-wrap { grid-template-columns: 1.1fr 1fr; }
  .login-art { padding: 2.5rem; border-bottom: 0; border-right: 6px solid var(--marigold); }
  .login-board { display: block; }
}

/* ---------- Top bar ---------- */
.staff-bar {
  background-color: var(--primary);
  background-image: var(--banig);
  color: #FFFFFF;
  border-bottom: 5px solid var(--marigold);
}
.staff-bar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  max-width: 84rem;
  margin: 0 auto;
  padding: 0.75rem 1.125rem;
}
.staff-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin: 0 auto 0 0;
  font-family: var(--font-display);
  font-size: 1.625rem;
  font-weight: 800;
  line-height: 1;
}
.staff-brand .logo { width: 2.25rem; height: 2.25rem; }
.staff-brand span { font-weight: 500; opacity: 0.8; }
.staff-who { margin: 0; font-size: 0.9375rem; }
.btn-bar {
  min-height: 2.75rem;
  padding: 0.375rem 0.875rem;
  background: transparent;
  color: #FFFFFF;
  border-color: rgba(255, 255, 255, 0.55);
}
.btn-bar:hover { background: rgba(255, 255, 255, 0.12); }

/* ---------- Layout: queues | counter | line ---------- */
.staff-main {
  display: grid;
  gap: 1.25rem;
  max-width: 84rem;
  margin: 0 auto;
  padding: 1.25rem 1.125rem 2.5rem;
}
.panel-title { margin: 0 0 0.625rem; font-weight: 700; color: var(--muted); }

/* ---------- Queue tabs ---------- */
.queue-tab-list { display: grid; gap: 0.5rem; }
.queue-tab {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  min-height: 3.5rem;
  padding: 0.5rem 0.75rem;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow-1);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.queue-tab:hover { border-color: var(--accent); }
.queue-tab[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent);
}
.queue-tab .service-prefix { width: 2.5rem; height: 2.5rem; font-size: 1.375rem; }
.queue-tab-name { flex: 1; font-weight: 700; line-height: 1.25; }
.queue-tab-count {
  min-width: 2.25rem;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.queue-tab-count.has-waiting { background: var(--accent); color: #FFFFFF; }

/* ---------- The counter (center column) ---------- */
.counter {
  padding: 1.25rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.counter-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.counter-title {
  flex: 1;
  margin: 0;
  font-family: var(--font-display);
  font-size: 2.125rem;
  font-weight: 800;
  line-height: 1;
}

.action-message {
  margin: 0 0 1rem;
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius-md);
  font-weight: 700;
}
.action-message[data-tone="ok"]    { background: var(--primary-soft); color: var(--primary-dark); }
.action-message[data-tone="error"] { background: var(--danger-soft);  color: var(--danger); }

/* Empty counter */
.serving-panel {
  padding: 2.5rem 1.25rem;
  border-radius: var(--radius-md);
  border: 2px dashed var(--line);
  background: var(--surface-2);
  text-align: center;
}
.serving-empty { margin: 0; color: var(--muted); font-size: 1.125rem; }

/* Someone at the counter: LED display board */
.serving-panel.is-serving {
  padding: 1.5rem 1.25rem 1.25rem;
  border: 0;
  background-color: var(--board);
  background-image: radial-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1.4px);
  background-size: 6px 6px;
  color: #E7F0ED;
}
.serving-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  color: var(--marigold);
  font-weight: 700;
}
.serving-label::before {
  content: "";
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 50%;
  background: #3DDC97;
  animation: live-dot-board 1.4s ease-in-out infinite;
}
@keyframes live-dot-board {
  0%, 100% { box-shadow: 0 0 0 0 rgba(61, 220, 151, 0.55); }
  50%      { box-shadow: 0 0 0 6px rgba(61, 220, 151, 0); }
}
.serving-code {
  margin: 0.25rem 0 0.125rem;
  font-family: var(--font-display);
  font-size: clamp(5rem, 11vw, 8.5rem);
  font-weight: 800;
  line-height: 0.9;
  white-space: nowrap;
  color: var(--marigold);
  text-shadow: 0 0 28px rgba(246, 177, 0, 0.35);
  font-variant-numeric: tabular-nums;
}
.serving-name { margin: 0; font-size: 1.5rem; font-weight: 700; color: #FFFFFF; }
.serving-meta { margin: 0.25rem 0 1.25rem; font-size: 0.9375rem; color: rgba(231, 240, 237, 0.7); }
.serving-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.625rem; }

/* No-show countdown: the resident's ticket page and the staff counter */
.no-show-timer { margin: 0 0 1rem; padding: 0.75rem 1rem; border-radius: var(--radius-md, 0.75rem); background: #FFF4D6; color: #5A3E00; font-weight: 700; font-variant-numeric: tabular-nums; }
.no-show-timer.is-low { background: #FFE2C2; color: #7A3300; }
.no-show-timer.is-late { background: #FBD4CF; color: #8A1C12; animation: noShowPulse 1.1s ease-in-out infinite; }
.serving-timer { margin: 0 0 1rem; padding: 0.5rem 0.75rem; border-radius: 0.5rem; background: rgba(246, 177, 0, 0.18); color: #FFD666; font-weight: 700; font-variant-numeric: tabular-nums; }
.serving-timer.is-late { background: rgba(255, 107, 87, 0.22); color: #FFB3A8; }
.serving-panel .serving-skip.is-late { background: #C0392B; border-color: #C0392B; animation: noShowPulse 1.1s ease-in-out infinite; }
@keyframes noShowPulse { 50% { opacity: 0.7; } }
@media (prefers-reduced-motion: reduce) { .no-show-timer.is-late, .serving-panel .serving-skip.is-late { animation: none; } }
.serving-panel .btn-primary { background: var(--primary-bright); }
.serving-panel .btn-primary:hover { background: #0F9A7F; }
.serving-panel .btn-quiet { background: transparent; color: #FFFFFF; border-color: rgba(255, 255, 255, 0.45); }
.serving-panel .btn-quiet:hover { background: rgba(255, 255, 255, 0.1); }

/* The one big action at the counter */
.btn-call {
  width: 100%;
  min-height: 5rem;
  margin-top: 1rem;
  background: var(--marigold);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  box-shadow: 0 8px 20px rgba(217, 154, 0, 0.35);
}
.btn-call:hover:not(:disabled) { background: var(--marigold-dark); }
.btn-call:disabled { background: #E1E8E6; color: #8A9A9D; box-shadow: none; cursor: not-allowed; opacity: 1; }

.day-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.625rem; margin: 1rem 0 0; }
.day-stats div { padding: 0.625rem 0.875rem; border-radius: var(--radius-md); background: var(--surface-2); }
.day-stats dt { font-size: 0.875rem; color: var(--muted); }
.day-stats dd {
  margin: 0;
  font-family: var(--font-display);
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.last-updated { margin: 0.75rem 0 0; }

/* ---------- Waiting line (right column), numbered in order ---------- */
.waiting-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  overflow: hidden;
  counter-reset: line;
}
.waiting-item {
  counter-increment: line;
  display: grid;
  grid-template-columns: 1.75rem auto 1fr;
  align-items: center;
  gap: 0 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
}
.waiting-item:last-child { border-bottom: 0; }
.waiting-item::before {
  content: counter(line);
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 700;
}
.waiting-item.is-next { background: var(--marigold-soft); box-shadow: inset 4px 0 0 var(--marigold); }
.waiting-item.is-next::before { background: var(--marigold); color: var(--ink); }
.waiting-code {
  grid-row: span 2;
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.waiting-name { font-weight: 700; line-height: 1.25; }
.waiting-time { font-size: 0.875rem; color: var(--muted); }
.waiting-empty { padding: 1.25rem 1rem; color: var(--muted); }

/* Wide screens: three columns */
@media (min-width: 60rem) {
  .staff-main {
    grid-template-columns: 16.5rem minmax(0, 1fr) 19rem;
    align-items: start;
    padding-top: 1.5rem;
  }
}
/* Tablets: queues on top, counter and line side by side */
@media (min-width: 40rem) and (max-width: 59.99rem) {
  .staff-main { grid-template-columns: 1fr 1fr; }
  .queue-tabs { grid-column: 1 / -1; }
  .queue-tab-list { grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); }
}

/* =============================================================
   AI HELP CHAT (Citizen Portal)
   ============================================================= */
body:not(.staff-page) main.wrap { padding-bottom: 6.5rem; }

.chat-launcher {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-height: 3.5rem;
  padding: 0.5rem 1.25rem 0.5rem 0.5rem;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: #FFFFFF;
  font: inherit;
  font-weight: 700;
  text-align: left;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(15, 42, 46, 0.3);
}
.chat-launcher:hover { background: var(--primary-dark); }
.chat-launcher-icon {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--marigold);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
}
.chat-launcher-tl { display: block; font-weight: 400; font-size: 0.8125rem; opacity: 0.8; }

.chat-panel {
  position: fixed;
  z-index: 30;
  right: 1rem;
  bottom: 1rem;
  width: min(24rem, calc(100vw - 2rem));
  height: min(36rem, calc(100vh - 2rem));
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 18px 44px rgba(15, 42, 46, 0.28);
  overflow: hidden;
  animation: chat-open 0.22s ease-out;
}
@keyframes chat-open {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-panel[hidden] { display: none !important; }

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  background-color: var(--primary);
  background-image: var(--banig);
  color: #FFFFFF;
  border-bottom: 4px solid var(--marigold);
}
.chat-title { margin: 0; font-family: var(--font-display); font-size: 1.5rem; font-weight: 800; line-height: 1.05; }
.chat-sub { margin: 0; font-size: 0.8125rem; opacity: 0.85; }
.chat-close {
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #FFFFFF;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.chat-close:hover { background: rgba(255, 255, 255, 0.28); }

.chat-log {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  background: var(--bg);
}
.chat-bubble {
  max-width: 85%;
  margin: 0;
  padding: 0.625rem 0.875rem;
  border-radius: 1.125rem;
  font-size: 1rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.chat-user  { align-self: flex-end; background: var(--primary); color: #FFFFFF; border-bottom-right-radius: 0.25rem; }
.chat-model { align-self: flex-start; background: var(--surface); box-shadow: var(--shadow-1); border-bottom-left-radius: 0.25rem; }
.chat-error { align-self: flex-start; background: var(--danger-soft); color: var(--danger); font-weight: 700; }

.chat-typing { display: flex; gap: 0.3rem; padding: 0.875rem 1rem; }
.chat-typing span {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--muted);
  animation: chat-dot 1s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chat-dot {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40%           { opacity: 1;   transform: translateY(-3px); }
}

.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  padding: 0 1rem 0.75rem;
  background: var(--bg);
}
.chat-chip {
  padding: 0.4rem 0.75rem;
  border: 1.5px solid var(--primary);
  border-radius: 999px;
  background: var(--surface);
  color: var(--primary);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}
.chat-chip:hover { background: var(--primary-soft); }

.chat-compose {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem 0.5rem;
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.chat-compose input {
  flex: 1;
  min-width: 0;
  min-height: 2.875rem;
  padding: 0.5rem 0.875rem;
  border: 2px solid transparent;
  border-radius: 999px;
  background: var(--surface-2);
  font: inherit;
  color: var(--ink);
}
.chat-compose input:focus { border-color: var(--primary); background: var(--surface); }
.chat-compose .btn { min-height: 2.875rem; padding: 0.5rem 1.125rem; border-radius: 999px; }

.chat-note {
  margin: 0;
  padding: 0 1rem 0.75rem;
  background: var(--surface);
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--muted);
}

@media (max-width: 30rem) {
  .chat-panel {
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 85vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
}

/* Respect users who turn off animations */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* =============================================================
   APPOINTMENTS, MODE SWITCH, AND STAFF LINKS
   ============================================================= */
.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding: 0.375rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.mode-switch[hidden] { display: none; }
.mode-btn {
  min-height: 3.25rem;
  padding: 0.5rem 0.625rem;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--primary);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.mode-btn .tl { display: block; font-weight: 400; font-size: 0.8125rem; }
.mode-btn[aria-pressed="true"] { background: var(--primary); color: #FFFFFF; }
.mode-btn[aria-pressed="true"] .tl { color: rgba(255, 255, 255, 0.85); }
.mode-btn:not([aria-pressed="true"]):hover { background: var(--primary-soft); }

.field select,
.field input[type="date"] {
  width: 100%;
  min-height: 3.25rem;
  padding: 0.625rem 0.875rem;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
}
.field select:focus { border-color: var(--primary); background: var(--surface); }
.field select[aria-invalid="true"],
.field input[type="date"][aria-invalid="true"] { border-color: var(--danger); background: var(--danger-soft); }

.appt-done {
  padding: 1.5rem 1.25rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  text-align: center;
}
.appt-done-title { margin: 0 0 1rem; font-weight: 700; font-size: 1.25rem; color: var(--primary); }
.appt-done-title .tl { display: block; font-weight: 400; font-size: 0.9375rem; }
.appt-code {
  margin: 0.25rem 0 0.75rem;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 3.25rem;
  letter-spacing: 0.06em;
  line-height: 1;
}
.appt-summary { margin: 0 0 1rem; font-weight: 700; }

a.btn { display: inline-flex; align-items: center; text-decoration: none; }

.appointments {
  padding: 1.25rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.appointment-list { list-style: none; margin: 0; padding: 0; }
.appointment-item {
  display: grid;
  gap: 0.25rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
}
.appointment-item:last-child { border-bottom: 0; }
.appointment-date { font-weight: 700; color: var(--primary); }
.appointment-who { font-weight: 700; }
.appointment-detail { color: var(--muted); font-size: 0.9375rem; }
.appointment-actions { display: flex; gap: 0.5rem; margin-top: 0.375rem; }
.appointment-empty { color: var(--muted); }
@media (min-width: 60rem) {
  .appointments { grid-column: 1 / -1; }
  .appointment-item { grid-template-columns: 8rem 1fr 2fr auto; align-items: center; gap: 1rem; }
  .appointment-actions { margin-top: 0; }
}

/* =============================================================
   PRIORITY LANE + COUNTER PICKER
   ============================================================= */
.ticket-priority {
  display: inline-block;
  margin: 0.5rem 0 0;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: var(--marigold);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.9375rem;
}
.ticket-priority[hidden] { display: none; }

.priority-badge {
  display: inline-block;
  padding: 0.0625rem 0.5rem;
  border-radius: 999px;
  background: var(--marigold);
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 700;
  vertical-align: middle;
}

.counter-pick { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; font-size: 0.9375rem; }
.counter-pick select {
  min-height: 2.5rem;
  padding: 0.25rem 0.625rem;
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

/* =============================================================
   SATISFACTION RATING (shown after service)
   ============================================================= */
.rating-box {
  margin: 1rem 0;
  padding: 1.25rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  text-align: center;
}
.rating-box[hidden], .rating-thanks[hidden] { display: none; }
.rating-title { margin: 0 0 0.75rem; font-weight: 700; font-size: 1.125rem; }
.rating-title .tl { display: block; font-weight: 400; font-size: 0.9375rem; }
.rating-stars { display: flex; justify-content: center; gap: 0.25rem; }
.rating-star {
  width: 3.25rem;
  height: 3.25rem;
  border: 0;
  background: transparent;
  color: #C9D4D1;
  font-size: 2.5rem;
  line-height: 1;
  cursor: pointer;
}
.rating-star.is-lit { color: var(--marigold); }
.rating-label { margin: 0.25rem 0 1rem; color: var(--muted); }
.rating-box .field { text-align: left; }
.rating-thanks { margin: 1rem 0; padding: 1rem; border-radius: var(--radius-md); background: var(--primary-soft); color: var(--primary-dark); font-weight: 700; text-align: center; }
.rating-thanks .tl { display: block; font-weight: 400; }

/* Live note under the sign-in screen's Now serving board */
.login-board-note { margin: 0.5rem 0 0; color: rgba(255, 255, 255, 0.75); font-size: 0.875rem; }
