/* ===================================================================
   Spesa — base stylesheet
   Direction A · Orto · soft sage + warm cream
   =================================================================== */

/* ---- Fonts -------------------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Public+Sans:ital,wght@0,300..800;1,300..800&family=Fraunces:opsz,wght@9..144,300..700&display=swap');

/* ---- Design tokens ------------------------------------------------ */
:root {
  /* palette — warm sage + cream */
  --bg:        #f4f3ed;
  --surface:   #fbfaf6;
  --ink:       #1e2520;
  --ink-2:     #3d4640;
  --ink-hover: #2a322c;
  --muted:     #7a8079;
  --hairline:  #e3e1d8;
  --hairline-2:#ecebe2;
  --sage:      #7ea389;
  --sage-deep: #4f7261;
  --sage-soft: #dde7df;
  --sand:      #d9c39a;
  --blush:     #dfb6a6;
  --error-bg:  #f4dcd1;
  --error-fg:  #6b3322;
  --error-dot: #b94a2c;

  /* type */
  --font-sans:   'Public Sans', -apple-system, system-ui, 'Segoe UI', sans-serif;
  --font-serif:  'Fraunces', 'Iowan Old Style', 'Georgia', serif;

  /* radius & shadow */
  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 22px;
  --r-pill: 999px;

  --shadow-pop: 0 12px 30px rgba(30, 37, 32, 0.18);
}

/* ---- Reset -------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.005em;
  line-height: 1.4;
}
button { font-family: inherit; cursor: pointer; }

/* ===================================================================
   Login page
   =================================================================== */
.login-page {
  min-height: 100dvh;
  background: var(--bg);
  display: flex;
  justify-content: center;
}
.login-page > main {
  width: 100%;
  max-width: 440px;
  padding: env(safe-area-inset-top, 0) 0 env(safe-area-inset-bottom, 0);
}

.login-box {
  min-height: 100dvh;
  padding: 60px 28px 32px;
  display: flex;
  flex-direction: column;
}
@media (min-width: 480px) {
  .login-box { padding: 80px 40px 40px; }
}

.login-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* wordmark */
.login-brand {
  font-family: var(--font-serif);
  font-size: clamp(48px, 14vw, 60px);
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--ink);
  font-variation-settings: "opsz" 144;
  margin: 0;
}
.login-brand .dot { color: var(--sage); }

.login-tagline {
  font-size: 16px;
  color: var(--muted);
  line-height: 1.45;
  margin: 12px 0 0;
  text-wrap: pretty;
}

/* form */
.login-form {
  margin-top: 44px;
  display: flex;
  flex-direction: column;
}

.field {
  display: flex;
  flex-direction: column;
}
.field + .field { margin-top: 28px; }

.field label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.field input {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  margin-top: 8px;
  padding: 0 0 10px;
  border: none;
  border-bottom: 1.5px solid var(--hairline);
  border-radius: 0;
  background: transparent;
  font-family: var(--font-sans);
  font-size: 18px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.005em;
  outline: none;
  transition: border-color 0.2s ease;
}
.field input::placeholder { color: var(--hairline); }
.field input:hover { border-bottom-color: var(--muted); }
.field input:focus { border-bottom-color: var(--ink); }
.field input[type="password"] {
  letter-spacing: 0.15em;
}

/* autofill — keep our colors */
.field input:-webkit-autofill,
.field input:-webkit-autofill:hover,
.field input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--ink);
  -webkit-box-shadow: 0 0 0 1000px var(--bg) inset;
  caret-color: var(--ink);
  transition: background-color 9999s ease;
}

/* primary CTA */
.btn-primary {
  height: 54px;
  border-radius: var(--r-pill);
  border: none;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.05s ease, background-color 0.15s ease;
}
.login-form .btn-primary { margin-top: 40px; }
.btn-primary:hover { background: var(--ink-hover); }
.btn-primary:active { transform: scale(0.985); }
.btn-primary:focus-visible {
  outline: 2px solid var(--sage-deep);
  outline-offset: 3px;
}
.btn-primary svg { width: 16px; height: 16px; transition: transform 0.2s ease; }
.btn-primary:hover svg { transform: translateX(2px); }

/* error message */
.login-error {
  margin-top: 28px;
  padding: 12px 14px;
  background: var(--error-bg);
  color: var(--error-fg);
  border-radius: var(--r-sm);
  font-size: 14px;
  line-height: 1.4;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.login-error::before {
  content: "";
  flex-shrink: 0;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--error-dot);
  margin-top: 7px;
}

/* footer */
.login-footer {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  margin-top: 24px;
}
.login-footer .dot-sep {
  display: inline-block;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--hairline);
  vertical-align: middle;
  margin: 0 8px;
}

