/* ════════════════════════════════════════════════════════════════════════════
   components.css — los ladrillos de la app (§5.1). Botones, campos, cards,
   chips de estado, listas, tiles de números y el sheet desde abajo.
   Regla: una pantalla nueva NO inventa CSS — compone estas clases.
   ════════════════════════════════════════════════════════════════════════════ */

/* ── Botones ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: var(--tap); /* §5.1: nada menor a 44px se toca con el dedo */
  padding: 0 var(--sp-4);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink-700);
  font-size: var(--txt-base);
  font-weight: var(--peso-medio);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.06s ease;
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--primario {
  background: var(--brand-500);
  border-color: var(--brand-500);
  color: #fff;
}
.btn--primario:hover {
  background: var(--brand-600);
  border-color: var(--brand-600);
}

.btn--secundario {
  background: var(--surface);
  border-color: var(--line-fuerte);
  color: var(--ink-900);
}
.btn--secundario:hover {
  background: var(--surface-2);
}

.btn--fantasma {
  background: transparent;
  color: var(--ink-500);
}
.btn--fantasma:hover {
  background: var(--surface-2);
  color: var(--ink-900);
}

.btn--peligro {
  background: var(--danger-500);
  border-color: var(--danger-500);
  color: #fff;
}

.btn--ancho {
  width: 100%;
}

/* FAB: crear turno desde cualquier lado (§5.2). En celular vive arriba del bottom-nav. */
.fab {
  position: fixed;
  right: var(--sp-4);
  bottom: calc(var(--bottomnav-h) + var(--sp-4) + env(safe-area-inset-bottom, 0px));
  width: var(--tap-lg);
  height: var(--tap-lg);
  border: 0;
  border-radius: var(--r-full);
  background: var(--brand-500);
  color: #fff;
  font-size: 1.75rem;
  line-height: 1;
  box-shadow: var(--sombra-2);
  cursor: pointer;
  z-index: var(--z-nav);
}
@media (min-width: 768px) {
  .fab {
    bottom: var(--sp-5);
    right: var(--sp-5);
  }
}

/* ── Campos ──────────────────────────────────────────────────────────────── */
.campo {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.campo__label {
  font-size: var(--txt-sm);
  font-weight: var(--peso-medio);
  color: var(--ink-700);
}
.campo__input,
.campo__select,
.campo__textarea {
  width: 100%;
  min-height: var(--tap);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--line-fuerte);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: var(--txt-base); /* 16px: menos que eso y iOS hace zoom al tocar el input */
  color: var(--ink-900);
}
.campo__input::placeholder {
  color: var(--ink-300);
}
.campo__input:focus,
.campo__select:focus,
.campo__textarea:focus {
  border-color: var(--brand-500);
  outline: 3px solid var(--brand-100);
  outline-offset: 0;
}
.campo__ayuda {
  font-size: var(--txt-xs);
  color: var(--ink-500);
}

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sombra-1);
}
.card__cuerpo {
  padding: var(--sp-4);
}
.card__titulo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-bottom: 1px solid var(--line);
  font-weight: var(--peso-fuerte);
  color: var(--ink-900);
}

/* ── Chips de estado de turno (§5.1) ─────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 2px var(--sp-2);
  border-radius: var(--r-full);
  font-size: var(--txt-xs);
  font-weight: var(--peso-medio);
  white-space: nowrap;
}
.chip::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: var(--r-full);
  background: currentColor;
}
.chip--pendiente {
  background: var(--t-pendiente-bg);
  color: var(--t-pendiente-ink);
}
.chip--confirmado {
  background: var(--t-confirmado-bg);
  color: var(--t-confirmado-ink);
}
.chip--atendido {
  background: var(--t-atendido-bg);
  color: var(--t-atendido-ink);
}
.chip--no_show {
  background: var(--t-no_show-bg);
  color: var(--t-no_show-ink);
}
.chip--cancelado {
  background: var(--t-cancelado-bg);
  color: var(--t-cancelado-ink);
}

/* ── Listas (clientes, cobros, gastos) ───────────────────────────────────── */
.lista {
  display: flex;
  flex-direction: column;
}
.lista__item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: var(--tap-lg);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
}
.lista__item:last-child {
  border-bottom: 0;
}
.lista__item:hover {
  background: var(--surface-2);
  text-decoration: none;
}
.lista__principal {
  flex: 1;
  min-width: 0;
}
.lista__titulo {
  font-weight: var(--peso-medio);
  color: var(--ink-900);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lista__sub {
  font-size: var(--txt-sm);
  color: var(--ink-500);
}
.lista__monto {
  font-weight: var(--peso-fuerte);
  color: var(--ink-900);
  font-variant-numeric: tabular-nums;
}

.avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: var(--r-full);
  background: var(--brand-50);
  color: var(--brand-700);
  font-weight: var(--peso-fuerte);
  font-size: var(--txt-sm);
}

/* ── Tiles de números (caja, reportes) ───────────────────────────────────── */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--sp-3);
}
.tile {
  padding: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.tile__label {
  font-size: var(--txt-sm);
  color: var(--ink-500);
}
.tile__valor {
  margin-top: var(--sp-1);
  font-size: var(--txt-2xl);
  font-weight: var(--peso-fuerte);
  color: var(--ink-900);
  font-variant-numeric: tabular-nums;
}
.tile__valor--ok {
  color: var(--ok-500);
}
.tile__valor--mal {
  color: var(--danger-500);
}
.tile__pie {
  font-size: var(--txt-xs);
  color: var(--ink-500);
}

/* ── Sheet desde abajo (crear/ver turno, §5.2) ───────────────────────────── */
.sheet-fondo {
  position: fixed;
  inset: 0;
  background: rgba(27, 24, 48, 0.45);
  z-index: var(--z-sheet);
}
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 88vh;
  overflow-y: auto;
  padding: var(--sp-4) var(--sp-4) calc(var(--sp-5) + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: var(--sombra-3);
  z-index: calc(var(--z-sheet) + 1);
  animation: sheet-sube 0.18s ease-out;
}
@keyframes sheet-sube {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}
.sheet__agarre {
  width: 36px;
  height: 4px;
  margin: 0 auto var(--sp-4);
  border-radius: var(--r-full);
  background: var(--line-fuerte);
}
/* En tablet/desktop el sheet deja de venir de abajo y se centra como modal. */
@media (min-width: 768px) {
  .sheet {
    left: 50%;
    bottom: auto;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(560px, 92vw);
    border-radius: var(--r-lg);
    animation: none;
  }
  .sheet__agarre {
    display: none;
  }
}

/* ── Varios ──────────────────────────────────────────────────────────────── */
.pila {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
.fila {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.fila--entre {
  justify-content: space-between;
}
.vacio {
  padding: var(--sp-6) var(--sp-4);
  text-align: center;
  color: var(--ink-500);
}
.alerta {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  font-size: var(--txt-sm);
}
.alerta--error {
  background: var(--danger-50);
  color: #7e2020;
}
.alerta--info {
  background: var(--info-50);
  color: #14508f;
}
.plata {
  font-variant-numeric: tabular-nums;
}
