/* ============================================================
   Aanbiedingen Radar — rustig beige/wit thema met olijfgroen accent
   ============================================================ */
:root {
  --beige-100: #f3eee4;
  --beige-200: #efe8da;
  --beige-300: #e4ddcf;

  --accent-700: #5f6d40;
  --accent-600: #7c8a5a;
  --accent-500: #8f9c6d;
  --accent-200: #d6ddc4;
  --accent-50:  #eef0e6;

  --bg:       var(--beige-100);
  --bg-soft:  var(--beige-200);
  --surface:  #ffffff;
  --ink:      #2c2a26;
  --ink-soft: #6f6a60;
  --line:     var(--beige-300);

  --ah:    #0088c2;
  --jumbo: #b8860b;
  --lidl:  #0050aa;

  --warn-bg:  #fdf1de;
  --warn:     #a05a1f;

  --grad-brand: linear-gradient(135deg, var(--accent-700) 0%, var(--accent-500) 100%);
  --shadow:    0 6px 20px rgba(44, 42, 38, 0.08);
  --shadow-sm: 0 2px 8px rgba(44, 42, 38, 0.06);
}

/* [hidden] heeft normaliter lagere prioriteit dan een class-regel met
   dezelfde specificiteit (bv. .grid { display: grid }) — deze expliciete
   override (ID + attribuut = hogere specificiteit) zorgt dat el.hidden = true
   in app.js altijd echt verbergt, ongeacht welke display-regel er verder geldt. */
#grid[hidden], .list-panel[hidden], #filters[hidden], .empty[hidden],
#loginForm[hidden], #registerForm[hidden], #authGate[hidden], #appMain[hidden],
.user-info[hidden], #accountPanel[hidden], #statsPanel[hidden] { display: none !important; }

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  /* clip (i.p.v. hidden) blokkeert ook programmatisch scrollen (bv. een
     browser-interne scrollIntoView) — anders kan de pagina alsnog opzij
     schuiven zonder dat er een scrollbar of overflow gemeten wordt. */
  overflow-x: clip;
}

/* ---------- Topbar ---------- */
.topbar { position: sticky; top: 0; z-index: 50; background: var(--surface); color: var(--ink); box-shadow: 0 2px 10px rgba(44, 42, 38, .06); }
.topbar-inner { max-width: 1200px; margin: 0 auto; padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.topbar-glow { height: 3px; background: var(--grad-brand); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { font-size: 28px; line-height: 1; }
.brand-name { display: block; font-weight: 700; font-size: 18px; letter-spacing: .2px; color: var(--ink); }
.brand-sub { display: block; font-size: 12px; color: var(--ink-soft); }
.updated { font-size: 12px; color: var(--ink-soft); }
.user-info { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }

/* ---------- Layout ---------- */
.container { max-width: 1200px; margin: 0 auto; padding: 24px; }

/* ---------- Login / registratie ---------- */
.auth-gate { display: flex; align-items: center; justify-content: center; min-height: calc(100vh - 74px); padding: 24px; }
.auth-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow); padding: 32px; width: 100%; max-width: 380px;
}
.auth-card h2 { margin: 0 0 8px; font-size: 20px; color: var(--ink); }
.auth-sub { margin: 0 0 20px; font-size: 13px; color: var(--ink-soft); line-height: 1.5; }
.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-form input {
  padding: 10px 14px; border: 1.5px solid var(--line); border-radius: 10px;
  font-size: 14px; background: var(--bg-soft); color: var(--ink);
}
.auth-form input:focus { outline: none; border-color: var(--accent-600); box-shadow: 0 0 0 3px var(--accent-50); background: var(--surface); }
.btn-primary {
  padding: 10px 16px; border: none; border-radius: 10px; background: var(--grad-brand);
  color: #fff; font-size: 14px; font-weight: 700; cursor: pointer; transition: opacity .15s;
}
.btn-primary:hover { opacity: .9; }
.auth-error { margin: 0; font-size: 12.5px; color: #c0553f; }
.auth-success { margin: 0; font-size: 12.5px; color: var(--accent-700); }
#authToggle, #browseGuest, #closeAccountPanel { display: block; width: 100%; text-align: center; margin-top: 14px; font-size: 12.5px; }
#accountPanel .auth-form { margin-bottom: 18px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.btn-danger {
  width: 100%; padding: 10px 16px; border: 1.5px solid #c0553f; border-radius: 10px;
  background: var(--surface); color: #c0553f; font-size: 14px; font-weight: 700; cursor: pointer;
  transition: all .15s;
}
.btn-danger:hover { background: rgba(192, 85, 63, .08); }

