/*
 * VAMO Turnos · Sistema de diseño
 *
 * Un solo archivo con los "tokens" (colores, tipografía, espaciado, radios, sombras) y los componentes base que usan
 * todas las pantallas: panel, página pública de reservas, portal del cliente y acceso. Las pantallas no inventan
 * estilos propios para lo que ya está acá.
 *
 * Reglas: el verde lima es el ÚNICO color de acento (botón principal, selección, indicadores positivos); el resto es
 * negro, grises y blanco. Los estados de un turno tienen su propio color porque se tienen que distinguir de un vistazo.
 * En las páginas públicas el negocio puede cambiar el acento (--brand); el panel conserva siempre la identidad de VAMO.
 */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/inter-var.woff2') format('woff2');
}

:root {
  /* ---- Paleta ---- */
  --black: #101114;
  --black-2: #191b20;
  --white: #ffffff;
  --gray-50: #f4f5f6;
  --gray-100: #eaebed;
  --gray-200: #dcdee2;
  --gray-300: #c3c6cc;
  --gray-400: #92969f;
  --gray-600: #5b5f69;
  --lime: #c5f45b;
  --lime-soft: #eefbd0;
  --lime-dark: #263a1a;

  /* acento: en las páginas públicas el negocio lo reemplaza (ver VT.brand.apply) */
  --brand: var(--lime);
  --brand-ink: var(--black);
  --brand-soft: var(--lime-soft);
  --brand-deep: var(--lime-dark);

  /* ---- Estados de un turno ---- */
  --st-confirmed: #1f9d57;
  --st-confirmed-bg: #e3f6ea;
  --st-pending: #b7791f;
  --st-pending-bg: #fdf1d8;
  --st-cancelled: #d14343;
  --st-cancelled-bg: #fbe5e5;
  --st-completed: #3858c8;
  --st-completed-bg: #e4e9fb;
  --st-no_show: #6b4fb8;
  --st-no_show-bg: #ece6fa;

  --danger: #d14343;
  --warning: #b7791f;
  --ok: #1f9d57;

  /* ---- Tipografía ---- */
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --fs-xs: 0.75rem;
  --fs-sm: 0.8125rem;
  --fs-md: 0.9375rem;
  --fs-lg: 1.0625rem;
  --fs-xl: 1.25rem;
  --fs-2xl: 1.5rem;
  --fs-3xl: 2rem;
  --fs-4xl: 2.5rem;

  /* ---- Espaciado (escala de 4 px) ---- */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;

  /* ---- Radios ---- */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 24px;
  --r-pill: 999px;

  /* ---- Sombras ---- */
  --shadow-sm: 0 1px 2px rgba(16, 17, 20, 0.06), 0 1px 1px rgba(16, 17, 20, 0.04);
  --shadow-md: 0 6px 18px rgba(16, 17, 20, 0.08), 0 2px 4px rgba(16, 17, 20, 0.04);
  --shadow-lg: 0 18px 48px rgba(16, 17, 20, 0.16), 0 4px 12px rgba(16, 17, 20, 0.06);
  --ring: 0 0 0 3px rgba(197, 244, 91, 0.55);

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --dur: 0.22s;
  color-scheme: light;
}

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

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.5;
  color: var(--black);
  background: var(--gray-50);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  margin: 0;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
h1 { font-size: var(--fs-3xl); font-weight: 800; }
h2 { font-size: var(--fs-2xl); font-weight: 700; }
h3 { font-size: var(--fs-xl); font-weight: 700; }
h4 { font-size: var(--fs-lg); font-weight: 600; }
p { margin: 0; }
a { color: inherit; }
img { max-width: 100%; display: block; }
button { font-family: inherit; }
[hidden] { display: none !important; }

