/* CareHome — stylesheet
 * Replaces the Tailwind-generated utility styles from the original Next.js build.
 * Design tokens mirror the original: teal primary, warm amber secondary,
 * neutral stone backgrounds, tabular numerals for clinical data, display serif
 * for headings. */

:root {
  --brand-primary: 15 118 110;       /* teal-700 */
  --brand-secondary: 245 158 11;     /* amber-500 */

  --ink: #1c1917;
  --ink-muted: #44403c;
  --ink-subtle: #78716c;
  --stroke: #e7e5e4;
  --surface: #ffffff;
  --surface-raised: #f5f5f4;
  --status-ok: #047857;
  --status-warn: #b45309;
  --status-alert: #b91c1c;
}

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

body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--surface-raised);
  line-height: 1.5;
  font-size: 14px;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }

.font-display { font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; font-weight: 500; letter-spacing: -0.01em; }
.font-mono    { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.tabular      { font-variant-numeric: tabular-nums; }

.eyebrow {
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-subtle);
  font-weight: 500;
}

/* ---------------- Shell & layout ---------------- */
.shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
@media (max-width: 768px) { .shell { grid-template-columns: 1fr; } }

.sidebar { display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--stroke); }
@media (max-width: 768px) { .sidebar { border-right: 0; border-bottom: 1px solid var(--stroke); } }

.sidebar-section { padding: 18px 20px; border-bottom: 1px solid var(--stroke); }
.org-name { font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif; font-size: 20px; margin-top: 2px; line-height: 1.15; }

.facility-form select { width: 100%; border: 1px solid var(--stroke); border-radius: 8px; padding: 8px 10px; background: var(--surface); font-size: 13px; margin-top: 6px; font-family: inherit; }

.sidebar-nav { flex: 1; padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-link { display: block; padding: 8px 12px; border-radius: 6px; color: var(--ink-muted); font-size: 13px; transition: background 0.15s; }
.nav-link:hover { background: var(--surface-raised); color: var(--ink); text-decoration: none; }
.nav-link.active { background: rgb(var(--brand-primary) / 0.08); color: rgb(var(--brand-primary)); }
.nav-link.disabled { color: color-mix(in srgb, var(--ink-subtle) 60%, transparent); cursor: not-allowed; }
.nav-section-title { margin: 14px 12px 4px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-subtle); }

.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--stroke); }
.user-line { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--ink-muted); gap: 10px; }
.logout-btn { background: transparent; border: 1px solid var(--stroke); border-radius: 6px; padding: 4px 10px; font-size: 12px; cursor: pointer; color: var(--ink-muted); font-family: inherit; }
.logout-btn:hover { border-color: var(--ink-subtle); color: var(--ink); }

.main { min-width: 0; display: flex; flex-direction: column; }
.content { padding: 40px; }
@media (max-width: 768px) { .content { padding: 24px; } }

