/* Backoffice: strumento di lavoro, sobrio. Si appoggia ai token di styles.css (caricato prima). */

.a-wrap { width: min(960px, 100%); margin-inline: auto; padding-inline: 1.25rem; }
.a-main { padding-block: 1.5rem 4rem; }
.a-main h1 { font-size: clamp(2rem, 1.6rem + 1.6vw, 2.6rem); margin-bottom: .75em; }
.a-main h2 { font-size: clamp(1.5rem, 1.3rem + .8vw, 1.85rem); margin-top: 1.5em; }

/* ---------- Intestazione e navigazione ---------- */
.a-header { background: var(--sand-200); }
.a-header__bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .25rem 1.5rem; padding-block: .75rem; }
.a-brand { font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; }
.a-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0 .25rem; margin-inline: -.5rem; }
.a-nav form { margin: 0; }
.a-nav a, .a-nav__out {
  display: inline-flex; align-items: center; min-height: 2.75rem; padding: .25rem .75rem;
  border: 0; border-radius: 999px; background: none; color: inherit;
  font: 500 var(--text-sm)/1 var(--font-body); text-decoration: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: background-color .2s var(--ease-out), color .2s var(--ease-out), transform .16s var(--ease-out);
}
.a-nav a[aria-current="page"] { background: var(--plum-700); color: var(--ivory-50); }
.a-nav a:active, .a-nav__out:active { transform: scale(.97); }
@media (hover: hover) and (pointer: fine) {
  .a-nav a:not([aria-current]):hover, .a-nav__out:hover { background: var(--sand-300); }
}

/* ---------- Messaggi ---------- */
.a-flash { margin: 0 0 1.25rem; padding: .85rem 1.1rem; border-radius: 12px; background: var(--sand-200); font-size: var(--text-sm); }
.a-flash--error { background: #F6DEDF; color: var(--coral-700); }
.a-empty { padding: 2rem 1rem; border-radius: var(--radius); background: var(--sand-200); color: var(--ink-soft); text-align: center; }

/* ---------- Cruscotto ---------- */
.a-stats { display: grid; grid-template-columns: 1fr; gap: .75rem; margin: 0; padding: 0; list-style: none; }
.a-stats a { display: flex; align-items: baseline; gap: .75rem; padding: 1rem 1.25rem; border-radius: var(--radius); background: var(--sand-200); text-decoration: none; font-size: var(--text-sm); transition: background-color .2s var(--ease-out), transform .16s var(--ease-out); }
.a-stats a:active { transform: scale(.98); }
.a-stats__n { min-width: 2.5ch; font-family: var(--font-display); font-size: 2.5rem; font-weight: 600; line-height: 1; font-variant-numeric: lining-nums; }
@media (hover: hover) and (pointer: fine) { .a-stats a:hover { background: var(--sand-300); } }
@media (min-width: 640px) { .a-stats { grid-template-columns: 1fr 1fr; } }

/* ---------- Moduli ---------- */
.a-form { display: grid; gap: 1.1rem; max-width: 40rem; }
.a-form--narrow { max-width: 24rem; }
.a-field { display: grid; gap: .35rem; }
.a-field label { font-size: var(--text-sm); font-weight: 600; }
.a-field small { font-size: var(--text-sm); color: var(--ink-soft); }
.a-field input, .a-field select, .a-field textarea {
  width: 100%; min-height: 2.75rem; padding: .6rem .85rem; border: 1.5px solid var(--mauve-500); border-radius: 12px;
  background: var(--white); color: var(--plum-900); font: inherit; font-size: 1rem;
  transition: border-color .2s var(--ease-out);
}
.a-field textarea { min-height: 7rem; resize: vertical; }
.a-field input:focus-visible, .a-field select:focus-visible, .a-field textarea:focus-visible { outline: 2px solid var(--coral-600); outline-offset: 2px; border-color: var(--plum-700); }
.a-field input[type="checkbox"] { width: 1.5rem; min-height: 1.5rem; height: 1.5rem; accent-color: var(--coral-600); }

/* ---------- Bottoni ---------- */
.a-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 2.75rem; padding: .55rem 1.4rem; border: 1.5px solid var(--coral-600); border-radius: 999px;
  background: var(--coral-600); color: var(--white); font: 600 var(--text-sm)/1.2 var(--font-body);
  text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: background-color .2s var(--ease-out), color .2s var(--ease-out), border-color .2s var(--ease-out), transform .16s var(--ease-out);
}
.a-btn:active { transform: scale(.97); }
.a-btn[disabled] { opacity: .6; cursor: progress; transform: none; }
.a-btn--danger { background: var(--white); border-color: var(--coral-700); color: var(--coral-700); }
@media (hover: hover) and (pointer: fine) {
  .a-btn:not(.a-btn--danger):hover { background: var(--plum-700); border-color: var(--plum-700); }
  .a-btn--danger:hover { background: var(--coral-700); color: var(--white); }
}

/* ---------- Etichette di stato ---------- */
.a-pill { display: inline-block; padding: .15rem .7rem; border-radius: 999px; font-size: var(--text-sm); font-weight: 500; line-height: 1.5; white-space: nowrap; }
.a-pill--ok { background: #DDEBD8; color: #25521F; }
.a-pill--warn { background: #F5E4B5; color: #6B4A00; }
.a-pill--error { background: #F6DEDF; color: var(--coral-700); }
.a-pill--muted { background: var(--sand-200); color: var(--ink-soft); }

/* ---------- Tabelle: su telefono diventano liste ---------- */
.a-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.a-table th { text-align: left; font-weight: 600; padding: .6rem .75rem; background: var(--sand-200); }
.a-table td { padding: .75rem; vertical-align: middle; border-bottom: 1.5px solid var(--sand-200); }
.a-table a { color: var(--coral-700); font-weight: 500; }
@media (max-width: 639px) {
  .a-table, .a-table tbody, .a-table tr, .a-table td { display: block; }
  .a-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .a-table tr { margin-bottom: .75rem; padding: .5rem .25rem; border-radius: var(--radius); background: var(--sand-200); }
  .a-table td { display: flex; justify-content: space-between; gap: 1rem; padding: .35rem .75rem; border: 0; text-align: right; }
  .a-table td::before { content: attr(data-label); flex: none; font-weight: 600; text-align: left; }
  .a-table td:not([data-label])::before { content: none; }
}

@media (prefers-reduced-motion: reduce) {
  .a-btn, .a-nav a, .a-nav__out, .a-stats a { transition: none; }
  .a-btn:active, .a-nav a:active, .a-nav__out:active, .a-stats a:active { transform: none; }
}
