/* BistroBook — sistema visual compartido -------------------------------- */
/* Tema oscuro por defecto (el de marca). El claro se activa con
   data-theme="light" en <html> y solo redefine tokens: ninguna regla de
   componente lleva colores fijos, así los dos temas quedan completos. */
:root {
  --bg: #0f1113;
  --bg-soft: #16191d;
  --panel: #1b1f24;
  --panel-2: #21262d;
  --line: #2b3138;
  --line-soft: #23282e;
  --text: #eceff3;
  --muted: #9aa5b1;
  --dim: #6b7683;
  --gold: #d9a441;
  --gold-soft: rgba(217, 164, 65, .12);
  --on-gold: #1a1408;
  --green: #35c17f;
  --green-soft: rgba(53, 193, 127, .12);
  --on-green: #08281a;
  --red: #e05a5a;
  --red-soft: rgba(224, 90, 90, .12);
  --blue: #5aa2e0;
  --violet: #9b7ce0;
  --pink: #e0699b;
  --hover: #2a3038;
  --hover-line: #39414a;
  /* Estados de las mesas en el plano */
  --st-free-bg: rgba(53, 193, 127, .14);
  --st-free-bd: rgba(53, 193, 127, .55);
  --st-reserved-bg: rgba(217, 164, 65, .16);
  --st-reserved-bd: rgba(217, 164, 65, .6);
  --st-seated-bg: rgba(90, 162, 224, .18);
  --st-seated-bd: rgba(90, 162, 224, .6);
  --st-blocked-bg: rgba(155, 124, 224, .12);
  --st-blocked-bd: rgba(155, 124, 224, .45);
  --st-stripe: rgba(255, 255, 255, .03);
  /* Gráficas */
  --chart-1: #5aa2e0;
  --chart-2: #d9a441;
  --chart-3: #35c17f;
  --chart-grid: #2b3138;
  --chart-axis: #6b7683;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: "Georgia", "Times New Roman", serif;
}

:root[data-theme="light"] {
  --bg: #f3f5f2;
  --bg-soft: #ffffff;
  --panel: #ffffff;
  --panel-2: #ecefe9;
  --line: #d5dad2;
  --line-soft: #e5e8e2;
  --text: #171b17;
  --muted: #5b635c;
  --dim: #828a82;
  --gold: #96690f;
  --gold-soft: rgba(150, 105, 15, .10);
  --on-gold: #ffffff;
  --green: #12704b;
  --green-soft: rgba(18, 112, 75, .10);
  --on-green: #ffffff;
  --red: #a8382c;
  --red-soft: rgba(168, 56, 44, .10);
  --blue: #1f5f96;
  --violet: #5b45a3;
  --pink: #a63a68;
  --hover: #e6eae3;
  --hover-line: #c3c9bf;
  --st-free-bg: rgba(18, 112, 75, .13);
  --st-free-bd: rgba(18, 112, 75, .5);
  --st-reserved-bg: rgba(150, 105, 15, .15);
  --st-reserved-bd: rgba(150, 105, 15, .5);
  --st-seated-bg: rgba(31, 95, 150, .14);
  --st-seated-bd: rgba(31, 95, 150, .5);
  --st-blocked-bg: rgba(91, 69, 163, .11);
  --st-blocked-bd: rgba(91, 69, 163, .4);
  --st-stripe: rgba(23, 27, 23, .05);
  --chart-1: #1f5f96;
  --chart-2: #96690f;
  --chart-3: #12704b;
  --chart-grid: #d5dad2;
  --chart-axis: #828a82;
  --shadow: 0 8px 24px rgba(23, 27, 23, .12);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0; }

/* Tipografía utilitaria */
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: 13px; }
.tiny { font-size: 11.5px; letter-spacing: .03em; text-transform: uppercase; color: var(--dim); font-weight: 600; }
/* Para valores técnicos (URLs, slugs, notas): mismo tamaño, sin mayúsculas forzadas. */
.tiny.raw { text-transform: none; letter-spacing: 0; font-weight: 500; }
.num { font-variant-numeric: tabular-nums; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.gold { color: var(--gold); }
.green { color: var(--green); }
.red { color: var(--red); }

/* Layout */
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 20px; }
.wrap-sm { max-width: 640px; margin: 0 auto; padding: 0 18px; }
.row { display: flex; gap: 12px; align-items: center; }
.row.between { justify-content: space-between; }
.row.wrap-row { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 12px; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0,1fr)); }
.spacer { flex: 1; }

/* Tarjetas */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.card.tight { padding: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; }
.card-title { font-size: 15px; font-weight: 600; }

/* KPI */
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.kpi .label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--dim); font-weight: 600; }
.kpi .value { font-size: 27px; font-weight: 650; margin-top: 6px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .foot { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.kpi.hero { background: linear-gradient(160deg, color-mix(in srgb, var(--gold) 14%, transparent), color-mix(in srgb, var(--gold) 3%, transparent)); border-color: color-mix(in srgb, var(--gold) 40%, transparent); }
.kpi.hero .value { color: var(--gold); }
.kpi.good .value { color: var(--green); }
.kpi.bad .value { color: var(--red); }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--panel-2); border: 1px solid var(--line);
  color: var(--text); border-radius: var(--radius-sm);
  padding: 9px 14px; font-size: 14px; font-weight: 550; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--hover); border-color: var(--hover-line); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: var(--on-gold); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.success { background: var(--green); border-color: var(--green); color: var(--on-green); }
