/* GaudierNeuro — shared styles
   Mobile-first. A few breakpoint overrides at the bottom for >=720px. */

:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e0;
  --text: #1a202c;
  --text-muted: #64748b;
  --primary: #2b6cb0;
  --primary-hover: #2c5282;
  --primary-soft: #ebf4ff;
  --success: #2f855a;
  --success-bg: #c6f6d5;
  --warn: #c05621;
  --warn-bg: #feebc8;
  --danger: #c53030;
  --danger-bg: #fed7d7;
  --info: #2c7a7b;
  --info-bg: #e6fffa;
  --accent: #ed8936;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 2px 8px rgba(15, 23, 42, 0.04);
  --radius: 8px;
  --radius-sm: 5px;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 var(--space-3) 0; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }

p { margin: 0 0 var(--space-3) 0; }
.muted { color: var(--text-muted); }
.small { font-size: 0.85rem; }

/* ---------------------------------------------------------------------- */
/* Header / nav                                                           */
/* ---------------------------------------------------------------------- */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow);
}
.site-header .inner {
  max-width: 1100px; margin: 0 auto; padding: var(--space-3) var(--space-4);
  display: flex; align-items: center; gap: var(--space-4);
  flex-wrap: wrap;
}
.brand {
  font-size: 1.15rem; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: var(--space-2);
}
.brand:hover { text-decoration: none; color: var(--primary); }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); display: inline-block; }

.nav { display: flex; gap: var(--space-2); margin-left: auto; align-items: center; flex-wrap: wrap; }
.nav a, .nav button {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.9rem; font-weight: 500;
  background: transparent; border: 0; cursor: pointer;
}
.nav a:hover, .nav button:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.user-chip {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--primary-soft); color: var(--primary);
  border-radius: 999px; font-size: 0.85rem; font-weight: 600;
}
.user-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success); display: inline-block;
}

/* ---------------------------------------------------------------------- */
/* Layout containers                                                      */
/* ---------------------------------------------------------------------- */

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--space-5) var(--space-4);
}
.container.narrow { max-width: 760px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow);
}
.card h2:first-child, .card h1:first-child { margin-top: 0; }

.page-title { display: flex; align-items: baseline; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-2); }
.page-title h1 { margin: 0; }
.page-title .meta { color: var(--text-muted); font-size: 0.9rem; }

.crumbs { font-size: 0.85rem; color: var(--text-muted); margin-bottom: var(--space-4); }
.crumbs a { color: var(--text-muted); }

/* ---------------------------------------------------------------------- */
/* Flash messages                                                          */
/* ---------------------------------------------------------------------- */

.flash {
  background: var(--info-bg); color: var(--info);
  border: 1px solid var(--info);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-4);
  font-weight: 500;
}

/* ---------------------------------------------------------------------- */
/* Forms / buttons                                                        */
/* ---------------------------------------------------------------------- */

label { display: block; margin: var(--space-3) 0 var(--space-1) 0; font-weight: 600; font-size: 0.92rem; }
input[type=text], input[type=email], input[type=search], input[type=password], textarea, select {
  width: 100%;
  padding: 0.6rem 0.8rem;
  font-size: 1rem;
  font-family: inherit;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus, select:focus {
  outline: 0;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.18);
}
textarea { font-family: inherit; resize: vertical; min-height: 100px; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-2);
  padding: 0.6rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  background: var(--primary);
  color: white;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, transform 0.05s;
  min-height: 42px; /* touch target */
}
button:hover, .btn:hover { background: var(--primary-hover); text-decoration: none; }
button:active, .btn:active { transform: translateY(1px); }
button[disabled], .btn[disabled] { opacity: 0.5; cursor: not-allowed; }

button.secondary, .btn.secondary { background: var(--surface-2); color: var(--text); }
button.secondary:hover, .btn.secondary:hover { background: var(--border); }

