/* ============================================================
   v0-palette.css — V0 Health surface palette + branding
   Owner: V0 · 2026-05-08
   ============================================================
   Surcharges --surface-* du design system v0 canonical.
   Préfixes réservés : ne PAS redéfinir --ds-* (DS) ni .ds-* (DS).

   Identité Health : bleu nuit médical sobre, fond clair clinique,
   accents discrets pour priority findings (orange chaud) et
   status in_range (vert sobre).

   Décidable plus tard par David si ajustements souhaités.
   ============================================================ */

:root {
  /* ----- Couleurs primaires ----- */
  --surface-color-bg:        #fcfcfd;   /* fond presque blanc, légèrement chaud */
  --surface-color-bg-card:   #ffffff;   /* fond cards (override DS si applicable) */
  --surface-color-text:      #1f2937;   /* gris foncé corps texte */
  --surface-color-muted:     #6b7280;   /* gris moyen labels secondaires */
  --surface-color-rule:      #e5e7eb;   /* gris clair séparateurs */

  /* ----- Liens / accents ----- */
  --surface-color-link:       #1e3a8a;  /* bleu nuit médical */
  --surface-color-link-hover: #1e40af;  /* bleu nuit hover (légèrement plus clair) */
  --surface-color-focus:      #3b82f6;  /* bleu vif outline a11y */

  /* ----- Code / inline ----- */
  --surface-color-code-bg: rgba(30, 58, 138, 0.06);  /* tint bleu très léger */

  /* ----- Status bloodwork (sémantique Health) ----- */
  --health-color-status-in-range:    #059669;  /* vert sobre */
  --health-color-status-high-normal: #d97706;  /* orange chaud */
  --health-color-status-low-normal:  #2563eb;  /* bleu */
  --health-color-status-high:        #dc2626;  /* rouge marqué */
  --health-color-status-low:         #dc2626;
  --health-color-status-unknown:     #6b7280;  /* gris muted */

  /* ----- Severity priority findings ----- */
  --health-color-severity-low:      #059669;
  --health-color-severity-moderate: #d97706;
  --health-color-severity-high:     #dc2626;

  /* ----- Trend arrows ----- */
  --health-color-trend-up:     #d97706;
  --health-color-trend-down:   #2563eb;
  --health-color-trend-stable: #6b7280;
}

/* ----- Layout local Health ----- */

.health-page-title {
  margin-block-start: var(--ds-space-6);
  margin-block-end: var(--ds-space-2);
}

.health-meta {
  color: var(--surface-color-muted);
  font-size: var(--ds-font-size-sm);
  margin-block-end: var(--ds-space-6);
}

.health-section-title {
  margin-block-start: var(--ds-space-7);
  margin-block-end: var(--ds-space-4);
}

.health-auth-status {
  margin-inline-start: auto;
  font-size: var(--ds-font-size-sm);
  color: var(--surface-color-muted);
  display: flex;
  align-items: center;
  gap: var(--ds-space-2);
}

.health-auth-status[data-state="authed"] {
  color: var(--health-color-status-in-range);
}

.health-auth-status[data-state="error"] {
  color: var(--health-color-status-high);
}

.health-auth-status__btn {
  background: none;
  border: none;
  color: var(--surface-color-link);
  cursor: pointer;
  font-size: inherit;
  text-decoration: underline;
}

.health-auth-gate {
  max-width: 32rem;
  margin: var(--ds-space-7) auto;
}

.health-gsi-button-wrap {
  margin-block-start: var(--ds-space-5);
  display: flex;
  justify-content: center;
}

.health-auth-error {
  color: var(--health-color-status-high);
  font-size: var(--ds-font-size-sm);
  margin-block-start: var(--ds-space-3);
}

/* ----- Markers bloodwork ----- */

.health-marker {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-block: var(--ds-space-2);
  border-bottom: 1px solid var(--surface-color-rule);
  font-size: var(--ds-font-size-sm);
}

.health-marker:last-child {
  border-bottom: none;
}

.health-marker__name {
  font-family: var(--ds-font-family-mono, monospace);
  color: var(--surface-color-muted);
}

.health-marker__value {
  font-weight: var(--ds-font-weight-semibold);
}

.health-marker__status {
  display: inline-block;
  padding-inline: var(--ds-space-2);
  padding-block: 0;
  border-radius: 0.25rem;
  font-size: var(--ds-font-size-xs);
  margin-inline-start: var(--ds-space-2);
}

.health-marker__status--in-range    { background: rgba(5, 150, 105, 0.10); color: var(--health-color-status-in-range); }
.health-marker__status--high-normal { background: rgba(217, 119, 6, 0.10);  color: var(--health-color-status-high-normal); }
.health-marker__status--low-normal  { background: rgba(37, 99, 235, 0.10);  color: var(--health-color-status-low-normal); }
.health-marker__status--high        { background: rgba(220, 38, 38, 0.12);  color: var(--health-color-status-high); }
.health-marker__status--low         { background: rgba(220, 38, 38, 0.12);  color: var(--health-color-status-low); }
.health-marker__status--unknown     { background: rgba(107, 114, 128, 0.10); color: var(--health-color-status-unknown); }

.health-marker__trend {
  font-size: var(--ds-font-size-xs);
  margin-inline-start: var(--ds-space-2);
}

.health-marker__trend--up     { color: var(--health-color-trend-up); }
.health-marker__trend--down   { color: var(--health-color-trend-down); }
.health-marker__trend--stable { color: var(--health-color-trend-stable); }

/* ----- Priority findings ----- */

.health-finding {
  border-left: 3px solid var(--health-color-severity-moderate);
  padding-inline-start: var(--ds-space-4);
  margin-block-end: var(--ds-space-4);
}

