/* MealieShopper Fresh: component styles. Class names are the app's own (static/styles.css), so a rule here maps one to one
   onto the codebase. Every colour, radius, size and font comes from tokens.css; only motion lives here. Load tokens.css first. */

:root {
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

html { color-scheme: light; }
[data-theme="dark"], [data-theme="graphite"] { color-scheme: dark; }

body {
  margin: 0;
  background: var(--bg) radial-gradient(900px 320px at 50% -160px, var(--page-glow), transparent 72%) no-repeat;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* { box-sizing: border-box; }

h1, h2, h3 {
  margin: 0;
  font-family: var(--font-heading);
  letter-spacing: -0.015em;
  text-wrap: balance;
}

h2 { font-size: 20px; font-weight: 800; line-height: 1.25; letter-spacing: -0.02em; }
h3 { font-size: 18px; font-weight: 700; line-height: 1.35; }
p { margin: 0; }

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

.muted { color: var(--muted); font-size: 14px; }

:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

.mdi, .icon { width: 20px; height: 20px; flex: none; fill: currentColor; }

/* ---------- Button, IconButton */
.button,
.icon-button,
.tab,
.subtab {
  border: 0;
  border-radius: var(--radius-control);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease), border-color 0.15s var(--ease),
    box-shadow 0.2s var(--ease), transform 0.12s var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--control-height);
  padding: 0 18px;
  background: var(--primary);
  color: var(--on-primary);
  box-shadow: var(--btn-shadow);
  text-decoration: none;
}

.button:hover {
  background: var(--primary-strong);
  box-shadow: var(--btn-shadow-hover);
}

.button:active:not(:disabled),
.icon-button:active:not(:disabled) {
  transform: translateY(1px) scale(0.98);
  box-shadow: none;
}

.button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  box-shadow: none;
}

.button--secondary,
.icon-button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}

.button--secondary:hover,
.icon-button:hover {
  border-color: var(--border-strong);
  background: var(--selection);
  color: var(--primary-strong);
  box-shadow: var(--shadow-sm);
}

.button--danger {
  border: 1px solid var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger);
  box-shadow: none;
}

.button--danger:hover {
  border-color: var(--danger);
  background: var(--danger-bg);
  color: var(--danger);
  box-shadow: none;
}

.button .mdi { width: 20px; height: 20px; }

.icon-button {
  width: var(--control-height);
  padding: 0;
  line-height: 1;
}

.icon-button .mdi { width: 24px; height: 24px; }

/* ---------- Field: label, input, textarea */
.field { display: grid; gap: 6px; }
.field > span { font-size: 14px; font-weight: 600; }

.input,
.textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  box-shadow: inset 0 1px 2px rgba(15, 35, 24, 0.04);
  transition: border-color 0.15s var(--ease), box-shadow 0.2s var(--ease);
}

.input::placeholder,
.textarea::placeholder { color: var(--placeholder); opacity: 1; }

.input:hover:not(:focus-visible),
.textarea:hover:not(:focus-visible) { border-color: var(--border-strong); }

.input:focus-visible,
.textarea:focus-visible {
  border-color: var(--primary);
  outline: 0;
  box-shadow: 0 0 0 5px var(--ring);
}

.input { min-height: var(--control-height); padding: 0 12px; }
.textarea { padding: 10px 12px; resize: vertical; }

/* ---------- Switch: a real checkbox with role="switch" */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }

.switch {
  position: relative;
  flex: none;
  width: 52px;
  height: 32px;
  margin: 6px 0;
  border: 2px solid var(--placeholder);
  border-radius: var(--radius-pill);
  background: var(--surface-muted);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease);
}

.switch::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--muted);
  transform: translateY(-50%);
  transition: transform 150ms var(--ease), background-color 150ms var(--ease);
}

.switch:checked { border-color: var(--primary); background: var(--primary); }
.switch:checked::before { background: var(--on-primary); transform: translate(20px, -50%); }

/* ---------- Quantity */
.qty { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.qty__note { flex: 1; color: var(--muted); font-size: 13px; }

.qty__step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--control-height-sm);
  height: var(--control-height-sm);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}

