/* ============================================================
   E-Stile Roma — Gestionale · Stili
   Palette allineata al sito pubblico (vermiglio Castiglioni, oro).
   ============================================================ */
:root {
  --bg: #f4f1ec;
  --ink: #15130f;
  --accent: #e63329;
  --accent-2: #c7a86a;
  --muted: #6e685e;
  --surface: #fbfaf7;
  --surface-2: #ffffff;
  --dark: #0a0908;
  --ok: #2f7d5b;
  --warn: #b7791f;
  --danger: #c0392b;
  --hair: rgba(21, 19, 15, 0.12);
  --hair-strong: rgba(21, 19, 15, 0.22);
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --body: "Inter Tight", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r: 6px;
  --r-lg: 12px;
  --shadow: 0 1px 2px rgba(21, 19, 15, 0.06), 0 8px 30px rgba(21, 19, 15, 0.06);
  --shadow-lg: 0 20px 60px rgba(21, 19, 15, 0.18);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-family: var(--display); font-weight: 500; margin: 0; letter-spacing: -0.01em; }

/* ---------- Login ---------- */
body.auth {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(199, 168, 106, 0.14), transparent 60%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 40px 32px 28px;
}
.auth-brand { text-align: center; margin-bottom: 20px; }
.auth-logo { width: 56px; height: 56px; object-fit: contain; border-radius: 8px; }
.auth-kicker {
  margin: 8px 0 0;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 11px;
  color: var(--muted);
}
.auth-title { text-align: center; font-size: 26px; margin-bottom: 24px; }
.auth-foot { text-align: center; margin: 18px 0 0; font-size: 13px; }
.auth-foot a { color: var(--muted); }

