/*
 * Layout primitives from the Apple Health redesign, compact density. The
 * Overview page itself is styled by overview.css since 2026-10-17.
 * Spec: docs/design/PHR_UI_Apple_Health_Redesign_Specification_v1_2.md
 * Loaded by Modules/Dashboard/Views/dashboard.php, and by
 * the profile, My Health and Medicines views for its layout primitives (cards,
 * grid, tiles, headings, links, chips, alert panels, dose buttons). Every class is dash- prefixed, so nothing here
 * reaches a page that does not load this file. Primitives other pages use
 * (dash-panel, dash-alert, dash-tile, dash-badge, dash-note-blue, dash-list,
 * dash-sos, ...) stay even where the Overview itself no longer renders them.
 *
 * Scale: body 14, card titles 15, section titles 18, greeting 28, reading
 * values 22 (blood pressure 24). Card padding 20 / 16, gaps 16 / 24.
 *
 * Contrast: text on a tinted or grey surface uses --text-secondary and the
 * *-text colour tokens, never --text-tertiary or --apple-blue, which fall
 * under 4.5:1 off white. Text links use --apple-blue-text for the same reason.
 */

/* ---- Opener ---------------------------------------------------------- */
.dash-opener {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 12px 16px; margin-bottom: 14px;
}
.dash-date { margin: 0 0 2px; font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.tabular-date { font-variant-numeric: tabular-nums; }
.dash-greeting {
  margin: 0; font-size: 28px; line-height: 1.15; font-weight: 700;
  letter-spacing: -0.6px; color: var(--text-primary);
}
.dash-opener-sub { margin: 4px 0 0; font-size: 15px; color: var(--text-secondary); }
.dash-opener-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---- Two-column grid: 2/3 + 1/3, stacks on a phone ------------------- */
/* Design parameters (2026-10-17): an 8/4 column ratio, 24px gap (20px between
   1024px and 1279px), stacked below 1024px - the same numbers as
   .grid-clinical-split in layout.css. */
.dash-grid {
  display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; gap: 24px; margin-top: 16px;
}
.dash-main { min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.dash-side { min-width: 0; display: flex; flex-direction: column; gap: 16px; }

/* ---- Cards ----------------------------------------------------------- */
.dash-card {
  background: var(--apple-card); border: 1px solid var(--card-border);
  border-radius: var(--radius-lg); box-shadow: var(--card-shadow); padding: 20px;
}
.dash-card-tight { padding: 16px; }
.dash-card-head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px;
}
.dash-h2 {
  display: block; margin: 0; font-size: 18px; line-height: 1.25; font-weight: 700;
  letter-spacing: -0.3px; color: var(--text-primary);
}
.dash-h3 {
  display: flex; align-items: center; gap: 8px; margin: 0; font-size: 15px;
  font-weight: 600; letter-spacing: -0.3px; color: var(--text-primary);
}
.dash-sub { display: block; margin: 4px 0 0; font-size: 14px; color: var(--text-secondary); }
.dash-strong { margin: 0; font-size: 14px; font-weight: 600; color: var(--text-primary); }
.dash-muted, .dash-muted-on-tint { margin: 0; font-size: 12px; color: var(--text-secondary); }
.dash-label {
  margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-tertiary);
}
.dash-label-gap { margin: 14px 0 8px; }
.dash-count {
  display: inline-flex; padding: 3px 10px; border-radius: var(--radius-full);
  background: var(--apple-canvas); color: var(--text-primary); font-size: 12px; font-weight: 600;
}
.dash-grow { flex: 1; min-width: 0; }
.dash-push { margin-left: auto; }
.dash-gap-top { margin-top: 10px; }
.dash-blue-text { color: var(--apple-blue-text); }
.dash-ico-blue { color: var(--apple-blue); }

/* Text links keep a 44px hit area (spec §2.4) without adding 44px to the row:
   the negative block margins let the padded box overlap its neighbours. */
.dash-link, .dash-link-dark {
  display: inline-flex; align-items: center; gap: 4px; min-height: 44px; margin-block: -12px;
  color: var(--apple-blue-text); font-size: 14px; font-weight: 600; text-decoration: none;
}
.dash-link:hover, .dash-link-dark:hover { text-decoration: underline; }
.dash-link-inline { color: var(--apple-blue-text); font-weight: 600; }
.dash-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 12px; }
.dash-links { display: flex; flex-wrap: wrap; gap: 4px 20px; margin-top: 8px; }

