/* IMM Patient Registration — Unified Design System
 *
 * Single source of truth for all pages (portal, booth pages, dashboard).
 * Noto Sans required: patient names are transliterated Hindi —
 * system-ui renders these incorrectly on some Android phones.
 *
 * Fonts are self-hosted (public/fonts/) for offline camp use.
 */

/* Devanagari subset (Hindi transliterated names) */
@font-face {
  font-family: 'Noto Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/NotoSans-devanagari.woff2') format('woff2');
  unicode-range: U+0900-097F, U+1CD0-1CF9, U+200C-200D, U+20B9, U+25CC, U+A8E0-A8FF, U+11B00-11B09;
}

/* Latin extended */
@font-face {
  font-family: 'Noto Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/NotoSans-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Latin (primary) */
@font-face {
  font-family: 'Noto Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/NotoSans-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Typography */
  --font-body: 'Noto Sans', system-ui, -apple-system, sans-serif;
  --text-xs:  11px;
  --text-sm:  13px;
  --text-base: 15px;
  --text-md:  16px;
  --text-lg:  18px;
  --text-xl:  20px;
  --text-2xl: 24px;

  /* ---- Color palette ---- */
  --color-primary:       #0F766E;
  --color-primary-hover: #0D9488;
  --color-primary-light: #CCFBF1;
  --color-primary-soft:  #F0FDFA;

  --color-danger:       #DC2626;
  --color-danger-light: #FEE2E2;
  --color-warning:      #D97706;
  --color-warning-light:#FEF3C7;
  --color-success:      #16A34A;
  --color-success-light:#DCFCE7;

  --color-bg:             #F8FAFC;
  --color-surface:        #FFFFFF;
  --color-text:           #0F172A;
  --color-text-secondary: #64748B;
  --color-text-muted:     #94A3B8;
  --color-border:         #E2E8F0;
  --color-border-hover:   #CBD5E1;

  /* Layout */
  --touch-target-min: 48px;
  --radius-sm:   4px;
  --radius-md:   8px;
  --radius-lg:  12px;
  --radius-full: 9999px;

  --space-xs:  4px;
  --space-sm:  8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);

  /* Booth colors (dashboard card map) */
  --booth-registration: #1565C0;
  --booth-triage:       #FDD835;
  --booth-vitals:       #FF8F00;
  --booth-eye-exam:     #7B1FA2;
  --booth-dental:       #EC407A;
  --booth-provider:     #5C6BC0;
  --booth-lab:          #26A69A;
  --booth-ekg:          #8D6E63;
  --booth-pt:           #6A1B9A;
  --booth-pharmacy:     #00897B;
  --booth-null:         #BDBDBD;

  /* Legacy aliases (booth-page.css and booth pages reference these) */
  --font-size-base:    var(--text-md);
  --font-size-label:   var(--text-base);
  --font-size-heading: var(--text-2xl);
  --color-readonly-bg: var(--color-bg);
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

/* Ensure the HTML `hidden` attribute is always respected.
 * Without this, any class rule that sets display (e.g. .banner { display: flex })
 * silently overrides the UA stylesheet's low-specificity [hidden]{display:none}. */
[hidden] { display: none !important; }

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.55;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--space-md) 0;
  font-weight: 700;
  line-height: 1.25;
  color: var(--color-text);
}
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }

a { color: var(--color-primary); }
a:hover { color: var(--color-primary-hover); }

label {
  display: block;
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-xs);
}

/* ===== Interactive elements — 48px touch targets ===== */

button, input, select, textarea {
  font-family: inherit;
  font-size: var(--text-md);
  min-height: var(--touch-target-min);
  padding: 10px 14px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 40px;
  cursor: pointer;
}

textarea {
  min-height: calc(var(--touch-target-min) * 2);
  resize: vertical;
}

/* iOS auto-zoom guard — touch keyboards zoom when inputs are <16px. */
@media (pointer: coarse) {
  input, select, textarea {
    font-size: 16px;
  }
}