.btn.success:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, transparent); background: transparent; }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.lg { padding: 13px 20px; font-size: 16px; width: 100%; }
.btn.block { width: 100%; }

/* Formularios */
.field { display: flex; flex-direction: column; gap: 6px; }
/* El atributo hidden debe ganar siempre: sin esto, cualquier clase con display propio lo anula. */
[hidden] { display: none !important; }
.field label { font-size: 12.5px; color: var(--muted); font-weight: 550; }
input[type=text], input[type=email], input[type=tel], input[type=number],
input[type=date], input[type=time], input[type=password], select, textarea {
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 12px; outline: none; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
textarea { resize: vertical; min-height: 70px; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 32px; }

/* Chips y badges */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--bg-soft);
  cursor: pointer; font-size: 14px; user-select: none; transition: all .12s;
}
.chip:hover { border-color: var(--hover-line); }
.chip.on { background: var(--gold); border-color: var(--gold); color: var(--on-gold); font-weight: 600; }
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .02em; background: var(--panel-2); color: var(--muted);
  border: 1px solid var(--line);
}
.badge.gold { background: var(--gold-soft); color: var(--gold); border-color: color-mix(in srgb, var(--gold) 35%, transparent); }
.badge.green { background: var(--green-soft); color: var(--green); border-color: color-mix(in srgb, var(--green) 35%, transparent); }
.badge.gray { background: color-mix(in srgb, var(--dim) 12%, transparent); color: var(--dim); border-color: color-mix(in srgb, var(--dim) 35%, transparent); }
.badge.red { background: var(--red-soft); color: var(--red); border-color: color-mix(in srgb, var(--red) 35%, transparent); }
.badge.blue { background: color-mix(in srgb, var(--blue) 12%, transparent); color: var(--blue); border-color: color-mix(in srgb, var(--blue) 35%, transparent); }
.badge.violet { background: color-mix(in srgb, var(--violet) 12%, transparent); color: var(--violet); border-color: color-mix(in srgb, var(--violet) 35%, transparent); }
.badge.pink { background: color-mix(in srgb, var(--pink) 12%, transparent); color: var(--pink); border-color: color-mix(in srgb, var(--pink) 35%, transparent); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }

/* Tablas */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--dim); font-weight: 600; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 10px; border-bottom: 1px solid var(--line-soft); font-size: 14px; vertical-align: middle; }
tbody tr:hover { background: color-mix(in srgb, var(--text) 3%, transparent); }
tbody tr:last-child td { border-bottom: none; }
.table-scroll { overflow-x: auto; }

/* Barras y progreso */
.bar { height: 7px; border-radius: 999px; background: var(--panel-2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--gold); border-radius: 999px; }
.bar.green > i { background: var(--green); }