/* ---- Hub tiers ------------------------------------------------------- */
.dash-tier { margin-top: 16px; }
.dash-tier-label {
  display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 12px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase; color: var(--text-tertiary);
}
.dash-tier-dot { width: 8px; height: 8px; border-radius: var(--radius-full); background: var(--text-quaternary); }
.dash-tier-dot.is-crimson { background: var(--apple-crimson); }
.dash-tier-dot.is-amber { background: var(--apple-amber); }
.dash-tier-dot.is-blue { background: var(--apple-blue); }
.dash-tier-dot.is-grey { background: var(--text-quaternary); }
.dash-stack { display: flex; flex-direction: column; gap: 10px; }

.dash-alert {
  display: flex; gap: 14px; padding: 16px; border-radius: var(--radius-lg);
  background: var(--apple-crimson-bg);
}
.dash-alert-icon {
  flex: none; display: flex; align-items: center; justify-content: center; width: 36px; height: 36px;
  border-radius: var(--radius-full); background: var(--apple-crimson); color: #FFFFFF; font-size: 20px;
}
.dash-alert-body { flex: 1; min-width: 0; }
.dash-alert-meta, .dash-panel-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 12px; }
.dash-alert-kind { font-size: 12px; font-weight: 700; color: var(--apple-crimson-text); }
.dash-alert-text { margin: 4px 0 0; font-size: 15px; font-weight: 600; color: var(--text-primary); }

