/* ============================================================
   PIETRAVIVA — login + pannello di gestione
   Estende i token di style.css: stesso linguaggio visivo del sito.
   ============================================================ */

/* ---------- LOGIN ---------- */
.auth-body { background: var(--cream-2); }
.auth {
  min-height: 100svh; display: grid; place-items: center; padding: var(--sp-5) var(--sp-4);
}
.auth__card {
  width: min(100%, 420px); background: var(--paper); padding: var(--sp-7) var(--sp-6);
  border: 1px solid var(--line); box-shadow: var(--shadow-2); text-align: center;
}
.auth__logo { justify-content: center; margin-bottom: var(--sp-5); }
.auth__title { font-size: 1.7rem; margin: 0 0 .3rem; }
.auth__sub { color: var(--granite); font-size: .9rem; margin: 0; }
.auth__card .field { text-align: left; }
.auth__card .rule-gold { margin: var(--sp-5) auto; }

.auth__pw { position: relative; display: flex; }
.auth__pw input { padding-right: 3rem; }
.auth__eye {
  position: absolute; right: 0; top: 0; bottom: 0; width: 46px;
  display: grid; place-items: center; color: var(--granite);
}
.auth__eye:hover { color: var(--wine); }
.auth__eye svg { width: 19px; height: 19px; }
.auth__eye[aria-pressed="true"] { color: var(--wine); }

.auth__err {
  background: rgba(176,42,42,.08); border-left: 3px solid var(--err);
  color: var(--err); font-size: .86rem; text-align: left;
  padding: .7rem .9rem; margin: 0 0 var(--sp-4);
}
.auth__err[hidden] { display: none; }
.auth__back { margin: var(--sp-5) 0 0; font-size: .82rem; }
.auth__back a { color: var(--granite); border-bottom: 1px solid var(--line); }
.auth__back a:hover { color: var(--wine); border-bottom-color: var(--wine); }

/* ============================================================
   AREA CLIENTE (registrati.html / account.html)
   Usa il guscio del sito, non quello del pannello admin: per chi compra
   dev'essere una pagina del negozio, non uno strumento di lavoro.
   ============================================================ */
.acct-narrow { width: min(100% - 2.5rem, 620px); margin-inline: auto; }
.acct-card { padding: var(--sp-6); margin-top: var(--sp-5); }
.acct-card .field:last-of-type { margin-bottom: var(--sp-4); }
.acct-alt { margin: var(--sp-5) 0 0; text-align: center; font-size: .9rem; color: var(--granite); }
.acct-alt a { color: var(--wine); border-bottom: 1px solid var(--gold); }
.acct-consent { align-items: flex-start; gap: .7rem; margin: var(--sp-4) 0; font-size: .86rem; line-height: 1.5; }
/* Selettore composto .adm-chk.acct-consent: la riga porta entrambe le classi
   e ".adm-chk input" (sezione admin, più in basso nel file) vincerebbe a
   parità di specificità, rimettendo la casella a 17px.
   Dimensione allineata alle altre caselle del sito (.check/.opt/.agecheck). */
.adm-chk.acct-consent input { margin-top: .15rem; width: 22px; height: 22px; flex: none; }
.acct-consent a { color: var(--wine); border-bottom: 1px solid var(--line); }
.acct-note { margin: var(--sp-4) 0 0; }

.acct-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-5);
}
.acct-head h1 { margin: 0; font-size: clamp(1.8rem, 4vw, 2.4rem); }
.acct-tabs { padding: 0; margin-bottom: var(--sp-5); background: none; }
.acct-panel { animation: fade .2s; }
.acct-h2 { font-size: 1.15rem; margin: 0 0 var(--sp-4); }
.acct-h2 + * { margin-top: 0; }
.acct-card .acct-h2:not(:first-child) {
  margin-top: var(--sp-5); padding-top: var(--sp-5); border-top: 1px solid var(--line-soft);
}

