/* ===========================================================
   B&B Il Frattiero — Motore di prenotazione (book.ilfrattiero.it)
   Design tokens + fonts copiati dal sito principale (parità visiva).
   Pure static, zero build. Font self-hosted (GDPR/CSP-safe).
   =========================================================== */

/* ---------- Self-hosted fonts ---------- */
@font-face {
  font-family: 'Playfair Display';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(/assets/fonts/playfair-latin.woff2) format('woff2');
}
@font-face {
  font-family: 'Geist';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url(/assets/fonts/geist-latin.woff2) format('woff2');
}

/* ---------- Design tokens (from main site) ---------- */
:root {
  --background: oklch(0.97 0.012 85);
  --foreground: oklch(0.26 0.018 60);
  --card: oklch(0.985 0.008 85);
  --card-foreground: oklch(0.26 0.018 60);
  --primary: oklch(0.55 0.13 45);          /* terracotta */
  --primary-foreground: oklch(0.98 0.01 85);
  --secondary: oklch(0.92 0.025 80);       /* warm sand */
  --secondary-foreground: oklch(0.34 0.04 55);
  --muted: oklch(0.93 0.018 82);
  --muted-foreground: oklch(0.5 0.03 60);
  --accent: oklch(0.62 0.07 130);          /* olive/sage */
  --accent-foreground: oklch(0.98 0.01 85);
  --primary-ink: oklch(0.47 0.14 45);
  --accent-ink: oklch(0.47 0.10 130);
  --border: oklch(0.88 0.02 78);
  --input: oklch(0.88 0.02 78);
  --ring: oklch(0.55 0.13 45);

  --overlay: oklch(0.26 0.018 60);
  --on-overlay: oklch(0.98 0.01 85);

  --header-bg: rgb(249 246 236 / 0.949);
  --soft-bg: rgb(244 238 226);
  --accent-soft: rgb(121 141 101 / 0.149);
  --ring-focus: rgb(176 86 40 / 0.302);

  /* OTA channel tints (admin calendar) */
  --ota-booking-bg: oklch(0.6 0.13 250 / 0.22);
  --ota-booking-bd: oklch(0.6 0.13 250 / 0.5);
  --ota-booking-fg: oklch(0.45 0.1 250);
  --ota-airbnb-bg: oklch(0.65 0.16 10 / 0.2);
  --ota-airbnb-bd: oklch(0.65 0.16 10 / 0.5);
  --ota-airbnb-fg: oklch(0.5 0.15 10);
  --danger: oklch(0.55 0.18 25);
  --danger-soft: oklch(0.65 0.16 25 / 0.08);
  --danger-bd: oklch(0.65 0.16 25 / 0.45);

  --radius: 0.5rem;
  --radius-sm: 0.375rem;
  --radius-lg: 0.75rem;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px oklch(0.26 0.018 60 / 0.06);
  --shadow-md: 0 10px 30px oklch(0.26 0.018 60 / 0.13);
  --shadow-lg: 0 18px 44px oklch(0.26 0.018 60 / 0.13);

  --transition-fast: .15s ease;
  --transition-base: .2s ease;

  --font-sans: 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --wrap: 56rem;
}

