/* ==========================================================================
   NXTPantry – Stylesheet
   Hell & freundlich: cremeweiß, frisches Grün, Koralle als Akzent
   ========================================================================== */

:root {
  --bg:        #FFFCF7;
  --surface:   #FFFFFF;
  --surface-2: #FBF6EC;
  --primary:   #2FA46B;
  --primary-d: #1F7A4D;
  --primary-l: #E5F4EC;
  --accent:    #FF7A59;
  --accent-d:  #E85F3D;
  --text:      #2B2B2B;
  --muted:     #6B7280;
  --border:    #ECE7DC;
  --danger:    #D64545;
  --danger-l:  #FBEAEA;
  --warn:      #C98A1C;
  --warn-l:    #FBF1DC;
  --radius:    16px;
  --radius-sm: 10px;
  --shadow:    0 2px 8px rgba(60, 50, 30, 0.06);
  --shadow-md: 0 8px 24px rgba(60, 50, 30, 0.10);
  --maxw:      960px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Nunito Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display {
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
  margin: 0 0 .5em;
}
h1 { font-size: 1.7rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }

a { color: var(--primary-d); }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.hidden { display: none !important; }

/* ---- Layout ------------------------------------------------------------- */
.app-header {
  position: sticky; top: 0; z-index: 40;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.app-header .bar {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
}
.brand {
  display: flex; align-items: center; gap: 8px;
  font-family: 'Baloo 2', sans-serif; font-weight: 800;
  font-size: 1.25rem; color: var(--primary-d); text-decoration: none;
}
.brand .logo { font-size: 1.5rem; }
.nav-desktop { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.nav-desktop a {
  text-decoration: none; color: var(--text); padding: 8px 14px;
  border-radius: var(--radius-sm); font-weight: 600; font-size: .95rem;
}
.nav-desktop a:hover { background: var(--surface-2); }
.nav-desktop a.active { background: var(--primary-l); color: var(--primary-d); }

main {
  max-width: var(--maxw); margin: 0 auto;
  padding: 20px 16px 96px; /* unten Platz für Bottom-Nav */
}

/* ---- Karten ------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.card-pad-sm { padding: 14px 16px; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 640px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr 1fr; }
}

/* ---- Statistik-Kacheln -------------------------------------------------- */
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; text-align: center;
  box-shadow: var(--shadow);
}
.stat .num { font-family: 'Baloo 2', sans-serif; font-size: 2rem; font-weight: 800; color: var(--primary-d); line-height: 1; }
.stat .lbl { color: var(--muted); font-size: .85rem; margin-top: 4px; }

/* ---- Buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: 'Nunito Sans', sans-serif; font-weight: 700; font-size: .95rem;
  padding: 10px 18px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
  transition: transform .04s ease, background .15s ease, box-shadow .15s ease;
  line-height: 1.2;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); color: #fff; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-d); color: #fff; }
.btn-ghost { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: #F3ECDD; }
.btn-danger { background: var(--danger-l); color: var(--danger); }
.btn-danger:hover { background: #f6dada; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: .85rem; }
.btn-icon { padding: 8px 11px; }

/* ---- Formulare ---------------------------------------------------------- */
label { display: block; font-weight: 700; font-size: .9rem; margin: 0 0 6px; }
.field { margin-bottom: 16px; }
input[type=text], input[type=email], input[type=password],
input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 11px 14px; font-size: 1rem; font-family: inherit;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-l);
}
textarea { resize: vertical; min-height: 70px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
@media (max-width: 520px) { .row { flex-direction: column; gap: 0; } }

/* ---- Flash-Meldungen ---------------------------------------------------- */
.flash { border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 14px; font-weight: 600; font-size: .92rem; border: 1px solid; }
.flash-success { background: var(--primary-l); color: var(--primary-d); border-color: #BFE3CD; }
.flash-error   { background: var(--danger-l); color: var(--danger); border-color: #F0CACA; }
.flash-warn    { background: var(--warn-l); color: var(--warn); border-color: #ECD8AC; }

/* ---- Listen / Bestand --------------------------------------------------- */
.item {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.item .info { flex: 1; min-width: 0; }
.item .name { font-weight: 700; }
.item .meta { color: var(--muted); font-size: .85rem; }
.item .menge {
  font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 1.05rem;
  min-width: 64px; text-align: right; color: var(--primary-d);
}
.item.leer .menge { color: var(--danger); }

.qty-ctrl { display: inline-flex; align-items: center; gap: 6px; }
.qty-ctrl button {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface-2); font-size: 1.2rem; font-weight: 700; cursor: pointer;
  color: var(--text); line-height: 1; display: inline-flex; align-items: center; justify-content: center;
}
.qty-ctrl button.plus { background: var(--primary); color: #fff; border-color: var(--primary); }
.qty-ctrl button:active { transform: scale(.94); }

.badge {
  display: inline-block; font-size: .75rem; font-weight: 700;
  padding: 2px 9px; border-radius: 999px; background: var(--surface-2);
  color: var(--muted); border: 1px solid var(--border);
}
.badge-lager { background: var(--primary-l); color: var(--primary-d); border-color: #cfe9da; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
  text-decoration: none; font-weight: 600; font-size: .85rem;
  padding: 7px 14px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
}
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---- Checkbox-Liste (Einkaufsliste) ------------------------------------- */
.check-item { display: flex; align-items: center; gap: 12px; }
.check-item.done .name { text-decoration: line-through; color: var(--muted); }
.check-box {
  width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--primary);
  background: var(--surface); cursor: pointer; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1rem; color: #fff;
}
.check-item.done .check-box { background: var(--primary); }

/* ---- Empty States ------------------------------------------------------- */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .em-ico { font-size: 3rem; display: block; margin-bottom: 8px; }

/* ---- Bottom Navigation (mobil) ----------------------------------------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: none; background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -2px 12px rgba(60,50,30,.06);
}
.bottom-nav a {
  flex: 1; text-decoration: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: .68rem; font-weight: 700; padding: 4px 0;
}
.bottom-nav a .ico { font-size: 1.35rem; line-height: 1; }
.bottom-nav a.active { color: var(--primary-d); }

@media (max-width: 760px) {
  .nav-desktop { display: none; }
  .bottom-nav { display: flex; }
}

/* ---- Auth-Seiten -------------------------------------------------------- */
.auth-wrap { max-width: 420px; margin: 6vh auto 0; padding: 0 16px; }
.auth-logo { text-align: center; font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 2rem; color: var(--primary-d); margin-bottom: 4px; }
.auth-sub { text-align: center; color: var(--muted); margin-bottom: 24px; }

/* ---- Welcome / Hero ----------------------------------------------------- */
.hero { text-align: center; padding: 8vh 16px 4vh; }
.hero .big { font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: clamp(2rem, 7vw, 3.2rem); color: var(--primary-d); margin-bottom: 12px; }
.hero p { font-size: 1.1rem; color: var(--muted); max-width: 520px; margin: 0 auto 28px; }
.feature-row { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; margin-top: 32px; }
.feature { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; width: 220px; box-shadow: var(--shadow); }
.feature .fi { font-size: 2rem; }

footer.legal { text-align: center; color: var(--muted); font-size: .8rem; padding: 24px 16px 8px; }
footer.legal a { color: var(--muted); margin: 0 6px; }

.list-reset { list-style: none; padding: 0; margin: 0; }
hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.flex-wrap { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---- Details/Dropdown-Politur ------------------------------------------ */
details > summary { cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
details > summary::marker { content: ""; }
.item-actions > summary { user-select: none; }

/* ==========================================================================
   v1.1 – Barcode-Scanner & Produktvorschau
   ========================================================================== */
.scan-modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(20, 16, 10, .82);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.scan-modal.hidden { display: none; }
.scan-modal-inner {
  background: var(--surface); border-radius: var(--radius);
  width: 100%; max-width: 440px; padding: 16px;
  box-shadow: var(--shadow-md);
}
.scan-modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.scan-video-wrap {
  position: relative; width: 100%; aspect-ratio: 4 / 3;
  background: #000; border-radius: var(--radius-sm); overflow: hidden;
}
#scan-video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-reticle {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 78%; height: 38%;
  border: 3px solid var(--accent); border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.18);
  pointer-events: none;
}
.scan-status { text-align: center; margin: 12px 0 4px; min-height: 1.2em; }
.scan-status.err { color: var(--danger); }
.scan-status.ok { color: var(--primary-d); font-weight: 700; }

.scan-preview {
  display: flex; align-items: center; gap: 12px;
  background: var(--primary-l); border: 1px solid #cfe9da;
  border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 16px;
}
.scan-preview.hidden { display: none; }
.scan-preview img {
  width: 56px; height: 56px; object-fit: contain;
  background: #fff; border-radius: 8px; flex-shrink: 0;
}
.scan-preview-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
