/* ==========================================================================
   Token di design — modificare qui colori, raggi e font per tutto il progetto
   ========================================================================== */

/* Stile "Mise": bianco e nero netti, un solo colore di marca (lime) usato come evidenziatore e mai per
   testi su chiaro, angoli decisi, niente ombre morbide. Titoli Bricolage Grotesque, testo Geist.
   :host = componente <prenota-tavolo> (shadow DOM). Nel componente il tema scuro è attivo solo con theme="auto". */
:root,
:host {
  /* Unità tipografica: 1rem sul sito; il componente la fissa a 16px (css/widget.css) per non dipendere
     dalla dimensione del font della pagina che lo ospita. Usare calc(N * var(--rem)) al posto di Nrem. */
  --rem: 1rem;
  color-scheme: light;
  --bg: #f7f7f4;
  --surface: #ffffff;
  --surface-2: #efefea;
  --line: #e2e2dc;
  --ink: #0e0e0d;
  --ink-2: #3b3b38;
  --muted: #74746e;

  /* Azioni principali (pulsanti, selezioni): nero su chiaro, lime su scuro. */
  --accent: #0e0e0d;
  --accent-hover: #2b2b29;
  --accent-ink: #ffffff;
  --accent-soft: #f1fbd0;

  /* Colore di marca: riempimenti ed evidenziazioni, sempre con testo --brand-ink sopra. */
  --brand: #d2fa3c;
  --brand-ink: #0e0e0d;
  --brand-soft: #f1fbd0;

  --ok: #19803d;
  --ok-soft: #e3f6e8;
  --warn: #a15c00;
  --warn-soft: #fdf0d9;
  --danger: #c4241a;
  --danger-soft: #fde6e4;
  --seated: #d9480f; /* arancione: tavolo in corso */
  --seated-soft: #ffeadb;

  --radius: 10px;
  --radius-sm: 8px;
  --radius-control: 8px; /* pulsanti, schede, campi */
  --shadow: 0 1px 0 rgba(14, 14, 13, 0.04);
  --shadow-pop: 0 12px 32px -12px rgba(14, 14, 13, 0.25); /* solo per ciò che galleggia: finestre, avvisi */
  --focus: 0 0 0 3px color-mix(in srgb, var(--brand) 85%, var(--ink));

  --font: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Bricolage Grotesque", "Geist", system-ui, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root,
  :host([theme="auto"]) {
    color-scheme: dark;
    --bg: #0c0c0b;
    --surface: #151514;
    --surface-2: #1f1f1d;
    --line: #2d2d2a;
    --ink: #f3f3ee;
    --ink-2: #c9c9c2;
    --muted: #8e8e86;

    --accent: #d2fa3c;
    --accent-hover: #e0ff6b;
    --accent-ink: #0e0e0d;
    --accent-soft: #263010;

    --brand-soft: #263010;

    --ok: #6ee591;
    --ok-soft: #123020;
    --warn: #f5b35c;
    --warn-soft: #36270f;
    --danger: #ff8a7f;
    --danger-soft: #3a1714;
    --seated: #ff8c4a;
    --seated-soft: #3a1f10;

    --shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
    --shadow-pop: 0 12px 32px -12px rgba(0, 0, 0, 0.7);
  }
}

/* ==========================================================================
   Base
   ========================================================================== */

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p,
dl,
dd,
ul {
  margin: 0;
}

h1,
h2 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.03em;
}

h1 {
  font-size: clamp(calc(2 * var(--rem)), 4.5vw, calc(2.9 * var(--rem)));
  line-height: 1.02;
}

h2 {
  font-size: calc(1.2 * var(--rem));
  letter-spacing: -0.02em;
}

h3 {
  font-size: calc(0.95 * var(--rem));
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

a {
  color: inherit;
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-color: currentColor;
}

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
}

/* ==========================================================================
   Layout
   ========================================================================== */

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px;
}

main {
  padding: 32px 0 64px;
}

.stack {
  display: grid;
  gap: 16px;
}

.stack-lg {
  display: grid;
  gap: 24px;
}

.grid-2,
.grid-3 {
  display: grid;
  gap: 16px;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.page-head {
  display: grid;
  gap: 8px;
}

.page-head-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: calc(0.72 * var(--rem));
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
}

/* Il quadratino lime: l'unico "segno" di marca ricorrente. */
.eyebrow::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--brand);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 15%, transparent);
}

.lead {
  color: var(--ink-2);
  font-size: calc(1.05 * var(--rem));
}

.hint,
.fine-print {
  color: var(--muted);
  font-size: calc(0.82 * var(--rem));
}

.empty {
  grid-column: 1 / -1;
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-align: center;
  font-size: calc(0.9 * var(--rem));
}

.spacer {
  flex: 1;
}

/* ==========================================================================
   Topbar
   ========================================================================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 64px;
}

.brand {
  display: flex;
  min-width: 0;
  white-space: nowrap;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: calc(1.15 * var(--rem));
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 7px;
  background: var(--brand);
  color: var(--brand-ink);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: calc(1 * var(--rem));
}

.nav {
  display: flex;
  gap: 4px;
}

.nav a {
  padding: 8px 12px;
  border-radius: var(--radius-control);
  color: var(--ink-2);
  font-weight: 600;
  font-size: calc(0.9 * var(--rem));
  text-decoration: none;
}

.nav a:hover {
  background: var(--surface-2);
}

.nav a[aria-current="page"] {
  background: var(--ink);
  color: var(--bg);
}

/* ==========================================================================
   Form
   ========================================================================== */