/* ---------- Dark theme (auto; dark-OS users may opt back to light) ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --background: oklch(0.20 0.012 70);
    --foreground: oklch(0.92 0.012 85);
    --card: oklch(0.245 0.014 70);
    --card-foreground: oklch(0.92 0.012 85);
    --primary: oklch(0.55 0.13 45);
    --primary-foreground: oklch(0.98 0.01 85);
    --secondary: oklch(0.30 0.022 72);
    --secondary-foreground: oklch(0.90 0.02 80);
    --muted: oklch(0.27 0.016 72);
    --muted-foreground: oklch(0.72 0.022 78);
    --accent: oklch(0.64 0.08 130);
    --accent-foreground: oklch(0.16 0.012 70);
    --primary-ink: oklch(0.76 0.12 45);
    --accent-ink: oklch(0.78 0.08 130);
    --border: oklch(0.34 0.015 72);
    --input: oklch(0.34 0.015 72);
    --ring: oklch(0.62 0.13 45);
    --header-bg: rgb(26 21 16 / 0.949);
    --soft-bg: rgb(36 30 23);
    --accent-soft: rgb(121 148 101 / 0.149);
    --ring-focus: rgb(195 106 63 / 0.302);
  }
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
* { border-color: var(--border); }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--foreground);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-serif); font-weight: 600; line-height: 1.15; margin: 0; }
a { color: var(--primary-ink); }
img { max-width: 100%; display: block; }
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 1.25rem; }
.muted { color: var(--muted-foreground); }
.center { text-align: center; }
.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;
}
.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--primary); color: var(--primary-foreground);
  padding: .6rem 1rem; border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  height: 60px;
}
.brand { font-family: var(--font-serif); font-size: 1.25rem; font-weight: 600; color: var(--foreground); text-decoration: none; }
.brand small { display: block; font-family: var(--font-sans); font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted-foreground); font-weight: 500; }
.header-actions { display: flex; align-items: center; gap: .5rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  border: 0; border-radius: var(--radius-pill); cursor: pointer;
  background: var(--primary); color: var(--primary-foreground);
  font-size: .9rem; font-weight: 500; padding: .65rem 1.5rem;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
  text-decoration: none;
}
.btn:hover { opacity: .9; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-block { width: 100%; padding: .95rem; font-size: .98rem; }
.btn-outline {
  background: transparent; color: var(--secondary-foreground);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--soft-bg); opacity: 1; }
.btn-ghost { background: transparent; color: var(--primary-ink); padding: .5rem .75rem; }
.btn-ghost:hover { background: var(--soft-bg); opacity: 1; }
.btn-danger {
  background: var(--danger-soft); color: var(--danger);
  border: 1px solid var(--danger-bd);
}
.btn-danger:hover { background: var(--danger-soft); opacity: .85; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: var(--radius-pill);
  border: 1px solid var(--border); background: transparent; color: var(--foreground);
  cursor: pointer;
}
.icon-btn:hover { background: var(--soft-bg); }

/* ---------- Layout shell ---------- */
main { padding: 1.75rem 0 4rem; }
.panel {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}
@media (min-width: 640px) { .panel { padding: 2rem; } }

.eyebrow {
  font-size: .7rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  color: var(--primary-ink);
}
.step-title { font-size: 1.5rem; margin: .35rem 0 1.25rem; }