/* ===================================================================
   App shell (base.html)
   =================================================================== */
nav {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--hairline-2);
  background: var(--surface);
}
nav .brand {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.02em;
}
nav ul {
  list-style: none;
  display: flex;
  gap: 18px;
  margin: 0;
  padding: 0;
  flex: 1;
}
nav ul a {
  color: var(--ink-2);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}
nav ul a:hover { color: var(--sage-deep); }
nav form button {
  background: transparent;
  border: 1px solid var(--hairline);
  color: var(--muted);
  font-size: 13px;
  padding: 6px 12px;
  border-radius: var(--r-pill);
}
main {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 20px;
}
body.lista-body > main {
  max-width: none;
  padding: 0;
}

/* ===================================================================
   Shared atoms
   =================================================================== */
.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot--sage { background: var(--sage); }

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.avatar--sage { background: var(--sage-soft); color: var(--sage-deep); }

.link-action {
  font-size: 14px;
  color: var(--sage-deep);
  font-weight: 600;
  text-decoration: none;
  padding: 6px 4px;
}
.link-action:hover { color: var(--ink); }

.link-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
  padding: 6px 4px;
}
.link-back:hover { color: var(--ink); }

/* ===================================================================
   Lista — main page
   =================================================================== */
body.lista-body { background: var(--bg); }

.lista {
  position: relative;
  min-height: 100dvh;
  padding-bottom: 110px;
}
.lista-spacer { height: 16px; }

/* ---- add bar ----------------------------------------------------- */
.add-bar {
  margin: 16px 22px 0;
  position: relative;
}
.add-bar__form {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--hairline-2);
  border-radius: 14px;
  border: 1.5px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}
.add-bar__form:focus-within {
  background: var(--surface);
  border-color: var(--ink);
}
.add-bar__icon {
  color: var(--muted);
  display: inline-flex;
  flex-shrink: 0;
}
.add-bar__form:focus-within .add-bar__icon { color: var(--ink-2); }
.add-bar__input {
  flex: 1;
  border: 0;
  background: transparent;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  outline: none;
  min-width: 0;
  padding: 0;
}
.add-bar__input::placeholder {
  color: var(--muted);
  font-weight: 400;
}
.add-bar__spinner {
  display: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid var(--hairline);
  border-top-color: var(--sage-deep);
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.add-bar__spinner.htmx-request { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.add-bar__clear {
  display: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 0;
  background: rgba(0,0,0,0.12);
  color: var(--surface);
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
}
.add-bar__form:focus-within .add-bar__clear,
.add-bar__input:not(:placeholder-shown) ~ .add-bar__clear { display: inline-flex; }

/* ---- add-results panel ------------------------------------------ */
.add-results:not(:empty) {
  margin-top: 12px;
  padding-bottom: 4px;
}

.add-hint {
  font-size: 13px;
  color: var(--muted);
  padding: 10px 4px;
}
.add-section-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 6px 4px 8px;
}

.add-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--hairline-2);
  border-radius: 18px;
  overflow: hidden;
}
.add-list__item + .add-list__item .add-list__btn {
  border-top: 1px solid var(--hairline-2);
}
.add-list__btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: transparent;
  border: 0;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s;
}
.add-list__btn:hover,
.add-list__btn:focus-visible {
  background: var(--bg);
  outline: none;
}
.add-list__swatch {
  width: 8px; height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}
