/* Registro de pacientes · Aurrera Klinika · sistema visual Apple (tokens heredados de facturas-eden). Solo modo claro. */
:root {
  color-scheme: light;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  --canvas: #f5f5f7;
  --surface: #ffffff;
  --ink: #1d1d1f;
  --ink-2: #6e6e73;
  --ink-3: #86868b;
  --accent: #0077b6;          /* azul del logo oscurecido para cumplir AA sobre blanco */
  --accent-hover: #0083c8;
  --accent-rgb: 0, 119, 182;
  --celeste: #37bcee;
  --turquesa: #00b2a9;
  --hairline: rgba(0, 0, 0, 0.08);
  --hairline-strong: rgba(0, 0, 0, 0.18);
  --fill: rgba(0, 0, 0, 0.05);
  --fill-2: rgba(0, 0, 0, 0.08);
  --ok: #1f8a3d;
  --danger: #d70015;
  --danger-rgb: 215, 0, 21;
  --shadow-card: 0 1px 4px rgba(0, 0, 0, 0.05), 0 0 1px rgba(0, 0, 0, 0.04);
  --shadow-float: 0 24px 60px rgba(0, 0, 0, 0.10), 0 4px 12px rgba(0, 0, 0, 0.05);
  --ambient:
    radial-gradient(900px 480px at 15% -10%, rgba(0, 133, 202, 0.07), transparent 70%),
    radial-gradient(700px 420px at 95% 5%, rgba(55, 188, 238, 0.06), transparent 70%),
    radial-gradient(600px 400px at 60% 110%, rgba(0, 178, 169, 0.06), transparent 70%);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --radius-card: 18px;
  --radius-input: 12px;
}


*, *::before, *::after { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--ambient), var(--canvas);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.47059;
  letter-spacing: -0.022em;
}
::selection { background: rgba(var(--accent-rgb), 0.18); }
input, select, textarea, button { font: inherit; letter-spacing: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Hover instantáneo tipo macOS: entra sin rampa, sale con transición */
@media (hover: hover) {
  :where(a, button):hover { transition-duration: 0s; }
}

.page {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: calc(56px + env(safe-area-inset-top)) 20px calc(40px + env(safe-area-inset-bottom));
}

/* Volver: fijo arriba a la izquierda, fuera del flujo de la página, cristal translúcido tipo iOS */
.back {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  left: calc(14px + env(safe-area-inset-left));
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px 0 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 0 0 1px var(--hairline), var(--shadow-card);
  color: var(--accent);
  font-size: 15px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.01em;
  text-decoration: none;
  transition: background 200ms var(--ease), transform 200ms var(--ease);
}
.back:hover { background: rgba(255, 255, 255, 0.95); text-decoration: none; }
.back:active { transform: scale(0.96); }
.back:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.back svg { flex: none; }
/* En escritorio queda a la altura del logo y fuera de la columna: su borde derecho queda a 24 px del borde izquierdo
   de la tarjeta (ancho 600 − 2×20 de padding). Entre 680 y 960 px no cabe fuera: se alinea con el borde. */
@media (min-width: 680px) {
  .back { left: calc(50% - 280px); top: calc(76px + env(safe-area-inset-top)); }
}
@media (min-width: 960px) {
  .back { left: auto; right: calc(50% + 280px + 24px); } /* 24 px de aire respecto a la tarjeta */
}

.brand { display: flex; justify-content: center; margin: 12px 0 34px; }
.brand img { height: 44px; width: auto; }
@media (min-width: 600px) { .brand img { height: 52px; } .page { padding-top: calc(64px + env(safe-area-inset-top)); } }

.hero { text-align: center; margin-bottom: 30px; }
.hero h1 {
  margin: 0 0 8px;
  font-size: 32px;
  line-height: 1.125;
  font-weight: 600;
  letter-spacing: -0.012em;
}
.hero p { margin: 0 auto; max-width: 42ch; font-size: 17px; color: var(--ink-2); }
@media (min-width: 600px) { .hero h1 { font-size: 40px; letter-spacing: -0.015em; } .hero p { font-size: 19px; letter-spacing: 0.012em; } }

.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 28px 20px;
  border: 0;
}
@media (min-width: 600px) { .card { padding: 36px 40px; box-shadow: var(--shadow-float); border-color: transparent; } }

