/* ===== Fonts (stessi del sito) ===== */
@font-face { font-family: "ABC Diatype"; src: url("assets/fonts/ABCDiatype-Light.otf") format("opentype"); font-weight: 300; font-style: normal; font-display: swap; }
@font-face { font-family: "ABC Diatype"; src: url("assets/fonts/ABCDiatype-Regular.otf") format("opentype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "ABC Diatype"; src: url("assets/fonts/ABCDiatype.ttf") format("truetype"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Newsreader"; src: url("assets/fonts/Newsreader.ttf") format("truetype"); font-weight: 200 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Newsreader"; src: url("assets/fonts/Newsreader-Italic.ttf") format("truetype"); font-weight: 200 700; font-style: italic; font-display: swap; }

/* ===== Palette (stessa del sito) ===== */
:root {
  --bg: #ffffff; --bg-alt: #f5f7fc;
  --ink: #0d0f14; --ink-2: #16181d; --ink-soft: #3f4654; --muted: #717888;
  --line: #e7eaf1; --line-2: #eef1f7;
  --accent: #1e66d6; --accent-d: #1551b0; --accent-l: #e9f1fe;
  --brand-red: #c41e2a; --ok: #1f8a5b; --no: #c2453a;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "ABC Diatype", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --r: 18px; --r-lg: 26px; --r-pill: 999px;
  --shadow-sm: 0 2px 8px rgba(13,15,20,.05);
  --shadow: 0 18px 50px rgba(13,15,20,.08);
  --shadow-lg: 0 30px 80px rgba(13,15,20,.16);
}
* { box-sizing: border-box; }
/* L'attributo [hidden] deve vincere sui display delle classi (login/dash/drawer) */
[hidden] { display: none !important; }
body { margin: 0; font-family: var(--sans); font-weight: 300; color: var(--ink); background: var(--bg-alt); -webkit-font-smoothing: antialiased; overflow-x: hidden; -webkit-tap-highlight-color: transparent; }
button, a, .switch, input { touch-action: manipulation; }
h1 { font-family: var(--sans); font-weight: 700; letter-spacing: -.025em; line-height: 1.05; margin: 0; }
.wrap { max-width: 1000px; margin: 0 auto; padding: 0 clamp(1.1rem, 4vw, 2rem); }

.brand { display: flex; align-items: center; gap: .85rem; }
.brand-mark { width: 44px; height: 44px; border-radius: 12px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; letter-spacing: -.02em; font-size: 1.05rem; }
.brand h1 { font-size: 1.25rem; }
.brand.small h1 { font-size: 1.1rem; }
.brand-sub { margin: .15rem 0 0; font-size: .82rem; color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; padding: .7rem 1.3rem; border: 1px solid var(--accent); background: var(--accent); color: #fff; text-decoration: none; font-family: var(--sans); font-weight: 500; font-size: .98rem; border-radius: var(--r-pill); cursor: pointer; transition: background .2s, transform .15s, box-shadow .2s; }
.btn:hover { background: var(--accent-d); border-color: var(--accent-d); transform: translateY(-1px); box-shadow: 0 12px 26px rgba(18,87,198,.28); }
.btn:disabled { opacity: .6; cursor: default; transform: none; box-shadow: none; }
.btn.ghost { background: transparent; color: var(--ink-soft); border-color: var(--line); }
.btn.ghost:hover { background: #fff; color: var(--ink); border-color: var(--muted); box-shadow: var(--shadow-sm); }

/* ===== Login ===== */
.login-view { min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem; background:
  radial-gradient(1200px 500px at 50% -10%, var(--accent-l), transparent 60%), var(--bg-alt); }
.login-card { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg); padding: clamp(1.6rem, 5vw, 2.4rem); box-shadow: var(--shadow); }
.login-card .brand { margin-bottom: 1.8rem; }
.field { margin-bottom: 1.1rem; display: flex; flex-direction: column; gap: .4rem; }
.field label { font-size: .82rem; font-weight: 500; color: var(--ink-soft); }
.field input { font-family: var(--sans); font-size: 1rem; font-weight: 300; padding: .8rem .95rem; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-alt); color: var(--ink); transition: border-color .15s, box-shadow .15s, background .15s; }
.field input:focus { outline: none; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 4px var(--accent-l); }
.login-card .btn { width: 100%; margin-top: .4rem; }
.divider { display: flex; align-items: center; gap: .8rem; margin: 1.1rem 0 .3rem; color: var(--muted); font-size: .78rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.btn.google { background: #fff; color: var(--ink); border-color: var(--line); gap: .65rem; }
.btn.google:hover { background: var(--bg-alt); color: var(--ink); border-color: var(--muted); box-shadow: var(--shadow-sm); }
.btn.google svg { flex: none; }
.login-error { min-height: 1.2rem; margin: .9rem 0 0; font-size: .88rem; color: var(--no); text-align: center; }
.login-foot { margin-top: 1.4rem; font-size: .78rem; color: var(--muted); text-align: center; }

/* ===== Dashboard ===== */
.dash-header { position: sticky; top: 0; z-index: 10; background: rgba(255,255,255,.85); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.dash-header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-top: .9rem; padding-bottom: .9rem; flex-wrap: wrap; }
.dash-tools { display: flex; align-items: center; gap: .7rem; }
#search { font-family: var(--sans); font-size: .92rem; font-weight: 300; padding: .6rem .9rem; border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--bg-alt); min-width: 220px; }
#search:focus { outline: none; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 4px var(--accent-l); }
.dash-main { padding-top: 1.6rem; padding-bottom: 4rem; }
.empty { text-align: center; color: var(--muted); padding: 3rem 0; }
.list-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; padding: 0 .3rem; min-height: 34px; }
.sel-all { display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--ink-soft); cursor: pointer; user-select: none; }
#selAll { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.card-check { display: flex; align-items: center; flex: none; padding-right: .1rem; }
.card-check .sel { width: 19px; height: 19px; accent-color: var(--accent); cursor: pointer; }
.client-card.selected { border-color: var(--accent); background: #f4f8ff; }
.client-card.selected:hover { border-color: var(--accent); }

/* Bottoni "pericolo" */
.btn.danger { background: var(--no); border-color: var(--no); color: #fff; }
.btn.danger:hover { background: #a5382f; border-color: #a5382f; box-shadow: 0 12px 26px rgba(194,69,58,.28); }
.btn.danger-outline { background: transparent; color: var(--no); border-color: rgba(194,69,58,.4); }
.btn.danger-outline:hover { background: rgba(194,69,58,.08); color: var(--no); border-color: var(--no); box-shadow: none; }

.client-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .8rem; }
.client-card { background: #fff; border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-sm); transition: transform .18s, box-shadow .18s, border-color .18s; overflow: hidden; }
.client-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: transparent; }
.client-card.done { opacity: .72; }
.card-row { display: flex; align-items: center; gap: 1rem; padding: 1.05rem 1.3rem; }
.card-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 1rem; background: none; border: 0; text-align: left; cursor: pointer; font-family: var(--sans); padding: 0; }
.avatar { flex: none; width: 42px; height: 42px; border-radius: 50%; background: var(--accent-l); color: var(--accent-d); display: grid; place-items: center; font-weight: 700; font-size: 1rem; }
.card-info { min-width: 0; }
.card-name { font-weight: 500; font-size: 1.02rem; color: var(--ink); letter-spacing: -.01em; }
.card-meta { font-size: .84rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-meta a { color: var(--ink-soft); text-decoration: none; }
.card-meta a:hover { color: var(--accent); }
.card-side { flex: none; display: flex; align-items: center; gap: .9rem; }
.card-date { font-size: .78rem; color: var(--muted); text-align: right; }
.badge { font-size: .72rem; font-weight: 500; padding: .25rem .6rem; border-radius: var(--r-pill); background: var(--accent-l); color: var(--accent-d); }
.badge.done { background: rgba(31,138,91,.12); color: var(--ok); }

/* ===== iOS switch (adattato alla palette) ===== */
.switch-wrap { display: flex; align-items: center; gap: .5rem; }
.switch-label { font-size: .74rem; color: var(--muted); user-select: none; }
.switch { width: 52px; height: 30px; display: inline-block; cursor: pointer; position: relative; flex: none; }
.switch input { display: none; }
.switch .slider { position: absolute; inset: 0; background: #c9ced9; border-radius: var(--r-pill); transition: background .3s; }
.switch .slider::before { content: ""; position: absolute; height: 24px; width: 24px; left: 3px; top: 3px; background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(13,15,20,.25); transition: transform .3s; }
.switch input:checked + .slider { background: var(--ok); }
.switch input:checked + .slider::before { transform: translateX(22px); }

/* ===== Drawer dettaglio ===== */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(13,15,20,.4); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; height: 100dvh; width: min(460px, 100vw); background: #fff; z-index: 50; box-shadow: var(--shadow-lg); padding: 2rem clamp(1.3rem, 4vw, 2.2rem); overflow-y: auto; animation: slideIn .28s cubic-bezier(.22,.61,.36,1); }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.drawer-close { position: absolute; top: 1rem; right: 1.1rem; width: 38px; height: 38px; border: 0; background: var(--bg-alt); border-radius: 50%; font-size: 1.5rem; line-height: 1; color: var(--ink-soft); cursor: pointer; }
.drawer-close:hover { background: var(--line); }
.drawer h2 { font-family: var(--sans); font-weight: 700; font-size: 1.5rem; letter-spacing: -.025em; margin: .3rem 0 .2rem; }
.drawer .d-sub { color: var(--muted); font-size: .86rem; margin: 0 0 1.6rem; }
.d-block { margin-bottom: 1.3rem; }
.d-block .d-key { font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; font-weight: 700; color: var(--muted); margin-bottom: .35rem; }
.d-block .d-val { font-size: 1rem; color: var(--ink); font-weight: 300; }
.d-block .d-val a { color: var(--accent); text-decoration: none; }
.d-msg { background: var(--bg-alt); border: 1px solid var(--line); border-radius: 14px; padding: 1rem 1.1rem; font-size: .98rem; line-height: 1.55; color: var(--ink-soft); white-space: pre-wrap; }
.d-quote { font-family: var(--serif); font-style: italic; }
.d-actions { display: flex; gap: .7rem; margin-top: 1.6rem; flex-wrap: wrap; }
.d-actions .btn { flex: 1; min-width: 130px; }

/* Compose email dentro il drawer */
.compose { margin-top: 1.2rem; display: flex; flex-direction: column; gap: .45rem; }
.compose .d-key { margin-bottom: 0; margin-top: .5rem; }
.compose-in { font-family: var(--sans); font-size: 1rem; font-weight: 300; padding: .7rem .9rem; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-alt); color: var(--ink); width: 100%; }
.compose-in:focus { outline: none; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 4px var(--accent-l); }
textarea.compose-in { resize: vertical; line-height: 1.5; min-height: 140px; }
.compose-actions { display: flex; gap: .6rem; margin-top: .5rem; }
.compose-actions .btn { flex: 1; }
.compose-hint { font-size: .78rem; color: var(--muted); margin: .4rem 0 0; line-height: 1.4; }

/* Zona pericolo (elimina) */
.d-danger { margin-top: 1.6rem; padding-top: 1.3rem; border-top: 1px solid var(--line); }
.d-danger .btn { width: 100%; }

/* ===== Tablet ===== */
@media (max-width: 720px) {
  .dash-header-inner { gap: .6rem .8rem; }
  .brand.small h1 { font-size: 1.05rem; }
  .dash-tools { width: 100%; }
  #search { flex: 1; min-width: 0; font-size: 16px; }
  .card-meta { max-width: 46vw; }
}

/* ===== Telefono: la card si riorganizza in due righe ===== */
@media (max-width: 560px) {
  .wrap { padding: 0 1rem; }
  .dash-main { padding-top: 1.1rem; padding-bottom: 3rem; }
  .brand-mark { width: 40px; height: 40px; }

  .card-row { flex-wrap: wrap; row-gap: .85rem; padding: .95rem 1.05rem; column-gap: .7rem; }
  .card-open { flex: 1 1 auto; min-width: 0; gap: .8rem; }
  .card-name { font-size: 1rem; }
  .card-meta { max-width: none; white-space: normal; overflow: visible; font-size: .82rem; line-height: 1.35; }
  .card-side { flex: 1 1 100%; justify-content: space-between; gap: .6rem; padding-left: 0; }
  .card-date { display: block; font-size: .74rem; order: 1; align-self: center; }
  .badge { order: 2; }
  .switch-wrap { order: 3; }
}

/* ===== Telefono piccolo: azioni drawer in colonna ===== */
@media (max-width: 400px) {
  .brand small, .brand.small h1 { font-size: 1rem; }
  .card-side { padding-left: 0; }
  .d-actions { flex-direction: column; }
  .d-actions .btn { width: 100%; }
  .drawer h2 { font-size: 1.35rem; }
}

/* ===== Touch: niente hover "appiccicoso" ===== */
@media (hover: none) {
  .client-card:hover { transform: none; box-shadow: var(--shadow-sm); border-color: var(--line); }
  .btn:hover, .btn.ghost:hover { transform: none; box-shadow: none; }
  .client-card:active { transform: scale(.994); }
}