.muted { color: var(--gray-600); }
.faint { color: var(--gray-400); }
.small { font-size: var(--fs-sm); }
.tiny { font-size: var(--fs-xs); }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: var(--s-3); }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: var(--s-4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--s-2); }
.grow { flex: 1 1 auto; min-width: 0; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--black);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------------------------------------------------------------- iconos */
.icon { width: 1.25em; height: 1.25em; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------------------------------------------- botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 44px;
  padding: 0 var(--s-5);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-size: var(--fs-md);
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn:disabled, .btn[aria-disabled='true'] { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary { background: var(--brand); color: var(--brand-ink); box-shadow: 0 1px 0 rgba(16, 17, 20, 0.12), inset 0 -2px 0 rgba(16, 17, 20, 0.08); }
.btn-primary:hover { box-shadow: var(--shadow-md), inset 0 -2px 0 rgba(16, 17, 20, 0.08); }
.btn-dark { background: var(--black); color: var(--white); }
.btn-dark:hover { background: var(--black-2); box-shadow: var(--shadow-md); }
.btn-secondary { background: var(--white); color: var(--black); border-color: var(--gray-200); }
.btn-secondary:hover { border-color: var(--black); box-shadow: var(--shadow-sm); }
.btn-ghost { background: transparent; color: var(--black); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger-ghost { background: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: var(--st-cancelled-bg); }
.btn-sm { min-height: 36px; padding: 0 var(--s-3); font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn-lg { min-height: 52px; padding: 0 var(--s-6); font-size: var(--fs-lg); border-radius: var(--r-lg); }
.btn-block { width: 100%; }
.btn-icon { width: 44px; padding: 0; }
.btn-icon.btn-sm { width: 36px; }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  color: var(--black);
  animation: vt-spin 0.7s linear infinite;
}
.btn-dark.is-loading::after, .btn-danger.is-loading::after { color: var(--white); }
@keyframes vt-spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- formularios */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: var(--fs-sm); font-weight: 600; color: var(--black); }
.field .hint { font-size: var(--fs-xs); color: var(--gray-600); }
.field .error { font-size: var(--fs-xs); color: var(--danger); font-weight: 500; min-height: 0; }
.input, .select, .textarea {
  width: 100%;
  min-height: 46px;
  padding: 0 var(--s-4);
  border: 1px solid var(--gray-200);
  border-radius: var(--r-md);
  background: var(--white);
  color: var(--black);
  font: inherit;
  font-size: 16px; /* 16 px evita el zoom automático de iOS al enfocar */
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.textarea { padding: var(--s-3) var(--s-4); min-height: 96px; resize: vertical; line-height: 1.45; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2392969f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 40px; }
.input::placeholder, .textarea::placeholder { color: var(--gray-400); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--gray-300); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--black); box-shadow: var(--ring); }
.has-error .input, .has-error .select, .has-error .textarea { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(209, 67, 67, 0.15); }
.input-group { position: relative; display: flex; align-items: center; }
.input-group > .icon { position: absolute; left: 14px; color: var(--gray-400); pointer-events: none; }
.input-group > .input { padding-left: 42px; }
input[type='color'].input { padding: 4px; min-height: 46px; cursor: pointer; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.switch { position: relative; display: inline-flex; align-items: center; gap: var(--s-3); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 44px; height: 26px; border-radius: var(--r-pill); background: var(--gray-300); position: relative; transition: background-color var(--dur) var(--ease); flex: none; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--white); box-shadow: var(--shadow-sm); transition: transform var(--dur) var(--ease); }
.switch input:checked + .track { background: var(--black); }
.switch input:checked + .track::after { transform: translateX(18px); background: var(--brand); }
.switch input:focus-visible + .track { outline: 2px solid var(--black); outline-offset: 2px; }

/* selector segmentado (vistas Día / Semana / Mes, filtros, etc.) */
.seg { display: inline-flex; padding: 3px; background: var(--gray-100); border-radius: var(--r-md); gap: 2px; }
.seg button { min-height: 36px; padding: 0 var(--s-4); border: 0; background: transparent; border-radius: 9px; font-size: var(--fs-sm); font-weight: 600; color: var(--gray-600); cursor: pointer; transition: all var(--dur) var(--ease); }
.seg button:hover { color: var(--black); }
.seg button[aria-pressed='true'], .seg button.is-active { background: var(--white); color: var(--black); box-shadow: var(--shadow-sm); }

/* elegir una opción tocando (días de la semana, íconos, colores) */
.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.chip { min-height: 38px; padding: 0 var(--s-4); border: 1px solid var(--gray-200); background: var(--white); border-radius: var(--r-pill); font-size: var(--fs-sm); font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: all var(--dur) var(--ease); }
.chip:hover { border-color: var(--black); }
.chip[aria-pressed='true'], .chip.is-active { background: var(--black); border-color: var(--black); color: var(--white); }

/* ---------------------------------------------------------------- tarjetas */
.card { background: var(--white); border: 1px solid var(--gray-100); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); padding: var(--s-5); }
.card-flush { padding: 0; overflow: hidden; }
.card-hover { transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease); }
.card-hover:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--gray-200); }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-4); }
.card-title h3 { font-size: var(--fs-lg); }

/* ---------------------------------------------------------------- insignias y estados */
.badge { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 0 10px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; background: var(--gray-100); color: var(--gray-600); }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge-confirmed { background: var(--st-confirmed-bg); color: var(--st-confirmed); }
.badge-pending { background: var(--st-pending-bg); color: var(--st-pending); }
.badge-cancelled { background: var(--st-cancelled-bg); color: var(--st-cancelled); }
.badge-completed { background: var(--st-completed-bg); color: var(--st-completed); }
.badge-no_show { background: var(--st-no_show-bg); color: var(--st-no_show); }
.badge-lime { background: var(--lime); color: var(--black); }
.badge-dark { background: var(--black); color: var(--white); }

/* ---------------------------------------------------------------- avatar */
.avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: var(--fs-sm); color: var(--black); background: var(--lime); overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 28px; height: 28px; font-size: var(--fs-xs); }
.avatar-lg { width: 64px; height: 64px; font-size: var(--fs-xl); }