/* ---------- Step indicator ---------- */
.steps { display: flex; align-items: center; gap: .4rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.steps .dot {
  width: 26px; height: 26px; border-radius: var(--radius-pill);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 600;
  background: var(--muted); color: var(--muted-foreground);
}
.steps .dot[data-state="active"] { background: var(--primary); color: var(--primary-foreground); }
.steps .dot[data-state="done"] { background: var(--accent); color: var(--accent-foreground); }
.steps .bar { flex: 1 1 14px; height: 2px; background: var(--border); min-width: 14px; }

/* ---------- Best-price badge ---------- */
.guarantee {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .72rem; font-weight: 500;
  background: var(--accent-soft); border: 1px solid var(--accent);
  color: var(--accent-ink); border-radius: var(--radius-pill);
  padding: .3rem .75rem; margin-bottom: 1rem;
}

/* ---------- Calendar ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
.cal-head h3 { font-size: 1.05rem; text-transform: capitalize; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-dow {
  text-align: center; font-size: .68rem; font-weight: 600; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted-foreground); padding: .35rem 0;
}
.cal-cell {
  aspect-ratio: 1 / 1; min-height: 40px; border: 0; background: transparent;
  border-radius: var(--radius); cursor: pointer; font: inherit; font-size: .9rem;
  color: var(--foreground); display: flex; align-items: center; justify-content: center;
  transition: background var(--transition-fast);
}
.cal-cell:hover:not(:disabled) { background: var(--soft-bg); }
.cal-cell.is-empty { visibility: hidden; cursor: default; }
.cal-cell:disabled {
  color: var(--muted-foreground); text-decoration: line-through;
  cursor: not-allowed; opacity: .65;
}
.cal-cell[aria-selected="true"] { background: oklch(0.55 0.13 45 / 0.3); color: var(--foreground); font-weight: 600; }
.cal-cell.in-range { background: oklch(0.55 0.13 45 / 0.14); border-radius: 0; }
.cal-cell.range-start { border-top-left-radius: var(--radius); border-bottom-left-radius: var(--radius); }
.cal-cell.range-end { border-top-right-radius: var(--radius); border-bottom-right-radius: var(--radius); }
.cal-legend { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 1rem; font-size: .75rem; color: var(--muted-foreground); }
.cal-legend span { display: inline-flex; align-items: center; gap: .4rem; }
.swatch { width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--border); display: inline-block; }
.swatch.free { background: var(--card); }
.swatch.busy { background: var(--muted); }
.swatch.sel { background: oklch(0.55 0.13 45 / 0.3); border-color: transparent; }

.stay-summary { margin: 1rem 0; font-size: .9rem; }
.stay-summary strong { font-weight: 600; }

/* ---------- Stepper ---------- */
.field-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 1.25rem 0; }
.stepper { display: inline-flex; align-items: center; gap: .25rem; border: 1px solid var(--border); border-radius: var(--radius-pill); padding: .2rem; }
.stepper button {
  width: 36px; height: 36px; min-width: 36px; border-radius: var(--radius-pill);
  border: 0; background: var(--soft-bg); color: var(--foreground); font-size: 1.1rem; cursor: pointer;
}
.stepper button:disabled { opacity: .4; cursor: not-allowed; }
.stepper .count { min-width: 2ch; text-align: center; font-weight: 600; font-size: .95rem; }

/* ---------- Room cards ---------- */
.rooms { display: grid; gap: .9rem; }
.room {
  display: flex; gap: 1.1rem; align-items: stretch;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1rem; background: var(--card);
}
.room.unavailable { border-style: dashed; opacity: .6; }
.room .photo {
  width: 130px; min-width: 130px; height: 100px; border-radius: var(--radius);
  object-fit: cover; background: var(--muted);
}
.room .body { flex: 1; display: flex; flex-direction: column; }
.room .top { display: flex; justify-content: space-between; gap: 1rem; }
.room h3 { font-size: 1.2rem; }
.room .rdesc { font-size: .8rem; color: var(--muted-foreground); margin-top: .15rem; }
.room .price { text-align: right; white-space: nowrap; }
.room .price .amt { font-family: var(--font-serif); font-size: 1.5rem; font-weight: 600; }
.room .price .per { font-size: .72rem; color: var(--muted-foreground); }
.room .bottom { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: auto; padding-top: .75rem; }
.chip {
  display: inline-flex; align-items: center; gap: .3rem; font-size: .72rem; font-weight: 500;
  background: var(--accent-soft); color: var(--accent-ink);
  border-radius: var(--radius-sm); padding: .2rem .55rem;
}
@media (max-width: 520px) {
  .room { flex-direction: column; }
  .room .photo { width: 100%; height: 150px; }
  .room .price { text-align: left; }
}

/* ---------- Forms ---------- */
.form-grid { display: grid; gap: 1rem; }
@media (min-width: 560px) { .form-grid.cols-2 { grid-template-columns: 1fr 1fr; } .form-grid .col-2 { grid-column: 1 / -1; } }
.fld-label { display: block; font-size: .82rem; font-weight: 500; margin-bottom: .35rem; }
input[type="text"], input[type="email"], input[type="tel"], input[type="number"], input[type="date"], textarea, select {
  width: 100%; font: inherit; font-size: .95rem;
  border: 1px solid var(--input); border-radius: var(--radius-sm);
  background: var(--background); color: var(--foreground);
  padding: .65rem .85rem;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 0; border-color: var(--ring); box-shadow: 0 0 0 3px var(--ring-focus); }
