/* =========================================================
   Smiles Campana: tokens y componentes compartidos
   ========================================================= */
:root {
  color-scheme: light;

  /* Marca: tomada del logo (diente lavanda, trazo dorado) */
  --esmalte: #f5f5fa;       /* fondo: blanco con tinte lavanda */
  --papel: #ffffff;         /* superficies */
  --tinta: #262140;         /* texto principal, berenjena profunda */
  --tinta-2: #5d5875;       /* texto secundario */
  --tinta-3: #8a86a0;       /* texto terciario */
  --lavanda: #8d8ac6;       /* color del diente del logo */
  --lavanda-osc: #4b4796;   /* acciones, enlaces */
  --lavanda-hover: #3d3a80;
  --lavanda-claro: #e8e7f5;
  --lavanda-tenue: #f0eff9;
  --oro: #e6b422;           /* trazo de firma del logo, uso puntual */
  --oro-claro: #fbf1cf;
  --linea: #dddcea;
  --linea-fuerte: #c6c4dc;

  /* Estados */
  --ok: #1d7a55;
  --ok-claro: #e2f3eb;
  --error: #b3261e;
  --error-claro: #fbe7e5;
  --aviso: #8a5a00;
  --aviso-claro: #fdf0d5;

  /* Odontograma: convención clínica */
  --od-rojo: #d22a3c;
  --od-azul: #1d5ad4;

  /* Tipografía */
  --fuente: 'Bricolage Grotesque', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --t-xs: 0.8125rem;
  --t-s: 0.9375rem;
  --t-m: 1.0625rem;
  --t-l: 1.3125rem;
  --t-xl: 1.75rem;
  --t-2xl: clamp(2.25rem, 1.6rem + 3vw, 3.75rem);

  /* Forma: los radios siguen la jerarquía (acciones redondeadas, paneles suaves, campos discretos) */
  --r-campo: 10px;
  --r-panel: 16px;
  --r-pastilla: 999px;
  --sombra-flotante: 0 18px 50px -20px rgb(38 33 64 / 0.35);

  --foco: 0 0 0 3px var(--papel), 0 0 0 5px var(--lavanda-osc);
  --ancho: 1120px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
body {
  margin: 0;
  font-family: var(--fuente);
  font-size: var(--t-m);
  line-height: 1.55;
  color: var(--tinta);
  background: var(--esmalte);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
img { height: auto; }
h1, h2, h3, h4 { line-height: 1.15; margin: 0 0 0.5em; font-weight: 650; letter-spacing: -0.015em; }
p { margin: 0 0 1em; }
a { color: var(--lavanda-osc); text-underline-offset: 3px; }
a:hover { color: var(--lavanda-hover); }
:focus-visible { outline: none; box-shadow: var(--foco); border-radius: 6px; }
button { font: inherit; color: inherit; }
.visualmente-oculto { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.texto-suave { color: var(--tinta-2); }
.contenedor { width: 100%; max-width: var(--ancho); margin: 0 auto; padding: 0 20px; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5em;
  min-height: 46px; padding: 0 1.25em;
  border: 1.5px solid transparent; border-radius: var(--r-pastilla);
  font-weight: 600; font-size: var(--t-s); text-decoration: none; cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primario { background: var(--lavanda-osc); color: #fff; }
.btn-primario:hover { background: var(--lavanda-hover); color: #fff; }
.btn-secundario { background: var(--papel); border-color: var(--linea-fuerte); color: var(--tinta); }
.btn-secundario:hover { border-color: var(--lavanda-osc); color: var(--lavanda-osc); }
.btn-fantasma { background: transparent; color: var(--lavanda-osc); padding: 0 0.75em; }
.btn-fantasma:hover { background: var(--lavanda-tenue); }
.btn-peligro { background: var(--error); color: #fff; }
.btn-peligro:hover { background: #921f18; color: #fff; }
.btn-chico { min-height: 36px; padding: 0 0.9em; font-size: var(--t-xs); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.cargando { position: relative; color: transparent !important; }
.btn.cargando::after {
  content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-color: #fff #fff transparent transparent; animation: girar 0.7s linear infinite;
}
.btn-secundario.cargando::after, .btn-fantasma.cargando::after { border-color: var(--lavanda-osc) var(--lavanda-osc) transparent transparent; }
.btn-icono {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: transparent; cursor: pointer; color: var(--tinta-2);
}
.btn-icono:hover { background: var(--lavanda-tenue); color: var(--tinta); }
@keyframes girar { to { transform: rotate(360deg); } }

/* ---------- Formularios ---------- */
.campo { display: grid; gap: 6px; margin-bottom: 16px; }
.campo > span, .campo > label { font-size: var(--t-s); font-weight: 600; color: var(--tinta); }
.campo small { color: var(--tinta-2); font-size: var(--t-xs); }
input, select, textarea {
  font: inherit; font-size: 16px; /* evita el zoom automático en iPhone */
  width: 100%; min-height: 46px; padding: 10px 14px;
  color: var(--tinta); background: var(--papel);
  border: 1.5px solid var(--linea-fuerte); border-radius: var(--r-campo);
  transition: border-color 0.15s;
}
select { height: 46px; padding-top: 0; padding-bottom: 0; }
textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
input:hover, select:hover, textarea:hover { border-color: var(--lavanda); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--lavanda-osc); box-shadow: 0 0 0 3px var(--lavanda-claro); }
input[type='checkbox'], input[type='radio'] { width: auto; min-height: 0; accent-color: var(--lavanda-osc); }
.fila-campos { display: grid; gap: 0 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.error-campo { color: var(--error); font-size: var(--t-s); margin: -4px 0 12px; }

.interruptor { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: var(--t-s); color: var(--tinta-2); user-select: none; }
.interruptor input { appearance: none; width: 38px; height: 22px; border-radius: 999px; background: var(--linea-fuerte); position: relative; border: 0; padding: 0; cursor: pointer; transition: background 0.15s; min-height: 0; }
.interruptor input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.interruptor input:checked { background: var(--lavanda-osc); }
.interruptor input:checked::after { transform: translateX(16px); }
.interruptor input:disabled { opacity: 0.5; cursor: default; }

/* ---------- Modal / hoja ---------- */
dialog.hoja {
  border: 0; padding: 0; color: var(--tinta); background: var(--papel);
  border-radius: var(--r-panel); box-shadow: var(--sombra-flotante);
  width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 48px);
  display: flex; flex-direction: column; overflow: hidden;
}
dialog.hoja:not([open]) { display: none; }
dialog.hoja-chico { width: min(420px, calc(100vw - 32px)); }
dialog.hoja-ancho { width: min(820px, calc(100vw - 32px)); }
dialog.hoja::backdrop { background: rgb(38 33 64 / 0.45); }
.hoja-cabecera { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 8px 24px; }
.hoja-cabecera h2 { margin: 0; font-size: var(--t-l); }
.hoja-cuerpo { padding: 8px 24px 20px; overflow-y: auto; }
.hoja-pie { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; padding: 14px 24px; border-top: 1px solid var(--linea); background: var(--esmalte); }
@media (max-width: 600px) {
  dialog.hoja, dialog.hoja-chico, dialog.hoja-ancho {
    width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 20px 20px 0 0; max-height: 92dvh;
    animation: subir 0.22s ease-out;
  }
  .hoja-pie .btn { flex: 1; }
}
@keyframes subir { from { transform: translateY(40px); opacity: 0.4; } }

/* ---------- Avisos ---------- */
.avisos { position: fixed; z-index: 100; left: 50%; bottom: 20px; transform: translateX(-50%); display: grid; gap: 8px; width: min(440px, calc(100vw - 32px)); pointer-events: none; }
.aviso { padding: 12px 16px; border-radius: 12px; background: var(--tinta); color: #fff; font-size: var(--t-s); box-shadow: var(--sombra-flotante); animation: subir 0.2s ease-out; transition: opacity 0.3s, transform 0.3s; }
.aviso-error { background: var(--error); }
.aviso.saliendo { opacity: 0; transform: translateY(8px); }

.vacio { text-align: center; padding: 32px 16px; color: var(--tinta-2); }
.vacio p { margin-bottom: 14px; }
.cargando-bloque { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px; color: var(--tinta-2); }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--lavanda-claro); border-top-color: var(--lavanda-osc); animation: girar 0.7s linear infinite; }