/* Embudo */
.funnel { display: flex; flex-direction: column; gap: 9px; }
.funnel-step { display: grid; grid-template-columns: 190px 1fr 100px; gap: 12px; align-items: center; }
.funnel-bar { height: 32px; border-radius: 8px; background: var(--panel-2); overflow: hidden; position: relative; }
.funnel-bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), color-mix(in srgb, var(--gold) 70%, #000)); }
.funnel-step .n { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

/* Estados de carga / vacío */
.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty .big { font-size: 34px; margin-bottom: 10px; opacity: .5; }
.skeleton { background: linear-gradient(90deg, var(--panel-2) 25%, var(--hover) 50%, var(--panel-2) 75%); background-size: 200% 100%; animation: sk 1.3s infinite; border-radius: 8px; }
@keyframes sk { 0% { background-position: 200% 0 } 100% { background-position: -200% 0 } }

/* Toast */
#toasts { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 90; }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--gold); border-radius: 10px; padding: 12px 16px; box-shadow: var(--shadow); max-width: 340px; animation: slide .2s ease; }
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
@keyframes slide { from { transform: translateX(20px); opacity: 0 } }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: color-mix(in srgb, var(--text) 55%, transparent); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 80; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; box-shadow: var(--shadow); }
.modal-head { padding: 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }

/* Marca */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: -.02em; }
.brand .mark { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(140deg, var(--gold), color-mix(in srgb, var(--gold) 72%, #000)); display: grid; place-items: center; color: var(--on-gold); font-weight: 800; font-size: 15px; }

@media (max-width: 900px) {
  .grid-4, .grid-5 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-3 { grid-template-columns: 1fr; }
  .funnel-step { grid-template-columns: 120px 1fr 64px; }
}
@media (max-width: 560px) {
  .grid-2, .grid-4, .grid-5 { grid-template-columns: 1fr; }
  .wrap { padding: 0 14px; }
}

/* ───── Plano del salón ───── */
.floor {
  position: relative; width: 100%; height: 0;
  background:
    linear-gradient(var(--line-soft) 1px, transparent 1px) 0 0 / 5% 7.8125%,
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px) 0 0 / 5% 7.8125%,
    var(--bg-soft);
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  user-select: none;
}
.floor-stage { position: absolute; inset: 0; }
.table-shape {
  position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; border: 1.5px solid var(--line); background: var(--panel-2); color: var(--text);
  border-radius: 8px; font-size: 12px; line-height: 1.1; overflow: hidden; transition: box-shadow .12s, transform .06s;
}
.table-shape.shape-round { border-radius: 50%; }
.table-shape.shape-bar { border-radius: 4px; }
.table-shape .t-num { font-weight: 700; font-size: 13px; }
.table-shape .t-cap { font-size: 10px; opacity: .7; }
.table-shape .t-guest { font-size: 10px; max-width: 92%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-shape .t-next { font-size: 10px; opacity: .75; }
.table-shape.dragging { box-shadow: var(--shadow); transform: scale(1.04); z-index: 5; }
.table-shape.selected { outline: 2px solid var(--gold); outline-offset: 2px; }

/* Estados */
.st-free { border-color: var(--st-free-bd); background: var(--st-free-bg); }
.st-reserved { border-color: var(--st-reserved-bd); background: var(--st-reserved-bg); }
.st-seated { border-color: var(--st-seated-bd); background: var(--st-seated-bg); }
.st-blocked { border-color: var(--st-blocked-bd); background: var(--st-blocked-bg); }
.st-inactive { border-color: var(--line); background: repeating-linear-gradient(45deg, var(--st-stripe) 0 6px, transparent 6px 12px); color: var(--dim); }
.floor-guest .st-free:hover { box-shadow: 0 0 0 3px var(--gold-soft); }
.floor-guest .st-reserved, .floor-guest .st-inactive { cursor: not-allowed; }
.table-shape.oversized { border-style: dashed; }

.zone-label {
  position: absolute; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--dim); font-weight: 700; pointer-events: none; white-space: nowrap;
}
.legend-dot { width: 11px; height: 11px; border-radius: 3px; border: 1.5px solid; display: inline-block; }
.legend-dot.st-inactive { background: var(--panel-2); }

/* Barra de herramientas del editor */
.floor-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.floor-side { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .floor-side { grid-template-columns: minmax(0, 1fr); } }

/* Selector de hora del plano */
.time-strip { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; }
.time-strip button {
  flex-shrink: 0; background: var(--bg-soft); border: 1px solid var(--line); color: var(--muted);
  border-radius: 8px; padding: 7px 11px; font-size: 13px; cursor: pointer; font-variant-numeric: tabular-nums;
}
.time-strip button:hover { border-color: var(--hover-line); color: var(--text); }
.time-strip button.on { background: var(--gold); border-color: var(--gold); color: var(--on-gold); font-weight: 600; }
.time-strip button.past { opacity: .45; }

/* ───── Crédito de autoría ───── */
.credit {
  display: flex; align-items: center; gap: 6px;
  font-size: 10.5px; letter-spacing: .02em; color: var(--dim);
  opacity: .85;
}
.credit.compact { font-size: 9.5px; }
.credit .sp-logo { height: 26px; width: auto; display: block; flex-shrink: 0; }
.credit.compact .sp-logo { height: 22px; }
/* El logotipo de Sparkplug es gris (SPARK oscuro, PLUG claro): está pensado
   para fondo blanco. Se compensa en los dos temas para que se lea igual. */
:root:not([data-theme="light"]) .sp-logo { filter: brightness(1.5); }
:root[data-theme="light"] .sp-logo { filter: brightness(.85); }
footer .credit, .wrap-sm .credit { justify-content: center; margin-top: 10px; }

/* ───── Táctil (tablets y celulares) ───── */
@media (hover: none) {
  /* Sin cursor no hay hover: los estados de hover se apagan para que un toque
     no deje un botón "pegado" con el color de hover. */
  .btn:hover, .chip:hover, .slot:hover, .time-strip button:hover { background: inherit; border-color: var(--line); }
  .btn.primary:hover { background: var(--gold); filter: none; }
  .btn.success:hover { background: var(--green); filter: none; }
  tbody tr:hover { background: transparent; }
  /* Áreas de toque cómodas */
  .btn { min-height: 40px; }
  .btn.sm { min-height: 36px; padding: 8px 12px; }
  .chip, .slot, .date-chip { min-height: 44px; }
  .time-strip button { min-height: 42px; padding: 9px 14px; }
  input, select, textarea { min-height: 42px; font-size: 16px; } /* 16px evita el zoom automático de iOS */
  .tabs button { min-height: 44px; }
  .nav a { min-height: 42px; }
}
* { -webkit-tap-highlight-color: transparent; }

/* Mapa de Google incrustado (perfil del restaurante y confirmación al comensal). */
.mapa-embed { width: 100%; height: 240px; border: 0; border-radius: 12px; background: var(--bg-soft); margin-top: 10px; }

/* Asiento de barra: cuadrito de una persona; solo muestra su número. */
.table-shape.bar-seat { border-radius: 50% 50% 8px 8px; }
.table-shape.bar-seat .t-num { font-size: 11px; }