/* ---------- Forms ---------- */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field__label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  text-transform: uppercase;
}
.input, .select, .textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--hair-strong);
  border-radius: var(--r);
  padding: 10px 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.textarea { resize: vertical; min-height: 84px; }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(230, 51, 41, 0.14);
}
.form__error {
  margin: 0;
  color: var(--danger);
  font-size: 13px;
  background: rgba(192, 57, 43, 0.08);
  border: 1px solid rgba(192, 57, 43, 0.24);
  padding: 8px 12px;
  border-radius: var(--r);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ---------- Buttons ---------- */
.btn {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--hair-strong);
  background: var(--surface-2);
  color: var(--ink);
  border-radius: var(--r);
  padding: 9px 16px;
  transition: transform 0.05s, background 0.15s, border-color 0.15s, opacity 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.btn:hover { border-color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: #cf2b22; border-color: #cf2b22; }
.btn--ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn--ghost:hover { background: rgba(21, 19, 15, 0.06); border-color: transparent; }
.btn--danger { color: var(--danger); border-color: rgba(192, 57, 43, 0.4); background: transparent; }
.btn--danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn--block { width: 100%; justify-content: center; }
.btn--sm { padding: 6px 10px; font-size: 13px; }

/* ---------- App layout ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: rgba(251, 250, 247, 0.92);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--hair);
}
.topbar__brand { display: flex; align-items: center; gap: 12px; }
.topbar__logo { width: 34px; height: 34px; object-fit: contain; border-radius: 6px; }
.topbar__title { font-size: 18px; }
.topbar__title small {
  display: block;
  font-family: var(--body);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}
.topbar__actions { display: flex; align-items: center; gap: 8px; }
.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  padding-right: 6px;
}
.user-chip strong { color: var(--ink); }

.container { max-width: 1360px; margin: 0 auto; padding: 24px; }

/* ---------- Stat cards ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat__label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin: 0 0 6px;
}
.stat__value { font-family: var(--display); font-size: 28px; line-height: 1; }
.stat__value.is-warn { color: var(--warn); }
.stat__value.is-danger { color: var(--danger); }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}
.toolbar .input, .toolbar .select { width: auto; }
.toolbar__search { flex: 1 1 240px; min-width: 200px; }
.toolbar__spacer { flex: 1 1 auto; }

/* ---------- Table ---------- */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  overflow: auto;
}
table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
.grid thead th {
  position: sticky;
  top: 0;
  background: var(--surface);
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 700;
  padding: 12px 14px;
  border-bottom: 1px solid var(--hair-strong);
  white-space: nowrap;
}
.grid tbody td { padding: 10px 14px; border-bottom: 1px solid var(--hair); vertical-align: middle; }
.grid tbody tr:hover { background: rgba(199, 168, 106, 0.07); }
.grid tbody tr:last-child td { border-bottom: none; }
.cell-thumb img {
  width: 46px; height: 46px; object-fit: cover;
  border-radius: 6px; border: 1px solid var(--hair); background: #fff; display: block;
}
.cell-thumb .thumb-empty {
  width: 46px; height: 46px; border-radius: 6px;
  border: 1px dashed var(--hair-strong); display: grid; place-items: center;
  color: var(--muted); font-size: 10px; text-align: center;
}
.cell-name strong { display: block; font-weight: 600; }
.cell-name span { color: var(--muted); font-size: 12px; }
.cell-sku { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; color: var(--muted); }
.cell-price { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.stock-input {
  width: 72px; text-align: center; font-variant-numeric: tabular-nums;
  padding: 6px 8px; border: 1px solid var(--hair-strong); border-radius: var(--r);
  background: var(--surface-2); font: inherit;
}
.stock-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(230, 51, 41, 0.14); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px;
  border: 1px solid transparent; white-space: nowrap;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge--in { color: var(--ok); background: rgba(47, 125, 91, 0.1); border-color: rgba(47, 125, 91, 0.25); }
.badge--low { color: var(--warn); background: rgba(183, 121, 31, 0.1); border-color: rgba(183, 121, 31, 0.28); }
.badge--out { color: var(--danger); background: rgba(192, 57, 43, 0.1); border-color: rgba(192, 57, 43, 0.28); }
.pill-status {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); border: 1px solid var(--hair); padding: 2px 8px; border-radius: 999px;
}
.pill-status.is-draft { color: var(--warn); border-color: rgba(183, 121, 31, 0.3); }
.pill-status.is-archived { color: var(--muted); opacity: 0.7; }

.row-actions { display: flex; gap: 4px; justify-content: flex-end; }

.empty-state { padding: 60px 20px; text-align: center; color: var(--muted); }
.empty-state h3 { font-size: 20px; margin-bottom: 6px; color: var(--ink); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(10, 9, 8, 0.5);
  display: grid; place-items: center; padding: 20px;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  width: 100%; max-width: 560px; max-height: 92vh; overflow: auto;
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); border: 1px solid var(--hair);
}
.modal__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--hair);
  position: sticky; top: 0; background: var(--surface);
}
.modal__head h2 { font-size: 20px; }
.modal__body { padding: 22px; }
.modal__foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 22px; border-top: 1px solid var(--hair);
  position: sticky; bottom: 0; background: var(--surface);
}
.image-drop {
  display: flex; align-items: center; gap: 14px;
  border: 1px dashed var(--hair-strong); border-radius: var(--r);
  padding: 12px; background: var(--surface-2);
}
.image-drop img {
  width: 64px; height: 64px; object-fit: cover; border-radius: 6px; border: 1px solid var(--hair);
}
.image-drop .hint { font-size: 12px; color: var(--muted); }

/* ---------- Toast ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 80; display: grid; gap: 10px; }
.toast {
  background: var(--dark); color: #fff; padding: 12px 16px; border-radius: var(--r);
  box-shadow: var(--shadow-lg); font-size: 14px; max-width: 340px;
  animation: toast-in 0.2s ease-out;
}
.toast--ok { background: #1f5c43; }
.toast--err { background: #8f271e; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Prose (pagina privacy) ---------- */
.container--narrow { max-width: 760px; }
.modal--narrow { max-width: 440px; }
.table-wrap--flush { box-shadow: none; border: 1px solid var(--hair); }
.prose {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--r-lg);
  padding: 32px;
  box-shadow: var(--shadow);
}
.prose h1 { font-size: 30px; margin-bottom: 8px; }
.prose h2 { font-size: 20px; margin-top: 28px; }
.prose > p.lead { margin-top: 0; }
.prose ul { padding-left: 20px; margin: 8px 0; }
.prose li { margin: 6px 0; }
.prose code {
  background: rgba(21, 19, 15, 0.06);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 13px;
}
.prose .fineprint { margin-top: 28px; font-size: 13px; }

/* ---------- Utility ---------- */
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.spinner {
  display: inline-block; width: 40px; height: 40px; border-radius: 50%;
  border: 3px solid var(--hair); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
.loading-wrap { padding: 60px; display: grid; place-items: center; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .topbar__title small { display: none; }
}
@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .container { padding: 16px; }
}
