/* Cáscara mínima de página para la interfaz de desarrollo/pruebas de Salud
   V1. No toca los estilos de los fragmentos canónicos (van con su propio
   <style> embebido, sin modificar, dentro de cada página). Esto es solo el
   fondo, el ancho de columna y los estados compartidos (carga, vacío,
   error, acceso denegado, conflicto de versión). */
:root { color-scheme: light dark; }

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: clamp(14px, 3vw, 40px);
  background: light-dark(#eef3f8, #0b1622);
  font-family: Manrope, ui-sans-serif, system-ui, sans-serif;
  min-height: 100vh;
}

.fh-session-controls {
  max-width: 1080px;
  margin: 0 auto 12px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  color: light-dark(#526b84, #c2d0df);
  font-size: 0.9rem;
}

.fh-session-controls a,
.fh-session-controls button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid light-dark(#b8c9da, #3a5674);
  border-radius: 9px;
  background: light-dark(#fff, #142943);
  color: light-dark(#17324d, #e7f0f8);
  padding: 8px 14px;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.fh-session-controls a:focus-visible,
.fh-session-controls button:focus-visible {
  outline: 3px solid light-dark(#4779a8, #90c2ed);
  outline-offset: 2px;
}

.fh-page {
  max-width: 1080px;
  margin: 0 auto;
}

.fh-state {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-radius: 10px;
  font-size: 0.92rem;
  margin: 14px 0;
}

.fh-state-loading {
  background: light-dark(#eef3f8, #142943);
  color: light-dark(#526b84, #c2d0df);
}

.fh-state-empty {
  background: light-dark(#f7fafc, #142943);
  color: light-dark(#61788f, #bfd0e2);
  border: 1px dashed light-dark(#c9d6e2, #3a5674);
}

.fh-state-error {
  background: light-dark(#fdecec, #3a1f22);
  color: light-dark(#8a2c2c, #f3b0b0);
  border: 1px solid light-dark(#f0c6c6, #5c2b30);
}

.fh-state-denied {
  background: light-dark(#fff6e5, #493716);
  color: light-dark(#80580f, #f2d18a);
  border: 1px solid light-dark(#f0d9a6, #6b501f);
}

.fh-state-info {
  background: light-dark(#eef6fc, #142943);
  color: light-dark(#315f83, #c5e3fa);
  border: 1px solid light-dark(#c8dff0, #355779);
}

.fh-state-conflict {
  background: light-dark(#fdecec, #3a1f22);
  color: light-dark(#8a2c2c, #f3b0b0);
  border: 1px solid light-dark(#f0c6c6, #5c2b30);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.fh-state-conflict button {
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  border-radius: 8px;
  padding: 7px 11px;
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}

[hidden] { display: none !important; }

a.fh-plain, button.fh-plain {
  all: unset;
  cursor: pointer;
}

/* --- Shell de Ajustes (Family Hub V1, Mi espacio) -------------------------
   No hay mockup canónico aprobado para Ajustes todavía (los mockups de
   revisión son evidencia de diseño en revisión, no activos canónicos --
   ver ACTIVOS_CANONICOS_SALUD_V1.md, que no los incluye). Este shell es
   marcado nuevo, coherente en tipografía/paleta con los fragmentos
   canónicos de Salud (Navy Trust / Manrope), reutilizable por las cuatro
   páginas de esta fase y por cualquier página de Ajustes futura. */
.fh-ajustes-shell {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  min-height: 470px;
  background: light-dark(#ffffff, #102036);
  border: 1px solid light-dark(#d9e3ee, #2a405c);
  border-radius: 18px;
  overflow: hidden;
  color: light-dark(#17324d, #edf4fb);
}

.fh-ajustes-side {
  padding: 24px 16px;
  background: light-dark(#f7fafc, #13243b);
  border-right: 1px solid light-dark(#e4ebf3, #2a405c);
  display: flex;
  flex-direction: column;
  gap: 25px;
}

.fh-ajustes-brand {
  font-weight: 700;
  letter-spacing: -0.03em;
  color: light-dark(#17324d, #f3f7fc);
  display: flex;
  align-items: center;
  gap: 9px;
}

.fh-ajustes-mark {
  width: 22px;
  height: 22px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px;
}
.fh-ajustes-mark span { background: light-dark(#17324d, #7db9e8); border-radius: 5px; }

.fh-ajustes-side nav { display: grid; gap: 6px; }

.fh-ajustes-navlink {
  border: 0;
  background: transparent;
  color: light-dark(#526b84, #b9c9da);
  padding: 10px 11px;
  text-align: left;
  border-radius: 9px;
  font: inherit;
  display: flex;
  gap: 10px;
  align-items: center;
  cursor: pointer;
}
.fh-ajustes-navlink.active {
  background: light-dark(#e8f2f9, #1d3b5a);
  color: light-dark(#17324d, #f1f7fd);
  font-weight: 700;
}

.fh-ajustes-main { padding: 34px clamp(22px, 5vw, 62px); }

.fh-ajustes-back {
  display: inline-block;
  margin: 0 0 14px;
  color: light-dark(#315f83, #a9d5f4);
  font-weight: 650;
  text-decoration: none;
}
.fh-ajustes-back:hover, .fh-ajustes-cancel:hover { text-decoration: underline; }
.fh-ajustes-cancel {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid light-dark(#b9c8d8, #46617e);
  border-radius: 9px;
  color: light-dark(#315f83, #c5e3fa);
  font: inherit;
  font-weight: 650;
  text-decoration: none;
}

.fh-ajustes-crumb {
  color: light-dark(#64748b, #b6c6d7);
  margin-bottom: 20px;
  display: block;
}
.fh-ajustes-crumb a { color: inherit; text-decoration: none; }
.fh-ajustes-crumb a:hover { text-decoration: underline; }

.fh-ajustes-main h1 {
  margin: 0 0 10px;
  color: light-dark(#17324d, #f3f7fc);
  font-size: clamp(1.5rem, 3vw, 2rem);
  letter-spacing: -0.04em;
}

.fh-ajustes-lead {
  max-width: 580px;
  color: light-dark(#526b84, #c2d0df);
  margin: 0 0 28px;
}

/* Portada: tarjetas de recorrido -- cada una abre su propia página, nunca
   despliega un formulario debajo (CONSOLIDACION_AJUSTES_FAMILY_HUB_V1_PARA_REVISION.md §2). */
.fh-ajustes-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  max-width: 720px;
}

.fh-ajustes-card {
  text-align: left;
  border: 1px solid light-dark(#d9e3ee, #2a405c);
  background: light-dark(#ffffff, #142943);
  border-radius: 13px;
  padding: 22px;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.fh-ajustes-card:disabled { opacity: 0.55; cursor: not-allowed; }

.fh-ajustes-card-title {
  display: flex;
  gap: 10px;
  align-items: center;
  font-weight: 700;
  font-size: 1.05rem;
}

.fh-ajustes-card p {
  margin: 10px 0 0;
  color: light-dark(#61788f, #bfd0e2);
  line-height: 1.5;
}

/* Formularios de Perfil/Preferencias. */
.fh-ajustes-form {
  display: grid;
  gap: 16px;
  max-width: 480px;
}

.fh-ajustes-form label {
  display: grid;
  gap: 6px;
  color: light-dark(#61788f, #bfd0e2);
  font-size: 0.85rem;
}

.fh-ajustes-form input,
.fh-ajustes-form select {
  box-sizing: border-box;
  width: 100%;
  padding: 10px 11px;
  border: 1px solid light-dark(#b9c8d8, #46617e);
  border-radius: 9px;
  background: light-dark(#fff, #162b45);
  color: light-dark(#17324d, #eef6fc);
  font: inherit;
}

.fh-ajustes-form-static {
  color: light-dark(#526b84, #c2d0df);
  font-size: 0.85rem;
}
.fh-ajustes-form-static strong { color: light-dark(#17324d, #edf4fb); font-weight: 600; }

.fh-ajustes-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 6px;
}

.fh-ajustes-save {
  border: 0;
  border-radius: 9px;
  background: light-dark(#17324d, #7db9e8);
  color: light-dark(#fff, #0d2237);
  font: inherit;
  font-weight: 700;
  padding: 11px 16px;
  cursor: pointer;
}
.fh-ajustes-save:disabled { opacity: 0.6; cursor: not-allowed; }

.fh-ajustes-saved-note {
  color: light-dark(#2f7a4f, #7fd1a1);
  font-size: 0.85rem;
}

@media (max-width: 620px) {
  .fh-ajustes-shell { grid-template-columns: 1fr; }
  .fh-ajustes-side { display: none; }
  .fh-ajustes-main { padding: 24px 18px; }
  /* auto-fit/minmax(220px,1fr) todavía intenta 2 columnas de 220px+ antes
     de colapsar a 1 -- en un viewport angosto (390px) eso desborda. Se
     fuerza una sola columna explícita en vez de depender del auto-fit. */
  .fh-ajustes-cards { grid-template-columns: 1fr; }
}

/* --- Mi familia / Personas (Participación Familiar V1, FP-B) -------------
   Estructura, jerarquía visual, menú de tres puntos, estados, acciones
   sensibles y confirmaciones vinculantes de
   `docs/mockups/family-hub-participation-v1/` (PR documental #113, rama
   `docs/family-participation-mockups`) -- paleta y tipografía siguen el
   sistema `--fh-ajustes-*`/light-dark ya establecido (mismo criterio que
   Ajustes: sin mockup canónico "congelado" en `ACTIVOS_CANONICOS_SALUD_V1.md`
   todavía, así que se reutilizan los tokens de color vigentes en vez de la
   paleta propia del archivo de mockup, que es evidencia de estructura, no
   de color final). */
.fh-familia-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin: 8px 0 20px;
}

.fh-familia-control,
.fh-familia-btn {
  border: 1px solid light-dark(#b9c8d8, #46617e);
  border-radius: 10px;
  padding: 10px 14px;
  font: inherit;
  font-size: 0.92rem;
  background: light-dark(#fff, #162b45);
  color: light-dark(#17324d, #eef6fc);
  cursor: pointer;
}

.fh-familia-btn.primary {
  border: 0;
  background: light-dark(#17324d, #7db9e8);
  color: light-dark(#fff, #0d2237);
  font-weight: 700;
}

.fh-familia-btn.ghost {
  background: transparent;
}

.fh-familia-btn.danger {
  border: 0;
  background: light-dark(#b8323d, #e5828c);
  color: #fff;
  font-weight: 700;
}

.fh-familia-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.fh-familia-table {
  border: 1px solid light-dark(#d9e3ee, #2a405c);
  border-radius: 14px;
  overflow: hidden;
}

.fh-familia-row {
  display: grid;
  grid-template-columns: 2fr 1.2fr 1.2fr 1.2fr 48px;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid light-dark(#d9e3ee, #2a405c);
  font-size: 0.92rem;
  position: relative;
}
.fh-familia-row:last-child { border-bottom: none; }

.fh-familia-row.head {
  background: light-dark(#f5f9fd, #142943);
  font-weight: 700;
  color: light-dark(#61788f, #bfd0e2);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.fh-familia-row-name { font-weight: 700; }
.fh-familia-row-sub {
  display: block;
  font-weight: 400;
  color: light-dark(#61788f, #bfd0e2);
  font-size: 0.85rem;
  margin-top: 2px;
}

.fh-familia-badge {
  display: inline-block;
  padding: 5px 10px;
  border-radius: 999px;
  background: light-dark(#e7f1fb, #1c3550);
  color: light-dark(#215c8a, #9cc6ee);
  font-weight: 650;
  font-size: 0.82rem;
}
.fh-familia-badge.managed { background: light-dark(#edf0f5, #24384f); color: light-dark(#4d6075, #b7c6d8); }
.fh-familia-badge.pending { background: light-dark(#fff2d9, #4a3712); color: light-dark(#9b6200, #f2c46b); }
.fh-familia-badge.suspended { background: light-dark(#fdecec, #3a1f22); color: light-dark(#8a2c2c, #f3b0b0); }
.fh-familia-badge.ended { background: light-dark(#f0f0f0, #2b2b2b); color: light-dark(#707070, #a0a0a0); }

.fh-familia-menu-wrap { position: relative; text-align: center; }
.fh-familia-dots {
  all: unset;
  cursor: pointer;
  font-size: 1.3rem;
  line-height: 1;
  padding: 6px 10px;
  border-radius: 8px;
  color: light-dark(#61788f, #bfd0e2);
}
.fh-familia-dots:hover { background: light-dark(#eef3f8, #1c3550); }

.fh-familia-menu {
  /* `position`/`top`/`left` los fija JS en línea (`position: fixed`,
     anclado a coordenadas de pantalla) -- ver
     pagina-ajustes-mi-familia-personas.js. La tabla usa `overflow: hidden`
     para las esquinas redondeadas, así que un menú posicionado dentro de
     la fila (`position: absolute` relativo a `.fh-familia-menu-wrap`)
     quedaría recortado. */
  z-index: 5;
  min-width: 210px;
  background: light-dark(#fff, #142943);
  border: 1px solid light-dark(#d9e3ee, #2a405c);
  border-radius: 12px;
  box-shadow: 0 12px 30px light-dark(#28405c26, #00000060);
  padding: 6px;
  text-align: left;
}

.fh-familia-menu button {
  all: unset;
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border-radius: 8px;
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  color: light-dark(#17324d, #eef6fc);
}
.fh-familia-menu button:hover { background: light-dark(#eef3f8, #1c3550); }
.fh-familia-menu button.danger { color: light-dark(#b8323d, #f3b0b0); }

.fh-familia-archived-note {
  margin-top: 22px;
  color: light-dark(#61788f, #bfd0e2);
  font-size: 0.88rem;
}

/* Modales (invitación, alta/edición de persona, acciones sensibles) --
   comparten el mismo overlay/caja. */
.fh-familia-modal-overlay {
  position: fixed;
  inset: 0;
  background: light-dark(#17324d40, #00000080);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 20;
}

.fh-familia-modal {
  max-width: 560px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  background: light-dark(#fff, #142943);
  border: 1px solid light-dark(#d9e3ee, #2a405c);
  border-radius: 18px;
  padding: 28px;
  box-shadow: 0 20px 55px light-dark(#28405c26, #00000070);
}

.fh-familia-modal h2 { margin: 0 0 8px; font-size: 1.35rem; }
.fh-familia-modal .fh-ajustes-lead { margin: 0 0 20px; font-size: 0.95rem; }

.fh-familia-field { margin: 16px 0; }
.fh-familia-field label {
  display: block;
  font-size: 0.82rem;
  color: light-dark(#61788f, #bfd0e2);
  margin-bottom: 6px;
}
.fh-familia-field input,
.fh-familia-field select,
.fh-familia-field textarea {
  box-sizing: border-box;
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid light-dark(#b9c8d8, #46617e);
  border-radius: 9px;
  background: light-dark(#fff, #162b45);
  color: light-dark(#17324d, #eef6fc);
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.35;
}
.fh-familia-field input:focus-visible,
.fh-familia-field select:focus-visible,
.fh-familia-field textarea:focus-visible {
  outline: 3px solid light-dark(#82b8e2, #5b9bd0);
  outline-offset: 2px;
}
.fh-familia-scope {
  padding: 12px 14px;
  background: light-dark(#f4f8fc, #0f2338);
  border-radius: 10px;
  color: light-dark(#526b84, #c2d0df);
  font-size: 0.9rem;
}

.fh-familia-linkbox {
  font-family: ui-monospace, monospace;
  border: 1px dashed light-dark(#8ba8c3, #46617e);
  padding: 12px;
  border-radius: 10px;
  overflow-wrap: break-word;
  color: light-dark(#215c8a, #9cc6ee);
  font-size: 0.85rem;
  cursor: text;
  user-select: all;
}

.fh-familia-copy-btn {
  margin-top: 8px;
  border: 1px solid light-dark(#b9c8d8, #46617e);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 0.85rem;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.fh-familia-notice {
  padding: 16px 18px;
  border-radius: 12px;
  background: light-dark(#fff5f5, #3a1f22);
  border-left: 4px solid light-dark(#b8323d, #e5828c);
  color: light-dark(#7a2730, #f3b0b0);
  margin: 18px 0;
  font-size: 0.9rem;
}

.fh-familia-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 26px;
}

/* Tabla de Módulos (FP-C) -- 3 columnas (Módulo/Estado/Acción) en vez de
   las 4+dots de Personas/Autorizaciones; misma tabla/fila/badge base. */
#fh-tabla-modulos .fh-familia-row { grid-template-columns: 2fr 1fr 1fr; }

@media (max-width: 620px) {
  .fh-familia-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .fh-familia-row.head { display: none; }
  .fh-familia-menu-wrap { text-align: left; position: absolute; top: 14px; right: 16px; }
  .fh-familia-row { position: relative; padding-right: 52px; }
  .fh-familia-toolbar { justify-content: stretch; }
  .fh-familia-toolbar > * { flex: 1; }
  .fh-familia-modal { padding: 20px; }
}
/* El valor del indicador queda centrado respecto del bloque cuando el
   nombre ocupa más de una línea. La especificidad evita que la regla base
   del fragmento canónico vuelva a imponer la alineación por línea base. */
.fh-page #family-hub-health-history .fh-row > .fh-mainval {
  align-items: center;
}