.dash-panel { padding: 14px 16px; border-radius: var(--radius-lg); background: var(--apple-canvas); }
.dash-panel-amber { background: var(--apple-amber-bg); }
.dash-panel > * + * { margin-top: 6px; }
.dash-panel-text { margin: 0; font-size: 14px; color: var(--text-primary); }
.dash-kind { font-size: 12px; font-weight: 700; color: var(--text-primary); }
.dash-kind-amber { color: var(--apple-amber-text); }
.dash-quote { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.3px; color: var(--text-primary); }
.dash-choice { display: flex; flex-wrap: wrap; gap: 8px; }
.dash-choice-btn {
  min-height: 44px; padding: 0 14px; border-radius: var(--radius-full);
  border: 1px solid var(--control-border); background: #FFFFFF; color: var(--text-primary);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.dash-choice-btn:hover { border-color: var(--apple-blue); color: var(--apple-blue-text); }

/* Today: one card per medicine, one tile per dose. */
.dash-med {
  padding: 14px; border-radius: var(--radius-lg); background: var(--apple-canvas);
  border: 1px solid var(--card-border-subtle);
}
.dash-med-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.dash-med-name { margin: 8px 0 2px; font-size: 15px; font-weight: 600; letter-spacing: -0.3px; color: var(--text-primary); }
.dash-med-dose { margin-left: 4px; font-size: 14px; font-weight: 500; color: var(--text-secondary); }
.dash-med-form { margin-left: 4px; font-size: 13px; font-weight: 400; letter-spacing: 0; color: var(--text-secondary); }
.dash-doses { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.dash-dose {
  flex: 1 1 150px; min-width: 0; padding: 10px 12px; border-radius: var(--radius-md);
  background: #FFFFFF; border: 1px solid var(--card-border);
}
.dash-dose.is-due { flex: 2 1 280px; border: 1.5px solid var(--apple-blue); }
.dash-dose-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; }
.dash-dose-time { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.dash-dose-slot { font-weight: 500; color: var(--text-secondary); }
.dash-dose-note { margin: 6px 0 0; font-size: 12px; color: var(--text-secondary); }
.dash-dose-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.dash-dose-btn {
  display: inline-flex; align-items: center; gap: 5px; min-height: 44px; padding: 0 12px;
  border-radius: var(--radius-full); border: 1px solid transparent;
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.dash-dose-btn.is-taken { background: var(--apple-emerald-text); border-color: var(--apple-emerald-text); color: #FFFFFF; }
.dash-dose-btn.is-missed { background: var(--apple-crimson-bg); border-color: rgba(184, 24, 16, 0.25); color: var(--apple-crimson-text); }
.dash-dose-btn.is-skipped { background: var(--apple-canvas); border-color: var(--control-border); color: var(--text-primary); }

.dash-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: var(--radius-full);
  font-size: 12px; font-weight: 600; background: var(--apple-slate-bg); color: var(--text-secondary);
}
.dash-chip-blue { background: var(--apple-blue-subtle); color: var(--apple-blue-text); }
.dash-chip-taken { background: var(--apple-emerald-bg); color: var(--apple-emerald-text); }
.dash-chip-missed { background: var(--apple-crimson-bg); color: var(--apple-crimson-text); }
.dash-chip-due { background: var(--apple-amber-bg); color: var(--apple-amber-text); }
.dash-chip-skipped, .dash-chip-later { background: var(--apple-slate-bg); color: var(--text-secondary); }
.dash-chip-white { align-self: flex-start; background: #FFFFFF; color: var(--apple-blue-text); }
.dash-dot { width: 6px; height: 6px; border-radius: var(--radius-full); background: currentColor; }

.dash-icon-tile {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 9px; font-size: 17px;
  background: var(--apple-blue-subtle); color: var(--apple-blue);
}
.dash-icon-tile.is-blue { background: var(--apple-blue-subtle); color: var(--apple-blue); }
.dash-icon-tile.is-indigo { background: var(--apple-indigo-bg); color: var(--apple-indigo-text); }
.dash-icon-tile.is-emerald { background: var(--apple-emerald-bg); color: var(--apple-emerald-text); }
.dash-icon-tile.is-amber { background: var(--apple-amber-bg); color: var(--apple-amber-text); }
.dash-icon-tile.is-crimson { background: var(--apple-crimson-bg); color: var(--apple-crimson-text); }
.dash-icon-tile.is-teal { background: var(--apple-teal-bg); color: var(--apple-teal-text); }
.dash-icon-tile.is-purple { background: var(--apple-purple-bg); color: var(--apple-purple-text); }
.dash-icon-tile.is-slate { background: var(--apple-slate-bg); color: var(--text-secondary); }

/* When you can: completion. */
.dash-complete { padding: 16px; border-radius: var(--radius-lg); border: 1px solid var(--card-border); }
.dash-complete-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px; }
.dash-complete .dash-h3 { display: block; }
.dash-progress {
  margin-top: 10px; height: 8px; border-radius: var(--radius-full); background: #E5E5EA; overflow: hidden;
}
.dash-progress > span { display: block; height: 100%; border-radius: var(--radius-full); background: var(--apple-blue); }
.dash-complete-next {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--card-border-subtle);
}

.dash-limits {
  margin-top: 16px; padding: 12px 16px; border-radius: var(--radius-md);
  background: var(--apple-canvas); font-size: 13px; color: var(--text-secondary);
}
.dash-limits p { margin: 0 0 6px; }
.dash-limits strong { color: var(--text-primary); }

/* ---- Blocks shared with other pages (profile, vitals, ...) ---------- */
.dash-block-head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: 4px 12px; margin-bottom: 10px;
}

.dash-pack-pill {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px;
  border-radius: var(--radius-full); background: var(--apple-canvas); border: 1px solid var(--card-border);
  color: var(--text-primary); font-size: 13px; font-weight: 600; text-decoration: none;
}
.dash-pack-pill.is-primary { background: var(--apple-indigo-bg); border-color: #DCDCF7; color: var(--apple-indigo-text); }
.dash-note-blue { padding: 12px 16px; border-radius: var(--radius-md); background: var(--apple-blue-subtle); }
.dash-note-blue > * + * { margin-top: 4px; }

/* Readings tiles (vitals and predictors pages). */
.dash-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.dash-tile {
  display: flex; flex-direction: column; gap: 2px; min-height: 140px; padding: 12px 14px 14px;
  border-radius: var(--radius-lg); background: var(--apple-canvas); border: 1.5px solid var(--card-border-subtle);
  color: var(--text-primary); text-decoration: none;
}
.dash-tile:hover { box-shadow: var(--card-shadow-hover); }
.dash-tile-crimson { background: #FFF6F5; border-color: #F4B9B3; }
.dash-tile-amber { background: #FFF9F0; border-color: #F6DDB4; }
.dash-tile-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.dash-tile .dash-icon-tile { width: 28px; height: 28px; border-radius: 8px; font-size: 16px; }
.dash-tile-name { font-size: 14px; font-weight: 600; }
.dash-tile-sub { font-size: 12px; color: var(--text-secondary); }
.dash-tile-value { margin-top: auto; padding-top: 8px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 6px; }
.dash-tile-num { font-size: 22px; font-weight: 600; letter-spacing: -0.5px; color: var(--text-primary); }
.dash-tile-num.is-lead { font-size: 24px; }
.dash-tile-unit { font-size: 13px; color: var(--text-secondary); }
.dash-tile-foot { font-size: 12px; color: var(--text-secondary); }
.dash-badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: var(--radius-full);
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.dash-badge-crimson { background: var(--apple-crimson-bg); color: var(--apple-crimson-text); }
.dash-badge-amber { background: var(--apple-amber-bg); color: var(--apple-amber-text); }

.dash-block-line { display: block; }
.dash-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.dash-rule { margin: 14px 0; border: 0; border-top: 1px solid var(--card-border-subtle); }

.dash-disclaimer {
  display: flex; gap: 8px; margin: 14px 0 0; padding: 10px 14px; border-radius: var(--radius-md);
  background: var(--apple-canvas); font-size: 12px; color: var(--text-secondary);
}

/* ---- Right column ---------------------------------------------------- */
.dash-doctor {
  padding: 20px; border-radius: var(--radius-xl); background: var(--text-primary); color: #FFFFFF;
}
.dash-doctor .dash-h2 { color: #FFFFFF; margin-top: 4px; }
.dash-eyebrow {
  margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #A1A1A6;
}
.dash-doctor-text { margin: 6px 0 0; font-size: 14px; color: #D2D2D7; }
.dash-doctor-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.dash-doctor-actions .btn { justify-content: center; }
.dash-btn-light { background: #FFFFFF; color: var(--text-primary); }
.dash-btn-light:hover { background: #F0F0F2; color: var(--text-primary); }
.dash-btn-ghost { background: transparent; border: 1px solid rgba(255, 255, 255, 0.3); color: #FFFFFF; box-shadow: none; }
.dash-btn-ghost:hover { background: rgba(255, 255, 255, 0.08); color: #FFFFFF; }

.dash-quick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.dash-quick-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px; min-height: 76px; padding: 12px;
  border-radius: 16px; background: var(--apple-canvas); border: 1px solid var(--card-border-subtle);
  color: var(--text-primary); font-size: 14px; font-weight: 600; line-height: 1.3; text-decoration: none;
}
.dash-quick-tile i { font-size: 22px; color: var(--apple-blue); }
.dash-quick-tile:hover { border-color: var(--apple-blue); }
/* One colour per kind of record, as in the design canvas. Icons are decorative
   (aria-hidden) and sit beside a text label, so colour carries no meaning alone. */
.dash-quick-tile .fa-prescription-bottle-medical { color: var(--apple-emerald-text); }
.dash-quick-tile .fa-flask-vial, .dash-quick-tile .fa-layer-group { color: var(--apple-indigo-text); }
.dash-quick-tile .fa-notes-medical { color: var(--apple-amber-text); }
.dash-quick-tile .fa-x-ray { color: var(--apple-indigo); }
.dash-quick-tile .fa-droplet { color: var(--apple-pink-text); }
.dash-quick-tile .fa-comment-medical, .dash-quick-tile .fa-calculator { color: var(--apple-teal-text); }
.dash-quick-tile .fa-syringe { color: var(--apple-purple-text); }
.dash-quick-tile .fa-shield-virus { color: var(--apple-crimson-text); }
.dash-quick-tile .fa-newspaper, .dash-quick-tile .fa-clock-rotate-left { color: var(--text-secondary); }
.dash-quick-tile.is-suggested { background: var(--apple-blue-subtle); border: 1.5px solid var(--apple-blue); color: var(--apple-blue-text); }
.dash-quick-tile.is-suggested i { color: var(--apple-blue-text); }
.dash-quick-reason { font-size: 12px; font-weight: 500; }

.dash-sos {
  display: flex; align-items: center; gap: 12px; margin-top: 12px; padding: 12px; border-radius: var(--radius-md);
  background: var(--apple-crimson-bg);
}
.dash-sos-icon {
  flex: none; display: flex; align-items: center; justify-content: center; width: 36px; height: 36px;
  border-radius: 10px; background: var(--apple-crimson); color: #FFFFFF; font-size: 19px;
}
.dash-sos-number { margin: 0; font-size: 16px; font-weight: 600; color: var(--apple-crimson-text); }
.btn-danger-solid { background: var(--apple-crimson-text); border-color: var(--apple-crimson-text); color: #FFFFFF; }
.btn-danger-solid:hover { background: #9C140D; color: #FFFFFF; }

.dash-list {
  margin: 10px 0 0; padding: 0; list-style: none; border-radius: var(--radius-md);
  border: 1px solid var(--card-border); overflow: hidden;
}
.dash-list li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.dash-list li + li { border-top: 1px solid var(--card-border-subtle); }
.dash-avatar {
  flex: none; display: flex; align-items: center; justify-content: center; width: 36px; height: 36px;
  border-radius: var(--radius-full); background: var(--apple-blue-subtle); color: var(--apple-blue-text);
  font-size: 14px; font-weight: 700;
}

/* The Overview itself is styled by overview.css (V2 "Calm Clinical", ported
   from the design artifact 2026-10-17). What is left here is shared by the
   profile, My Health, Medicines and Timeline pages. */

/* ---- Responsive ---------------------------------------------------------- */
@media (max-width: 1279px) { .dash-grid { gap: 20px; } }
@media (max-width: 1023px) { .dash-grid { grid-template-columns: minmax(0, 1fr); } }
@media print {
  .dash-opener-actions, .dash-quick, .dash-dose-actions, .dash-choice, .dash-link, .dash-link-inline, .btn { display: none !important; }
  .dash-grid { display: block; }
  .dash-card { box-shadow: none; border: 1px solid #CCCCCC; break-inside: avoid; margin-top: 12px; }
  .dash-doctor { background: #FFFFFF; color: #000000; border: 1px solid #CCCCCC; }
  .dash-doctor .dash-h2, .dash-doctor-text, .dash-eyebrow { color: #000000; }
}