/* ---- storico ordini ---- */
.order {
  background: var(--paper); border: 1px solid var(--line);
  padding: var(--sp-5); margin-bottom: var(--sp-4);
}
.order__head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--sp-4); flex-wrap: wrap; padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--line-soft); margin-bottom: var(--sp-3);
}
.order__num { font-family: var(--serif); font-size: 1.2rem; }
.order__date { font-size: .82rem; color: var(--granite); }
.order__total { font-family: var(--serif); font-size: 1.3rem; margin-left: auto; }
.order__line {
  display: flex; justify-content: space-between; gap: var(--sp-4);
  font-size: .9rem; padding: .3rem 0;
}
.order__line span:first-child { color: var(--ink-soft); }
.order__qty { color: var(--granite); }
.order__foot {
  display: flex; justify-content: space-between; gap: var(--sp-4);
  flex-wrap: wrap; margin-top: var(--sp-3); padding-top: var(--sp-3);
  border-top: 1px solid var(--line-soft); font-size: .84rem; color: var(--granite);
}

@media (max-width: 640px) {
  .acct-card { padding: var(--sp-4); }
  .acct-head { align-items: flex-start; }
  .acct-head .btn { width: 100%; }
  .order__total { margin-left: 0; }
}

/* ============================================================
   PANNELLO ADMIN
   ============================================================ */
.adm-body { background: var(--cream-2); }

.adm-top {
  position: sticky; top: 0; z-index: 40;
  background: var(--ink); color: var(--cream);
  display: flex; align-items: center; gap: var(--sp-4);
  padding: 0 var(--sp-5); min-height: 58px; flex-wrap: wrap;
}
.adm-top .logo__name { color: var(--cream); font-size: 1.1rem; }
.adm-top .logo__sub  { color: rgba(247,243,236,.5); }
.adm-top__spacer { flex: 1; }
.adm-top__user { font-size: .8rem; color: rgba(247,243,236,.7); }
.adm-top__user strong { color: var(--gold-lt); font-weight: 600; }
.adm-top a.adm-link, .adm-top button.adm-link {
  font-size: .74rem; letter-spacing: .1em; text-transform: uppercase; font-weight: 600;
  color: rgba(247,243,236,.8); padding: .5rem .2rem;
}
.adm-top a.adm-link:hover, .adm-top button.adm-link:hover { color: var(--gold); }

.adm-tabs {
  display: flex; gap: var(--sp-5); background: var(--paper);
  border-bottom: 1px solid var(--line); padding: 0 var(--sp-5);
  overflow-x: auto; scrollbar-width: none;
}
.adm-tabs::-webkit-scrollbar { display: none; }
.adm-tabs button {
  padding: var(--sp-4) 0; white-space: nowrap;
  font-size: .76rem; letter-spacing: .13em; text-transform: uppercase; font-weight: 600;
  color: var(--granite); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.adm-tabs button[aria-selected="true"] { color: var(--wine); border-bottom-color: var(--wine); }
.adm-tabs .adm-tabs__n {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px;
  margin-left: .45rem; border-radius: 999px; background: var(--cream-2);
  font-size: .66rem; color: var(--granite);
}

.adm-main { padding: var(--sp-5); max-width: 1400px; margin-inline: auto; }

.adm-bar {
  display: flex; align-items: center; gap: var(--sp-3);
  margin-bottom: var(--sp-4); flex-wrap: wrap;
}
.adm-bar h1 { font-size: 1.5rem; margin: 0; }
.adm-bar__spacer { flex: 1; }
.adm-search {
  border: 1px solid var(--line); background: var(--paper); border-radius: var(--radius);
  padding: .6rem .8rem; font-size: .88rem; min-width: 200px; flex: 1; max-width: 320px;
}
.adm-search:focus { outline: 0; border-color: var(--wine); box-shadow: 0 0 0 3px rgba(123,30,43,.09); }

/* ---------- tabella ---------- */
.adm-tablewrap { background: var(--paper); border: 1px solid var(--line); overflow-x: auto; }
.adm-table { width: 100%; border-collapse: collapse; min-width: 720px; }
.adm-table th, .adm-table td {
  text-align: left; padding: .7rem .8rem; border-bottom: 1px solid var(--line-soft);
  font-size: .88rem; vertical-align: middle;
}
.adm-table th {
  font-size: .68rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--granite); font-weight: 700; background: var(--cream);
  position: sticky; top: 0; z-index: 1;
}
.adm-table tbody tr:hover { background: var(--cream); }
.adm-table__thumb {
  width: 44px; height: 58px; object-fit: cover; background: var(--cream-2);
  border: 1px solid var(--line-soft);
}
.adm-table__name { font-family: var(--serif); font-size: 1.02rem; }
.adm-table__sku { font-size: .72rem; color: var(--granite-lt); font-family: var(--mono); }
.adm-table__num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.adm-table__actions { display: flex; gap: .4rem; justify-content: flex-end; }