.add-list__main {
  flex: 1;
  min-width: 0;
}
.add-list__name {
  display: block;
  font-size: 15.5px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.005em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.add-list__name mark {
  background: var(--sage-soft);
  color: var(--sage-deep);
  font-weight: 700;
  border-radius: 2px;
  padding: 0 2px;
}
.add-list__meta {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.add-list__add {
  color: var(--sage-deep);
  font-size: 18px;
  font-weight: 600;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.add-new {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 14px 16px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 14px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  letter-spacing: -0.005em;
  border: 0;
  width: 100%;
  cursor: pointer;
}
.add-new:hover { background: var(--ink-hover); }
.add-new__icon {
  color: var(--sage);
  font-size: 17px;
  font-weight: 600;
  display: inline-flex;
  width: 18px;
  justify-content: center;
}
.add-new__label { flex: 1; text-align: left; }
.add-new__query {
  font-weight: 600;
  color: rgba(255,255,255,0.85);
}

/* ---- items groups ------------------------------------------------ */
.items {
  padding: 18px 22px 0;
}
.items-group { margin-top: 18px; }
.items-group:first-child { margin-top: 4px; }
.items-group__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px 8px;
}
.items-group__swatch {
  width: 8px; height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}
.items-group__label {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
}
.items-group__rule {
  flex: 1;
  height: 1px;
  background: var(--hairline-2);
  margin: 0 4px;
}
.items-group__count {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.items-group__list {
  list-style: none;
  margin: 0;
  padding: 0 16px;
  background: var(--surface);
  border: 1px solid var(--hairline-2);
  border-radius: 18px;
}

/* ---- single item row -------------------------------------------- */
.item {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 13px 0;
  border-bottom: 1px solid var(--hairline-2);
}
.item:last-child { border-bottom: 0; }

.item__check {
  appearance: none;
  -webkit-appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1.6px solid var(--muted);
  background: transparent;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
  flex-shrink: 0;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.item__check:hover { border-color: var(--ink-2); }
.item__check:active { transform: scale(0.92); }
.item__check:focus-visible {
  outline: 2px solid var(--sage-deep);
  outline-offset: 2px;
}

.item__body {
  flex: 1;
  min-width: 0;
}
.item__name {
  font-size: 15.5px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.005em;
  word-break: break-word;
}

/* ---- empty state ------------------------------------------------ */
.empty {
  margin: 24px 22px 0;
  padding: 24px 20px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--hairline);
  border-radius: 18px;
}
.empty__title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: -0.02em;
}
.empty__body {
  margin: 6px 0 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.45;
}

/* ---- bottom CTA -------------------------------------------------- */
.cta-shop {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: max(20px, env(safe-area-inset-bottom));
  max-width: 408px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--ink);
  color: var(--bg);
  padding: 14px 20px;
  border-radius: var(--r-pill);
  text-decoration: none;
  box-shadow: var(--shadow-pop);
  font-family: var(--font-sans);
}
.cta-shop:hover { background: var(--ink-hover); }
.cta-shop__icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--sage);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.cta-shop__label {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
}

/* ===================================================================
   Nuovo prodotto — full-page form
   =================================================================== */
.np {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}
.np-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 22px 4px;
}
.np-head__title {
  font-size: 14px;
  color: var(--muted);
  font-weight: 500;
}
.np-head__spacer { width: 60px; }

.np-intro { padding: 14px 24px 4px; }
.np-intro__title {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 400;
  letter-spacing: -0.025em;
  margin: 0;
  line-height: 1.1;
  color: var(--ink);
}
.np-intro__body {
  margin: 6px 0 0;
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.45;
}

.np-body { padding: 20px 24px 16px; flex: 1; }
.np-field { margin-bottom: 22px; }
.np-field:last-child { margin-bottom: 0; }

.np-label {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.np-label__hint {
  text-transform: none;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--hairline);
  font-size: 12px;
}

.np-input {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  margin-top: 8px;
  padding: 0 0 10px;
  border: 0;
  border-bottom: 1.5px solid var(--ink);
  border-radius: 0;
  background: transparent;
  font-family: var(--font-sans);
  font-size: 18px;
  font-weight: 500;
  color: var(--ink);
  outline: none;
}

/* category chips */
.np-chips {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.np-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--ink-2);
  border: 1px solid var(--hairline-2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.np-chip input { position: absolute; opacity: 0; pointer-events: none; }
.np-chip__swatch {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.np-chip:has(input:checked) {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

/* segmented unit picker */
.np-seg {
  margin-top: 10px;
  display: flex;
  gap: 6px;
}
.np-seg__opt {
  flex: 1;
  text-align: center;
  padding: 9px 0;
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink-2);
  border: 1px solid var(--hairline-2);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.np-seg__opt input { position: absolute; opacity: 0; pointer-events: none; }
.np-seg__opt:has(input:checked) {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

/* stepper */
.np-stepper {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border-radius: 14px;
  padding: 6px;
  border: 1px solid var(--hairline-2);
}
.np-stepper__btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  border: 0;
  background: var(--bg);
  color: var(--ink-2);
  font-size: 20px;
  font-weight: 500;
  cursor: pointer;
}
.np-stepper__btn--plus {
  background: var(--ink);
  color: var(--bg);
}
.np-stepper__value {
  flex: 1;
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
}
.np-stepper__value input {
  width: 56px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: right;
  font-family: var(--font-sans);
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  outline: none;
  letter-spacing: -0.02em;
  -moz-appearance: textfield;
}
.np-stepper__value input::-webkit-outer-spin-button,
.np-stepper__value input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.np-stepper__unit {
  color: var(--muted);
  font-weight: 500;
  font-size: 14px;
  min-width: 14px;
}

.np-cta-wrap {
  padding: 4px 16px 44px;
}
.np-cta { width: 100%; margin-top: 0; }
