/* ==========================================================================
   Pokemon Lister — Design System
   Direzione: dark operativo raffinato (Linear/Stripe/Notion), non "AI navy".
   Font: Instrument Sans (UI) + IBM Plex Mono (numeri/denaro/dati tabellari).
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Instrument+Sans:ital,wght@0,400..700;1,400..700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  /* Superfici — nero freddo, tono viola/blu scuro */
  --bg: #0a0a10;
  --bg-elevated: #131320;
  --bg-card: #191828;
  --bg-hover: #212036;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);

  /* Testo — bianco freddo, non puro #fff */
  --text: #ece9f5;
  --text-dim: #9b96b0;
  --text-faint: #635e78;

  /* Accento — duotone viola/turchese */
  --accent: #2dd4bf;
  --accent-bright: #a78bfa;
  --accent-dim: rgba(167, 139, 250, 0.16);
  --accent-text: #10081f;

  /* Semantici — smorzati, non neon */
  --positive: #6fb08a;
  --positive-dim: rgba(111, 176, 138, 0.14);
  --negative: #c1667e;
  --negative-dim: rgba(193, 102, 126, 0.14);
  --warning: #e879b8;
  --warning-dim: rgba(232, 121, 184, 0.14);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;

  --shadow-card: 0 1px 2px rgba(0,0,0,0.3), 0 8px 24px -8px rgba(0,0,0,0.5);
  --shadow-float: 0 4px 12px rgba(0,0,0,0.4), 0 16px 40px -12px rgba(0,0,0,0.6);

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --font-ui: 'Instrument Sans', -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 1200px 600px at 50% -10%, rgba(139,92,246,0.08), transparent),
    repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255,255,255,0.008) 3px);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(84px + env(safe-area-inset-bottom)); /* spazio per bottom nav mobile, +home indicator iPhone */
}

a { color: inherit; text-decoration: none; }

/* ── App shell / nav ─────────────────────────────────────────────────── */

.app-topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 18px 14px;
  background: rgba(10,10,16,0.82);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--border);
}
.app-brand {
  display: flex; align-items: center; gap: 9px;
  font-size: 16px; font-weight: 600; letter-spacing: -0.01em;
  text-decoration: none; color: var(--text);
}
.app-brand .mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(155deg, var(--accent-bright), var(--accent) 60%, #4c1d95);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; box-shadow: 0 2px 8px rgba(139,92,246,0.35);
}

.app-nav {
  display: flex; gap: 2px;
}
.app-nav a {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; text-decoration: none;
  color: var(--text-dim);
  transition: background .15s var(--ease), color .15s var(--ease);
}
.app-nav a:hover { background: var(--bg-hover); color: var(--text); }
.app-nav a.active { background: var(--accent-dim); color: var(--accent-bright); }

/* Bottom tab bar — mobile only */
.app-bottomnav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  background: rgba(18,16,12,0.92);
  backdrop-filter: blur(16px) saturate(140%);
  border-top: 1px solid var(--border);
}
.app-bottomnav-row { display: flex; justify-content: space-around; }
.app-bottomnav a {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  text-decoration: none; color: var(--text-faint);
  font-size: 10.5px; font-weight: 500; padding: 4px 10px; border-radius: 10px;
  transition: color .15s var(--ease);
}
.app-bottomnav a .icon { font-size: 19px; line-height: 1; }
.app-bottomnav a.active { color: var(--accent-bright); }

@media (max-width: 720px) {
  .app-nav { display: none; }
  .app-bottomnav { display: block; }
  body { padding-bottom: 78px; }
}

/* ── Layout primitives ───────────────────────────────────────────────── */

.page {
  max-width: 1040px; margin: 0 auto; padding: 28px 18px 40px;
  opacity: 0; animation: rise .4s var(--ease) forwards;
}
.page-narrow { max-width: 460px; }

.page-head { margin-bottom: 22px; }
.page-head h1 {
  font-size: 22px; font-weight: 650; letter-spacing: -0.015em; margin: 0 0 4px;
}
.page-head p { margin: 0; color: var(--text-dim); font-size: 13.5px; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.stagger > * {
  opacity: 0; animation: rise .45s var(--ease) forwards;
}
.stagger > *:nth-child(1) { animation-delay: .03s; }
.stagger > *:nth-child(2) { animation-delay: .08s; }
.stagger > *:nth-child(3) { animation-delay: .13s; }
.stagger > *:nth-child(4) { animation-delay: .18s; }
.stagger > *:nth-child(5) { animation-delay: .23s; }
.stagger > *:nth-child(n+6) { animation-delay: .27s; }

/* ── Card ─────────────────────────────────────────────────────────────── */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-card);
  margin-bottom: 14px;
}
.card h2 {
  font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-dim); margin: 0 0 12px;
}
a.card {
  text-decoration: none; color: inherit;
  transition: transform .15s var(--ease), border-color .15s var(--ease), background .15s var(--ease);
}
a.card:hover { transform: translateY(-1px); border-color: var(--border-strong); background: var(--bg-hover); }
a.card:active { transform: translateY(0); }

