/* ============================================================
   Pannello cliente - stile mobile-first, pulito e premium.
   ============================================================ */
:root {
  --bg:        #f4efe8;
  --surface:   #ffffff;
  --surface-2: #faf6f0;
  --ink:       #2a2117;
  --ink-soft:  #6b5d4d;
  --line:      #e6ddd0;
  --brand:     #3d2b1f;
  --brand-2:   #5a4231;
  --accent:    #b8895a;
  --ok:        #2f7d4f;
  --danger:    #b23b3b;
  --warn-bg:   #fbf3e6;
  --radius:    16px;
  --radius-sm: 11px;
  --shadow:    0 6px 22px rgba(60, 42, 25, .10);
  --tap:       48px;
  --maxw:      640px;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}

.app { max-width: var(--maxw); margin: 0 auto; min-height: 100dvh; }
.loader { padding: 28vh 24px; text-align: center; color: var(--ink-soft); }

/* ---------- Tipografia ---------- */
h1 { font-size: 1.35rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0; }
.muted { color: var(--ink-soft); }
.small { font-size: .86rem; }

/* ---------- Header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; padding-top: calc(14px + env(safe-area-inset-top));
  background: var(--brand); color: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,.12);
}
.topbar .titolo { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.topbar .titolo strong { font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .titolo span { font-size: .76rem; opacity: .8; }
.topbar .spacer { flex: 1; }
.iconbtn {
  appearance: none; border: 0; background: rgba(255,255,255,.14); color: #fff;
  min-width: var(--tap); height: var(--tap); border-radius: 12px;
  font-size: .9rem; font-weight: 600; padding: 0 14px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.iconbtn:active { transform: scale(.96); }
.iconbtn.ghost { background: transparent; }

/* ---------- Contenuto ---------- */
.content { padding: 16px; }
.stack > * + * { margin-top: 12px; }

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

/* lista blocchi (home) */
.blocco-link {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 18px 16px; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); color: inherit;
}
.blocco-link:active { transform: scale(.99); }
.blocco-link .emoji { font-size: 1.5rem; }
.blocco-link .freccia { margin-left: auto; color: var(--accent); font-size: 1.3rem; }
.blocco-link b { display: block; }

/* ---------- Menu / elenco piatti ---------- */
.cat-titolo {
  margin: 22px 4px 8px; font-size: .8rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; color: var(--accent);
}
.cat-titolo:first-of-type { margin-top: 4px; }

.piatto {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 13px 14px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  margin-top: 8px;
}
.piatto.non-disp { opacity: .62; }
.piatto .info { flex: 1; min-width: 0; cursor: pointer; }
.piatto .nome { font-weight: 600; }
.piatto .desc { font-size: .85rem; color: var(--ink-soft); margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.piatto .meta { display: flex; gap: 8px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.prezzo { font-weight: 700; color: var(--brand-2); }
.badge {
  font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: var(--warn-bg); color: #9a6a1e; border: 1px solid #ecd9b6;
}
.piatto .azioni { display: flex; flex-direction: column; gap: 4px; }
.mini {
  appearance: none; border: 1px solid var(--line); background: var(--surface-2);
  width: 38px; height: 34px; border-radius: 9px; cursor: pointer; font-size: 1rem;
  display: inline-flex; align-items: center; justify-content: center; color: var(--ink-soft);
}
.mini:active { transform: scale(.94); }
.mini.del { color: var(--danger); }
.mini:disabled { opacity: .35; cursor: default; }

/* ---------- Bottoni ---------- */
.btn {
  appearance: none; cursor: pointer; border: 0; border-radius: 13px;
  min-height: var(--tap); padding: 0 20px; font-size: 1rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
}
.btn:active { transform: scale(.985); }
.btn--primary { background: var(--brand); color: #fff; }
.btn--accent  { background: var(--accent); color: #fff; }
.btn--ghost   { background: transparent; color: var(--brand); border: 1.5px solid var(--line); }
.btn--danger  { background: transparent; color: var(--danger); border: 1.5px solid #e7c4c4; }
.btn:disabled { opacity: .55; cursor: default; }

.barra-azione {
  position: sticky; bottom: 0; z-index: 4;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}

/* ---------- Form ---------- */
.campo { margin-top: 14px; }
.campo label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; color: var(--ink-soft); }
.campo input[type=text], .campo textarea {
  width: 100%; font: inherit; color: var(--ink);
  padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--surface); min-height: var(--tap);
}
.campo textarea { min-height: 92px; resize: vertical; }
.campo input:focus, .campo textarea:focus { outline: none; border-color: var(--accent); }
.campo .hint { font-size: .78rem; color: var(--ink-soft); margin-top: 4px; }

/* interruttore */
.switch { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 52px; height: 30px; border-radius: 999px; background: #d6ccbd;
  position: relative; transition: background .18s ease; flex: 0 0 auto;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .18s ease;
}
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { transform: translateX(22px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Login ---------- */
.login-wrap { padding: 8vh 20px 24px; }
.login-card { max-width: 380px; margin: 0 auto; padding: 26px 22px; }
.login-logo { width: 60px; height: 60px; display: block; margin: 0 auto 14px; }
.login-card h1 { text-align: center; }
.login-card p.sub { text-align: center; margin: 6px 0 18px; }

/* ---------- Vari ---------- */
.errore-box {
  background: #fbeaea; color: #8f2d2d; border: 1px solid #eecaca;
  border-radius: 12px; padding: 10px 14px; font-size: .9rem; margin-top: 12px;
}
.vuoto { text-align: center; color: var(--ink-soft); padding: 40px 20px; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 20;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px;
  font-size: .9rem; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 90vw;
}
.toast.ok { background: var(--ok); }
.toast.err { background: var(--danger); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .btn:active, .mini:active, .iconbtn:active, .blocco-link:active { transform: none; }
}