button {
  cursor: pointer;
  background: var(--color-primary);
  color: #FFFFFF;
  border: none;
  font-weight: 600;
  border-radius: var(--radius-md);
  padding: 10px 20px;
  transition: background 0.15s ease, transform 0.08s ease, box-shadow 0.15s ease;
}

button:hover:not(:disabled) {
  background: var(--color-primary-hover);
  box-shadow: var(--shadow-sm);
}

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

button:disabled, input:disabled, select:disabled, textarea:disabled,
fieldset:disabled input, fieldset:disabled select,
fieldset:disabled textarea, fieldset:disabled button {
  opacity: 0.45;
  cursor: not-allowed;
}

button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] { -moz-appearance: textfield; }

/* ===== Sticky banners (privilege, critical vitals) ===== */

.banner {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  min-height: var(--touch-target-min);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm) var(--space-md);
  color: #FFFFFF;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: center;
  font-size: var(--text-sm);
}

.banner-priv {
  background: var(--color-danger);
}

.banner-vit-critical {
  background: var(--color-warning);
}

/* ===== Layout ===== */

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: var(--space-md);
}

.field {
  margin-bottom: var(--space-md);
}

.field input,
.field select,
.field textarea {
  width: 100%;
}

/* ===== Components ===== */

.readonly-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-lg);
}

.readonly-section h2 {
  margin-top: 0;
  font-size: var(--text-md);
  color: var(--color-text-secondary);
}

.empty-instruction {
  font-style: italic;
  color: var(--color-text-secondary);
  padding: var(--space-md) 0;
}

.error-inline {
  color: var(--color-danger);
  font-weight: 600;
  padding: var(--space-sm) 0;
  font-size: var(--text-base);
}

.error-inline a {
  color: var(--color-primary);
}

.flash-success {
  background: var(--color-success);
  color: #FFFFFF;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: var(--text-base);
}

.booth-count {
  display: inline-block;
  padding: var(--space-xs) 12px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 600;
}

.spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  border: 2px solid #FFFFFF;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Reduced motion ===== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== Visit Summary Panel ===== */

.vs-panel {
  margin: 0 0 var(--space-md);
}

.vs-panel-title {
  font-size: var(--text-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-secondary);
  margin: 0 0 var(--space-sm);
}

.vs-section {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-sm);
  background: var(--color-surface);
  overflow: hidden;
}

.vs-station-header {
  padding: 10px var(--space-md);
  cursor: pointer;
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  list-style: none;
  background: var(--color-bg);
  user-select: none;
}

.vs-station-header::-webkit-details-marker { display: none; }

.vs-station-header::after {
  content: '›';
  font-size: 18px;
  color: var(--color-text-secondary);
  transition: transform 0.15s ease;
}

details[open] > .vs-station-header::after {
  transform: rotate(90deg);
}

.vs-station-meta {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 400;
  margin-left: var(--space-sm);
}

.vs-section-body {
  padding: var(--space-sm) var(--space-md) var(--space-md);
  border-top: 1px solid var(--color-border);
}

.vs-field-list {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 4px var(--space-sm);
  margin: 0 0 var(--space-sm);
  font-size: var(--text-sm);
}

.vs-field-list dt {
  color: var(--color-text-secondary);
  font-weight: 600;
}

.vs-field-list dd {
  color: var(--color-text);
  margin: 0;
  word-break: break-word;
}

.vs-critical-tag {
  display: inline-block;
  background: var(--color-danger-light);
  color: var(--color-danger);
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.vs-reroute-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--color-border);
}

.vs-reroute-btn {
  background: transparent;
  color: var(--color-primary);
  border: 1.5px solid var(--color-primary);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 6px 14px;
  min-height: 36px;
  border-radius: var(--radius-md);
}

.vs-reroute-btn:hover:not(:disabled) {
  background: var(--color-primary-soft);
}

.vs-reroute-flash {
  font-size: var(--text-sm);
  font-weight: 600;
}

.vs-empty {
  color: var(--color-text-muted);
  font-style: italic;
  font-size: var(--text-sm);
  padding: var(--space-sm) 0;
  margin: 0;
}
