/* =====================================================================
   base.css — reset, tipografía, formularios, botones y estados
   Reglas del proyecto: inputs de 16px (evita el zoom de iOS), botones
   táctiles de 44px, y toda vista con estados cargando / vacío / error.
   ===================================================================== */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--grad-fondo) no-repeat top center / 100% 520px, var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

img, svg { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 var(--space-3); letter-spacing: -0.01em; }
h1 { font-size: var(--fs-xl); font-weight: 800; }
h2 { font-size: var(--fs-lg); font-weight: 750; }
h3 { font-size: var(--fs-md); font-weight: 700; }
p { margin: 0 0 var(--space-3); }
a { color: var(--brand); text-underline-offset: 3px; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
  border-radius: 6px;
}

.solo-lectores {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Layout ---------- */
.contenedor {
  width: 100%;
  max-width: 1040px;
  margin-inline: auto;
  padding-inline: var(--space-4);   /* 16px de margen lateral */
}
.contenedor-angosto { max-width: 440px; }
.pila > * + * { margin-top: var(--space-4); }
.fila { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }
.fila-espaciada { justify-content: space-between; }
.texto-suave { color: var(--text-muted); font-size: var(--fs-sm); }
.centrado { text-align: center; }
.derecha { text-align: right; }
.negrita { font-weight: 700; }

/* ---------- Tarjetas ---------- */
.tarjeta {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  box-shadow: var(--shadow);
}
.tarjeta > h2:first-child, .tarjeta > h3:first-child { margin-top: 0; }

/* ---------- Barra superior (panel, SuperAdmin, ingreso) ---------- */
.barra-superior {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface-glass);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.barra-superior .contenedor {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 60px;
}
.barra-superior .marca {
  font-weight: 850;
  letter-spacing: -0.02em;
  background: var(--grad-marca);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.barra-superior .espacio { flex: 1; }
.barra-superior .local { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Cuadrícula de tarjetas y datos ---------- */
.rejilla {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}
.dato { position: relative; overflow: hidden; }
.dato::before {
  content: "";
  position: absolute; inset: 0 auto 0 0; width: 5px;
  background: var(--grad-marca);
}
.dato .valor { font-size: var(--fs-xl); font-weight: 850; line-height: 1.15; }
.dato .nombre { color: var(--text-muted); font-size: var(--fs-sm); }

/* ---------- Formularios ---------- */
.campo { display: block; margin-bottom: var(--space-4); }
.campo > .etiqueta, .campo > label.etiqueta { display: block; font-weight: 650; margin-bottom: var(--space-1); }
.campo > .ayuda { display: block; color: var(--text-muted); font-size: var(--fs-sm); margin-top: var(--space-1); }
.campo > .error-campo { display: block; color: var(--danger); font-size: var(--fs-sm); margin-top: var(--space-1); }
.error-campo:empty { display: none; }

input[type="text"], input[type="email"], input[type="password"], input[type="tel"],
input[type="number"], input[type="date"], input[type="time"], input[type="search"],
input[type="datetime-local"], select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 14px;
  font: inherit;
  font-size: 16px;                 /* nunca menos de 16px */
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--anillo);
}
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] {
  border-color: var(--danger);
}
input[type="color"] {
  width: 56px; height: var(--tap); padding: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--brand); }
textarea { min-height: 96px; resize: vertical; }