.field {
  display: grid;
  gap: 6px;
  align-content: start;
}

.label {
  font-size: calc(0.82 * var(--rem));
  font-weight: 600;
  color: var(--ink-2);
}

.label small {
  font-weight: 400;
  color: var(--muted);
}

input:not([type="radio"], [type="checkbox"]),
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:not([type="radio"], [type="checkbox"]):focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus);
}

textarea {
  resize: vertical;
  font: inherit;
  color: inherit;
  line-height: 1.4;
}

input::placeholder {
  color: var(--muted);
}

input[type="checkbox"] {
  accent-color: var(--accent);
  width: 18px;
  height: 18px;
  margin: 0;
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}

/* Bottoni */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  font-weight: 600;
  font-size: calc(0.92 * var(--rem));
  white-space: nowrap;
  text-decoration: none; /* anche quando il pulsante è un link */
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn-sm {
  min-height: 34px;
  padding: 0 14px;
  font-size: calc(0.84 * var(--rem));
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-primary:disabled {
  opacity: 0.45;
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.btn-ghost:hover {
  background: var(--surface-2);
}

.btn-danger-ghost {
  background: transparent;
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
  color: var(--danger);
}

.btn-danger-ghost:hover {
  background: var(--danger-soft);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: calc(1.2 * var(--rem));
  line-height: 1;
}

.icon-btn:hover:not(:disabled) {
  background: var(--surface-2);
}

.icon-btn.danger {
  color: var(--danger);
}

.icon-btn:disabled {
  opacity: 0.4;
}

/* Scelte a scheda (radio) — date, servizi, sale, orari */

.choice {
  position: relative;
  display: block;
}

.choice input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.choice input:disabled {
  cursor: not-allowed;
}

.choice-face {
  display: grid;
  place-items: center;
  gap: 2px;
  height: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  text-align: center;
  font-weight: 600;
  transition: border-color 0.15s, background 0.15s;
}

.choice-face small {
  font-size: calc(0.72 * var(--rem));
  font-weight: 600;
  color: var(--muted);
}

.choice:hover input:not(:disabled) + .choice-face {
  border-color: var(--accent);
}

.choice input:checked + .choice-face {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.choice input:checked + .choice-face small {
  color: inherit;
  opacity: 0.85;
}

.choice input:focus-visible + .choice-face {
  box-shadow: var(--focus);
}

.choice input:disabled + .choice-face {
  opacity: 0.45;
  background: var(--surface-2);
}

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 6px;
}

.segmented .choice-face {
  min-height: 42px;
  padding: 8px 10px;
  font-size: calc(0.9 * var(--rem));
}

.date-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 8px;
  scroll-snap-type: x mandatory;
}

.date-strip .choice {
  flex: 0 0 68px;
  scroll-snap-align: start;
}

.date-strip strong {
  font-size: calc(1.25 * var(--rem));
  line-height: 1.1;
}

.time-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}

.time-grid strong {
  font-size: calc(1.05 * var(--rem));
}

.stepper {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}

.stepper button {
  width: 42px;
  height: 40px;
  border: 0;
  background: transparent;
  font-size: calc(1.2 * var(--rem));
}

.stepper button:hover {
  background: var(--surface-2);
}

.stepper input[type="number"] {
  width: 48px;
  min-height: 40px;
  padding: 0;
  border: 0;
  border-radius: 0;
  text-align: center;
  font-weight: 700;
  -moz-appearance: textfield;
}

.stepper input::-webkit-inner-spin-button,
.stepper input::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

/* Toni di stato */

.tone-ok {
  color: var(--ok) !important;
}

.tone-warn {
  color: var(--warn) !important;
}

.tone-danger {
  color: var(--danger) !important;
}

.tone-bg-ok {
  background: var(--ok);
}

.tone-bg-warn {
  background: var(--warn);
}

.tone-bg-danger {
  background: var(--danger);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: calc(0.72 * var(--rem));
  font-weight: 700;
  font-family: var(--font);
  vertical-align: middle;
}

.badge-online {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge-telefono {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge-ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge-cancelled {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ==========================================================================
   Dialog e toast
   ========================================================================== */

.dialog {
  width: min(560px, calc(100% - 32px));
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-pop);
}

.dialog::backdrop {
  background: rgba(14, 14, 13, 0.5);
  backdrop-filter: blur(2px);
}

.dialog-head,
.dialog-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-foot {
  justify-content: flex-end;
  padding-top: 8px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 100;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: var(--radius-control);
  background: var(--ink);
  color: var(--bg);
  font-weight: 600;
  font-size: calc(0.9 * var(--rem));
  box-shadow: var(--shadow-pop);
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.toast[data-tone="error"] {
  background: var(--danger);
  color: #fff;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Pagina in caricamento: il contenuto appare quando i dati sono pronti. */
.is-loading main {
  visibility: hidden;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 640px) {
  main {
    padding-top: 20px;
  }

  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .nav a {
    padding: 8px 10px;
  }

  /* Intestazione con il solo logo (pagina cliente): centrata */
  .topbar-inner:not(:has(.nav)) {
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