.adm-flags { display: flex; gap: .25rem; flex-wrap: wrap; }
.adm-flags .badge { font-size: .58rem; padding: .18rem .42rem; }

.adm-stock { font-weight: 600; }
.adm-stock--out { color: var(--err); }
.adm-stock--low { color: #9a6b12; }

.adm-btn {
  display: inline-flex; align-items: center; gap: .35rem; min-height: 34px;
  padding: .4rem .75rem; border: 1px solid var(--line); background: var(--paper);
  border-radius: var(--radius); font-size: .76rem; font-weight: 600;
  letter-spacing: .04em; color: var(--ink-soft); transition: background .15s, border-color .15s, color .15s;
}
.adm-btn:hover { border-color: var(--ink); background: var(--cream); }
.adm-btn svg { width: 15px; height: 15px; }
.adm-btn--danger:hover { border-color: var(--err); color: var(--err); background: rgba(176,42,42,.06); }
.adm-btn--primary {
  background: var(--wine); border-color: var(--wine); color: #fff;
}
.adm-btn--primary:hover { background: var(--wine-deep); border-color: var(--wine-deep); color: #fff; }

.adm-empty { padding: var(--sp-8) var(--sp-4); text-align: center; color: var(--granite); }

/* ---------- editor ---------- */
.adm-editor { position: fixed; inset: 0; z-index: 120; display: grid; grid-template-columns: 1fr min(860px, 100%); }
.adm-editor[hidden] { display: none; }
.adm-editor__scrim { background: rgba(22,17,15,.55); animation: fade .2s; }
.adm-editor__panel {
  background: var(--bg); display: flex; flex-direction: column;
  box-shadow: var(--shadow-2); animation: slide .28s cubic-bezier(.2,.7,.3,1);
}
.adm-editor__head {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--line); background: var(--paper);
}
.adm-editor__head h2 { margin: 0; font-size: 1.25rem; flex: 1; }
.adm-editor__body { flex: 1; overflow-y: auto; padding: var(--sp-5); }
.adm-editor__foot {
  display: flex; gap: var(--sp-3); justify-content: flex-end; align-items: center;
  padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--line);
  background: var(--paper); flex-wrap: wrap;
}
.adm-editor__foot .adm-msg { margin-right: auto; font-size: .82rem; }
.adm-msg--ok  { color: var(--ok); }
.adm-msg--err { color: var(--err); }

.adm-sec { border: 1px solid var(--line); background: var(--paper); margin-bottom: var(--sp-4); }
.adm-sec > summary {
  list-style: none; cursor: pointer; padding: var(--sp-4) var(--sp-5);
  font-size: .74rem; letter-spacing: .14em; text-transform: uppercase; font-weight: 700;
  display: flex; justify-content: space-between; align-items: center;
}
.adm-sec > summary::-webkit-details-marker { display: none; }
.adm-sec > summary::after { content: "+"; font-size: 1.2rem; color: var(--granite); font-weight: 400; }
.adm-sec[open] > summary::after { content: "–"; }
.adm-sec__body { padding: 0 var(--sp-5) var(--sp-5); }

/* align-items:start — senza, i campi privi di testo d'aiuto si stirano
   in altezza per pareggiare la riga e gli input risultano disallineati */
.adm-grid {
  display: grid; gap: var(--sp-4); align-items: start;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.adm-grid--2 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.adm-grid .field { align-content: start; }

/* selettore lingua dei campi tradotti */
.adm-lang { display: flex; gap: .3rem; margin-bottom: var(--sp-4); }
.adm-lang button {
  padding: .35rem .8rem; border: 1px solid var(--line); background: var(--paper);
  font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; font-weight: 700;
  color: var(--granite); border-radius: var(--radius);
}
.adm-lang button[aria-pressed="true"] {
  background: var(--ink); color: var(--cream); border-color: var(--ink);
}
.adm-i18n[hidden] { display: none; }

.adm-chk { display: flex; align-items: center; gap: .55rem; font-size: .9rem; cursor: pointer; }
.adm-chk input { width: 17px; height: 17px; accent-color: var(--wine); flex: none; }

/* upload foto */
.adm-photo { display: flex; gap: var(--sp-4); align-items: flex-start; flex-wrap: wrap; }
.adm-photo__preview {
  width: 132px; aspect-ratio: 3/4; object-fit: cover;
  background: var(--cream-2); border: 1px solid var(--line); flex: none;
}
.adm-photo__side { flex: 1; min-width: 220px; }
.adm-photo__hint { font-size: .78rem; color: var(--granite); margin: .5rem 0 0; }
.adm-photo__bar { height: 4px; background: var(--line-soft); margin-top: .6rem; }
.adm-photo__bar > i { display: block; height: 100%; background: var(--gold); width: 0; transition: width .25s; }

.adm-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 300;
  background: var(--ink); color: var(--cream); padding: .8rem 1.3rem;
  box-shadow: var(--shadow-2); font-size: .88rem; animation: pop .2s;
  display: flex; align-items: center; gap: .6rem; max-width: calc(100vw - 32px);
}
.adm-toast svg { width: 17px; height: 17px; flex: none; color: var(--gold); }
.adm-toast--err svg { color: var(--err); }