.qty__step:hover { background: var(--selection); color: var(--primary-strong); }
.qty__step svg { width: 20px; height: 20px; fill: currentColor; }

.qty__input {
  width: 52px;
  height: var(--control-height-sm);
  padding: 0 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ---------- Tabs and subtabs */
.tabs, .subtabs { display: flex; flex-wrap: wrap; gap: 4px; }

.tab,
.subtab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: var(--control-height);
  padding: 0 16px;
  background: transparent;
  color: var(--muted);
  text-decoration: none;
}

.tab:hover:not(.is-active),
.subtab:hover:not(.is-active) { background: var(--selection); color: var(--primary-strong); }

.tab.is-active {
  background: var(--selection);
  color: var(--primary-strong);
  box-shadow: inset 0 0 0 1px var(--selection-border);
}

.tab.is-active > svg { color: var(--primary); }

.subtabs {
  width: fit-content;
  padding: 4px;
  border-radius: calc(var(--radius-control) + 4px);
  background: var(--surface-muted);
}

.subtab { min-height: 36px; padding: 0 14px; }

.subtab.is-active {
  background: var(--surface);
  color: var(--primary-strong);
  box-shadow: 0 1px 2px rgba(15, 35, 24, 0.12), 0 0 0 1px var(--border);
}

/* ---------- Segment control */
.segment-control {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  overflow: hidden;
  background: var(--surface);
}

.segment-control__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: var(--control-height-sm);
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.segment-control__button + .segment-control__button { border-left: 1px solid var(--border); }
.segment-control__button svg { width: 20px; height: 20px; fill: currentColor; }
.segment-control__button:hover { color: var(--text); }
.segment-control__button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }

/* ---------- Tab bar (phone, installed app) */
.tabbar {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 2px;
  padding: 6px;
  border: 1px solid var(--tabbar-border);
  border-radius: 32px;
  background: var(--tabbar-solid);
  box-shadow: var(--shadow-md), inset 0 1px 0 var(--tabbar-border);
}

.tabbar__tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  min-height: 56px;
  padding: 6px 1px;
  border: 0;
  border-radius: 26px;
  background: transparent;
  color: var(--tabbar-ink);
  font: inherit;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.1;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.tabbar__tab svg { width: 24px; height: 24px; fill: currentColor; }
.tabbar__tab.is-active { background: var(--tabbar-tint); color: var(--tabbar-ink-active); }
.tabbar__tab:active { transform: scale(0.95); }

/* ---------- Top bar */
.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--topbar-glass);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  backdrop-filter: saturate(180%) blur(18px);
  box-shadow: 0 1px 0 rgba(15, 35, 24, 0.02), 0 6px 20px rgba(15, 35, 24, 0.04);
}

.topbar__inner {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: var(--shell-max);
  min-height: var(--topbar-height);
  margin: 0 auto;
  padding: 8px 16px;
}

.brand-link { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; border-radius: 8px; }
.brand-mark { width: 40px; height: 40px; flex: none; }
.wordmark { font-family: var(--font-heading); font-size: 21px; font-weight: 800; line-height: 1.1; letter-spacing: -0.025em; }
.wordmark span { color: var(--primary); }

.beta-badge {
  padding: 1px 8px;
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-pill);
  background: var(--warning-bg);
  color: var(--warning-text);
  font-size: 12px;
  font-weight: 700;
}

/* ---------- Badge and tag */
.badge {
  --badge: var(--muted);
  --badge-ink: var(--badge);
  display: inline-block;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--badge) 12%, var(--surface));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--badge) 45%, var(--surface));
  color: var(--badge-ink);
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
}

.badge--status-delivered { --badge: var(--primary); --badge-ink: var(--primary-strong); }
.badge--status-planned { --badge: var(--info); }
.badge--status-imported { --badge: var(--muted); }
.badge--status-receipt { --badge: var(--lemon); --badge-ink: var(--warning-text); }
.badge--saved { --badge: var(--warning-text); background: transparent; }

/* A sticker, not a status: solid tomato with dark ink. */
.badge--bonus {
  background: var(--tomato);
  box-shadow: none;
  color: var(--on-tomato);
}

.badge--before { --badge: var(--muted); background: var(--surface-muted); box-shadow: none; }

