/* ─── NiCitas — sistema de diseño (compartido por la web pública y el panel) ─────────────────
   Criterios (skill apple-design): tipografía del sistema con interletraje según el tamaño,
   jerarquía por peso + tamaño + interlineado, materiales translúcidos solo en la capa flotante,
   respuesta inmediata al pulsar, y versiones para movimiento reducido, menos transparencia y
   más contraste. El color de marca llega en --acento (lo pone el servidor desde la configuración). */

:root {
  --acento: #b5502f;
  --acento-tinta: #fff;
  --acento-suave: color-mix(in srgb, var(--acento) 11%, transparent);
  --acento-medio: color-mix(in srgb, var(--acento) 22%, transparent);

  --fondo: #f5f5f7;
  --superficie: #ffffff;
  --superficie-2: #fbfbfd;
  --texto: #1d1d1f;
  --texto-2: #515154;
  --texto-3: #86868b;
  --linea: rgba(0, 0, 0, 0.08);
  --linea-fuerte: rgba(0, 0, 0, 0.14);
  --relleno: rgba(120, 120, 128, 0.12);
  --relleno-2: rgba(120, 120, 128, 0.2);
  --cristal: rgba(255, 255, 255, 0.72);
  --velo: rgba(0, 0, 0, 0.32);
  --ok: #248a3d;
  --aviso: #b25000;
  --mal: #d70015;

  --sombra-1: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
  --sombra-2: 0 2px 6px rgba(0, 0, 0, 0.05), 0 18px 50px rgba(0, 0, 0, 0.10);
  --sombra-3: 0 10px 30px rgba(0, 0, 0, 0.12), 0 40px 100px rgba(0, 0, 0, 0.22);

  --r-xl: 28px; --r-l: 20px; --r-m: 14px; --r-s: 10px;
  --salida: cubic-bezier(0.22, 1, 0.36, 1);        /* asentarse sin rebote (muelle críticamente amortiguado) */
  --ancho: 1120px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --acento-suave: color-mix(in srgb, var(--acento) 22%, transparent);
    --acento-medio: color-mix(in srgb, var(--acento) 36%, transparent);
    --fondo: #000000;
    --superficie: #1c1c1e;
    --superficie-2: #161618;
    --texto: #f5f5f7;
    --texto-2: #c7c7cc;
    --texto-3: #8e8e93;
    --linea: rgba(255, 255, 255, 0.10);
    --linea-fuerte: rgba(255, 255, 255, 0.18);
    --relleno: rgba(120, 120, 128, 0.24);
    --relleno-2: rgba(120, 120, 128, 0.36);
    --cristal: rgba(28, 28, 30, 0.72);
    --velo: rgba(0, 0, 0, 0.56);
    --ok: #30d158; --aviso: #ff9f0a; --mal: #ff453a;
    --sombra-1: 0 0 0 1px rgba(255, 255, 255, 0.06);
    --sombra-2: 0 0 0 1px rgba(255, 255, 255, 0.07), 0 20px 60px rgba(0, 0, 0, 0.5);
    --sombra-3: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 40px 100px rgba(0, 0, 0, 0.7);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 5rem; }
body {
  margin: 0; background: var(--fondo); color: var(--texto);
  font: 100%/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  font-optical-sizing: auto;
}
h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--acento) 55%, transparent); outline-offset: 2px; border-radius: 8px; }
::selection { background: var(--acento-medio); }
[hidden] { display: none !important; }

/* Tipografía: cuanto más grande, más apretada (interletraje negativo e interlineado corto) */
.t-display { font-size: clamp(2.7rem, 7.2vw, 5.2rem); line-height: 1.03; letter-spacing: -0.035em; font-weight: 700; }
.t-titulo  { font-size: clamp(1.9rem, 4vw, 2.9rem); line-height: 1.08; letter-spacing: -0.028em; font-weight: 700; }
.t-seccion { font-size: 1.375rem; line-height: 1.2; letter-spacing: -0.018em; font-weight: 650; }
.t-cuerpo-g { font-size: clamp(1.06rem, 1.6vw, 1.3rem); line-height: 1.42; letter-spacing: -0.012em; color: var(--texto-2); }
.t-nota { font-size: 0.8125rem; line-height: 1.38; letter-spacing: 0; color: var(--texto-3); }
.t-etiqueta { font-size: 0.75rem; line-height: 1.3; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 600; color: var(--texto-3); }
.num { font-variant-numeric: tabular-nums; }

