/* ===== Piano Pasti AI — Rossella Ilacqua ===== */
:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --ink: #1f1b16;
  --muted: #6f6a61;
  --accent: #b3502e;
  --accent-soft: #f6e3da;
  --sage: #5f7058;
  --border: #e8e2d9;
  --radius: 16px;
  --shadow: 0 8px 30px rgba(31, 27, 22, .07);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
}

.container { max-width: 920px; margin: 0 auto; padding: 0 1.25rem; }

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: .9rem; padding-bottom: .9rem;
}
.brand { display: flex; align-items: center; gap: .8rem; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-family: 'Fraunces', serif; font-weight: 700; font-size: 1.05rem;
}
.brand-title { font-family: 'Fraunces', serif; font-size: 1.15rem; line-height: 1.1; }
.brand-sub { font-size: .75rem; color: var(--muted); }
nav a {
  color: var(--muted); text-decoration: none; font-weight: 500;
  margin-left: 1.4rem; font-size: .92rem;
}
nav a:hover { color: var(--accent); }

/* Hero */
.hero { text-align: center; padding: 3.2rem 0 2.2rem; }
.hero h2 {
  font-family: 'Fraunces', serif; font-size: clamp(1.9rem, 4.5vw, 3rem);
  font-weight: 600; letter-spacing: -.01em;
}
.hero h2 em { color: var(--accent); font-style: italic; }
.hero p { max-width: 620px; margin: 1rem auto 0; color: var(--muted); }

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.8rem;
  margin-bottom: 1.6rem;
}
.card h3 { font-family: 'Fraunces', serif; font-size: 1.2rem; margin-bottom: .35rem; }
.hint { color: var(--muted); font-size: .88rem; margin-bottom: 1rem; }

/* Dropzone */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: .5rem;
  border: 2px dashed var(--border); border-radius: 12px;
  padding: 2rem; cursor: pointer; text-align: center;
  transition: border-color .2s, background .2s;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input { display: none; }
.dropzone-icon { font-size: 2rem; }
.dropzone-text { color: var(--muted); font-size: .95rem; }
.dropzone.has-file .dropzone-text { color: var(--sage); font-weight: 600; }

/* Textarea */
textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 12px;
  padding: .9rem 1rem; font-family: inherit; font-size: .95rem;
  resize: vertical; background: #fffdf9; color: var(--ink);
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

/* Buttons */
.btn-primary {
  margin-top: 1.4rem; width: 100%;
  background: var(--accent); color: #fff; border: none;
  padding: 1rem 1.5rem; border-radius: 12px;
  font-size: 1.02rem; font-weight: 600; cursor: pointer;
  transition: transform .15s, box-shadow .15s, opacity .2s;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(179, 80, 46, .35); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-secondary {
  display: inline-block; background: var(--ink); color: #fff; text-decoration: none;
  padding: .65rem 1.3rem; border-radius: 10px; font-weight: 600; font-size: .92rem;
}
.btn-secondary:hover { background: var(--accent); }

.error { color: #b3261e; font-size: .9rem; margin-top: .8rem; }

/* Loader */
.loader-card { text-align: center; padding: 3rem 1.8rem; }
.spinner {
  width: 46px; height: 46px; margin: 0 auto 1.1rem;
  border: 4px solid var(--accent-soft); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loaderText { color: var(--muted); font-weight: 500; }

/* Risultati */
.results-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 1rem; margin: .5rem 0 1.4rem;
}
.results-header h2 { font-family: 'Fraunces', serif; font-size: 1.7rem; }

.vincoli-card ul { padding-left: 1.2rem; color: var(--muted); font-size: .92rem; }
.vincoli-card li { margin: .25rem 0; }

/* Giorni */
.giorno-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.4rem 1.6rem; margin-bottom: 1.2rem;
}
.giorno-head {
  display: flex; justify-content: space-between; align-items: baseline;
  border-bottom: 1px solid var(--border); padding-bottom: .6rem; margin-bottom: .9rem;
}
.giorno-head h4 { font-family: 'Fraunces', serif; font-size: 1.15rem; }
.kcal-badge {
  background: var(--accent-soft); color: var(--accent);
  padding: .2rem .75rem; border-radius: 999px;
  font-size: .82rem; font-weight: 700; white-space: nowrap;
}
.pasto { margin-bottom: .85rem; }
.pasto-tipo {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--sage); font-weight: 700;
}
.pasto-nome { font-weight: 600; }
.pasto-desc { color: var(--muted); font-size: .9rem; }
.pasto-kcal { font-size: .82rem; color: var(--muted); }