input:user-invalid, textarea:user-invalid { border-color: var(--danger); }
.check { display: flex; align-items: flex-start; gap: .6rem; font-size: .88rem; margin-top: 1rem; }
.check input { width: 1.1rem; height: 1.1rem; margin-top: .15rem; accent-color: var(--primary); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.field-error { color: var(--danger); font-size: .8rem; margin-top: .3rem; }

/* ---------- Price breakdown ---------- */
.breakdown { margin: 1.25rem 0; }
.breakdown .row { display: flex; justify-content: space-between; gap: 1rem; padding: .4rem 0; font-size: .95rem; }
.breakdown .row.green { color: var(--accent-ink); }
.breakdown .row.muted { color: var(--muted-foreground); font-size: .85rem; }
.breakdown .total { border-top: 1px solid var(--border); margin-top: .5rem; padding-top: .85rem; align-items: baseline; }
.breakdown .total .lbl { font-weight: 600; }
.breakdown .total .amt { font-family: var(--font-serif); font-size: 1.75rem; font-weight: 600; }

.banner-ok {
  background: oklch(0.62 0.07 130 / 0.12); border: 1px solid var(--accent);
  color: var(--accent-ink); border-radius: var(--radius); padding: .85rem 1rem;
  font-size: .88rem; margin: 1rem 0;
}

/* ---------- Success ---------- */
.success-badge {
  width: 58px; height: 58px; border-radius: var(--radius-pill); margin: 0 auto 1rem;
  background: oklch(0.62 0.07 130 / 0.16); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center; font-size: 1.7rem;
}
.ref-box {
  display: inline-block; background: var(--soft-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .9rem 1.6rem; margin: 1rem 0; text-align: center;
}
.ref-box .lbl { font-size: .68rem; letter-spacing: .15em; text-transform: uppercase; color: var(--muted-foreground); }
.ref-box .val { font-family: var(--font-serif); font-size: 1.6rem; font-weight: 600; letter-spacing: .06em; }
.contact-block { font-size: .82rem; color: var(--muted-foreground); line-height: 1.7; margin-top: 1.25rem; }

/* ---------- Nav buttons row ---------- */
.nav-row { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1.5rem; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 1.5rem 0; font-size: .8rem; color: var(--muted-foreground); }
.site-footer a { color: var(--muted-foreground); }

/* ---------- Spinner / states ---------- */
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--primary);
  animation: spin .8s linear infinite; margin: 2rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.notice { padding: 1.25rem; border-radius: var(--radius); background: var(--soft-bg); font-size: .9rem; }
.notice.error { background: var(--danger-soft); border: 1px solid var(--danger-bd); color: var(--danger); }

/* ===========================================================
   ADMIN CONSOLE
   =========================================================== */
.admin-gate { max-width: 22rem; margin: 4rem auto; }
.tabs { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--border); }
.tab {
  border: 0; background: transparent; cursor: pointer; font: inherit; font-size: .85rem;
  padding: .6rem .9rem; color: var(--muted-foreground); border-bottom: 2px solid transparent;
}
.tab[aria-selected="true"] { color: var(--primary-ink); border-bottom-color: var(--primary); font-weight: 600; }