.section { margin-bottom: 26px; }
.section + .section { padding-top: 10px; }
.eyebrow {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
}

.grid { display: grid; gap: 12px; }
@media (min-width: 480px) { .grid.two { grid-template-columns: 1fr 1fr; } }

/* ---------- Campo con etiqueta flotante (estilo Apple ID) ---------- */
.field { position: relative; }
.field input, .field select {
  width: 100%;
  min-height: 56px;
  padding: 24px 16px 8px;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-input);
  background: var(--surface);
  color: var(--ink);
  font-size: 17px;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 160ms ease-out, box-shadow 160ms ease-out;
}
.field input::placeholder { color: transparent; }
.field label {
  position: absolute;
  left: 17px;
  top: 28px; /* mitad del input (56px), no del .field (que incluye el error) */
  transform: translateY(-50%);
  color: var(--ink-2);
  font-size: 17px;
  pointer-events: none;
  transform-origin: left top;
  transition: transform 180ms var(--ease), color 160ms, font-size 180ms var(--ease), top 180ms var(--ease);
}
.field input:focus + label,
.field input:not(:placeholder-shown) + label,
.field.always-up label,
.field select + label {
  top: 9px;
  transform: none;
  font-size: 12px;
  color: var(--ink-2);
}
.field input:focus, .field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.22);
}
.field input[aria-invalid="true"], .field select[aria-invalid="true"] {
  border-color: rgba(var(--danger-rgb), 0.7);
}
.field input[aria-invalid="true"]:focus { box-shadow: 0 0 0 4px rgba(var(--danger-rgb), 0.18); }
.field .error {
  display: none;
  /* aria-live en el HTML */
  margin: 6px 4px 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--danger);
}
.field.invalid .error { display: block; }
.hint { margin: 6px 4px 0; font-size: 13px; color: var(--ink-3); }
.field select { padding-right: 40px; cursor: pointer; }
.field .chev {
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--ink-2); pointer-events: none;
}
/* ---------- Fecha: máscara dd/mm/aaaa + calendario propio ---------- */
.field.date input { padding-right: 52px; font-variant-numeric: tabular-nums; }
.cal-btn {
  position: absolute; right: 6px; top: 6px;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 0; border-radius: 10px; background: transparent; color: var(--ink-2);
  transition: background 150ms, color 150ms;
}
.cal-btn:hover { background: var(--fill); color: var(--ink); }
.cal-btn[aria-expanded="true"] { color: var(--accent); background: rgba(var(--accent-rgb), 0.1); }
.cal-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cal-btn svg { width: 20px; height: 20px; }
.cal {
  position: absolute; z-index: 20; right: 0; top: calc(100% + 8px);
  width: 312px; max-width: calc(100vw - 40px);
  padding: 14px 12px 12px;
  background: rgba(255, 255, 255, 0.97);
  -webkit-backdrop-filter: blur(24px) saturate(1.8); backdrop-filter: blur(24px) saturate(1.8);
  border-radius: 16px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.75), 0 0 0 0.5px rgba(0,0,0,0.06), 0 12px 36px rgba(0,0,0,0.10), 0 2px 8px rgba(0,0,0,0.05);
  transform-origin: top right;
  animation: cal-in 260ms var(--ease);
}
@supports not (backdrop-filter: blur(1px)) { .cal { background: #fff; } }
@keyframes cal-in { from { opacity: 0; transform: scale(0.94) translateY(-6px); } to { opacity: 1; transform: none; } }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 10px; }
.cal-title { display: flex; gap: 2px; flex: 1; justify-content: center; }
#cal-mes { min-width: 128px; text-align: left; }
.cal-title select {
  appearance: none; -webkit-appearance: none;
  border: 0; border-radius: 8px; background: transparent;
  padding: 6px 22px 6px 8px; font-size: 15px; font-weight: 600; color: var(--ink); cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path d='M3 4.5l3 3 3-3' fill='none' stroke='%236e6e73' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat; background-position: right 6px center; background-size: 11px;
  transition: background-color 150ms;
}
.cal-title select:hover { background-color: var(--fill); }
.cal-title select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cal-nav {
  width: 36px; height: 36px; border: 0; border-radius: 50%; background: transparent; color: var(--accent);
  display: grid; place-items: center; transition: background 150ms;
}
.cal-nav svg { width: 14px; height: 14px; }
.cal-nav:hover { background: var(--fill); }
.cal-nav:active { transform: scale(0.94); }
.cal-week, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-week span { text-align: center; font-size: 11px; font-weight: 600; color: var(--ink-3); padding: 4px 0 6px; }
.cal-grid button {
  height: 40px; margin: 1px auto; width: 40px;
  border: 0; border-radius: 50%; background: transparent;
  font-size: 15px; color: var(--ink); font-variant-numeric: tabular-nums;
  transition: background 120ms, color 120ms, transform 150ms var(--ease);
}
.cal-grid button:hover { background: var(--fill); }
.cal-grid button:active { transform: scale(0.92); }
.cal-grid button.otro { color: var(--ink-3); }
.cal-grid button.hoy { color: var(--accent); font-weight: 600; }
.cal-grid button.sel { background: var(--accent); color: #fff; font-weight: 600; }
.cal-grid button:disabled { color: var(--ink-3); opacity: 0.4; cursor: default; background: transparent; }
.cal-grid button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
@media (max-width: 480px) {
  .cal { position: fixed; left: 50%; right: auto; top: 50%; transform: translate(-50%, -50%); transform-origin: center; width: min(340px, calc(100vw - 32px)); padding: 16px 14px 14px; }
  @keyframes cal-in { from { opacity: 0; transform: translate(-50%, -50%) scale(0.94); } to { opacity: 1; transform: translate(-50%, -50%); } }
  .cal-grid button { height: 42px; width: 42px; font-size: 16px; }
}
.cal-backdrop { position: fixed; inset: 0; z-index: 19; cursor: default; background: rgba(0,0,0,0.18); animation: fade 200ms; }
@keyframes fade { from { opacity: 0; } }
@media (min-width: 481px) { .cal-backdrop { background: transparent; } }

/* Teléfono: prefijo + número en un solo grupo */
.phone { display: grid; grid-template-columns: 112px 1fr; gap: 12px; }
@media (max-width: 380px) { .phone { grid-template-columns: 96px 1fr; } }

/* ---------- Segmented control (iOS) ---------- */
.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 2px;
  padding: 3px;
  border-radius: 9999px;
  background: var(--fill);
  position: relative;
}
.segmented label {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 9px 12px;
  border-radius: 9999px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
  transition: color 200ms;
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented input:checked + label { color: var(--ink); font-weight: 600; }
.segmented .thumb {
  position: absolute;
  top: 3px; bottom: 3px; left: 3px;
  width: calc(50% - 4px);
  border-radius: 9999px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
  transition: transform 350ms var(--ease);
}
.segmented[data-sel="1"] .thumb { transform: translateX(calc(100% + 2px)); }
.segmented input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Bloque del tutor: se despliega con altura animada */
.reveal { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 420ms var(--ease), opacity 300ms; opacity: 0; }
.reveal > div { overflow: hidden; }
.reveal.open { grid-template-rows: 1fr; opacity: 1; }
.reveal .inner { padding-top: 14px; }

/* ---------- Checkbox (círculo iOS) ---------- */
.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; padding: 6px 0; }
.check input { position: absolute; opacity: 0; width: 0; height: 0; }
.check .box {
  flex: 0 0 auto;
  width: 24px; height: 24px; margin-top: 1px;
  border-radius: 50%;
  border: 1.5px solid var(--hairline-strong);
  background: var(--surface);
  display: grid; place-items: center;
  transition: background 180ms var(--ease), border-color 180ms, transform 180ms var(--ease);
}
.check .box svg { width: 13px; height: 13px; stroke: #fff; stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transform: scale(0.6); transition: opacity 150ms, transform 250ms var(--ease); }
.check input:checked + .box { background: var(--accent); border-color: var(--accent); }
.check input:checked + .box svg { opacity: 1; transform: scale(1); }
.check:active .box { transform: scale(0.92); }
.check input:focus-visible + .box { box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.22); }
.check .text { font-size: 14px; color: var(--ink-2); line-height: 1.45; }
.check .text strong { color: var(--ink); font-weight: 500; }
.check.invalid .box { border-color: var(--danger); }
.check-error { display: none; margin: 4px 0 0 36px; font-size: 13px; font-weight: 500; color: var(--danger); }
.check.invalid + .check-error { display: block; }

.check .mas { display: block; margin-top: 4px; }
.check .mas summary { list-style: none; cursor: pointer; color: var(--accent); font-size: 14px; font-weight: 500; display: inline-block; }
.check .mas summary::-webkit-details-marker { display: none; }
.check .mas summary:hover { text-decoration: underline; }
.check .mas p { margin: 6px 0 0; font-size: 13px; color: var(--ink-2); line-height: 1.5; }

/* ---------- Botón ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  min-height: 52px;
  padding: 12px 24px;
  border: 0;
  border-radius: 9999px;
  background: var(--accent);
  color: #fff;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.01em;
  transition: background-color 200ms ease-out, transform 150ms var(--ease), opacity 200ms;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.btn.secondary { background: var(--fill); color: var(--ink); }
.btn.secondary:hover { background: var(--fill-2); }
.btn .spinner { display: none; width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.35); border-top-color: #fff; animation: spin 0.8s linear infinite; }
.btn.loading .spinner { display: inline-block; }
.btn.loading .label { opacity: 0.85; }
@keyframes spin { to { transform: rotate(360deg); } }

.actions { margin-top: 30px; }
.legal { margin: 12px 0 0; text-align: center; font-size: 12px; color: var(--ink-3); line-height: 1.5; }
.legal a { color: var(--ink-2); }

/* Aviso global (error del servidor) */
.alert {
  display: none;
  margin: 0 0 20px;
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(var(--danger-rgb), 0.08);
  color: var(--danger);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.45;
}
.alert.show { display: block; }
.alert a { color: inherit; text-decoration: underline; }

/* ---------- Pantalla de éxito ---------- */
.done { display: none; text-align: center; padding: 12px 0 4px; }
.done.show { display: block; }
.done .mark { width: 88px; height: 88px; margin: 6px auto 22px; }
.done .mark circle { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-dasharray: 270; stroke-dashoffset: 270; animation: draw 0.5s var(--ease) forwards; }
.done .mark path { fill: none; stroke: var(--accent); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 60; stroke-dashoffset: 60; animation: draw 0.35s 0.3s var(--ease) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.done h2 { margin: 0 0 10px; font-size: 32px; font-weight: 600; letter-spacing: -0.012em; line-height: 1.15; }
.done p { margin: 0 auto 8px; max-width: 40ch; color: var(--ink-2); font-size: 17px; }
.done .actions { display: grid; gap: 10px; margin-top: 28px; }

.footer { margin-top: 28px; text-align: center; font-size: 12px; color: var(--ink-3); }

/* ---------- Entrada "Rise" escalonada ---------- */
.rise { opacity: 0; transform: translateY(18px); animation: rise 0.7s var(--ease) forwards; }
.rise:nth-child(1) { animation-delay: 0.02s; }
.rise:nth-child(2) { animation-delay: 0.09s; }
.rise:nth-child(3) { animation-delay: 0.16s; }
@keyframes rise { to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0s !important; transition-duration: 0.01ms !important; }
  .rise { opacity: 1; transform: none; }
}

.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; }
.hp { position: absolute; left: -9999px; opacity: 0; height: 0; width: 0; }