/* Ricette */
.ricetta {
  border: 1px solid var(--border); border-radius: 12px;
  padding: 1.1rem 1.3rem; margin-bottom: 1rem; background: #fffdf9;
}
.ricetta h5 { font-family: 'Fraunces', serif; font-size: 1.02rem; margin-bottom: .4rem; }
.ricetta .kcal-badge { font-size: .75rem; }
.ricetta ul { padding-left: 1.2rem; font-size: .9rem; margin: .5rem 0; color: var(--muted); }
.ricetta .proc { font-size: .9rem; color: var(--ink); }
.ricetta .proc strong { color: var(--accent); }

/* Storico */
.storico-list { list-style: none; }
.storico-list li {
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; flex-wrap: wrap;
  border: 1px solid var(--border); border-radius: 10px;
  padding: .8rem 1.1rem; margin-bottom: .6rem; background: #fffdf9;
}
.storico-nome { font-weight: 600; font-size: .92rem; word-break: break-all; }
.storico-data { color: var(--muted); font-size: .82rem; }
.storico-list a { color: var(--accent); font-weight: 600; text-decoration: none; font-size: .88rem; }
.storico-list a:hover { text-decoration: underline; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); margin-top: 3rem; padding: 1.5rem 0; }
.site-footer p { color: var(--muted); font-size: .85rem; text-align: center; }
.site-footer a { color: var(--accent); text-decoration: none; }

@media (max-width: 600px) {
  nav a { margin-left: .9rem; font-size: .85rem; }
  .card { padding: 1.3rem; }
}

/* ==== v7: persone, spesa, sostituzione ==== */
#persone {
  width: 100%; border: 1px solid var(--border); border-radius: 12px;
  padding: .85rem 1rem; font-family: inherit; font-size: .95rem;
  background: #fffdf9; color: var(--ink);
}
#persone:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.badge-persone {
  display: inline-block; margin-top: .35rem;
  background: var(--sage); color: #fff;
  padding: .3rem .85rem; border-radius: 999px;
  font-size: .85rem; font-weight: 700;
}
.spesa-list { list-style: none; }
.spesa-item { margin: .35rem 0; }
.spesa-item label { display: flex; align-items: baseline; gap: .5rem; cursor: pointer; }
.spesa-item input[type="checkbox"] { transform: scale(1.15); accent-color: var(--sage); cursor: pointer; }
.spesa-qta { color: var(--sage); font-weight: 700; font-size: .85rem; }
.spesa-gia-titolo {
  margin-top: 1rem; color: var(--sage); font-weight: 700;
  font-size: .8rem; text-transform: uppercase; letter-spacing: .07em;
}
.spesa-gia { color: var(--muted); font-size: .92rem; margin: .25rem 0; }
.spesa-vuota { color: var(--muted); font-style: italic; }
.btn-sostituisci {
  margin-top: .5rem; background: var(--accent-soft); color: var(--accent);
  border: none; border-radius: 8px; padding: .3rem .75rem;
  font-size: .78rem; font-weight: 700; cursor: pointer;
  transition: background .15s, color .15s;
}
.btn-sostituisci:hover { background: var(--accent); color: #fff; }
.btn-sostituisci:disabled { opacity: .55; cursor: wait; }

/* ==== v8: nome persona + spesa solo-mancanti ==== */
#nomeUtente {
  width: 100%; border: 1px solid var(--border); border-radius: 12px;
  padding: .85rem 1rem; font-family: inherit; font-size: .95rem;
  background: #fffdf9; color: var(--ink);
}
#nomeUtente:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.spesa-intro {
  color: var(--muted); font-size: .82rem; margin-bottom: .75rem;
  font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
}
.spesa-item label { display: flex; align-items: baseline; gap: .55rem; cursor: pointer; padding: .2rem 0; }
.spesa-item input[type="checkbox"]:checked + strong {
  text-decoration: line-through; color: var(--muted);
}
.storico-mini { display: flex; flex-direction: column; gap: .1rem; }
.storico-persona {
  color: var(--accent); font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
}
