/* ==========================================================================
   MindeLine app theme layer. Loaded last.
   Values come from the landing's design tokens (Guía de diseño MindeLine v1.0):
   navy #192436, teal #237873, Montserrat headings, Inter text, 8px controls,
   2px teal focus ring, and the dark "mar profundo" surfaces.
   ========================================================================== */

/* ---------- Shared fixes ---------- */

/* Global heading color (navy) made the hero titles invisible on the navy hero. */
.hero-panel h1, .hero-panel h2 { color: #fff; }

:focus-visible { outline: 2px solid var(--teal-700, #237873); outline-offset: 2px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Accent-colored text follows the patient's accent (and its light tone in dark mode). */
.patient-workspace .eyebrow { color: var(--pz-accent-text, var(--teal-700)); }
.patient-workspace .care-sidebar nav button.active { color: var(--pz-accent-text, var(--teal-700)); }
.patient-workspace .text-link { color: var(--pz-accent-text, var(--teal-700)); }

/* Phone: the patient menu is a scrollable row of pills. A width:100% rule elsewhere
   made each pill fill the row, so only "Overview" was visible. */
@media (max-width: 760px) {
  .patient-workspace .care-sidebar nav { gap: 6px; padding-bottom: 2px; scroll-snap-type: x proximity; scrollbar-width: none;
    mask-image: linear-gradient(90deg, #000 85%, transparent); }
  .patient-workspace .care-sidebar nav::-webkit-scrollbar { display: none; }
  .patient-workspace .care-sidebar nav button { width: auto; flex: 0 0 auto; scroll-snap-align: start; min-height: 40px;
    border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; }
  .patient-workspace .care-sidebar nav button.active { border-color: transparent; }
  .patient-workspace .care-sidebar .portal-brand, .patient-workspace .care-sidebar .portal-nav-label { display: none; }
  .patient-workspace .care-section-heading { flex-wrap: wrap; gap: 12px; }
}

/* ---------- Home shortcuts: cards or list ---------- */
.patient-action-card[hidden], .patient-workspace [data-patient-tab][hidden] { display: none !important; }
.patient-workspace.pz-layout-list .patient-quick-grid { grid-template-columns: 1fr; gap: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--white, #fff); }
.patient-workspace.pz-layout-list .patient-action-card { display: grid; grid-template-columns: 140px minmax(0, 1fr) auto; align-items: center; gap: 4px 16px;
  min-height: 0; padding: 14px 18px; border: 0; border-radius: 0; border-bottom: 1px solid var(--line); box-shadow: none; text-align: left; }
.patient-workspace.pz-layout-list .patient-action-card:last-child { border-bottom: 0; }
.patient-workspace.pz-layout-list .patient-action-card .eyebrow { margin: 0; }
.patient-workspace.pz-layout-list .patient-action-card::after { content: "›"; grid-column: 3; grid-row: 1 / span 2; font-size: 22px; color: var(--muted); }
.patient-workspace.pz-layout-list .patient-action-card strong { grid-column: 2; }
.patient-workspace.pz-layout-list .patient-action-card small { grid-column: 2; }
.patient-workspace.pz-layout-list .patient-action-card .eyebrow { grid-row: 1 / span 2; }
@media (max-width: 640px) {
  .patient-workspace.pz-layout-list .patient-action-card { grid-template-columns: minmax(0, 1fr) auto; }
  .patient-workspace.pz-layout-list .patient-action-card .eyebrow { grid-row: auto; grid-column: 1; }
  .patient-workspace.pz-layout-list .patient-action-card strong, .patient-workspace.pz-layout-list .patient-action-card small { grid-column: 1; }
  .patient-workspace.pz-layout-list .patient-action-card::after { grid-column: 2; grid-row: 1 / span 3; }
}

/* ---------- Personalize entry points ---------- */
.topbar .pz-avatar-button, .pz-avatar-button { font-size: 22px; }
.pz-avatar-button { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 50%;
  background: var(--white, #fff); font-size: 20px; line-height: 1; cursor: pointer; transition: box-shadow 160ms cubic-bezier(.25,1,.5,1); }
.pz-avatar-button:hover { box-shadow: 0 0 0 3px var(--teal-50, #E9F5F4); }
.pz-open-button { gap: 8px; }
.pz-heading-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* ---------- Personalize sheet ---------- */
.pz-sheet { width: min(520px, 100vw); max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0 0 0 auto; padding: 0;
  border: 0; border-left: 1px solid var(--line); border-radius: 0; background: var(--white, #fff); color: var(--ink, #192436);
  box-shadow: 0 24px 48px -16px rgba(25,36,54,.22), 0 8px 16px -8px rgba(25,36,54,.1); }
.pz-sheet::backdrop { background: rgba(14, 21, 34, .28); }
.pz-sheet[open] { animation: pz-slide 240ms cubic-bezier(.25,1,.5,1); }
@keyframes pz-slide { from { transform: translateX(24px); opacity: 0; } }
.pz-form { display: flex; flex-direction: column; height: 100%; margin: 0; }
.pz-head { display: flex; justify-content: space-between; gap: 16px; padding: 24px 24px 16px; border-bottom: 1px solid var(--line); }
.pz-head h2 { margin: 4px 0 4px; }
.pz-head p { margin: 0; color: var(--muted); }
.pz-body { flex: 1; overflow: auto; padding: 8px 24px 24px; }
.pz-group { margin: 18px 0 0; padding: 0; border: 0; min-width: 0; }
.pz-group legend { margin-bottom: 8px; padding: 0; font: 600 15px/1.4 var(--font-display, Montserrat, sans-serif); color: var(--navy-800, #192436); }
.pz-help { margin: 0 0 10px; color: var(--muted); }
.pz-icon { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 8px;
  background: transparent; color: inherit; font-size: 16px; cursor: pointer; }
.pz-icon:hover:not(:disabled) { background: var(--navy-50, #F1F4F9); }
.pz-icon:disabled { opacity: .35; cursor: default; }
.pz-close { font-size: 22px; }

.pz-sections { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.pz-section { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto auto; align-items: center; gap: 10px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--white, #fff); }
.pz-section.is-hidden .pz-section-name { opacity: .6; }
.pz-section[draggable="true"] { cursor: grab; }
.pz-section.is-dragging { opacity: .5; }
.pz-section.is-drop-target { border-color: var(--teal-700); box-shadow: 0 0 0 2px var(--teal-50); }
.pz-handle { color: var(--muted); letter-spacing: -3px; user-select: none; }
.pz-section-name strong { display: block; }
.pz-section-name small { display: block; color: var(--muted); }
.pz-lock { padding: 2px 8px; border-radius: 999px; background: var(--navy-50, #F1F4F9); color: var(--muted); font-weight: 600; }
.pz-move { display: inline-flex; gap: 4px; }

.pz-switch { position: relative; display: inline-flex; cursor: pointer; }
.pz-switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.pz-switch span[aria-hidden] { width: 40px; height: 24px; border-radius: 999px; background: #AAB3C1; position: relative; transition: background 160ms; }
.pz-switch span[aria-hidden]::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(25,36,54,.3); transition: transform 160ms cubic-bezier(.25,1,.5,1); }
.pz-switch input:checked + .sr-only + span[aria-hidden] { background: var(--teal-700); }
.pz-switch input:checked + .sr-only + span[aria-hidden]::after { transform: translateX(16px); }
.pz-switch input:focus-visible + .sr-only + span[aria-hidden] { outline: 2px solid var(--teal-700); outline-offset: 2px; }

.pz-segmented { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 10px; background: var(--navy-50, #F1F4F9); }
.pz-segmented label { position: relative; }
.pz-segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.pz-segmented span { display: block; min-height: 36px; padding: 8px 14px; border-radius: 7px; font-weight: 600; color: var(--muted); cursor: pointer; }
.pz-segmented input:checked + span { background: var(--white, #fff); color: var(--pz-accent-text, var(--teal-700)); box-shadow: 0 1px 3px rgba(25,36,54,.12); }
.pz-segmented input:checked + span::before { content: "✓ "; }
.pz-segmented input:focus-visible + span { outline: 2px solid var(--teal-700); outline-offset: 2px; }

.pz-swatches { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.pz-swatch, .pz-face { position: relative; cursor: pointer; }
.pz-swatch input, .pz-face input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.pz-swatch { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.pz-swatch span { flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--swatch); }
.pz-swatch:has(input:checked) { border-color: var(--swatch-border, var(--ink)); box-shadow: 0 0 0 2px var(--teal-50); }
.pz-swatch:has(input:checked) span { box-shadow: 0 0 0 2px var(--white, #fff), 0 0 0 4px var(--swatch); }
.pz-swatch:has(input:checked) small::after { content: " ✓"; }
.pz-swatch:has(input:focus-visible), .pz-face:has(input:focus-visible) { outline: 2px solid var(--teal-700); outline-offset: 2px; }
.pz-faces { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.pz-face span[aria-hidden] { display: grid; place-items: center; height: 44px; border: 1px solid var(--line); border-radius: 8px; font-size: 22px; }
.pz-face:has(input:checked) span[aria-hidden] { border-color: var(--teal-700); background: var(--teal-50); box-shadow: inset 0 0 0 1px var(--teal-700); }
.pz-check { display: flex; align-items: center; gap: 10px; min-height: 40px; cursor: pointer; }
.pz-check input { width: 18px; height: 18px; accent-color: var(--teal-700); }

.pz-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; padding: 14px 24px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: var(--white, #fff); }
.pz-status { flex: 1; min-width: 120px; color: var(--muted); }
.pz-status[data-tone="ok"] { color: var(--stable-fg, #1E6443); }
.pz-status[data-tone="error"] { color: var(--risk-fg, #A12C2C); }
.pz-status[data-tone="ok"]::before { content: "✓ "; }
.pz-foot .text-link { font-size: 14px; line-height: 20px; }
.pz-actions { display: inline-flex; gap: 8px; margin-left: auto; }
@media (max-width: 520px) {
  .pz-swatches { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pz-section { grid-template-columns: 14px minmax(0, 1fr) auto; }
  .pz-move { grid-column: 2 / -1; justify-content: flex-end; }
  .pz-actions { width: 100%; }
  .pz-actions .button { flex: 1; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  .pz-sheet[open] { animation: none; }
  .pz-switch span[aria-hidden], .pz-switch span[aria-hidden]::after { transition: none; }
}

/* ==========================================================================
   Dark theme ("mar profundo" from the landing), only for the patient space.
   Surfaces: page #121B2A, raised #1F2C42, chrome #192436. Text #FFF / #C9D1DE / #9AA3B2.
   ========================================================================== */
body.pz-dark {
  color-scheme: dark;
  --white: #1F2C42;
  --bg: #121B2A;
  --line: rgba(201, 209, 222, .16);
  --muted: #B8C1CF;
  --ink: #E8EDF4;
  --navy-50: rgba(255, 255, 255, .06);
  --blue: rgba(141, 180, 232, .14);
  --amber: rgba(232, 145, 58, .16);
  --amber-ink: #F2C08E;
  --red: rgba(214, 69, 69, .18);
  --red-ink: #F3A5A5;
  background: #121B2A;
  color: #C9D1DE;
}
body.pz-dark .topbar, body.pz-dark .app-footer { background: #192436; border-color: var(--line); }
body.pz-dark .topbar .button, body.pz-dark .breadcrumbs strong, body.pz-dark .signed-in-name { color: #FFFFFF; }
body.pz-dark .breadcrumbs, body.pz-dark .secure-label, body.pz-dark .reset-link { color: #B8C1CF; }
body.pz-dark .page-content, body.pz-dark .main-area, body.pz-dark .app-shell { background: #121B2A; }
body.pz-dark .patient-workspace .care-sidebar, body.pz-dark .patient-workspace.portal-workspace .care-sidebar { background: #192436; border-color: var(--line); }
body.pz-dark .patient-workspace .care-sidebar nav button { color: #C9D1DE; }
body.pz-dark .patient-workspace .care-sidebar nav button:hover { background: rgba(255,255,255,.06); }
body.pz-dark .patient-workspace .care-sidebar nav button.active { background: rgba(255,255,255,.08); }
body.pz-dark .patient-workspace .brand-logo { filter: brightness(0) invert(1); }
body.pz-dark .patient-workspace h1, body.pz-dark .patient-workspace h2, body.pz-dark .patient-workspace h3,
body.pz-dark .patient-workspace h4, body.pz-dark .patient-workspace strong, body.pz-dark .pz-sheet h2 { color: #FFFFFF; }
body.pz-dark .patient-workspace p, body.pz-dark .patient-workspace small, body.pz-dark .patient-workspace label,
body.pz-dark .patient-workspace li, body.pz-dark .patient-workspace td { color: #C9D1DE; }
body.pz-dark .patient-workspace .quiet-note, body.pz-dark .patient-workspace .care-section-heading p { color: #B8C1CF; }

body.pz-dark .patient-workspace :is(.panel, .stat-card, .patient-action-card, .appointment-card, .agenda-task, .patient-week-day,
  .patient-course-quiz, .patient-course-reflection, .patient-share-option, .patient-ai-audio-composer, .consent-copy, .notice,
  .empty-state, .response-card, .message, .participant-message, .choice, .patient-ai-starters button, .cn-patient-card,
  .patient-course-card, .patient-program-row, .event-tag, .tag) {
  background: #1F2C42; border-color: var(--line); color: #C9D1DE; box-shadow: none;
}
body.pz-dark .patient-workspace .hero-panel { background: #0E1522; }
body.pz-dark .patient-workspace .notice { background: rgba(255,255,255,.05); }
body.pz-dark .patient-workspace :is(.field, .select, .textarea, input[type="text"], input[type="email"], input[type="tel"], input[type="date"], input[type="time"], select, textarea) {
  background: #121B2A; border-color: #7E8798; color: #FFFFFF;
}
body.pz-dark .patient-workspace :is(.field, .textarea)::placeholder { color: #9AA3B2; }
body.pz-dark :is(.patient-workspace, .pz-sheet) .button:not(.button-primary):not(.button-danger) { background: transparent; border-color: #C9D1DE; color: #FFFFFF; }
body.pz-dark :is(.patient-workspace, .pz-sheet) .button-soft { background: rgba(255,255,255,.08); border-color: transparent; color: var(--pz-accent-text); }
body.pz-dark .patient-workspace .button-danger { background: transparent; border-color: #F3A5A5; color: #F3A5A5; }
body.pz-dark .patient-workspace .choice.selected { background: rgba(255,255,255,.1); border-color: var(--pz-accent-text); color: #FFFFFF; }
body.pz-dark .patient-workspace .patient-ai-message { background: #1F2C42; border-color: var(--line); }
body.pz-dark .patient-workspace .patient-ai-message-own { background: rgba(255,255,255,.1); }
body.pz-dark .patient-workspace .status { background: rgba(255,255,255,.08); color: #E8EDF4; }
body.pz-dark .patient-workspace .status.teal { color: #7CC4A0; }
body.pz-dark .patient-workspace :is(.status.review, .status.amber) { color: #F2C08E; }
body.pz-dark .patient-workspace .status.red { color: #F3A5A5; }
body.pz-dark .patient-workspace .status.blue { color: #A9C3E8; }
body.pz-dark .patient-workspace .cn-avatar { background: rgba(255,255,255,.1); color: #FFFFFF; }
body.pz-dark .patient-workspace .cn-chip { background: rgba(255,255,255,.08); color: var(--pz-accent-text); }
body.pz-dark .patient-workspace.pz-layout-list .patient-quick-grid { background: #1F2C42; }
body.pz-dark .pz-avatar-button { background: #1F2C42; border-color: var(--line); }
body.pz-dark .pz-sheet { background: #192436; color: #C9D1DE; border-color: var(--line); }
body.pz-dark .pz-sheet :is(.pz-section, .pz-foot) { background: #1F2C42; }
body.pz-dark .pz-sheet .pz-segmented input:checked + span { background: #33425E; color: #FFFFFF; }
body.pz-dark .pz-sheet .pz-group legend, body.pz-dark .pz-sheet strong { color: #FFFFFF; }
body.pz-dark .pz-sheet .pz-swatch:has(input:checked) { border-color: #FFFFFF; }
body.pz-dark .pz-sheet .pz-swatch:has(input:checked) span { box-shadow: 0 0 0 2px #192436, 0 0 0 4px var(--swatch); }
body.pz-dark .pz-sheet .pz-status[data-tone="ok"] { color: #7CC4A0; }
body.pz-dark .pz-sheet .pz-status[data-tone="error"] { color: #F3A5A5; }
body.pz-dark .pz-switch span[aria-hidden] { background: #566076; }
body.pz-dark .pz-sheet .text-link { color: var(--pz-accent-text); }

/* Dark mode: chrome and decorations that use fixed light colors elsewhere. */
body.pz-dark .topbar .button { background: transparent; border-color: #C9D1DE; color: #FFFFFF; }
body.pz-dark .patient-workspace .hero-panel::after { background: #121B2A; }
body.pz-dark .patient-workspace .care-sidebar nav button.active,
body.pz-dark .patient-workspace .care-sidebar nav button.active * { color: var(--pz-accent-text); }
body.pz-dark .patient-workspace .care-sidebar nav button.active .care-nav-icon svg { stroke: currentColor; }

/* The week calendar scrolls inside its panel instead of widening the page. */
.patient-care-view, .patient-care-view > .panel, .patient-week-calendar, .patient-week-grid { min-width: 0; max-width: 100%; }

/* Dark mode: rules elsewhere set heading and tile colors with higher specificity. */
body.pz-dark .portal-workspace.patient-workspace :is(h1, h2, h3, h4),
body.pz-dark .portal-workspace.care-workspace.patient-workspace .care-section-heading h1 { color: #FFFFFF; }
body.pz-dark .patient-workspace .appointment-time { background: rgba(255, 255, 255, .08); color: #FFFFFF; }
body.pz-dark .patient-workspace .appointment-time strong { color: #FFFFFF; }
body.pz-dark .patient-workspace .appointment-time span { color: #C9D1DE; }
body.pz-dark .patient-workspace .patient-activity-mark { background: rgba(255, 255, 255, .1); color: var(--pz-accent-text); border-color: transparent; }
body.pz-dark .patient-workspace .patient-week-day h4 strong { color: #FFFFFF; }
body.pz-dark .patient-workspace .patient-week-day h4 { color: #C9D1DE; }
body.pz-dark .patient-workspace :is(.patient-course-hero, .patient-course-intro > .patient-course-evidence:first-child)::after {
  background: radial-gradient(circle, rgba(92, 194, 186, .14) 0%, rgba(92, 194, 186, 0) 72%);
}
body.pz-dark .patient-workspace :is(.patient-course-progress, .patient-checkin-progress > div, .progress-track) { background: rgba(255, 255, 255, .12); }

/* Visual parts of the custom controls let clicks reach the real input underneath. */
.pz-switch span[aria-hidden], .pz-segmented span, .pz-swatch > span, .pz-swatch small, .pz-face span { pointer-events: none; }
.pz-segmented input, .pz-swatch input, .pz-face input, .pz-switch input { z-index: 1; }

/* ---------- Demo mode top bar: view switcher ---------- */
.demo-view-switch { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 600; }
.demo-view-switch .select { width: auto; min-height: 36px; padding: 6px 30px 6px 10px; }
@media (max-width: 760px) { .demo-view-switch span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); } }
#authForm[aria-busy="true"] input { opacity: .7; }