/* ---------- Statistieken ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.stat-tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-sm); padding: 18px; text-align: center;
}
.stat-tile .stat-value { font-size: 26px; font-weight: 800; color: var(--accent-700); display: block; }
.stat-tile .stat-label { font-size: 12.5px; color: var(--ink-soft); margin-top: 4px; }
.stat-note { font-size: 12px; color: var(--ink-soft); text-align: center; margin-top: 4px; }

/* ---------- Huishouden (boodschappenlijst delen) ---------- */
.household-box {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-sm); padding: 14px 16px; display: flex; flex-wrap: wrap;
  align-items: center; gap: 10px; justify-content: space-between;
}
.household-members { font-size: 13px; color: var(--ink-soft); }
.household-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.household-actions input {
  padding: 8px 12px; border: 1.5px solid var(--line); border-radius: 10px;
  font-size: 13px; background: var(--bg-soft); color: var(--ink); width: 110px;
}
.household-code { font-family: monospace; font-size: 16px; font-weight: 700; color: var(--accent-700); letter-spacing: 1px; }

/* ---------- Controls ---------- */
.controls { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
/* min-width:0 overschrijft de flex-item-default (min-width:auto = intrinsieke
   content-breedte) — anders kan .chips niet krimpen tot de beschikbare
   ruimte en groeit hij buiten .controls in plaats van intern te scrollen. */
.chips { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }
.chip {
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink-soft);
  padding: 8px 16px; border-radius: 999px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all .15s ease; white-space: nowrap;
}
.chip:hover { border-color: var(--accent-200); color: var(--accent-700); }
.chip.active { background: var(--grad-brand); color: #fff; border-color: transparent; box-shadow: var(--shadow-sm); }

.search { display: flex; gap: 8px; align-items: center; }
.search input {
  width: 280px; max-width: 60vw; padding: 9px 14px; border: 1.5px solid var(--line);
  border-radius: 10px; font-size: 14px; background: var(--surface); color: var(--ink);
}
.search input:focus { outline: none; border-color: var(--accent-600); box-shadow: 0 0 0 3px var(--accent-50); }
.btn-refresh {
  width: 38px; height: 38px; border: 1.5px solid var(--line); background: var(--surface);
  border-radius: 10px; font-size: 18px; cursor: pointer; color: var(--accent-700); transition: all .15s;
  flex-shrink: 0;
}
.btn-refresh:hover { border-color: var(--accent-600); background: var(--accent-50); }

/* ---------- Filters (categorie + AH online) ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 14px; }
.filters select {
  padding: 8px 12px; border: 1.5px solid var(--line); border-radius: 10px;
  font-size: 13px; background: var(--surface); color: var(--ink); cursor: pointer;
}
.filters select:focus { outline: none; border-color: var(--accent-600); box-shadow: 0 0 0 3px var(--accent-50); }
.chips-sm .chip { padding: 6px 12px; font-size: 12.5px; }

/* ---------- Status bar ---------- */
.status-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; min-height: 4px; }
.status-pill { font-size: 12px; padding: 4px 10px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px; }
.status-pill.ok { background: var(--accent-50); color: var(--accent-700); }
.status-pill.error { background: var(--warn-bg); color: var(--warn); }
.status-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.demo-banner { width: 100%; background: var(--bg-soft); color: var(--accent-700); border: 1px dashed var(--accent-200); border-radius: 8px; padding: 8px 12px; font-size: 13px; }