/* ---------------------------------------------------------------- tablas */
.table-wrap { overflow: hidden; border: 1px solid var(--gray-100); border-radius: var(--r-lg); background: var(--white); box-shadow: var(--shadow-sm); }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--gray-600); padding: var(--s-3) var(--s-4); background: var(--gray-50); border-bottom: 1px solid var(--gray-100); }
.table td { padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--gray-100); font-size: var(--fs-md); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color var(--dur) var(--ease); }
.table tbody tr.is-clickable { cursor: pointer; }
.table tbody tr.is-clickable:hover { background: var(--gray-50); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- estados vacíos y de carga */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s-3); padding: var(--s-10) var(--s-6); }
.empty .empty-icon { width: 64px; height: 64px; border-radius: 50%; background: var(--gray-100); color: var(--gray-600); display: inline-flex; align-items: center; justify-content: center; }
.empty .empty-icon .icon { width: 28px; height: 28px; }
.empty h4 { font-size: var(--fs-lg); }
.empty p { max-width: 38ch; color: var(--gray-600); }

.skeleton { position: relative; overflow: hidden; background: var(--gray-100); border-radius: var(--r-sm); min-height: 14px; }
.skeleton::after { content: ''; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.7), transparent); animation: vt-shimmer 1.3s infinite; }
@keyframes vt-shimmer { to { transform: translateX(100%); } }
.skeleton-line { height: 14px; margin: 8px 0; }
.skeleton-block { height: 96px; border-radius: var(--r-lg); }
.loading-state { display: flex; flex-direction: column; gap: var(--s-3); padding: var(--s-4); }
.spinner { width: 22px; height: 22px; border: 2px solid var(--gray-200); border-top-color: var(--black); border-radius: 50%; animation: vt-spin 0.7s linear infinite; display: inline-block; }

.alert { display: flex; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-radius: var(--r-md); font-size: var(--fs-sm); background: var(--gray-100); color: var(--black); }
.alert .icon { margin-top: 2px; }
.alert-info { background: var(--st-completed-bg); color: #243b8f; }
.alert-warn { background: var(--st-pending-bg); color: #7a5314; }
.alert-error { background: var(--st-cancelled-bg); color: #8f2626; }
.alert-ok { background: var(--st-confirmed-bg); color: #136b3a; }
.alert-demo { background: var(--lime-soft); color: var(--lime-dark); }

/* ---------------------------------------------------------------- modales */
.modal-overlay { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: var(--s-4); background: rgba(16, 17, 20, 0.5); backdrop-filter: blur(3px); opacity: 0; transition: opacity var(--dur) var(--ease); }
.modal-overlay.is-open { opacity: 1; }
.modal { width: 100%; max-width: 520px; max-height: calc(100dvh - 32px); display: flex; flex-direction: column; background: var(--white); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); transform: translateY(16px) scale(0.98); transition: transform 0.3s var(--ease); }
.modal-overlay.is-open .modal { transform: none; }
.modal-lg { max-width: 760px; }
.modal-sm { max-width: 400px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3); padding: var(--s-5) var(--s-6) var(--s-3); }
.modal-head h3 { font-size: var(--fs-xl); }
.modal-body { padding: var(--s-2) var(--s-6) var(--s-5); overflow-y: auto; overscroll-behavior: contain; }
.modal-foot { display: flex; gap: var(--s-3); justify-content: flex-end; padding: var(--s-4) var(--s-6) var(--s-5); border-top: 1px solid var(--gray-100); flex-wrap: wrap; }

/* ---------------------------------------------------------------- avisos (toast) */
.toasts { position: fixed; left: 50%; bottom: var(--s-6); transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: var(--s-2); align-items: center; width: min(92vw, 420px); pointer-events: none; }
.toast { display: flex; align-items: center; gap: var(--s-3); width: 100%; padding: var(--s-3) var(--s-4); background: var(--black); color: var(--white); border-radius: var(--r-md); box-shadow: var(--shadow-lg); font-size: var(--fs-sm); font-weight: 500; opacity: 0; transform: translateY(12px); transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease); pointer-events: auto; }
.toast.is-open { opacity: 1; transform: none; }
.toast .icon { color: var(--lime); }
.toast-error .icon { color: #ff8a8a; }

/* ---------------------------------------------------------------- ayudas (tooltip) */
[data-tip] { position: relative; }
[data-tip]::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translate(-50%, 4px); padding: 6px 10px; background: var(--black); color: var(--white); font-size: var(--fs-xs); font-weight: 500; border-radius: var(--r-sm); white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease); z-index: 60; }
[data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }

/* ---------------------------------------------------------------- movimiento */
.fade-in { animation: vt-fade 0.35s var(--ease) both; }
.rise-in { animation: vt-rise 0.45s var(--ease) both; }
@keyframes vt-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes vt-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Quien pidió menos movimiento en su sistema no ve animaciones ni transiciones largas. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
  .skeleton::after { display: none; }
}