/* Gantt reservations calendar */
.gantt-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; gap: 1rem; flex-wrap: wrap; }
.gantt-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.gantt { min-width: 640px; }
.gantt-dates { display: grid; border-bottom: 1px solid var(--border); }
.gantt-dates .lead { border-right: 1px solid var(--border); }
.gantt-dates .d { text-align: center; font-size: .68rem; color: var(--muted-foreground); padding: .35rem 0; border-right: 1px solid oklch(0.88 0.02 78 / 0.5); }
.gantt-dates .d.weekend { background: var(--soft-bg); }
.gantt-row { display: grid; position: relative; height: 46px; border-bottom: 1px solid var(--border); }
.gantt-row:last-child { border-bottom: 0; }
.gantt-row .lead {
  border-right: 1px solid var(--border); display: flex; align-items: center;
  padding: 0 .6rem; font-size: .8rem; font-weight: 500; background: var(--card); position: sticky; left: 0; z-index: 1;
}
.gantt-cells { position: relative; }
.gantt-grid-line { position: absolute; top: 0; bottom: 0; width: 1px; background: oklch(0.88 0.02 78 / 0.5); }
.gbar {
  position: absolute; top: 7px; bottom: 7px; border-radius: 6px;
  font-size: .72rem; font-weight: 500; padding: 0 .5rem;
  display: flex; align-items: center; overflow: hidden; white-space: nowrap;
}
.gbar.direct { background: var(--primary); color: var(--primary-foreground); box-shadow: 0 2px 6px oklch(0.55 0.13 45 / 0.4); cursor: pointer; }
.gbar.booking { background: var(--ota-booking-bg); border: 1px solid var(--ota-booking-bd); color: var(--ota-booking-fg); }
.gbar.airbnb { background: var(--ota-airbnb-bg); border: 1px solid var(--ota-airbnb-bd); color: var(--ota-airbnb-fg); }
.gbar.block {
  border: 1px solid oklch(0.5 0.03 60 / 0.4); color: var(--muted-foreground);
  background: repeating-linear-gradient(45deg, oklch(0.5 0.03 60 / 0.22) 0 5px, oklch(0.5 0.03 60 / 0.08) 5px 10px);
}
.gantt-legend { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 1rem; font-size: .75rem; color: var(--muted-foreground); }

/* Drawer */
.drawer-scrim { position: fixed; inset: 0; background: oklch(0.26 0.018 60 / 0.45); z-index: 60; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 92vw); z-index: 61;
  background: var(--card); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
  padding: 1.5rem; overflow-y: auto;
}
.drawer h2 { font-size: 1.3rem; }
.detail-grid { display: grid; grid-template-columns: auto 1fr; gap: .5rem 1rem; margin: 1rem 0; font-size: .88rem; }
.detail-grid dt { color: var(--muted-foreground); }
.detail-grid dd { margin: 0; }
.status-pill { display: inline-block; font-size: .72rem; font-weight: 500; padding: .25rem .7rem; border-radius: var(--radius-pill); background: oklch(0.62 0.07 130 / 0.16); color: var(--accent-ink); white-space: nowrap; }
.status-pill.cancelled { background: var(--danger-soft); color: var(--danger); }
/* temporal + test tags (admin list) */
.status-pill.now { background: oklch(0.62 0.07 130 / 0.18); color: var(--accent-ink); }        /* In corso — sage */
.status-pill.upcoming { background: var(--accent-soft); color: var(--primary-ink); }             /* In arrivo — terracotta */
.status-pill.past { background: var(--muted); color: var(--muted-foreground); }                  /* Conclusa — muted */
.status-pill.test { background: oklch(0.6 0.13 300 / 0.16); color: oklch(0.5 0.15 300); }         /* PROVA — viola */
.msg-box { background: oklch(0.93 0.018 82 / 0.7); border-radius: var(--radius); padding: .8rem .9rem; font-size: .85rem; margin: 1rem 0; }

/* Admin tables / lists */
.adm-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.adm-table th, .adm-table td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--border); }
.adm-table th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted-foreground); font-weight: 600; }
.adm-table tr.clickable { cursor: pointer; }
.adm-table tr.clickable:hover { background: var(--soft-bg); }

.config-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem; margin-bottom: 1rem; }
.config-card h3 { font-size: 1.05rem; margin-bottom: .75rem; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .8rem; }
.copy-row { display: flex; gap: .5rem; align-items: center; margin: .4rem 0; }
.copy-row input { flex: 1; }
.scope-out { background: var(--danger-soft); border: 1px solid var(--danger-bd); color: var(--danger); border-radius: var(--radius); padding: .85rem 1rem; font-size: .8rem; margin-top: 1.5rem; }
.toast { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%); background: var(--foreground); color: var(--background); padding: .7rem 1.2rem; border-radius: var(--radius-pill); font-size: .85rem; z-index: 80; box-shadow: var(--shadow-md); }