/* ---------- Grid + cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  overflow: hidden; box-shadow: var(--shadow-sm); display: flex; flex-direction: column;
  transition: transform .15s ease, box-shadow .15s ease; color: inherit; text-decoration: none;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.card-img { position: relative; height: 150px; background: var(--bg-soft); display: flex; align-items: center; justify-content: center; }
.card-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.card-img .noimg { font-size: 40px; opacity: .35; }
.store-badge { position: absolute; top: 8px; left: 8px; font-size: 11px; font-weight: 700; color: #fff; padding: 3px 9px; border-radius: 999px; }
.store-badge.ah { background: var(--ah); }
.store-badge.jumbo { background: var(--jumbo); }
.store-badge.lidl { background: var(--lidl); }
.discount-badge { position: absolute; top: 8px; right: 8px; background: var(--accent-600); color: #fff; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; box-shadow: var(--shadow-sm); }

.card-actions { position: absolute; bottom: 8px; right: 8px; z-index: 2; display: flex; gap: 6px; }
.fav-btn, .list-btn {
  width: 32px; height: 32px; border-radius: 50%; border: none;
  background: rgba(255, 255, 255, .92); color: var(--ink-soft);
  font-size: 16px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: var(--shadow-sm); transition: all .15s ease;
}
.fav-btn:hover { color: var(--accent-700); transform: scale(1.08); }
.fav-btn.active { color: #c0553f; }
.list-btn:hover { color: var(--accent-700); transform: scale(1.08); }
.list-btn.active { color: var(--accent-700); background: var(--accent-50); }

.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-title { font-weight: 600; font-size: 14px; line-height: 1.3; }
.card-desc { font-size: 12px; color: var(--ink-soft); }
.card-meta { margin-top: auto; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.price-now { font-size: 19px; font-weight: 800; color: var(--accent-700); }
.price-old { font-size: 13px; color: var(--ink-soft); text-decoration: line-through; }
.valid { font-size: 11px; color: var(--ink-soft); }
.online-tag { font-size: 10.5px; font-weight: 600; color: var(--ink-soft); background: var(--bg-soft); padding: 2px 8px; border-radius: 999px; display: inline-block; width: fit-content; }
.member-tag { color: var(--lidl); background: rgba(0, 80, 170, .08); }
.ending-soon-badge {
  position: absolute; top: 34px; left: 8px;
  background: var(--warn); color: #fff; font-size: 10.5px; font-weight: 700;
  padding: 3px 9px; border-radius: 999px; box-shadow: var(--shadow-sm);
}

/* ---------- Favorieten ---------- */
.price-lowest { font-size: 11px; color: var(--ink-soft); }
.price-drop {
  font-size: 11px; font-weight: 700; color: var(--accent-700); background: var(--accent-50);
  padding: 2px 8px; border-radius: 999px; display: inline-block; width: fit-content;
}
.sparkline-wrap { padding: 2px 0 4px; }
.sparkline { display: block; width: 100%; height: 32px; }