/* Campo trampa (honeypot): fuera de pantalla pero no display:none */
.campo-trampa {
  position: absolute !important;
  left: -9999px;
  width: 1px; height: 1px;
  overflow: hidden;
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 10px 20px;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  color: var(--brand-contrast);
  background: var(--grad-marca);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  box-shadow: 0 6px 16px rgba(29, 78, 216, 0.28);
  transition: transform 0.12s, box-shadow 0.12s, filter 0.12s;
}
@supports (color: color-mix(in srgb, red 10%, white)) {
  .btn { box-shadow: 0 6px 16px color-mix(in srgb, var(--brand) 32%, transparent); }
}
.btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn:active { transform: translateY(0); filter: brightness(0.96); }
.btn[disabled], .btn[aria-busy="true"] { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-secundario { color: var(--text); background: var(--surface); border-color: var(--border); box-shadow: none; }
.btn-suave { color: var(--brand); background: var(--brand-soft); box-shadow: none; }
.btn-peligro { color: #fff; background: linear-gradient(135deg, #c4243a, #e0485b); box-shadow: 0 6px 16px rgba(196, 36, 58, 0.25); }
.btn-enlace {
  color: var(--brand); background: transparent; border-color: transparent; box-shadow: none;
  padding-inline: 8px; text-decoration: underline;
}
.btn-claro { color: var(--azul-900); background: #fff; box-shadow: 0 6px 18px rgba(5, 20, 70, 0.25); }
.btn-fantasma { color: inherit; background: rgba(255, 255, 255, 0.16); border-color: rgba(255, 255, 255, 0.4); box-shadow: none; }
.btn-chico { min-height: 36px; padding: 6px 12px; font-size: 0.9rem; }
.btn-bloque { width: 100%; }

/* ---------- Avisos y estados de vista ---------- */
.aviso {
  display: block;               /* también cuando es un enlace <a>: si no, el borde se corta entre renglones */
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: var(--fs-md);
}
a.aviso { text-decoration: none; font-weight: 650; }
a.aviso:hover, a.aviso:focus-visible { text-decoration: underline; }
.aviso-error { color: var(--danger); background: var(--danger-soft); border-color: var(--danger); }
.aviso-ok    { color: var(--ok);     background: var(--ok-soft);     border-color: var(--ok); }
.aviso-info  { color: var(--info);   background: var(--info-soft);   border-color: var(--info); }
.aviso-warn  { color: var(--warn);   background: var(--warn-soft);   border-color: var(--warn); }

.estado {
  text-align: center;
  padding: var(--space-6) var(--space-4);
  color: var(--text-muted);
}
.estado .titulo { color: var(--text); font-weight: 750; font-size: 1.1rem; margin-bottom: var(--space-1); }
.estado .acciones { margin-top: var(--space-4); }

/* Esqueletos de carga */
.esqueleto {
  display: block;
  height: 18px;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: brillo 1.4s ease infinite;
}
.esqueleto + .esqueleto { margin-top: var(--space-3); }
.esqueleto-bloque { height: 76px; border-radius: var(--radius); }
@keyframes brillo {
  0%   { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* Aviso flotante */
.toast-zona {
  position: fixed;
  inset: auto 0 var(--space-4) 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding-inline: var(--space-4);
  pointer-events: none;
  z-index: 80;
}
.toast {
  pointer-events: auto;
  max-width: 480px;
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--azul-900);
  color: #fff;
  box-shadow: var(--shadow-fuerte);
  font-weight: 650;
  animation: entra 0.18s ease-out;
}
.toast-error { background: var(--danger); }
.toast-ok { background: var(--ok); color: #fff; }
@keyframes entra {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Etiquetas de estado de una cita */
.etiqueta-estado {
  display: inline-block;
  padding: 2px 11px;
  border-radius: 999px;
  font-size: var(--fs-sm);
  font-weight: 700;
  white-space: nowrap;
}
.estado-pending   { color: var(--st-pending);   background: var(--st-pending-bg); }
.estado-confirmed { color: var(--st-confirmed); background: var(--st-confirmed-bg); }
.estado-completed { color: var(--st-completed); background: var(--st-completed-bg); }
.estado-cancelled, .estado-expired { color: var(--st-cancelled); background: var(--st-cancelled-bg); }
.estado-no_show   { color: var(--st-noshow);    background: var(--st-noshow-bg); }

@media (prefers-reduced-motion: reduce) {
  .esqueleto, .toast { animation: none; }
  .btn { transition: none; }
}

/* ---------- Tarjeta de visitas (Fase 6) ---------- */
.sellos { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.sello {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  font-weight: 800; color: var(--text-muted);
  background: var(--surface-2); border: 2px dashed var(--border);
}
.sello.lleno { color: var(--brand-contrast); background: var(--brand); border: 2px solid var(--brand); }
.lista-simple { margin: var(--space-2) 0 0; padding-left: 1.2em; }