.tags { display: flex; flex-wrap: wrap; gap: 5px; }

.tag {
  border-radius: var(--radius-pill);
  background: var(--selection);
  box-shadow: inset 0 0 0 1px var(--selection-border);
  color: var(--primary-strong);
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
}

/* ---------- Offer sticker */
.offer-badge {
  display: inline-block;
  border-radius: var(--radius-sm);
  padding: 3px 7px;
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.offer-badge--50 { background: var(--offer-50); color: var(--on-offer-50); }
.offer-badge--35 { background: var(--offer-35); color: var(--on-offer-35); }
.offer-badge--20 { background: var(--offer-20); color: var(--on-offer-20); }
.offer-badge--10 { background: var(--offer-10); color: var(--on-offer-10); }
.offer-badge--1 { background: var(--offer-1); color: var(--on-offer-1); }
.offer-badge--0 { background: var(--offer-0); color: var(--on-offer-0); box-shadow: inset 0 0 0 1px var(--offer-0-border); }
.offer-badge--store { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 2px currentColor; }
.offer-badge--inline { padding: 2px 6px; font-size: 12px; box-shadow: none; vertical-align: middle; }
.offer-badge--inline.offer-badge--store { box-shadow: inset 0 0 0 2px currentColor; }

/* ---------- Message */
.message {
  margin: 0;
  padding: 12px 16px 12px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  font-size: 15px;
}

.message.success {
  border-color: var(--success-border);
  background: var(--success-bg);
  color: var(--success-text);
  box-shadow: inset 4px 0 0 var(--primary);
}

.message.error {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger);
  box-shadow: inset 4px 0 0 var(--danger);
}

.message.warning {
  border-color: var(--warning-border);
  background: var(--warning-bg);
  color: var(--warning-text);
  box-shadow: inset 4px 0 0 var(--warning-border);
}

.message code { padding: 0 4px; border-radius: var(--radius-xs); background: var(--code-on-message); }

.message--action {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
}

/* ---------- Box */
.box {
  max-width: var(--box-max);
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.box--wide { max-width: none; }
.box > h2 + .muted { margin-top: 6px; }
.box > .muted + form, .box > .muted + .form-row { margin-top: 16px; }
.box .muted + .button { margin-top: 14px; }

/* ---------- Product card */
.product-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  color: inherit;
  text-decoration: none;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.15s var(--ease), background-color 0.15s var(--ease), box-shadow 0.2s var(--ease), transform 0.2s var(--ease);
}

a.product-card:hover {
  border-color: var(--primary);
  background: var(--selection);
  box-shadow: var(--shadow-sm);
}

.product-card__photo {
  position: relative;
  flex: none;
}

.product-card img,
.product-card__img {
  display: block;
  width: var(--thumb);
  height: var(--thumb);
  flex: none;
  border-radius: var(--radius-sm);
  object-fit: contain;
  background: #ffffff;
  outline: 1px solid rgba(15, 35, 24, 0.08);
  outline-offset: -1px;
}

.product-card__photo .offer-badge { position: absolute; top: -6px; left: -6px; }
a.product-card strong { color: var(--primary); }
.product-card strong { display: block; font-weight: 600; }
.product-card small { display: block; margin-top: 3px; color: var(--muted); font-size: 13px; }