/* ---------- Boodschappenlijst ---------- */
.list-panel { display: flex; flex-direction: column; gap: 18px; }
.list-total {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-sm); padding: 14px 16px; display: flex; align-items: baseline;
  justify-content: space-between; font-size: 14px;
}
.list-total strong { font-size: 19px; color: var(--accent-700); }
.list-subtotal { font-size: 12px; color: var(--ink-soft); font-weight: 600; }
.list-item-price { font-size: 13px; font-weight: 700; color: var(--accent-700); flex-shrink: 0; white-space: nowrap; }
.list-item-price.unknown { font-size: 11px; font-weight: 500; color: var(--ink-soft); font-style: italic; }
.list-group {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.list-group-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
/* .store-badge is elders position:absolute (t.o.v. de kaart-afbeelding); hier
   staat hij inline in een gewone flex-header, dus die positionering uitzetten. */
.list-group-header .store-badge { position: static; }
.link-btn { border: none; background: none; color: var(--accent-700); font-size: 12.5px; font-weight: 600; cursor: pointer; padding: 4px 6px; }
.link-btn:hover { text-decoration: underline; }

.list-items { list-style: none; margin: 0; padding: 4px 0; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--bg-soft); }
.list-item:last-child { border-bottom: none; }
.list-item.checked .list-item-name { text-decoration: line-through; color: var(--ink-soft); }
.list-item-label { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; cursor: pointer; }
.list-item-label input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent-600); flex-shrink: 0; }
.list-item-name { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item-cat { font-size: 11px; color: var(--ink-soft); background: var(--bg-soft); padding: 2px 8px; border-radius: 999px; flex-shrink: 0; white-space: nowrap; }
.list-empty { padding: 16px; color: var(--ink-soft); font-size: 13px; text-align: center; }
.icon-btn {
  border: none; background: none; color: var(--ink-soft); font-size: 14px; cursor: pointer;
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  transition: all .15s ease;
}
.icon-btn:hover { color: #c0553f; background: var(--bg-soft); }

.list-add-form { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--bg-soft); flex-wrap: wrap; }
.list-add-form input[type="text"] {
  flex: 1; min-width: 120px; padding: 8px 12px; border: 1.5px solid var(--line); border-radius: 10px;
  font-size: 13px; background: var(--surface); color: var(--ink);
}
.list-add-form select {
  padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 10px; font-size: 13px;
  background: var(--surface); color: var(--ink); max-width: 40%;
}
.list-add-form input:focus, .list-add-form select:focus { outline: none; border-color: var(--accent-600); box-shadow: 0 0 0 3px var(--accent-50); }
.btn-add {
  width: 38px; height: 38px; border: none; border-radius: 10px; background: var(--grad-brand);
  color: #fff; font-size: 18px; font-weight: 700; cursor: pointer; flex-shrink: 0; transition: opacity .15s;
}
.btn-add:hover { opacity: .9; }

/* ---------- Empty / loading ---------- */
.empty { text-align: center; color: var(--ink-soft); padding: 60px 20px; }
.skeleton { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; height: 280px; overflow: hidden; position: relative; }
.skeleton::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(124,138,90,.08), transparent); animation: shimmer 1.3s infinite; }
@keyframes shimmer { 100% { transform: translateX(100%); } }

@media (prefers-reduced-motion: reduce) {
  .skeleton::after { animation: none; }
  .card, .fav-btn, .list-btn, .chip, .btn-refresh, .btn-add { transition: none; }
}

/* ---------- Footer ---------- */
.footer { max-width: 1200px; margin: 24px auto 40px; padding: 0 24px; }
.footer p { font-size: 12px; color: var(--ink-soft); border-top: 1px solid var(--line); padding-top: 16px; }

/* ---------- Mobiel ---------- */
@media (max-width: 640px) {
  .container { padding: 16px; }
  .topbar-inner { padding: 12px 16px; gap: 6px 16px; }
  .updated { order: 3; width: 100%; }

  .controls { flex-direction: column; align-items: stretch; gap: 12px; }
  /* width:100% i.p.v. op stretch/min-width vertrouwen: .chips is een flex-item
     in een column-flex-container en groeide anders naar zijn intrinsieke
     inhoudsbreedte in plaats van intern te scrollen binnen de beschikbare breedte. */
  .chips { flex-wrap: nowrap; overflow-x: auto; width: 100%; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
  .chips::-webkit-scrollbar { height: 0; }
  .chip { flex-shrink: 0; }

  .search { width: 100%; }
  .search input { width: 100%; max-width: none; flex: 1; }

  .filters { flex-direction: column; align-items: stretch; }
  .filters select { width: 100%; }
  .chips-sm { overflow-x: auto; flex-wrap: nowrap; }
  #endingSoonFilter { width: 100%; }

  .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .card-img { height: 110px; }
  .card-body { padding: 10px; }
  .card-title { font-size: 13px; }
  .price-now { font-size: 16px; }
  .fav-btn, .list-btn { width: 34px; height: 34px; font-size: 15px; } /* blijft goed tapbaar */

  .list-add-form { flex-direction: column; }
  .list-add-form select { max-width: none; width: 100%; }
  .list-item-cat { display: none; } /* te veel ruis op een smal scherm */
}

@media (max-width: 420px) {
  .grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .brand-name { font-size: 16px; }
  .brand-logo { font-size: 24px; }
}
