/* ShopEasy — shared components: buttons, cards, sheets, steppers, pills, tabs */

/* ---------- App layout ---------- */
#app { display: flex; flex-direction: column; min-height: 100vh; }

#screen {
  flex: 1;
  padding: var(--sp-4) var(--sp-4) calc(var(--tabbar-h) + var(--safe-bottom) + 88px);
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
}

/* ---------- Bottom tab bar ---------- */
#tabbar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 40;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: linear-gradient(rgba(6, 10, 15, 0.82), rgba(6, 10, 15, 0.92));
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  border-top: 1px solid var(--glass-border);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; min-height: var(--tap-min); color: var(--text-dim);
  font-size: 12px; font-weight: 600; position: relative; -webkit-tap-highlight-color: transparent;
}
.tab .tab-icon { font-size: 22px; line-height: 1; }
.tab.active { color: var(--accent); }
.tab.tab-raised .tab-icon {
  transform: translateY(-8px);
  background: var(--glass-strong); border: 1px solid var(--glass-border);
  border-radius: 50%; width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
}
.tab-badge {
  position: absolute; top: 4px; right: calc(50% - 22px);
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: var(--radius-pill); background: var(--red); color: #2a0505;
  font-size: 12px; font-weight: 800; line-height: 18px; text-align: center;
}
.tab-dot {
  position: absolute; top: 8px; right: calc(50% - 16px);
  width: 10px; height: 10px; border-radius: 50%; background: var(--red);
}
.tab-badge[hidden], .tab-dot[hidden] { display: none; }

/* ---------- Buttons ---------- */
button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: var(--sp-2);
  width: 100%; min-height: var(--tap-min);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius); border: 1px solid var(--glass-border);
  background: var(--glass-strong); color: var(--text);
  font-size: var(--fs-base); font-weight: 650; cursor: pointer;
  margin-bottom: var(--gap-tap);
}
.btn:active { transform: scale(0.985); }
.btn-primary {
  min-height: var(--btn-primary-h);
  background: var(--accent); border-color: var(--accent);
  color: var(--accent-text); font-weight: 750;
}
.btn-primary:active { background: var(--accent-press); }
.btn-danger { background: var(--red-bg); border-color: var(--red); color: var(--red); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn:disabled { opacity: 0.45; pointer-events: none; }

/* Bottom-anchored primary action zone (thumb zone) */
.action-zone {
  position: fixed; inset-inline: 0; bottom: calc(var(--tabbar-h) + var(--safe-bottom));
  padding: var(--sp-3) var(--sp-4);
  max-width: 480px; margin: 0 auto; z-index: 30;
  background: linear-gradient(transparent, rgba(6, 10, 15, 0.85) 40%);
}
.action-zone .btn:last-child { margin-bottom: 0; }
.wizard-open .action-zone { bottom: 0; }

/* ---------- Cards ---------- */
.card {
  background: linear-gradient(var(--overlay), var(--overlay)), var(--glass);
  border: 1px solid var(--glass-border); border-radius: var(--radius);
  -webkit-backdrop-filter: blur(var(--glass-blur)); backdrop-filter: blur(var(--glass-blur));
  padding: var(--sp-4); margin-bottom: var(--sp-3);
}
.card-tap { cursor: pointer; }
.card-tap:active { background: var(--glass-strong); }
.card h2 { margin-bottom: var(--sp-2); }
.card-row { display: flex; align-items: center; gap: var(--sp-3); }
.card-row .grow { flex: 1; min-width: 0; }

.warn-card { border-color: var(--red); background: linear-gradient(var(--overlay), var(--overlay)), var(--red-bg); }
.warn-card.amber { border-color: var(--amber); background: linear-gradient(var(--overlay), var(--overlay)), var(--amber-bg); }
.warn-card.green { border-color: var(--green); background: linear-gradient(var(--overlay), var(--overlay)), var(--green-bg); }
.warn-card .btn { margin: var(--sp-3) 0 0; }

/* ---------- Pills / chips ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: var(--radius-pill);
  font-size: 13px; font-weight: 700; line-height: 1.5;
}
.pill-green { background: var(--green-bg); color: var(--green); }
.pill-amber { background: var(--amber-bg); color: var(--amber); }
.pill-red   { background: var(--red-bg);   color: var(--red); }
.pill-dim   { background: var(--glass-strong); color: var(--text-dim); }

.chips { display: flex; gap: var(--sp-2); overflow-x: auto; padding-bottom: var(--sp-2); margin-bottom: var(--sp-3); }
.chip {
  flex: none; min-height: 40px; padding: 6px 14px;
  border-radius: var(--radius-pill); border: 1px solid var(--glass-border);
  background: var(--glass); color: var(--text-dim); font-size: var(--fs-small); font-weight: 600; cursor: pointer;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

/* ---------- Forms ---------- */
.field { margin-bottom: var(--sp-4); }
.field label { display: block; font-size: var(--fs-small); color: var(--text-dim); margin-bottom: var(--sp-2); font-weight: 600; }
.input, textarea.input, select.input {
  width: 100%; min-height: var(--tap-min);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-sm); border: 1px solid var(--glass-border);
  background: rgba(0, 0, 0, 0.35); color: var(--text);
  font-size: var(--fs-base);
}
.input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
textarea.input { min-height: 96px; resize: vertical; }
.field-error { color: var(--red); font-size: var(--fs-small); margin-top: var(--sp-1); }
.input-money { display: flex; align-items: center; gap: var(--sp-2); }
.input-money .cur { color: var(--text-dim); font-weight: 700; }