/* ── Buttons ──────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 14px 18px; margin-top: 4px;
  border: none; border-radius: var(--radius-sm);
  font-family: var(--font-ui); font-size: 15px; font-weight: 600;
  cursor: pointer; text-decoration: none;
  transition: transform .12s var(--ease), box-shadow .12s var(--ease), background .12s var(--ease);
}
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: linear-gradient(155deg, var(--accent-bright), var(--accent));
  color: var(--accent-text);
  box-shadow: 0 2px 6px rgba(139,92,246,0.25), 0 8px 20px -8px rgba(45,212,191,0.4);
}
.btn-primary:hover { box-shadow: 0 2px 10px rgba(139,92,246,0.35), 0 10px 28px -8px rgba(45,212,191,0.5); }

.btn-ghost {
  background: var(--bg-hover); color: var(--text); border: 1px solid var(--border-strong);
}
.btn-ghost:hover { background: #2b2620; }

.btn-danger {
  background: var(--negative-dim); color: #e58e92; border: 1px solid rgba(193,102,107,0.3);
}
.btn-sm { width: auto; padding: 7px 12px; font-size: 12.5px; margin-top: 0; }

/* ── Forms ────────────────────────────────────────────────────────────── */

label.field-label {
  display: block; margin: 14px 0 6px; font-size: 12.5px; font-weight: 500;
  color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em;
}
input[type=text], input[type=number], input[type=file], select, textarea {
  width: 100%; box-sizing: border-box; padding: 11px 12px;
  background: var(--bg-elevated); border: 1px solid var(--border-strong);
  color: var(--text); border-radius: var(--radius-sm);
  font-family: var(--font-ui); font-size: 14.5px;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
input[type=file] { padding: 9px 12px; cursor: pointer; }

/* ── Tables ───────────────────────────────────────────────────────────── */

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; padding: 8px 10px; color: var(--text-faint);
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
}
td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.015); }

.num, .money { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ── Badges / status ──────────────────────────────────────────────────── */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
}
.badge-positive { background: var(--positive-dim); color: var(--positive); }
.badge-negative { background: var(--negative-dim); color: var(--negative); }
.badge-warning  { background: var(--warning-dim); color: var(--warning); }
.badge-neutral  { background: var(--bg-hover); color: var(--text-dim); }

.text-positive { color: var(--positive); }
.text-negative { color: var(--negative); }

/* ── Stat blocks (dashboard) ──────────────────────────────────────────── */

.stat-value {
  font-family: var(--font-mono); font-size: 30px; font-weight: 600;
  letter-spacing: -0.02em; line-height: 1.15;
}
.stat-label { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }

.callout {
  display: flex; align-items: flex-start; gap: 8px;
  background: var(--warning-dim); border: 1px solid rgba(232,121,184,0.3);
  color: var(--warning); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 12.5px; font-weight: 500; margin-top: 10px;
}

/* ── Photo / scan components ──────────────────────────────────────────── */

.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 44px 20px; text-align: center;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius-lg);
  background: var(--bg-card); cursor: pointer;
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.dropzone:hover { border-color: var(--accent); background: var(--bg-hover); }
.dropzone.dropzone-active {
  border-color: var(--accent-bright); background: var(--bg-hover);
  border-style: solid;
}
.dropzone .icon { font-size: 34px; }
.dropzone .hint { color: var(--text-dim); font-size: 13px; }

.result-card {
  border-left: 3px solid var(--border-strong);
}
.result-card.ok   { border-left-color: var(--positive); }
.result-card.warn { border-left-color: var(--warning); }
.result-card.err  { border-left-color: var(--negative); }

.card-thumb { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; }

/* ── Misc ─────────────────────────────────────────────────────────────── */

.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.mono  { font-family: var(--font-mono); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.flex-row { display: flex; gap: 10px; align-items: center; }
.hr { height: 1px; background: var(--border); margin: 14px 0; border: none; }

/* ── List rows (set picker, ecc.) ─────────────────────────────────────── */

.list-scroll {
  max-height: 55vh; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-card);
}
.list-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: none; border-bottom: 1px solid var(--border);
  color: var(--text); padding: 12px 14px; text-align: left; cursor: pointer;
  font-family: var(--font-ui); font-size: 13.5px;
  transition: background .12s var(--ease);
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--bg-hover); }
.list-row.selected { background: var(--accent-dim); }
.chip {
  color: var(--accent-bright); font-weight: 600; font-size: 11.5px;
  display: inline-block; min-width: 58px; font-family: var(--font-mono);
}

/* ── Empty state ──────────────────────────────────────────────────────── */

.empty-state {
  text-align: center; padding: 30px 16px; color: var(--text-faint); font-size: 13px;
}

/* ── Row-card (liste editabili dense: revisione batch, vendite) ─────────
   Alternativa a <table> per dataset con molte colonne su mobile: invece di
   scroll orizzontale (fastidioso in un flusso ripetuto 50 volte per batch),
   impila foto+identità sopra e controlli in una riga compatta sotto. ───── */

.row-card {
  display: flex; gap: 12px; padding: 12px; border-bottom: 1px solid var(--border);
}
.row-card:last-child { border-bottom: none; }
.row-card-review { background: var(--warning-dim); border-left: 3px solid var(--warning); }
.row-card-main { flex: 1; min-width: 0; }
.row-card-title { font-weight: 600; font-size: 14.5px; margin-bottom: 1px; }
.row-card-sub { color: var(--text-faint); font-size: 12px; font-family: var(--font-mono); }
.row-card-controls {
  display: flex; gap: 6px; align-items: center; margin-top: 8px; flex-wrap: wrap;
}
.row-card-controls select,
.row-card-controls input {
  padding: 7px 8px; font-size: 12.5px; width: auto;
}
.field-compact-price { width: 68px !important; font-family: var(--font-mono); }
.field-compact-qty { width: 46px !important; font-family: var(--font-mono); }
