/* Estilos compartidos por las tres superficies.
   Todo el color y la forma sale de tokens.css — acá no hay hex hardcodeado. */

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--texto);
  font-family: var(--fuente-cuerpo);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  font-family: var(--fuente-titulo);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0;
}

h1 { font-size: clamp(1.5rem, 4vw, 2rem); }
h2 { font-size: clamp(1.2rem, 3vw, 1.5rem); }
h3 { font-size: 1.05rem; }

p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--acento);
  outline-offset: 2px;
  border-radius: var(--radio-sm);
}

.oculto { display: none !important; }

/* El atributo hidden debe ganarle a los display:flex/grid de los componentes. */
[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Layout ---------- */

.envoltura {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px;
}

.envoltura-ancha {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
}

.pila { display: flex; flex-direction: column; gap: 12px; }
.fila { display: flex; align-items: center; gap: 10px; }
.fila-entre { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.crece { flex: 1; min-width: 0; }

/* ---------- Encabezado ---------- */

.encabezado {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.encabezado-cont {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  max-width: 1400px;
  margin: 0 auto;
}

.marca { display: flex; align-items: center; gap: 10px; min-width: 0; }

.marca-logo {
  width: 38px; height: 38px;
  flex-shrink: 0;
  border-radius: var(--radio-sm);
  background: var(--acento);
  color: var(--sobre-acento);
  display: grid;
  place-items: center;
  font-family: var(--fuente-titulo);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.03em;
  overflow: hidden;
}
.marca-logo img { width: 100%; height: 100%; object-fit: cover; }

.marca-txt { min-width: 0; display: flex; flex-direction: column; }
.marca-nombre {
  font-family: var(--fuente-titulo);
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.marca-sub {
  font-size: 0.75rem;
  color: var(--texto-tenue);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Botones ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--radio);
  background: var(--surface-2);
  color: var(--texto);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--trans), border-color var(--trans), color var(--trans), opacity var(--trans);
  text-decoration: none;
  white-space: nowrap;   /* el texto del botón no se parte en varias líneas */
}
.btn:hover:not(:disabled) { background: var(--surface-3); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primario {
  background: var(--acento);
  color: var(--sobre-acento);
  font-weight: 600;
}
.btn-primario:hover:not(:disabled) { background: var(--acento-hover); }

.btn-fantasma {
  background: transparent;
  border-color: var(--border-fuerte);
  color: var(--texto-suave);
}
.btn-fantasma:hover:not(:disabled) { background: var(--surface-2); color: var(--texto); }

.btn-peligro { background: var(--error-suave); color: var(--error); border-color: transparent; }
.btn-peligro:hover:not(:disabled) { background: var(--error); color: #fff; }

.btn-bloque { width: 100%; }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 0.85rem; border-radius: var(--radio-sm); }

.btn-icono {
  min-height: 44px; min-width: 44px;
  padding: 0;
  border-radius: var(--radio-sm);
  background: transparent;
  color: var(--texto-suave);
}
.btn-icono:hover:not(:disabled) { background: var(--surface-2); color: var(--texto); }

/* ---------- Tarjetas ---------- */

.tarjeta {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radio-lg);
  box-shadow: var(--sombra-sm);
}

.tarjeta-pad { padding: 16px; }

/* Tarjeta seleccionable: servicios y barberos */
.opcion {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radio-lg);
  cursor: pointer;
  transition: border-color var(--trans), background var(--trans);
}
.opcion:hover { border-color: var(--border-fuerte); background: var(--surface-2); }
.opcion[aria-pressed='true'] {
  border-color: var(--acento);
  background: var(--acento-suave);
}
.opcion:disabled { opacity: 0.45; cursor: not-allowed; }
.opcion:disabled:hover { border-color: var(--border); background: var(--surface); }

.opcion-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.opcion-titulo { display: block; font-weight: 600; font-size: 0.98rem; line-height: 1.35; }
.opcion-sub { display: block; font-size: 0.82rem; line-height: 1.4; color: var(--texto-tenue); }
.opcion-precio {
  font-family: var(--fuente-titulo);
  font-weight: 600;
  white-space: nowrap;
  color: var(--acento);
}

/* ---------- Avatar ---------- */

.avatar {
  width: 46px; height: 46px;
  flex-shrink: 0;
  border-radius: var(--radio-full);
  background: var(--surface-3);
  color: var(--texto-suave);
  display: grid;
  place-items: center;
  font-family: var(--fuente-titulo);
  font-weight: 600;
  font-size: 0.95rem;
  overflow: hidden;
  border: 1px solid var(--border);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 30px; height: 30px; font-size: 0.75rem; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.2rem; }

/* ---------- Etiquetas ---------- */

.etiqueta {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radio-full);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.etiqueta-ok { background: var(--ok-suave); color: var(--ok); }
.etiqueta-alerta { background: var(--alerta-suave); color: var(--alerta); }
.etiqueta-error { background: var(--error-suave); color: var(--error); }
.etiqueta-neutra { background: var(--surface-3); color: var(--texto-suave); }
.etiqueta-acento { background: var(--acento-suave); color: var(--acento); }

.punto { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

/* ---------- Formularios ---------- */

.campo { display: flex; flex-direction: column; gap: 6px; }

.campo label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--texto-suave);
}