.health-finding[data-severity="high"]     { border-left-color: var(--health-color-severity-high); }
.health-finding[data-severity="low"]      { border-left-color: var(--health-color-severity-low); }
.health-finding[data-severity="moderate"] { border-left-color: var(--health-color-severity-moderate); }

.health-finding__topic {
  font-weight: var(--ds-font-weight-semibold);
  text-transform: capitalize;
}

.health-finding__summary {
  margin-block: var(--ds-space-1);
  color: var(--surface-color-text);
}

.health-finding__actions {
  font-size: var(--ds-font-size-xs);
  color: var(--surface-color-muted);
  list-style: square inside;
  margin-block: 0;
}

/* ----- Tests / lifestyle / supplements lists ----- */

.health-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.health-list__item {
  padding-block: var(--ds-space-2);
  border-bottom: 1px solid var(--surface-color-rule);
}

.health-list__item:last-child {
  border-bottom: none;
}

.health-list__item-rationale {
  font-size: var(--ds-font-size-xs);
  color: var(--surface-color-muted);
  margin-block-start: var(--ds-space-1);
}

.health-supplements-section {
  margin-block-end: var(--ds-space-4);
}

.health-supplements-section__title {
  font-size: var(--ds-font-size-sm);
  font-weight: var(--ds-font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--surface-color-muted);
  margin-block-end: var(--ds-space-2);
}

/* ----- Cross-link cards (digests / briefs / research) ----- */

.health-md-link {
  display: block;
  padding: var(--ds-space-2);
  text-decoration: none;
  color: var(--surface-color-text);
  border-radius: 0.25rem;
}

.health-md-link:hover {
  background: var(--surface-color-code-bg);
}

.health-md-link__date {
  display: block;
  font-size: var(--ds-font-size-xs);
  color: var(--surface-color-muted);
  font-family: var(--ds-font-family-mono, monospace);
}

.health-md-link__title {
  display: block;
  font-weight: var(--ds-font-weight-medium);
}

/* ----- Markdown viewer modal ----- */

.health-md-viewer {
  border: none;
  border-radius: 0.5rem;
  padding: 0;
  width: min(48rem, 90vw);
  max-height: 80vh;
}

.health-md-viewer::backdrop {
  background: rgba(31, 41, 55, 0.4);
}

.health-md-viewer .ds-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.health-md-viewer .ds-card__body {
  max-height: 60vh;
  overflow-y: auto;
}

/* ----- Apple Santé card ----- */

.health-section-subtitle {
  font-size: var(--ds-font-size-sm);
  font-weight: var(--ds-font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--surface-color-muted);
  margin-block-start: var(--ds-space-4);
  margin-block-end: var(--ds-space-3);
}

.health-section-subtitle:first-child {
  margin-block-start: 0;
}

.health-apple-latest {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
  gap: var(--ds-space-3);
}

.health-apple-tile {
  display: flex;
  flex-direction: column;
  align-items: baseline;
  padding: var(--ds-space-3);
  border-radius: 0.5rem;
  background: var(--surface-color-code-bg);
}

.health-apple-tile__value {
  font-size: var(--ds-font-size-2xl);
  font-weight: var(--ds-font-weight-semibold);
  color: var(--surface-color-link);
  line-height: var(--ds-line-height-tight);
}

.health-apple-tile__unit {
  font-size: var(--ds-font-size-sm);
  color: var(--surface-color-muted);
  margin-inline-start: var(--ds-space-1);
}

.health-apple-tile__label {
  font-size: var(--ds-font-size-xs);
  color: var(--surface-color-muted);
  margin-block-start: var(--ds-space-1);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.health-apple-30d {
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-1);
}

.health-apple-row {
  display: grid;
  grid-template-columns: minmax(8rem, 12rem) auto 1fr;
  gap: var(--ds-space-3);
  padding-block: var(--ds-space-2);
  align-items: baseline;
  border-bottom: 1px solid var(--surface-color-rule);
  font-size: var(--ds-font-size-sm);
}

.health-apple-row:last-child {
  border-bottom: none;
}

.health-apple-row__label {
  color: var(--surface-color-muted);
}

.health-apple-row__value {
  font-weight: var(--ds-font-weight-semibold);
  color: var(--surface-color-text);
}

.health-apple-row__sub {
  font-size: var(--ds-font-size-xs);
  color: var(--surface-color-muted);
  font-weight: var(--ds-font-weight-normal);
}

.health-apple-workouts {
  margin-block-start: var(--ds-space-4);
}

/* ----- Disabled nav (Todo phase 2) ----- */

.ds-navbar__link[data-disabled] {
  opacity: 0.5;
  pointer-events: none;
}

.ds-navbar__link[data-disabled]::after {
  content: " (phase 2)";
  font-size: var(--ds-font-size-xs);
}

/* ---------- onglets (health v2) ---------- */

.health-tabs {
  display: flex;
  gap: var(--ds-space-1);
  border-bottom: 1px solid var(--surface-color-rule, #e5e7eb);
  margin-block: var(--ds-space-5) var(--ds-space-5);
  flex-wrap: wrap;
}

.health-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: var(--ds-space-3) var(--ds-space-4);
  font: inherit;
  font-size: var(--ds-font-size-sm);
  font-weight: var(--ds-font-weight-semibold);
  color: var(--surface-color-muted, #6b7280);
  cursor: pointer;
}
.health-tab--active {
  color: var(--surface-color-link, #1e3a8a);
  border-bottom-color: var(--surface-color-link, #1e3a8a);
}

.health-view {
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-5);
}
/* l'attribut [hidden] doit l'emporter sur le display:flex ci-dessus */
.health-view[hidden] {
  display: none;
}

/* marqueur en mouvement : valeur prior → latest */
.health-marker__move {
  font-variant-numeric: tabular-nums;
}
