/* ==========================================================================
   Medical Camp Portal — Design System
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
  --ink: #16241f;
  --ink-soft: #33443d;
  --paper: #f2f5f0;
  --surface: #ffffff;
  --teal-deep: #0b5d57;
  --teal-mid: #12786f;
  --teal-wash: #e4f0ee;
  --amber: #e2a73e;
  --amber-wash: #fbf1de;
  --coral: #c1473c;
  --coral-wash: #f8e6e4;
  --green: #3f8f5c;
  --green-wash: #e5f2ea;
  --slate: #5b6b66;
  --line: #dce3dd;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(22, 36, 31, 0.06), 0 4px 16px rgba(22, 36, 31, 0.06);
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "IBM Plex Sans", -apple-system, Segoe UI, sans-serif;
  --font-mono: "IBM Plex Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 4px;
}

h1 { font-size: 28px; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }

p { margin: 0 0 8px; }

a { color: var(--teal-deep); }

button, input, select, textarea { font-family: inherit; font-size: inherit; }

:focus-visible {
  outline: 2px solid var(--teal-mid);
  outline-offset: 2px;
}

/* ------------------------------ app shell ------------------------------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--teal-deep);
  color: #eef5f3;
  display: flex;
  flex-direction: column;
  padding: 22px 18px;
}

.sidebar__brand {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  color: #ffffff;
  line-height: 1.25;
  margin-bottom: 2px;
}

.sidebar__camp {
  font-size: 12px;
  color: #b9d8d3;
  margin-bottom: 26px;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.sidebar__nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #d7ebe8;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s ease;
}

.sidebar__nav a:hover { background: rgba(255,255,255,0.08); }

.sidebar__nav a.active {
  background: #ffffff;
  color: var(--teal-deep);
}

.sidebar__nav .badge-count {
  margin-left: auto;
  background: var(--amber);
  color: #3a2a08;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 20px;
}

.sidebar__nav a.active .badge-count {
  background: var(--teal-wash);
  color: var(--teal-deep);
}

.sidebar__footer {
  border-top: 1px solid rgba(255,255,255,0.15);
  padding-top: 14px;
  font-size: 13px;
}

.sidebar__staff {
  color: #ffffff;
  font-weight: 600;
  margin-bottom: 1px;
}

.sidebar__role {
  color: #b9d8d3;
  font-size: 12px;
  margin-bottom: 10px;
}

.sidebar__logout {
  color: #f0c4bd;
  text-decoration: none;
  font-size: 13px;
}
.sidebar__logout:hover { text-decoration: underline; }

.main {
  flex: 1;
  min-width: 0;
  padding: 28px 36px 48px;
}

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.topbar__meta {
  font-size: 13px;
  color: var(--slate);
}

/* -------------------------------- cards ---------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-bottom: 20px;
}

.card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.stat-card__label {
  font-size: 12.5px;
  color: var(--slate);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 6px;
}

.stat-card__value {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 600;
}

.stat-card--amber .stat-card__value { color: var(--amber); }
.stat-card--teal .stat-card__value { color: var(--teal-deep); }
.stat-card--green .stat-card__value { color: var(--green); }

/* -------------------------------- forms ----------------------------------- */

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px 20px;
}

@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field--full { grid-column: 1 / -1; }

.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}

.field .hint {
  font-size: 12px;
  color: var(--slate);
  font-weight: 400;
}

.field input,
.field select,
.field textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfbfa;
  color: var(--ink);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  background: #fff;
  border-color: var(--teal-mid);
}

.field textarea { resize: vertical; min-height: 70px; }

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
  align-items: center;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s ease, transform 0.05s ease;
}
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--teal-deep); color: #ffffff; }
.btn-primary:hover { background: var(--teal-mid); }

.btn-amber { background: var(--amber); color: #3a2a08; }
.btn-amber:hover { opacity: 0.9; }

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.btn-ghost:hover { background: #eef1ec; }

.btn-danger { background: transparent; color: var(--coral); border: 1px solid var(--coral); }

.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* -------------------------------- badges/status ---------------------------------- */

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
}
.status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.status--registered { background: #eceeec; color: var(--slate); }
.status--vitals-done { background: var(--amber-wash); color: #8a5f13; }
.status--completed { background: var(--green-wash); color: var(--green); }

/* -------------------------------- patient id badge (ticket) ---------------------------------- */

.ticket {
  display: flex;
  align-items: stretch;
  background: var(--teal-deep);
  color: #ffffff;
  border-radius: 10px;
  overflow: hidden;
  max-width: 460px;
  box-shadow: var(--shadow);
}

.ticket__main {
  flex: 1;
  padding: 18px 20px;
}

.ticket__label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #a9d6ce;
  margin-bottom: 6px;
}

.ticket__name {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 2px;
}

.ticket__sub {
  font-size: 12.5px;
  color: #c4e2dc;
}

.ticket__stub {
  width: 130px;
  flex-shrink: 0;
  background: var(--amber);
  color: #3a2a08;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 10px;
  position: relative;
  border-left: 2px dashed rgba(58,42,8,0.3);
}

.ticket__id {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.02em;
}

.patient-id-inline {
  font-family: var(--font-mono);
  font-weight: 600;
  background: var(--teal-wash);
  color: var(--teal-deep);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 13px;
}

/* -------------------------------- tables ---------------------------------- */

table { width: 100%; border-collapse: collapse; }

th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--slate);
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  vertical-align: middle;
}

tr.row-link { cursor: pointer; }
tr.row-link:hover td { background: #f8faf7; }

.table-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--slate);
}

/* -------------------------------- search / toolbar ---------------------------------- */

.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
  align-items: center;
}

.search-input {
  flex: 1;
  min-width: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--surface);
}

.select-filter {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--surface);
}

/* -------------------------------- stepper ---------------------------------- */

.stepper {
  display: flex;
  align-items: center;
  margin-bottom: 24px;
  gap: 0;
}

.stepper__step {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.stepper__dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  background: #eceeec;
  color: var(--slate);
  flex-shrink: 0;
}

.stepper__step.done .stepper__dot { background: var(--green); color: #fff; }
.stepper__step.current .stepper__dot { background: var(--teal-deep); color: #fff; }

.stepper__label { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.stepper__step.done .stepper__label { color: var(--green); }
.stepper__step.current .stepper__label { color: var(--teal-deep); }

.stepper__line {
  flex: 1;
  height: 2px;
  background: var(--line);
  margin: 0 4px;
}
.stepper__line.done { background: var(--green); }

/* -------------------------------- record sections ---------------------------------- */

.record-section {
  border-top: 1px solid var(--line);
  padding-top: 18px;
  margin-top: 18px;
}
.record-section:first-child { border-top: none; padding-top: 0; margin-top: 0; }

.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px 20px;
}

.kv-grid .k {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--slate);
  margin-bottom: 3px;
}
.kv-grid .v { font-size: 15px; font-weight: 600; }

.empty-note {
  color: var(--slate);
  font-size: 13.5px;
  font-style: italic;
}

.callout {
  background: var(--teal-wash);
  border: 1px solid #c7e2dd;
  border-radius: 8px;
  padding: 14px 16px;
  font-size: 13.5px;
  color: var(--teal-deep);
  margin-bottom: 20px;
}

.callout--amber { background: var(--amber-wash); border-color: #efd9a8; color: #8a5f13; }
