/* ============================================================
   Carwash PVS — hoja de estilos
   Diseño pensado para terminal de mostrador: alto contraste,
   objetivos táctiles grandes y tipografía legible.
   ============================================================ */

:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --primary: #0ea5e9;
  --primary-602: #0284c7;
  --primary-soft: #e0f2fe;
  --nav: #0f172a;
  --nav-2: #1e293b;
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --info: #7c3aed;
  --info-soft: #ede9fe;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .16);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

.boot { padding: 40px; color: var(--text-2); }

/* ---------------- Estructura general ---------------- */
.app-shell { min-height: 100vh; display: flex; }

.sidebar {
  width: 240px;
  flex: 0 0 240px;
  background: var(--nav);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.brand strong { display: block; color: #fff; font-size: 19px; letter-spacing: .3px; }
.brand span { font-size: 12px; color: #64748b; }

.nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 4px; flex: 1; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 14px; border-radius: 10px;
  color: #cbd5e1; text-decoration: none; font-size: 15px; font-weight: 500;
}
.nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav a.active { background: var(--primary); color: #fff; }
.nav a .ico { width: 20px; text-align: center; }

.nav-user { padding: 14px 18px; border-top: 1px solid rgba(255, 255, 255, .08); font-size: 13px; }
.nav-user .who { color: #fff; font-weight: 600; font-size: 14px; }
.nav-user .role { color: #64748b; text-transform: capitalize; margin-bottom: 8px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { margin: 0; font-size: 20px; font-weight: 700; }
.topbar .sub { color: var(--text-3); font-size: 13px; margin-top: 2px; }

.content { padding: 24px; max-width: 1400px; width: 100%; }

/* ---------------- Componentes ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card + .card { margin-top: 16px; }
.card h2 { margin: 0 0 4px; font-size: 16px; }
.card h3 { margin: 0 0 12px; font-size: 14px; color: var(--text-2); text-transform: uppercase; letter-spacing: .4px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
}
.kpi .label { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-3); }
.kpi .value { font-size: 27px; font-weight: 700; margin-top: 6px; line-height: 1.1; }
.kpi .hint { font-size: 12px; color: var(--text-2); margin-top: 6px; }
.kpi.ok .value { color: var(--ok); }
.kpi.warn .value { color: var(--warn); }
.kpi.info .value { color: var(--primary-602); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--primary); color: #fff; border: none;
  padding: 12px 18px; border-radius: 10px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  min-height: 44px;
  transition: background .15s, transform .05s;
}
.btn:hover { background: var(--primary-602); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.ghost { background: transparent; color: var(--primary-602); border: 1px solid var(--primary-soft); }
.btn.ok { background: var(--ok); }
.btn.ok:hover { background: #15803d; }
.btn.warn { background: var(--warn); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b91c1c; }
.btn.sm { padding: 8px 12px; min-height: 36px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 12px 14px; font-size: 15px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text); min-height: 46px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
textarea { min-height: 80px; resize: vertical; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 10px 16px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; font-size: 14px; font-weight: 600;
  color: var(--text-2); min-height: 42px;
}
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge.primary { background: var(--primary-soft); color: var(--primary-602); border-color: transparent; }
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-3); font-weight: 700; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
.table-scroll { max-height: 420px; overflow-y: auto; }

.empty { padding: 28px; text-align: center; color: var(--text-3); font-size: 14px; }

/* ---------------- Login ---------------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #0f172a 0%, #1e3a5f 60%, #0ea5e9 140%);
  padding: 24px;
}
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 16px; padding: 32px; box-shadow: var(--shadow-lg); }
.login-card h1 { margin: 0 0 4px; font-size: 24px; }
.login-card p.sub { margin: 0 0 24px; color: var(--text-3); font-size: 14px; }

/* ---------------- Escáner de asistencia ---------------- */
.scanner { display: grid; grid-template-columns: minmax(300px, 1.2fr) minmax(300px, 1fr); gap: 16px; }
.scan-view {
  position: relative; background: #0f172a; border-radius: var(--radius);
  min-height: 320px; display: flex; align-items: center; justify-content: center;
  overflow: hidden; color: #94a3b8; text-align: center; padding: 20px;
}
.scan-view video { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.scan-frame {
  position: absolute; width: 220px; height: 220px; border: 4px solid var(--primary);
  border-radius: 18px; box-shadow: 0 0 0 9999px rgba(15, 23, 42, .45); z-index: 2;
}
.scan-result { text-align: center; padding: 24px; }
.scan-result .big { font-size: 46px; }
.scan-result .name { font-size: 22px; font-weight: 700; margin-top: 8px; }
.scan-result .meta { color: var(--text-2); margin-top: 6px; }

/* ---------------- Tablero de turnos ---------------- */
.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.station-col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.station-col header {
  padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.station-col header .title { font-weight: 700; font-size: 15px; }
.station-col .body { padding: 12px; display: flex; flex-direction: column; gap: 10px; min-height: 120px; }
.station-col.free header { background: var(--ok-soft); }

.turn-card { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--surface); }
.turn-card .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.turn-card .num { font-weight: 800; color: var(--primary-602); }
.turn-card .client { font-weight: 600; margin-top: 6px; }
.turn-card .meta { font-size: 13px; color: var(--text-2); margin-top: 4px; }
.turn-card .total { font-weight: 800; font-size: 16px; }
.turn-card .actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.queue-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px; background: var(--warn-soft); border-radius: 10px; font-size: 14px; }

/* ---------------- Gráficas ---------------- */
.chart { display: flex; align-items: flex-end; gap: 3px; height: 190px; padding-top: 10px; border-bottom: 2px solid var(--border); }
.chart .bar { flex: 1; min-width: 4px; background: var(--primary); border-radius: 4px 4px 0 0; position: relative; min-height: 2px; }
.chart .bar:hover { background: var(--primary-602); }
.chart .bar span {
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  background: var(--nav); color: #fff; font-size: 11px; padding: 3px 6px; border-radius: 6px;
  white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .12s;
}
.chart .bar:hover span { opacity: 1; }
.chart-labels { display: flex; gap: 3px; margin-top: 6px; font-size: 10px; color: var(--text-3); }
.chart-labels div { flex: 1; text-align: center; overflow: hidden; }

.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px; font-size: 13px; color: var(--text-2); }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; margin-right: 6px; }

/* ---------------- Modal / toasts ---------------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .55);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100;
}
.modal {
  background: var(--surface); border-radius: 14px; width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg);
}
.modal header { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal header h3 { margin: 0; font-size: 17px; text-transform: none; letter-spacing: 0; color: var(--text); }
.modal .body { padding: 22px; }
.modal footer { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.modal .x { border: none; background: none; font-size: 24px; cursor: pointer; color: var(--text-3); line-height: 1; }

.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast {
  background: var(--nav); color: #fff; padding: 13px 18px; border-radius: 10px;
  box-shadow: var(--shadow-lg); font-size: 14px; max-width: 360px;
  animation: slidein .18s ease-out;
}
.toast.ok { background: var(--ok); }
.toast.err { background: var(--danger); }
.toast.warn { background: var(--warn); }
@keyframes slidein { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------------- Diversos ---------------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; border-bottom: 2px solid var(--border); }
.tabs button {
  background: none; border: none; padding: 11px 16px; font-size: 14px; font-weight: 600;
  color: var(--text-2); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px;
  min-height: 44px;
}
.tabs button.active { color: var(--primary-602); border-bottom-color: var(--primary); }

.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.mt { margin-top: 16px; }
.muted { color: var(--text-3); font-size: 13px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

.currency-select {
  width: auto; min-width: 96px; min-height: 38px; padding: 6px 10px;
  font-size: 13px; font-weight: 700; border-radius: 999px;
  background: var(--surface-2); cursor: pointer;
}

.price-input { width: 110px; padding: 8px 10px; min-height: 40px; text-align: right; }

.qr-box { text-align: center; }
.qr-box img { width: 260px; height: 260px; border: 1px solid var(--border); border-radius: 12px; background: #fff; }

.rank-pos { font-size: 20px; font-weight: 800; width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--surface-2); color: var(--text-2); }
.rank-pos.p1 { background: #fbbf24; color: #78350f; }
.rank-pos.p2 { background: #cbd5e1; color: #334155; }
.rank-pos.p3 { background: #fdba74; color: #7c2d12; }

.matrix td, .matrix th { padding: 8px; }
.matrix td.cell { text-align: right; }

.pill-list { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------------- Responsive ---------------- */
@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .nav { flex-direction: row; overflow-x: auto; }
  .nav a { white-space: nowrap; padding: 10px 12px; }
  .brand, .nav-user { display: none; }
  .content { padding: 14px; }
  .scanner { grid-template-columns: 1fr; }
}