@media (max-width: 760px) {
  .adm-main { padding: var(--sp-4) var(--sp-3); }
  .adm-editor { grid-template-columns: 0 100%; }
  .adm-editor__body { padding: var(--sp-4); }
  .adm-sec__body { padding: 0 var(--sp-4) var(--sp-4); }
  .adm-sec > summary { padding: var(--sp-4); }
  .adm-editor__foot .adm-btn, .adm-editor__foot .btn { flex: 1; justify-content: center; }

  /* stessa soglia tattile di 44px adottata sul sito pubblico */
  .adm-btn { min-height: 44px; padding: .5rem .9rem; }
  .adm-top a.adm-link, .adm-top button.adm-link { min-height: 44px; display: inline-flex; align-items: center; }
  .adm-tabs button { padding: var(--sp-4) 0; min-height: 48px; }
  .adm-search { min-height: 44px; }
  .adm-lang button { min-height: 40px; padding: .4rem 1rem; }
  .adm-chk { min-height: 40px; }

  /* intestazione compatta: su una riga sola, senza etichetta lunga */
  .adm-top { min-height: 52px; padding: 0 var(--sp-4); gap: var(--sp-3); flex-wrap: nowrap; }
  .adm-top .logo__sub { display: none; }
  .adm-top__user { display: none; }
  .adm-top a.adm-link { display: none; }

  /* ---- la tabella diventa un elenco di schede ----
     Una tabella a 8 colonne su 375px comprime i nomi su tre righe:
     qui ogni riga diventa una scheda e ogni cella mostra la propria
     intestazione a sinistra, presa da data-label. */
  .adm-tablewrap { border: 0; background: none; overflow: visible; }
  .adm-table { min-width: 0; display: block; }
  .adm-table thead { display: none; }
  .adm-table tbody { display: grid; gap: var(--sp-3); }
  .adm-table tr {
    display: block; position: relative;
    background: var(--paper); border: 1px solid var(--line); padding: var(--sp-4);
    padding-left: 88px; min-height: 104px;
  }
  .adm-table td {
    display: flex; gap: var(--sp-4); align-items: baseline;
    padding: .25rem 0; border: 0; justify-content: space-between;
  }
  .adm-table td::before {
    content: attr(data-label);
    font-size: .64rem; letter-spacing: .12em; text-transform: uppercase;
    color: var(--granite); font-weight: 700; flex: none;
  }
  .adm-table td:empty, .adm-table td[data-label=""]::before { display: none; }
  .adm-table .adm-table__num { text-align: left; }

  /* la miniatura esce dal flusso e ancora la scheda a sinistra */
  .adm-table td.adm-td-thumb { position: absolute; left: var(--sp-4); top: var(--sp-4); padding: 0; }
  .adm-table td.adm-td-thumb::before { display: none; }
  .adm-table__thumb { width: 60px; height: 80px; }

  /* il nome fa da titolo della scheda: niente etichetta, tutta la riga */
  .adm-table td.adm-td-title { display: block; padding-bottom: .5rem; }
  .adm-table td.adm-td-title::before { display: none; }
  .adm-table td.adm-td-title .adm-table__name { font-size: 1.15rem; line-height: 1.2; }

  .adm-table td.adm-td-actions { margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--line-soft); }
  .adm-table__actions { width: 100%; justify-content: stretch; }
  .adm-table__actions .adm-btn { flex: 1; justify-content: center; }
}
