/* ============================================================
   styles.css — Portal del ecosistema de Calidad y Seguridad del Paciente
   Tokens copiados de Auditorías (los mismos en todas las apps del ecosistema); los componentes propios del portal van al final.
   Móvil primero (360 px). Tema: html[data-tema="claro|oscuro"] (por defecto el del sistema, ver index.html)
   ============================================================ */

:root {
  --bg: #f0f7fb; --bg-2: #ffffff; --bg-3: #e6f3f7; --bg-4: #d4e8ef;
  --border: #b8d4dc; --border-lite: #9bbfca;
  --cyan: #0d9488; --cyan-dim: rgba(13,148,136,.10); --cyan-glow: rgba(13,148,136,.28);
  --green: #15803d; --green-dim: rgba(21,128,61,.10);
  --amber: #b45309; --amber-dim: rgba(180,83,9,.10);
  --red: #be123c; --red-dim: rgba(190,18,60,.08);
  --pink: #be185d;
  --text-1: #0c1e2e; --text-2: #34556e; --text-3: #52697d;  /* text-3 algo más oscuro que en las apps para cumplir AA (4,5:1) */
  --radius: 10px; --radius-lg: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --shadow: 0 8px 32px rgba(13,27,42,.12); --shadow-sm: 0 2px 8px rgba(13,27,42,.06);
  --header-h: 58px;
  --pP: #2563eb; --pH: #15803d; --pV: #c2410c; --pA: #7c3aed;
  --pP-dim: rgba(37,99,235,.10); --pH-dim: rgba(21,128,61,.10); --pV-dim: rgba(194,65,12,.10); --pA-dim: rgba(124,58,237,.10);
  /* Propios del portal: texto sobre el acento (AA) y color de la Guía */
  --on-cyan: #ffffff; --link: #0f766e; --guia: #4f46e5; --guia-dim: rgba(79,70,229,.10);
}
:root[data-tema="oscuro"] {
  --bg: #0d1b2a; --bg-2: #142535; --bg-3: #1b3145; --bg-4: #234058;
  --border: #2d4761; --border-lite: #3f5e80;
  --cyan: #2dd4bf; --cyan-dim: rgba(45,212,191,.13); --cyan-glow: rgba(45,212,191,.32);
  --green: #4ade80; --green-dim: rgba(74,222,128,.13);
  --amber: #fbbf24; --amber-dim: rgba(251,191,36,.13);
  --red: #fb7185; --red-dim: rgba(251,113,133,.13);
  --pink: #f472b6;
  --pP: #60a5fa; --pH: #4ade80; --pV: #fb923c; --pA: #c084fc;
  --pP-dim: rgba(96,165,250,.14); --pH-dim: rgba(74,222,128,.13); --pV-dim: rgba(251,146,60,.14); --pA-dim: rgba(192,132,252,.14);
  --text-1: #e6f0fa; --text-2: #8fb1ce; --text-3: #8aa6bd;
  --shadow: 0 8px 32px rgba(0,0,0,.5); --shadow-sm: 0 2px 8px rgba(0,0,0,.3);
  --on-cyan: #06231f; --link: #2dd4bf; --guia: #a5b4fc; --guia-dim: rgba(165,180,252,.14);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; } }
body { margin: 0; background: var(--bg); color: var(--text-1); font-family: var(--font); font-size: 16px; line-height: 1.5; min-height: 100vh; display: flex; flex-direction: column; }
[hidden] { display: none !important; }
button { font-family: inherit; cursor: pointer; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
a { color: var(--link); }
:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.saltar { position: absolute; left: 8px; top: -60px; z-index: 50; padding: 10px 14px; background: var(--cyan); color: var(--on-cyan); font-weight: 700; border-radius: 10px; text-decoration: none; }
.saltar:focus { top: 8px; }

/* ---------- Header (igual que las apps) ---------- */
.app-header { position: sticky; top: 0; z-index: 30; height: var(--header-h); padding: 0 14px; padding-top: env(safe-area-inset-top); display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--bg-2); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.header-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text-1); min-width: 0; }
.header-logo { width: 38px; height: 38px; flex: none; border-radius: 11px; }
.header-title { display: block; font-weight: 800; font-size: 17px; letter-spacing: -.2px; }
.header-subtitle { display: block; font-size: 11.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-actions { display: flex; gap: 6px; }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-3); color: var(--text-2); font-size: 16px; }
.icon-btn:hover { color: var(--cyan); border-color: var(--cyan); }