/* ---------------- Flashes ---------------- */
.flashes { padding: 16px 40px 0; }
.flash { border: 1px solid var(--stroke); padding: 10px 14px; border-radius: 8px; background: var(--surface); margin-bottom: 8px; font-size: 13px; }
.flash-error { border-color: #fca5a5; background: #fef2f2; color: #991b1b; }
.flash-ok    { border-color: #a7f3d0; background: #ecfdf5; color: #047857; }
.flash-info  { border-color: var(--stroke); }

/* ---------------- Typography ---------------- */
.h-eyebrow { font-family: ui-monospace, Consolas, monospace; font-size: 11px; text-transform: uppercase; letter-spacing: 0.2em; color: var(--ink-subtle); }
.h1 { font-family: "Iowan Old Style", Georgia, serif; font-size: 36px; font-weight: 500; margin: 4px 0 0; letter-spacing: -0.01em; }
.h1-xl { font-family: "Iowan Old Style", Georgia, serif; font-size: 44px; font-weight: 500; margin: 0; letter-spacing: -0.02em; line-height: 1.1; }
.h2 { font-family: "Iowan Old Style", Georgia, serif; font-size: 22px; font-weight: 500; margin: 0 0 16px; letter-spacing: -0.005em; }
.h3 { font-family: "Iowan Old Style", Georgia, serif; font-size: 18px; font-weight: 500; margin: 0 0 12px; }

.muted { color: var(--ink-muted); }
.subtle { color: var(--ink-subtle); }

/* ---------------- Layout primitives ---------------- */
.max-w-4xl { max-width: 800px; }
.max-w-5xl { max-width: 1000px; }
.max-w-6xl { max-width: 1200px; }

.flex { display: flex; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.items-baseline { align-items: baseline; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }

.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 40px; }
@media (max-width: 768px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.mb-2 { margin-bottom: 8px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.mb-8 { margin-bottom: 32px; } .mb-10 { margin-bottom: 40px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; }
.mt-8 { margin-top: 32px; } .mt-12 { margin-top: 48px; }

/* ---------------- Stat tiles ---------------- */
.stat { border: 1px solid var(--stroke); border-radius: 14px; background: var(--surface); padding: 22px 24px; }
.stat.emphasis { border-color: rgb(var(--brand-primary)); background: rgb(var(--brand-primary) / 0.05); }
.stat .label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-subtle); font-weight: 600; }
.stat .value { font-family: "Iowan Old Style", Georgia, serif; font-size: 44px; margin-top: 6px; font-variant-numeric: tabular-nums; line-height: 1; }
.stat .sublabel { font-size: 11px; color: var(--ink-subtle); margin-top: 4px; }

/* ---------------- Tables ---------------- */
.card { border: 1px solid var(--stroke); border-radius: 12px; background: var(--surface); overflow: hidden; }
.card-pad { padding: 24px; }
.table { width: 100%; font-size: 13px; border-collapse: collapse; }
.table thead { background: var(--surface-raised); color: var(--ink-subtle); }
.table th { text-align: left; padding: 10px 14px; font-weight: 500; font-size: 12px; letter-spacing: 0.02em; }
.table td { padding: 10px 14px; border-top: 1px solid var(--stroke); vertical-align: top; }
.table tr.clickable:hover { background: color-mix(in srgb, var(--surface-raised) 60%, transparent); }

/* ---------------- Chips ---------------- */
.chip { display: inline-block; font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; padding: 2px 8px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; font-weight: 500; }
.chip-ok    { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.chip-info  { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.chip-warn  { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.chip-alert { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }

/* ---------------- Forms ---------------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-subtle); font-weight: 500; }
.field input, .field select, .field textarea, .input, .select, .textarea {
  border: 1px solid var(--stroke);
  border-radius: 8px;
  padding: 8px 12px;
  font: inherit;
  font-size: 13px;
  background: var(--surface);
  color: var(--ink);
  width: 100%;
}
.field textarea { resize: vertical; min-height: 70px; }
.field input:focus, .field select:focus, .field textarea:focus,
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: rgb(var(--brand-primary));
  box-shadow: 0 0 0 3px rgb(var(--brand-primary) / 0.15);
}

.btn { display: inline-block; border-radius: 8px; padding: 8px 14px; font-size: 13px; font-weight: 500; border: 1px solid transparent; cursor: pointer; text-decoration: none; font-family: inherit; }
.btn-primary { background: rgb(var(--brand-primary)); color: white; }
.btn-primary:hover { background: color-mix(in srgb, rgb(var(--brand-primary)) 90%, black); text-decoration: none; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--stroke); }
.btn-secondary:hover { border-color: var(--ink-subtle); text-decoration: none; }
.btn-dark { background: var(--ink); color: white; }
.btn-dark:hover { background: var(--ink-muted); text-decoration: none; }
.btn[disabled] { opacity: 0.6; cursor: not-allowed; }

/* ---------------- Radio cards (ADL independence picker) ---------------- */
.radio-card { display: flex; align-items: center; gap: 12px; border: 1px solid var(--stroke); border-radius: 8px; padding: 8px 12px; font-size: 13px; cursor: pointer; background: var(--surface); }
.radio-card:hover { border-color: var(--ink-subtle); }
.radio-card.checked { border-color: rgb(var(--brand-primary)); background: rgb(var(--brand-primary) / 0.05); }
.radio-card .idx { color: var(--ink-subtle); width: 14px; font-variant-numeric: tabular-nums; }

/* ---------------- Pill row (resident picker on ADL page) ---------------- */
.pill-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.pill { display: inline-block; font-size: 13px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--stroke); background: var(--surface); color: var(--ink-muted); }
.pill:hover { border-color: var(--ink-subtle); text-decoration: none; color: var(--ink); }
.pill.active { background: rgb(var(--brand-primary)); color: white; border-color: rgb(var(--brand-primary)); }

/* ---------------- Data cell (resident detail fields) ---------------- */
.data-cell { display: flex; flex-direction: column; gap: 4px; }
.data-cell .label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-subtle); font-weight: 500; }
.data-cell .value { font-size: 15px; }
.data-cell.wide { grid-column: 1 / -1; }
.field-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px 40px; padding-bottom: 40px; border-bottom: 1px solid var(--stroke); }
@media (max-width: 768px) { .field-grid { grid-template-columns: 1fr; } }

/* ---------------- Login page ---------------- */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--surface-raised); padding: 20px; }
.login-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--stroke); border-radius: 16px; padding: 40px; box-shadow: 0 1px 3px rgb(0 0 0 / 0.04); }
.login-card .brand { text-align: center; margin-bottom: 24px; }
.login-card .brand .h1-xl { font-size: 32px; }
.login-card .brand p { color: var(--ink-subtle); margin: 4px 0 0; font-size: 13px; }
.login-card .demo-accounts {
  margin-top: 20px;
  font-size: 11px;
  color: var(--ink-subtle);
  border-top: 1px dashed var(--stroke);
  padding-top: 14px;
  font-family: ui-monospace, Consolas, monospace;
  line-height: 1.7;
}

/* ---------------- Section helpers ---------------- */
.section + .section { margin-top: 40px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.section-head .count { font-size: 11px; color: var(--ink-subtle); }

.empty {
  border: 1px dashed var(--stroke);
  border-radius: 12px;
  padding: 32px;
  text-align: center;
  background: var(--surface);
}
.empty .title { font-family: "Iowan Old Style", Georgia, serif; font-size: 18px; }
.empty .body { font-size: 13px; color: var(--ink-muted); margin-top: 4px; }

/* ---------------- Misc ---------------- */
.status-alert { color: var(--status-alert); }
.text-xs { font-size: 11px; } .text-sm { font-size: 13px; }
.text-right { text-align: right; } .text-center { text-align: center; }
.font-medium { font-weight: 500; }
.w-full { width: 100%; }
.inline-block { display: inline-block; }
.italic { font-style: italic; }