.campo input,
.campo select,
.campo textarea {
  min-height: 46px;
  padding: 10px 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radio);
  transition: border-color var(--trans), background var(--trans);
  width: 100%;
  min-width: 0;   /* deja que el campo se encoja dentro de una fila flex (móvil) */
}
.campo input:focus,
.campo select:focus,
.campo textarea:focus {
  outline: none;
  border-color: var(--acento);
  background: var(--surface);
}
.campo input::placeholder, .campo textarea::placeholder { color: var(--texto-tenue); }
.campo-error { font-size: 0.8rem; color: var(--error); }
.campo input[aria-invalid='true'] { border-color: var(--error); }

/* ---------- Pasos del flujo de reserva ---------- */

.pasos {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 16px 0;
  max-width: 560px;
  margin: 0 auto;
}

.paso {
  flex: 1;
  height: 3px;
  border-radius: var(--radio-full);
  background: var(--surface-3);
  transition: background var(--trans);
}
.paso.activo { background: var(--acento); }
.paso.hecho { background: var(--acento-borde); }

.paso-titulo { margin: 20px 0 4px; }
.paso-bajada { color: var(--texto-suave); font-size: 0.9rem; margin-bottom: 16px; }

/* ---------- Tira de días ---------- */

.dias {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 16px 12px;
  margin: 0 -16px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.dias::-webkit-scrollbar { display: none; }

.dia {
  flex: 0 0 auto;
  scroll-snap-align: start;
  width: 66px;
  padding: 10px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radio);
  background: var(--surface);
  cursor: pointer;
  text-align: center;
  transition: border-color var(--trans), background var(--trans);
}
.dia:hover:not(:disabled) { border-color: var(--border-fuerte); }
.dia[aria-pressed='true'] { border-color: var(--acento); background: var(--acento-suave); }
.dia:disabled { opacity: 0.35; cursor: not-allowed; }

.dia > span { display: block; }
.dia-sem { font-size: 0.7rem; color: var(--texto-tenue); text-transform: uppercase; letter-spacing: 0.05em; }
.dia-num { font-family: var(--fuente-titulo); font-size: 1.25rem; font-weight: 600; line-height: 1.3; }
.dia-libres { font-size: 0.68rem; color: var(--ok); font-weight: 600; }
.dia-lleno { font-size: 0.68rem; color: var(--texto-tenue); }

/* ---------- Grilla de horarios ---------- */

.horarios {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
}

.hora {
  min-height: 46px;
  padding: 8px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radio);
  background: var(--surface);
  font-family: var(--fuente-titulo);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--trans), background var(--trans), color var(--trans);
  position: relative;
}
.hora:hover:not(:disabled) { border-color: var(--acento-borde); background: var(--surface-2); }
.hora[aria-pressed='true'] {
  border-color: var(--acento);
  background: var(--acento);
  color: var(--sobre-acento);
  font-weight: 700;
}

/* No disponible: se muestra igual, tachado. El cliente necesita VER que está
   copado — si escondemos los horarios ocupados, cree que la app está rota. */
.hora:disabled {
  cursor: not-allowed;
  color: var(--texto-tenue);
  background: var(--surface-2);
  border-color: transparent;
  text-decoration: line-through;
  text-decoration-color: var(--texto-tenue);
}

