/* SPEC-0004 R21 — Estilo del panel del restaurante. Adaptado de whatsapp-agente@f6a5100
   (assets/panel.css): mismos tokens y piezas (tarjetas, botones, avisos, formularios), pensado
   para una tablet en la cocina o la barra: tablet primero, también móvil y ordenador; botones y
   campos de al menos 48 px, tipografía grande y alto contraste, legible a 1 m. Solo modo claro.
   Un solo fichero, sin fuentes ni recursos externos, sin estilos en línea (CSP: style-src 'self'). */

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --bg: #eef0f3;
  --surface: #ffffff;
  --surface-2: #f5f6f8;
  --fg: #0b0f17;
  --muted: #4b5563;
  --line: #c9ced6;
  --accent: #1d4ed8;
  --accent-fg: #ffffff;
  --accent-soft: #dbe6ff;
  --ok: #166534;
  --ok-soft: #dcfce7;
  --warn: #92400e;
  --warn-soft: #fef3c7;
  --err: #b91c1c;
  --err-soft: #fee2e2;
  --neutral: #374151;
  --neutral-soft: #e5e7eb;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px;
  --r-sm: 8px; --r: 12px; --r-lg: 16px; --r-pill: 999px;
  --shadow: 0 1px 2px rgb(16 24 40 / 8%), 0 1px 3px rgb(16 24 40 / 10%);
  --shadow-lg: 0 8px 24px rgb(16 24 40 / 14%);
  --touch: 48px; /* objetivo táctil mínimo */
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 18px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 1.75rem; line-height: 1.2; margin: 0 0 var(--s5); }
h2 { font-size: 1.25rem; margin: var(--s8) 0 var(--s3); }
p { margin: 0 0 var(--s3); }
.muted { color: var(--muted); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- Cabecera: restaurante y local, selector (operador), salir; navegación debajo ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s3) var(--s4);
  padding: var(--s3) var(--s5) 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.brand { display: flex; flex-direction: column; flex: 1 1 10rem; min-width: 0; color: var(--fg); text-decoration: none; }
.brand-name { font-size: 1.3rem; font-weight: 800; line-height: 1.2; overflow-wrap: anywhere; }
.brand-local { color: var(--muted); font-weight: 600; font-size: 1rem; overflow-wrap: anywhere; }
.logout { margin: 0; }
.nav { display: flex; flex: 1 0 100%; gap: var(--s1); margin: 0 calc(-1 * var(--s2)); }
.nav a {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 0 var(--s2);
  border-bottom: 4px solid transparent;
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.nav a:hover { color: var(--fg); background: var(--surface-2); }
.nav a.active { color: var(--accent); border-bottom-color: var(--accent); }

/* SPEC-0004 R4: selector de tenant (solo operador). */
.tenant-select { display: flex; align-items: center; gap: var(--s2); margin: 0; }
.tenant-select select { min-width: 12rem; }

/* ---------- Página y tarjetas ---------- */
.page { max-width: 1240px; margin: 0 auto; padding: var(--s6) var(--s5) var(--s8); }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: var(--s5);
}
.coming p:last-child { margin: 0; font-size: 1.1rem; }

/* ---------- Chips y avisos ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--s3);
  border-radius: var(--r-pill);
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
}
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-err { background: var(--err-soft); color: var(--err); }
.chip-neutral { background: var(--neutral-soft); color: var(--neutral); }
.alert { padding: var(--s3) var(--s4); border-radius: var(--r-sm); font-weight: 700; }
.alert-ok { background: var(--ok-soft); color: var(--ok); }
.alert-err { background: var(--err-soft); color: var(--err); }

/* ---------- Formularios y botones (≥ 48 px) ---------- */
.stack { display: flex; flex-direction: column; gap: var(--s4); }
.field { display: flex; flex-direction: column; gap: var(--s1); font-size: 1rem; font-weight: 700; color: var(--muted); }
input, select {
  min-height: var(--touch);
  padding: 0 var(--s3);
  font: inherit;
  color: var(--fg);
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--r-sm);
}
input:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch);
  min-width: var(--touch);
  padding: 0 var(--s5);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  border: 2px solid transparent;
  border-radius: var(--r-sm);
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); }
.btn-primary { background: var(--accent); color: var(--accent-fg); }
.btn-secondary { background: var(--surface); color: var(--fg); border-color: var(--line); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-block { width: 100%; }

/* ---------- Mi cuenta ---------- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: var(--s2) var(--s5); margin: 0; }
.kv dt { color: var(--muted); font-weight: 700; }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- Acceso ---------- */
body.bare { min-height: 100vh; display: grid; place-items: center; }
.login-wrap { width: 100%; padding: var(--s5); display: grid; place-items: center; }
.login-card { width: 100%; max-width: 420px; padding: var(--s8) var(--s6); box-shadow: var(--shadow-lg); }
.login-title { text-align: center; font-size: 1.2rem; font-weight: 800; margin-bottom: var(--s5); }
/* El logo de la plataforma es la versión «clara»: sobre una pastilla oscura fija (origen, PNL-21). */
.login-logo { display: block; height: 56px; width: auto; max-width: 100%; margin: 0 auto var(--s4); object-fit: contain; background: #111827; border-radius: var(--r); padding: 8px 14px; }

/* ---------- Móvil ---------- */
@media (max-width: 640px) {
  body { font-size: 17px; }
  .topbar { padding: var(--s2) var(--s4) 0; }
  .page { padding: var(--s4) var(--s4) var(--s6); }
  h1 { font-size: 1.45rem; }
  .tenant-select { flex: 1 0 100%; order: 3; }
  .tenant-select select { flex: 1; min-width: 0; }
  .nav { order: 4; display: grid; grid-template-columns: repeat(3, 1fr); }
  .nav a { min-height: var(--touch); }
  .kv { grid-template-columns: 1fr; gap: 0; }
  .kv dd { margin-bottom: var(--s2); }
}

/* ---------- Ordenador ---------- */
@media (min-width: 1280px) {
  .topbar { flex-wrap: nowrap; padding-top: 0; }
  .nav { flex: 0 1 auto; order: 1; margin: 0; }
  .nav a { flex: 0 0 auto; padding: 0 var(--s4); }
  .tenant-select { order: 2; }
  .logout { order: 3; }
}