button.success, .btn.success { background: var(--success); }
button.success:hover, .btn.success:hover { background: #276749; }

button.danger, .btn.danger { background: var(--danger); }
button.danger:hover, .btn.danger:hover { background: #9b2c2c; }

button.small, .btn.small { padding: 0.35rem 0.7rem; font-size: 0.82rem; min-height: 32px; }

form.inline { display: inline; margin: 0; }

.row { display: flex; gap: var(--space-4); flex-wrap: wrap; }
.row > * { flex: 1 1 240px; min-width: 0; }

.help { font-size: 0.82rem; color: var(--text-muted); margin-top: var(--space-1); }

/* Search bar */
.searchbar { display: flex; gap: var(--space-2); }
.searchbar input { flex: 1; }
.searchbar select { width: auto; min-width: 120px; flex: 0 0 auto; }

.pagination { display: flex; align-items: center; justify-content: center; gap: var(--space-3); margin-top: var(--space-4); }

.tribute {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.15rem;
  line-height: 1.8;
  color: var(--text);
  max-width: 700px;
  margin: 2rem auto;
  text-align: center;
  font-style: italic;
}
.tribute p { margin-bottom: 1.25rem; }

/* Filter card */
.filters { padding: var(--space-4); }
.filter-row { display: flex; gap: var(--space-3); align-items: flex-end; flex-wrap: wrap; }
.filter-row > div { flex: 1 1 160px; min-width: 0; }
.filter-row label { margin-top: 0; }
.filter-actions { flex: 0 0 auto; }
.presets { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-top: var(--space-3); }
.presets .preset {
  display: inline-block;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.85rem; font-weight: 600;
  text-decoration: none;
}
.presets .preset:hover { background: var(--border); color: var(--text); text-decoration: none; }
.presets .preset.active { background: var(--primary); color: white; }

/* ---------------------------------------------------------------------- */
/* Pills / badges                                                         */
/* ---------------------------------------------------------------------- */

.pill {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-muted);
  white-space: nowrap;
}
.pill.kind-Enc { background: #ebf4ff; color: #2c5282; }
.pill.kind-TelEnc { background: #faf5ff; color: #6b46c1; }
.pill.sent { background: var(--success-bg); color: var(--success); }
.pill.rejected { background: var(--danger-bg); color: var(--danger); }
.pill.error { background: var(--warn-bg); color: var(--warn); }
.pill.warn { background: var(--danger-bg); color: var(--danger); }
.pill.ok { background: var(--success-bg); color: var(--success); }

.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 7px;
  background: var(--accent); color: white;
  border-radius: 999px; font-size: 0.78rem; font-weight: 700;
}

/* ---------------------------------------------------------------------- */
/* Tables                                                                 */
/* ---------------------------------------------------------------------- */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: var(--space-4);
}

table.data {
  width: 100%;
  border-collapse: collapse;
}
table.data th, table.data td {
  text-align: left;
  padding: 0.75rem var(--space-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data th {
  background: var(--surface-2);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--surface-2); }
table.data tr.queued td { background: #f0fff4; }
table.data tr.queued:hover td { background: #e6f9ec; }

/* ---------------------------------------------------------------------- */
/* Demographics / definition list                                          */
/* ---------------------------------------------------------------------- */

.demographics dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--space-2) var(--space-4);
  margin: 0;
}
.demographics dt { font-weight: 600; color: var(--text-muted); font-size: 0.85rem; }
.demographics dd { margin: 0; }

/* ---------------------------------------------------------------------- */
/* Queue panel                                                            */
/* ---------------------------------------------------------------------- */

.queue {
  background: var(--primary-soft);
  border: 1px solid #bee3f8;
  border-radius: var(--radius);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}
.queue h2 { margin-top: 0; display: flex; align-items: center; gap: var(--space-2); }
.queue ul { margin: var(--space-2) 0; padding-left: var(--space-4); }
.queue li { margin: var(--space-1) 0; }
.queue .empty { color: var(--text-muted); font-style: italic; margin: 0; }
.queue-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-top: var(--space-3); }

/* ---------------------------------------------------------------------- */
/* Send form                                                              */
/* ---------------------------------------------------------------------- */

.send-form { background: var(--surface); border: 1px solid var(--accent); border-radius: var(--radius); padding: var(--space-5); box-shadow: var(--shadow); }
.send-form h2 { margin-top: 0; }
.send-form .method-toggle { display: flex; gap: var(--space-3); }
.send-form .method-toggle label { display: inline-flex; align-items: center; gap: 0.4rem; font-weight: 500; margin: 0; cursor: pointer; }

/* ---------------------------------------------------------------------- */
/* Encounter chips on send log                                            */
/* ---------------------------------------------------------------------- */

.encs { font-size: 0.85rem; line-height: 1.7; }
.encs .item {
  display: inline-block; margin: 0 0.3rem 0.3rem 0;
  padding: 0.18rem 0.55rem;
  background: var(--surface-2); color: var(--text);
  border-radius: var(--radius-sm);
  font-weight: 500;
}
.encs .item a { color: inherit; text-decoration: none; }
.encs .item.gone { background: var(--danger-bg); color: var(--danger); }
.encs .total { display: block; color: var(--text-muted); font-size: 0.78rem; margin-bottom: 0.2rem; }

/* Inbox */
.inbox-table tr.unread td { background: #f0f7ff; }
.inbox-table tr.unread strong { color: var(--text); }
.inbox-table .dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  background: transparent; border: 1px solid var(--border-strong);
}
.inbox-table .dot.on { background: var(--primary); border-color: var(--primary); }

dl.msg-meta { display: grid; grid-template-columns: max-content 1fr; gap: 0.4rem 1rem; margin: 0; font-size: 0.92rem; }
dl.msg-meta dt { font-weight: 600; color: var(--text-muted); text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.04em; padding-top: 2px; }
dl.msg-meta dd { margin: 0; }

/* ---------------------------------------------------------------------- */
/* Mobile (>=720px overrides; below = stack)                              */
/* ---------------------------------------------------------------------- */

@media (max-width: 719px) {
  html, body { font-size: 16.5px; line-height: 1.55; }
  .container { padding: var(--space-4) var(--space-3); }
  .card { padding: var(--space-4); }
  h1 { font-size: 1.4rem; }
  h2 { font-size: 1.15rem; }

  .site-header .inner { padding: var(--space-3); gap: var(--space-2); }
  .brand { font-size: 1.05rem; }
  .nav { gap: var(--space-1); width: 100%; justify-content: flex-start; margin-left: 0; }
  .nav a, .nav button { padding: 0.4rem 0.65rem; font-size: 0.85rem; }
  .user-chip { padding: 0.35rem 0.7rem; font-size: 0.8rem; margin-left: auto; }

  .row { gap: var(--space-3); }
  input[type=text], input[type=email], input[type=search], input[type=password], textarea, select {
    font-size: 16px; /* prevent iOS zoom */
    padding: 0.7rem 0.9rem;
  }
  button, .btn { width: 100%; padding: 0.85rem 1rem; font-size: 1rem; min-height: 48px; }
  button.small, .btn.small { width: auto; padding: 0.45rem 0.85rem; font-size: 0.85rem; min-height: 36px; }
  form.inline button.small { width: auto; }
  .searchbar { flex-direction: column; }
  .searchbar button { width: 100%; }

  /* Collapse data tables into card stacks */
  table.data, table.data thead, table.data tbody, table.data tr, table.data th, table.data td {
    display: block;
  }
  table.data thead { display: none; }
  table.data tbody tr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-3);
    padding: var(--space-2);
    box-shadow: var(--shadow);
  }
  table.data tbody tr:hover td { background: transparent; }
  table.data tr.queued { border-color: #9ae6b4; background: #f0fff4; }
  table.data td {
    border-bottom: 1px solid var(--border);
    padding: 0.7rem var(--space-3);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
    font-size: 0.95rem;
  }
  table.data td:last-child { border-bottom: 0; }
  table.data td::before {
    content: attr(data-label);
    font-size: 0.74rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 0.04em;
    flex-shrink: 0;
  }
  /* Wrap long content (encounter chips, etc) onto a new line below the label. */
  table.data td.encs { flex-direction: column; align-items: flex-start; }
}

@media (min-width: 720px) {
  .nav a, .nav button { font-size: 0.92rem; }
}