.leyenda {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 14px;
  font-size: 0.78rem;
  color: var(--texto-tenue);
}
.leyenda-item { display: flex; align-items: center; gap: 6px; }
.leyenda-muestra {
  width: 14px; height: 14px;
  border-radius: 4px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.leyenda-muestra.libre { background: var(--surface); border-color: var(--acento-borde); }
.leyenda-muestra.ocupado { background: var(--surface-2); border-color: transparent; }
.leyenda-muestra.elegido { background: var(--acento); border-color: var(--acento); }

/* ---------- Resumen / barra inferior ---------- */

.barra-inferior {
  position: sticky;
  bottom: 0;
  z-index: var(--z-sticky);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  margin-top: 24px;
}
.barra-cont { max-width: 560px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }

.resumen-linea { font-size: 0.8rem; color: var(--texto-tenue); }
.resumen-dato { font-weight: 600; color: var(--texto); font-size: 0.92rem; }

/* ---------- Avisos ---------- */

.aviso {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radio);
  font-size: 0.87rem;
  line-height: 1.5;
}
.aviso-info { background: var(--surface-2); color: var(--texto-suave); }
.aviso-ok { background: var(--ok-suave); color: var(--ok); }
.aviso-alerta { background: var(--alerta-suave); color: var(--alerta); }
.aviso-error { background: var(--error-suave); color: var(--error); }

.vacio {
  padding: 32px 16px;
  text-align: center;
  color: var(--texto-tenue);
  font-size: 0.9rem;
}

/* ---------- Modal ---------- */

.velo {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(3px);
  /* flex (no grid): así el modal SÍ se limita al ancho de la pantalla en móvil.
     Con grid + place-items:center el modal podía crecer más que el viewport. */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal {
  width: 100%;
  /* Nunca más ancho que la pantalla (menos el respiro de 16px por lado del velo).
     min() gana a cualquier ancho de contenido que intente empujar el modal. */
  max-width: min(460px, calc(100vw - 32px));
  min-width: 0;
  max-height: 88vh;
  overflow-y: auto;
  overflow-x: hidden;   /* nada se desborda a los lados en móvil */
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radio-lg);
  box-shadow: var(--sombra-lg);
  padding: 20px;
}

/* En móvil, dentro del modal: los botones de pie pueden bajar a otra línea en
   vez de cortarse, y las filas de dos columnas se apilan si no caben. El ancho
   del modal ya está topado (max-width con min()), así que no hace falta encoger
   los inputs de horario —que quedaban ilegibles ("10" en vez de "10:00"). */
@media (max-width: 480px) {
  .modal .fila-entre { flex-wrap: wrap; row-gap: 10px; }
  /* El ícono de reloj nativo del input de hora come ~24px; en pantallas
     angostas eso recorta el valor ("10:0" en vez de "10:00"). Se oculta y se
     ajusta el padding para que quepa HH:MM completo. En móvil, al enfocar el
     campo igual aparece el selector de hora del sistema. */
  .modal input[type='time']::-webkit-calendar-picker-indicator,
  .modal input[type='date']::-webkit-calendar-picker-indicator { display: none; }
  .modal input[type='time'],
  .modal input[type='date'] { padding-left: 8px; padding-right: 8px; }
}

/* ---------- Toast ---------- */

.toasts {
  position: fixed;
  left: 16px; right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  max-width: 460px;
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radio);
  background: var(--surface-3);
  border: 1px solid var(--border-fuerte);
  box-shadow: var(--sombra-lg);
  font-size: 0.88rem;
  animation: sube 240ms cubic-bezier(0.4, 0, 0.2, 1);
}
.toast-ok { border-color: var(--ok); color: var(--ok); }
.toast-error { border-color: var(--error); color: var(--error); }

@keyframes sube {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Carga ---------- */

.esqueleto {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: brillo 1.4s ease-in-out infinite;
  border-radius: var(--radio);
}
@keyframes brillo {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* ---------- Accesibilidad: movimiento reducido ---------- */

/* ---------- Header en celular ----------
   En pantallas chicas la marca va arriba y los botones de acción bajan a su
   propia fila (deslizable si aún no caben), en vez de amontonarse. */
@media (max-width: 560px) {
  .encabezado-cont { flex-wrap: wrap; row-gap: 8px; }
  #acciones-top {
    width: 100%;
    justify-content: flex-end;
    overflow-x: auto;
    scrollbar-width: none;
  }
  #acciones-top::-webkit-scrollbar { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