/* ---------- Vista y pie ---------- */
.view { flex: 1; width: 100%; max-width: 1060px; margin: 0 auto; padding: 16px 14px 28px; outline: none; }
.app-footer { padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); text-align: center; font-size: 13px; color: var(--text-2); border-top: 1px solid var(--border); background: var(--bg-2); }
.app-footer p { margin: 4px 0; }
.app-footer strong { color: var(--text-1); }

/* ============================================================
   Componentes propios del portal
   ============================================================ */

/* ---------- Portada ---------- */
.hero { padding: 22px 0 8px; display: grid; gap: 12px; }
.hero-kicker { margin: 0; font-size: 12.5px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--link); }
.hero h1 { font-size: clamp(27px, 7vw, 44px); font-weight: 800; letter-spacing: -.8px; max-width: 18ch; }
.hero-lead { margin: 0; font-size: clamp(16px, 2.4vw, 19px); color: var(--text-2); max-width: 62ch; }
.hero-puntos { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 0; padding: 0; list-style: none; }
.hero-puntos li { padding: 6px 12px; border-radius: 999px; font-size: 13.5px; font-weight: 600; color: var(--text-2); background: var(--bg-2); border: 1px solid var(--border); }
.hero-acciones { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--border-lite); background: var(--bg-2); color: var(--text-1); font-weight: 700; font-size: 15px; min-height: 44px; text-decoration: none; }
.btn:hover { border-color: var(--cyan); color: var(--link); }
.btn--primary { background: var(--link); border-color: var(--link); color: var(--on-cyan); }
.btn--primary:hover { color: var(--on-cyan); filter: brightness(1.08); }

/* ---------- Secciones ---------- */
.seccion { margin-top: 34px; scroll-margin-top: calc(var(--header-h) + 10px); }
.seccion-titulo { font-size: 22px; font-weight: 800; letter-spacing: -.3px; display: flex; align-items: center; gap: 10px; }
.seccion-titulo .marca { width: 6px; height: 24px; border-radius: 3px; background: var(--acento, var(--cyan)); flex: none; }
.seccion-lead { margin: 6px 0 14px; color: var(--text-2); font-size: 15px; max-width: 70ch; }

/* ---------- Tarjetas de apps ---------- */
.apps { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
@media (min-width: 640px) { .apps { grid-template-columns: 1fr 1fr; } }
@media (min-width: 980px) { .apps--3 { grid-template-columns: 1fr 1fr 1fr; } }
.app-card { height: 100%; display: flex; gap: 12px; align-items: flex-start; padding: 14px; text-decoration: none; color: var(--text-1); background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); transition: border-color .15s, transform .1s; }
a.app-card:hover { border-color: var(--cyan); }
a.app-card:active { transform: scale(.99); }
.app-icono { width: 52px; height: 52px; flex: none; border-radius: 13px; }
.app-texto { min-width: 0; flex: 1; }
.app-nombre { display: block; font-weight: 800; font-size: 16.5px; }
.app-frase { display: block; margin-top: 2px; font-size: 14px; color: var(--text-2); }
.app-ir { display: inline-block; margin-top: 6px; font-size: 13px; font-weight: 700; color: var(--link); }
.app-etiqueta { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; vertical-align: 2px; color: var(--text-2); background: var(--bg-3); border: 1px solid var(--border); }