.product-card__price {
  margin-top: 4px;
  color: var(--text);
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.product-card__price s { margin-left: 6px; color: var(--muted); font-family: var(--font-body); font-size: 13px; font-weight: 400; }
.product-card__badges { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 4px; }

.product-card[class*="cat--"] { border-color: var(--cat-line); background: var(--cat-bg); }
/* On a category tint basil drops under 4.5:1 in light: names take the stronger basil. */
.product-card[class*="cat--"] strong { color: var(--primary-strong); }

/* ---------- Category colours */
.cat--groente_fruit { --cat-bg: var(--cat-groente_fruit-bg); --cat-line: var(--cat-groente_fruit-line); }
.cat--vlees { --cat-bg: var(--cat-vlees-bg); --cat-line: var(--cat-vlees-line); }
.cat--vis { --cat-bg: var(--cat-vis-bg); --cat-line: var(--cat-vis-line); }
.cat--kaas_vleeswaren { --cat-bg: var(--cat-kaas_vleeswaren-bg); --cat-line: var(--cat-kaas_vleeswaren-line); }
.cat--zuivel_eieren { --cat-bg: var(--cat-zuivel_eieren-bg); --cat-line: var(--cat-zuivel_eieren-line); }
.cat--brood_bakkerij { --cat-bg: var(--cat-brood_bakkerij-bg); --cat-line: var(--cat-brood_bakkerij-line); }
.cat--maaltijden { --cat-bg: var(--cat-maaltijden-bg); --cat-line: var(--cat-maaltijden-line); }
.cat--sauzen_conserven { --cat-bg: var(--cat-sauzen_conserven-bg); --cat-line: var(--cat-sauzen_conserven-line); }
.cat--ontbijt_beleg { --cat-bg: var(--cat-ontbijt_beleg-bg); --cat-line: var(--cat-ontbijt_beleg-line); }
.cat--snacks_snoep { --cat-bg: var(--cat-snacks_snoep-bg); --cat-line: var(--cat-snacks_snoep-line); }
.cat--frisdrank { --cat-bg: var(--cat-frisdrank-bg); --cat-line: var(--cat-frisdrank-line); }
.cat--koffie_thee { --cat-bg: var(--cat-koffie_thee-bg); --cat-line: var(--cat-koffie_thee-line); }
.cat--bier_wijn { --cat-bg: var(--cat-bier_wijn-bg); --cat-line: var(--cat-bier_wijn-line); }
.cat--diepvries { --cat-bg: var(--cat-diepvries-bg); --cat-line: var(--cat-diepvries-line); }
.cat--huishouden { --cat-bg: var(--cat-huishouden-bg); --cat-line: var(--cat-huishouden-line); }
.cat--drogisterie { --cat-bg: var(--cat-drogisterie-bg); --cat-line: var(--cat-drogisterie-line); }
.cat--baby { --cat-bg: var(--cat-baby-bg); --cat-line: var(--cat-baby-line); }
.cat--huisdier { --cat-bg: var(--cat-huisdier-bg); --cat-line: var(--cat-huisdier-line); }
.cat--overig { --cat-bg: var(--cat-overig-bg); --cat-line: var(--cat-overig-line); }

.cat-section {
  overflow: hidden;
  border: 1px solid var(--cat-line, var(--border));
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.cat-section__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--cat-line, var(--border));
  background: var(--cat-bg);
}

.cat-section__title { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: 15px; }
.cat-section__title::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--cat-line); }
.cat-section__count { color: var(--muted); font-size: 13px; }
.cat-section__amount { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }

.cat-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 72px;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

.cat-line:first-child { border-top: 0; }
.cat-line__name { color: var(--primary); font-weight: 600; }
.cat-line__qty { color: var(--muted); }
.cat-line__amount { font-weight: 600; text-align: right; }

/* Filter chip of the offers and the order page, with the category dot. */
.offer-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease), border-color 0.15s var(--ease), box-shadow 0.2s var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.offer-chip:hover:not(.is-active) { border-color: var(--border-strong); background: var(--selection); color: var(--primary-strong); }

.offer-chip.is-active {
  border-color: var(--primary);
  background: var(--primary);
  box-shadow: var(--btn-shadow);
  color: var(--on-primary);
}

.offer-chip__dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--cat-line, var(--border-strong)); }
.offer-chip.is-active .offer-chip__dot { box-shadow: 0 0 0 2px var(--on-primary); }

/* ---------- Avatar */
.avatar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: var(--avatar);
  height: var(--avatar);
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--primary);
  color: var(--on-primary);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar--lg { width: var(--avatar-lg); height: var(--avatar-lg); font-size: 16px; }
.avatar--xl { width: var(--avatar-xl); height: var(--avatar-xl); font-family: var(--font-heading); font-size: 32px; font-weight: 800; }
.avatar--lemon { background: var(--lemon); color: var(--on-lemon); }
.avatar--tomato { background: var(--tomato); color: var(--on-tomato); }

@media (prefers-reduced-motion: reduce) {
  *, *::before { transition: none !important; }
}