/* Radio choice cards (wizards) */
.choice {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  width: 100%; text-align: start;
  padding: var(--sp-4); margin-bottom: var(--gap-tap);
  border-radius: var(--radius); border: 1px solid var(--glass-border);
  background: var(--glass); color: var(--text); cursor: pointer; min-height: var(--tap-min);
}
.choice.selected { border-color: var(--accent); background: rgba(45, 212, 191, 0.10); }
.choice .choice-dot {
  flex: none; width: 22px; height: 22px; margin-top: 2px;
  border-radius: 50%; border: 2px solid var(--text-faint);
}
.choice.selected .choice-dot { border-color: var(--accent); background: radial-gradient(circle at center, var(--accent) 0 45%, transparent 50%); }
.choice .choice-body { flex: 1; }
.choice .choice-title { font-weight: 700; }
.choice .choice-sub { color: var(--text-dim); font-size: var(--fs-small); }

/* ---------- Stepper (− qty +) ---------- */
.stepper { display: flex; align-items: center; gap: var(--sp-3); }
.stepper button {
  width: var(--tap-min); height: var(--tap-min); flex: none;
  border-radius: var(--radius-sm); border: 1px solid var(--glass-border);
  background: var(--glass-strong); color: var(--text); font-size: 24px; font-weight: 800; cursor: pointer;
}
.stepper .stepper-value {
  flex: 1; text-align: center; font-size: var(--fs-big-number); font-weight: 750;
  font-variant-numeric: tabular-nums; background: transparent; border: none; color: var(--text);
  min-width: 0; width: 100%;
}

/* ---------- Wizard chrome ---------- */
#wizard-layer { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; background: var(--bg); }
#wizard-layer[hidden] { display: none; }
.wizard-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-4); gap: var(--sp-3);
}
.wizard-dots { display: flex; gap: 6px; }
.wizard-dots span { width: 9px; height: 9px; border-radius: 50%; background: var(--text-faint); }
.wizard-dots span.done { background: var(--accent); opacity: 0.5; }
.wizard-dots span.now { background: var(--accent); }
.wizard-x {
  width: var(--tap-min); height: var(--tap-min);
  border-radius: 50%; border: 1px solid var(--glass-border); background: var(--glass);
  color: var(--text-dim); font-size: 20px; cursor: pointer;
}
.wizard-body { flex: 1; overflow-y: auto; padding: 0 var(--sp-4) 140px; max-width: 480px; width: 100%; margin: 0 auto; }
.wizard-foot {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 61;
  padding: var(--sp-3) var(--sp-4) calc(var(--sp-3) + var(--safe-bottom));
  max-width: 480px; margin: 0 auto;
  background: linear-gradient(transparent, rgba(6, 10, 15, 0.9) 35%);
  display: flex; gap: var(--sp-2);
}
.wizard-foot .btn { margin-bottom: 0; }
.wizard-foot .btn-back { width: auto; flex: none; padding-inline: var(--sp-5); }

/* ---------- Sheets, toasts, confirm ---------- */
#sheet-layer { position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, 0.6); display: flex; align-items: flex-end; }
#sheet-layer[hidden] { display: none; }
.sheet {
  width: 100%; max-width: 480px; margin: 0 auto;
  background: #121a24; border-radius: var(--radius) var(--radius) 0 0;
  border: 1px solid var(--glass-border); border-bottom: none;
  padding: var(--sp-5) var(--sp-4) calc(var(--sp-5) + var(--safe-bottom));
}
.sheet h2 { margin-bottom: var(--sp-4); }

#toast-zone {
  position: fixed; inset-inline: 0; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 12px);
  z-index: 80; display: flex; flex-direction: column; align-items: center; gap: var(--sp-2);
  pointer-events: none; padding: 0 var(--sp-4);
}
.toast {
  background: #1b2632; border: 1px solid var(--glass-border); border-radius: var(--radius);
  padding: var(--sp-3) var(--sp-4); font-size: var(--fs-small); font-weight: 600;
  max-width: 440px; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}
.toast-err { border-color: var(--red); }

/* ---------- Lists / misc ---------- */
.empty-state { text-align: center; padding: var(--sp-6) var(--sp-4); color: var(--text-dim); }
.empty-state .empty-icon { font-size: 44px; margin-bottom: var(--sp-3); }

.divider { border: none; border-top: 1px solid var(--glass-border); margin: var(--sp-3) 0; }

.list-line { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-3); padding: var(--sp-2) 0; }
.list-line .amount { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }

.thumb {
  width: 64px; height: 64px; flex: none; border-radius: var(--radius-sm);
  object-fit: cover; background: var(--glass-strong); border: 1px solid var(--glass-border);
  display: flex; align-items: center; justify-content: center; font-size: 26px; overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }

.freshness { text-align: center; color: var(--text-faint); font-size: 13px; margin: var(--sp-2) 0; }

.offline-pill {
  position: fixed; top: var(--sp-3); inset-inline: 0; margin: 0 auto; width: fit-content; z-index: 90;
  background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber);
  border-radius: var(--radius-pill); padding: 4px 14px; font-size: 13px; font-weight: 700;
}
.offline-pill[hidden] { display: none; }

/* Screen-reader only */
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  clip: rect(0 0 0 0); overflow: hidden; white-space: nowrap;
}