/* ---------- Guía (pieza que lo une todo) ---------- */
.guia { display: flex; gap: 14px; align-items: flex-start; padding: 18px; border-radius: var(--radius-lg); background: linear-gradient(135deg, var(--guia-dim), var(--cyan-dim)); border: 1.5px solid var(--guia); }
.guia .app-icono { width: 64px; height: 64px; border-radius: 15px; }
.guia h3 { font-size: 19px; font-weight: 800; }
.guia p { margin: 6px 0 0; color: var(--text-2); font-size: 14.5px; }
.guia-autores { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 12px; }
.guia-nota { color: var(--text-2); font-size: 13px; }
.pronto { display: inline-block; margin-left: 8px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; letter-spacing: .3px; vertical-align: 3px; color: #fff; background: #4338ca; }
:root[data-tema="oscuro"] .pronto { color: #1e1b4b; background: #a5b4fc; }

/* ---------- Mapa de interrelaciones (SVG propio) ---------- */
.mapa { margin: 0; padding: 14px; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.mapa svg { display: block; width: 100%; height: auto; }
.mapa-h { display: none !important; }
@media (min-width: 760px) { .mapa-h { display: block !important; } .mapa-v { display: none !important; } }
.mapa-v { max-width: 420px; margin: 0 auto; }
.mapa figcaption { margin-top: 10px; font-size: 13.5px; color: var(--text-2); }
/* Clases usadas dentro del SVG (heredan el tema) */
.m-fase { font: 800 13px var(--font); fill: var(--text-2); letter-spacing: .4px; text-transform: uppercase; }
.m-caja { fill: var(--bg-3); stroke: var(--border-lite); stroke-width: 1.5; }
.m-app { font: 700 14px var(--font); fill: var(--text-1); }
.m-flecha { stroke: var(--text-3); stroke-width: 2.2; fill: none; }
.m-punta { fill: var(--text-3); }
.m-vuelta { stroke: var(--cyan); stroke-width: 2.2; fill: none; stroke-dasharray: 6 5; }
.m-vuelta-txt { font: 600 13px var(--font); fill: var(--link); }
.m-mejora { fill: var(--cyan-dim); stroke: var(--cyan); stroke-width: 1.5; }
.m-guia { fill: var(--guia-dim); stroke: var(--guia); stroke-width: 1.5; }
.m-guia-txt { font: 700 13.5px var(--font); fill: var(--text-1); }
.m-c1 { stroke: var(--pA); } .m-c2 { stroke: var(--pP); } .m-c3 { stroke: var(--red); } .m-c4 { stroke: var(--pH); } .m-c5 { stroke: var(--pV); } .m-c6 { stroke: var(--cyan); }
.m-t1 { fill: var(--pA); } .m-t2 { fill: var(--pP); } .m-t3 { fill: var(--red); } .m-t4 { fill: var(--pH); } .m-t5 { fill: var(--pV); } .m-t6 { fill: var(--link); }

/* ---------- «Traer de…» ---------- */
.traer { display: grid; gap: 10px; margin: 14px 0 0; padding: 0; list-style: none; }
@media (min-width: 760px) { .traer { grid-template-columns: 1fr 1fr; } }
@media (min-width: 980px) { .traer { grid-template-columns: 1fr 1fr 1fr; } }
.traer li { padding: 12px 14px; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; color: var(--text-2); }
.traer strong { display: block; color: var(--text-1); font-size: 15px; margin-bottom: 4px; }
.traer .chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.traer .chips li { padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--cyan-dim); border: 1px solid var(--cyan-glow); color: var(--text-1); }
.nota { margin: 12px 0 0; padding: 10px 12px; font-size: 14px; color: var(--text-2); background: var(--cyan-dim); border-left: 3px solid var(--cyan); border-radius: 6px; }

/* ---------- Pie: autoría ---------- */
.autoria-area { font-weight: 700; color: var(--text-1); }
.autoria-autores { color: var(--text-2); }
.pie-legal { margin-top: 8px !important; font-size: 12px; color: var(--text-3); }
.nw { white-space: nowrap; }