/* Botones: la respuesta está en la pulsación (escala al instante), no al soltar */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5em;
  min-height: 2.75rem; padding: 0 1.25rem; border-radius: 999px;
  font-weight: 600; font-size: 1rem; letter-spacing: -0.01em; white-space: nowrap;
  background: var(--relleno); color: var(--texto);
  transition: transform 160ms var(--salida), background-color 160ms ease, opacity 160ms ease;
  touch-action: manipulation; user-select: none;
}
.btn:active { transform: scale(0.965); transition-duration: 60ms; }
.btn:hover { background: var(--relleno-2); }
.btn-p { background: var(--acento); color: var(--acento-tinta); }
.btn-p:hover { background: color-mix(in srgb, var(--acento) 90%, #000); }
.btn-g { min-height: 3.25rem; padding: 0 1.6rem; font-size: 1.0625rem; }
.btn-plano { background: transparent; color: var(--acento); padding: 0 0.6rem; }
.btn-plano:hover { background: var(--acento-suave); }
.btn[disabled] { opacity: 0.4; pointer-events: none; }
.btn-bloque { width: 100%; }

.tarjeta { background: var(--superficie); border-radius: var(--r-l); box-shadow: var(--sombra-1); }
.campo { display: grid; gap: 0.4rem; }
.campo > span { font-size: 0.875rem; font-weight: 600; color: var(--texto-2); }
.entrada {
  width: 100%; min-height: 3rem; padding: 0.7rem 0.95rem; border-radius: var(--r-m);
  background: var(--relleno); border: 1.5px solid transparent; outline: none; font-size: 1.0625rem;
  transition: border-color 140ms ease, background-color 140ms ease;
}
.entrada::placeholder { color: var(--texto-3); }
.entrada:focus { border-color: var(--acento); background: var(--superficie); }
textarea.entrada { resize: vertical; min-height: 5rem; line-height: 1.4; }
select.entrada { appearance: none; background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 1.15rem) 1.35rem, calc(100% - 0.8rem) 1.35rem; background-size: 0.36rem 0.36rem; background-repeat: no-repeat; padding-right: 2.2rem; }
.error { color: var(--mal); font-size: 0.9rem; font-weight: 600; }

.pastilla { display: inline-flex; align-items: center; gap: 0.4em; min-height: 1.7rem; padding: 0 0.7rem; border-radius: 999px;
  background: var(--relleno); font-size: 0.8125rem; font-weight: 600; color: var(--texto-2); white-space: nowrap; }
.pastilla.acento { background: var(--acento-suave); color: var(--acento); }
.punto { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: currentColor; flex: none; }

/* ── Hoja (panel que sube desde abajo en móvil, tarjeta centrada en pantallas grandes) ── */
.velo { position: fixed; inset: 0; z-index: 90; background: var(--velo); opacity: 0; pointer-events: none; transition: opacity 280ms ease; }
.velo.abierta { opacity: 1; pointer-events: auto; }
.hoja {
  position: fixed; z-index: 100; left: 0; right: 0; bottom: 0; margin: 0 auto;
  width: 100%; max-width: 560px; max-height: min(92dvh, 860px);
  display: flex; flex-direction: column;
  background: var(--superficie); border-radius: var(--r-xl) var(--r-xl) 0 0; box-shadow: var(--sombra-3);
  transform: translateY(105%); will-change: transform; visibility: hidden; overflow: hidden;
  overscroll-behavior: contain;
}
.hoja.visible { visibility: visible; }
.hoja-asa { flex: none; display: grid; place-items: center; height: 1.5rem; touch-action: none; cursor: grab; }
.hoja-asa::before { content: ""; width: 2.25rem; height: 0.3rem; border-radius: 999px; background: var(--relleno-2); }
.hoja-cab { flex: none; display: flex; align-items: center; gap: 0.5rem; padding: 0 1rem 0.75rem; touch-action: none; }
.hoja-cab h2 { flex: 1; font-size: 1.0625rem; font-weight: 650; letter-spacing: -0.015em; text-align: center; }
.hoja-cuerpo { flex: 1; overflow-y: auto; padding: 0.25rem 1.25rem 1.25rem; -webkit-overflow-scrolling: touch; }
.hoja-pie { flex: none; padding: 0.85rem 1.25rem calc(0.85rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--linea); background: var(--superficie); }
.redondo { width: 2.25rem; height: 2.25rem; border-radius: 50%; display: grid; place-items: center; background: var(--relleno); color: var(--texto-2);
  transition: transform 160ms var(--salida), background-color 160ms ease; flex: none; }
.redondo:active { transform: scale(0.9); transition-duration: 60ms; }
.redondo:hover { background: var(--relleno-2); }
.redondo svg { width: 1rem; height: 1rem; }
.redondo[hidden] + h2 { margin-left: 2.75rem; }
@media (min-width: 720px) {
  .hoja { bottom: auto; top: 50%; border-radius: var(--r-xl); max-height: min(86dvh, 780px); }
  .hoja-asa { display: none; }
  .hoja-cab { padding-top: 1rem; }
}

/* ── Aviso breve (confirmaciones y errores) ── */
.aviso-flotante { position: fixed; z-index: 200; left: 50%; bottom: calc(1.25rem + env(safe-area-inset-bottom)); translate: -50% 150%;
  max-width: min(92vw, 30rem); padding: 0.8rem 1.15rem; border-radius: 999px; background: var(--texto); color: var(--fondo);
  font-weight: 600; font-size: 0.95rem; box-shadow: var(--sombra-2); transition: translate 420ms var(--salida), opacity 200ms ease; opacity: 0; text-align: center; }
.aviso-flotante.visible { translate: -50% 0; opacity: 1; }

/* ── Preferencias de accesibilidad ── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 120ms !important; }
  .btn:active, .redondo:active { transform: none; }
}
@media (prefers-reduced-transparency: reduce) {
  :root { --cristal: var(--superficie); }
  .cristal { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
}
@media (prefers-contrast: more) {
  :root { --linea: rgba(0, 0, 0, 0.4); --texto-2: var(--texto); --texto-3: var(--texto); --cristal: var(--superficie); }
  .tarjeta, .entrada { border: 1.5px solid var(--texto); }
}
