/* חסכת — עיצוב אפליקציה: סרגל עליון דביק, בונה-רשימה עם שורות וצ'יפים,
   כפתור פעולה צף, כרטיס תשובה בגרדיאנט אמרלד. Heebo, נייבי עמוק, נקי. */

:root {
  --bg: #f6f9fb;
  --card: #ffffff;
  --ink: #0b2239;
  --muted: #5b6b7b;
  --line: #e6ecf2;
  --green: #0c8a5f;
  --green-deep: #067153;
  --grad: linear-gradient(135deg, #067153 0%, #0ea371 55%, #13b98d 100%);
  --grad-hero: linear-gradient(135deg, #05543e 0%, #0c8a5f 45%, #0fb583 100%);
  --red: #c0392b;
  --red-soft: #fdeeea;
  --shadow-card: 0 1px 2px rgba(11, 34, 57, 0.05), 0 16px 40px -24px rgba(11, 34, 57, 0.35);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 70px; }

body {
  font-family: 'Heebo', sans-serif;
  background: var(--bg);
  background-image: radial-gradient(900px 420px at 85% -80px, rgba(14, 163, 113, 0.09), transparent 70%);
  background-repeat: no-repeat;
  color: var(--ink);
  line-height: 1.55;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  /* מקום לכפתור הצף למטה */
  padding-bottom: 84px;
}

main {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 0 18px 24px;
  flex: 1;
}

/* ---------- סרגל עליון (אפ-בר) ---------- */

.appbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.appbar-in {
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--green); }
.brand-ic { width: 23px; height: 23px; flex: none; }
.brand-name { font-weight: 900; font-size: 1.25rem; color: var(--ink); letter-spacing: -0.02em; }

.city-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 6px 12px;
  color: var(--muted);
}
.city-pill svg { width: 15px; height: 15px; flex: none; }
.city-pill select {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--ink);
  outline: none;
  cursor: pointer;
  max-width: 130px;
}

/* ---------- הירו ---------- */

.hero { padding: 30px 0 18px; }

.hero h1 {
  font-weight: 900;
  font-size: clamp(1.9rem, 7vw, 2.7rem);
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.hero h1 em { font-style: normal; color: var(--green); }

.hero-sub {
  margin-top: 8px;
  font-size: 1rem;
  color: var(--muted);
  max-width: 48ch;
}

/* ---------- בונה הרשימה ---------- */

.builder {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.add-row {
  display: flex;
  gap: 10px;
  padding: 14px 14px 10px;
}

.add-wrap { position: relative; flex: 1; display: flex; }
.add-wrap input { width: 100%; }

.suggest {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  z-index: 60;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 18px 44px -18px rgba(11, 34, 57, 0.4);
  overflow: hidden;
  max-height: 330px;
  overflow-y: auto;
}

.sg {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 0.92rem;
  color: var(--ink);
  text-align: start;
  padding: 9px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f0f4f8;
}
.sg:last-child { border-bottom: 0; }
.sg:hover { background: rgba(14, 163, 113, 0.06); }
.sg span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg small { color: var(--muted); font-size: 0.75rem; white-space: nowrap; }
.sg .pimg { width: 30px; height: 30px; }

#itemInput {
  flex: 1;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fbfdfe;
  font: inherit;
  font-size: 1.02rem;
  color: var(--ink);
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.15s ease;
}
#itemInput:focus { border-color: rgba(12, 138, 95, 0.55); background: #fff; }
#itemInput::placeholder { color: #a9b6c2; }

#addBtn {
  width: 46px; height: 46px; flex: none;
  border: 0;
  border-radius: 12px;
  background: var(--grad);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 18px -10px rgba(12, 138, 95, 0.7);
  transition: transform 0.15s ease;
}
#addBtn:hover { transform: translateY(-1px); }
#addBtn svg { width: 20px; height: 20px; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 2px 14px 12px;
}

.chip {
  border: 1px solid var(--line);
  background: #fbfdfe;
  color: var(--muted);
  border-radius: 999px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 5px 12px;
  cursor: pointer;
  transition: all 0.14s ease;
}
.chip:hover { border-color: rgba(12, 138, 95, 0.5); color: var(--green-deep); background: rgba(14, 163, 113, 0.06); }

.items { list-style: none; border-top: 1px solid var(--line); }

.items:empty { display: none; }

.item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid #eff4f8;
  animation: pop 0.22s ease both;
}
.item:last-child { border-bottom: 0; }

.item-ic {
  width: 38px; height: 38px; flex: none;
  border-radius: 11px;
  background: rgba(14, 163, 113, 0.09);
  color: var(--green);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.item-ic svg { width: 18px; height: 18px; }

.item-name { flex: 1; font-weight: 500; font-size: 1rem; }

.item-del {
  width: 32px; height: 32px; flex: none;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #b6c2cd;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.14s ease;
}
.item-del:hover { background: var(--red-soft); color: var(--red); }
.item-del svg { width: 14px; height: 14px; }

@keyframes pop {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

.builder-foot {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--line);
  background: #fbfdfe;
}

#ocrBtn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1.5px dashed rgba(12, 138, 95, 0.4);
  border-radius: 12px;
  background: rgba(14, 163, 113, 0.05);
  color: var(--green-deep);
  font: inherit;
  font-weight: 500;
  font-size: 0.9rem;
  padding: 10px 12px;
  cursor: pointer;
  transition: background 0.16s ease;
}
#ocrBtn:hover { background: rgba(14, 163, 113, 0.1); }
#ocrBtn:disabled { opacity: 0.7; cursor: wait; }
#ocrBtn svg { width: 17px; height: 17px; flex: none; }

.ghost {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 8px 6px;
}
.ghost:hover { color: var(--red); }

/* ---------- כפתור פעולה צף ---------- */

.actionbar {
  position: fixed;
  bottom: 0;
  right: 0;
  left: 0;
  z-index: 50;
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(246, 249, 251, 0.97) 60%, rgba(246, 249, 251, 0));
  pointer-events: none;
}

.actionbar button {
  pointer-events: auto;
  display: block;
  width: 100%;
  max-width: 604px;
  margin: 0 auto;
  border: 0;
  border-radius: 14px;
  background: var(--grad);
  color: #fff;
  font: inherit;
  font-weight: 700;
  font-size: 1.08rem;
  padding: 15px 20px;
  cursor: pointer;
  box-shadow: 0 10px 26px -10px rgba(12, 138, 95, 0.75);
  transition: transform 0.16s ease, opacity 0.16s ease;
}
.actionbar button:hover { transform: translateY(-1px); }
.actionbar button:disabled { opacity: 0.55; cursor: default; transform: none; box-shadow: none; background: #9fb3ad; }

/* ---------- תוצאות ---------- */

.results { margin-top: 30px; }
.hidden { display: none; }

.answer {
  text-align: center;
  padding: 32px 20px 28px;
  border-radius: 20px;
  background: var(--grad-hero);
  color: #fff;
  box-shadow: 0 24px 48px -24px rgba(6, 113, 83, 0.65);
  animation: settle 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.answer .where { font-size: 0.95rem; font-weight: 500; color: rgba(255, 255, 255, 0.85); }

.answer .chain {
  font-weight: 900;
  font-size: clamp(2rem, 7.5vw, 2.7rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-top: 2px;
}

.answer .total {
  font-weight: 900;
  font-size: clamp(2.8rem, 11vw, 4rem);
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  margin-top: 8px;
  letter-spacing: -0.02em;
}

.answer .store-city { margin-top: 8px; font-size: 0.92rem; color: rgba(255, 255, 255, 0.8); }

.answer .savings {
  display: inline-block;
  margin-top: 16px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 7px 16px;
  border-radius: 999px;
  backdrop-filter: blur(4px);
}

.answer .coverage-note { margin-top: 14px; font-size: 0.85rem; font-weight: 500; color: #ffe3b3; }

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: var(--green-deep);
  font: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 10px 20px;
  cursor: pointer;
  box-shadow: 0 6px 18px -8px rgba(0, 0, 0, 0.35);
  transition: transform 0.16s ease;
}
.share-btn:hover { transform: translateY(-1px); }
.share-btn svg { width: 17px; height: 17px; }

.results h2 { font-weight: 700; font-size: 1.15rem; margin: 30px 4px 14px; }

.store-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  margin-bottom: 14px;
  padding: 18px;
  box-shadow: var(--shadow-card);
  animation: settle 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.store-card:nth-child(3) { animation-delay: 0.05s; }
.store-card:nth-child(4) { animation-delay: 0.1s; }
.store-card:nth-child(5) { animation-delay: 0.15s; }
.store-card:nth-child(6) { animation-delay: 0.2s; }

.store-card.best { border-color: rgba(14, 163, 113, 0.45); }

.store-head { display: flex; align-items: flex-start; gap: 12px; }
.store-id { flex: 1; min-width: 0; }

.avatar {
  width: 42px; height: 42px; flex: none;
  border-radius: 12px;
  color: #fff;
  font-weight: 900;
  font-size: 1.15rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 -8px 14px rgba(0, 0, 0, 0.12);
}

.store-name { font-weight: 700; font-size: 1.1rem; }

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  vertical-align: 2px;
  margin-inline-start: 7px;
}

.badge.best-badge { background: rgba(14, 163, 113, 0.12); color: var(--green-deep); }
.badge.sample-badge { background: var(--red-soft); color: var(--red); }

.store-sub { font-size: 0.85rem; color: var(--muted); margin-top: 1px; }

.store-total {
  font-weight: 900;
  font-size: 1.55rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  letter-spacing: -0.02em;
}

.coverage { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.coverage .bar { flex: 1; height: 6px; border-radius: 999px; background: #edf2f6; overflow: hidden; }
.coverage .bar i { display: block; height: 100%; border-radius: 999px; background: var(--grad); }
.coverage .txt { font-size: 0.8rem; font-weight: 500; color: var(--muted); white-space: nowrap; }

.breakdown { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }

.line {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  padding: 4px 0;
}

.pimg {
  width: 36px; height: 36px; flex: none;
  object-fit: contain;
  border-radius: 9px;
  background: #fff;
  border: 1px solid var(--line);
  padding: 2px;
}
.pimg.empty { visibility: hidden; }

.line .leader { flex: 1; border-bottom: 1px dotted #ccd7e0; }

.line .p { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }

.sub-tag {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  color: #92600a;
  background: #fdf3e0;
  border-radius: 999px;
  padding: 1px 8px;
  margin-inline-start: 5px;
  vertical-align: 1px;
}

.line.missing { color: #b04a3a; }
.line.missing .what { opacity: 0.75; }

.error-note {
  background: var(--red-soft);
  color: var(--red);
  border: 1px solid #f3cfc5;
  border-radius: 12px;
  padding: 13px 16px;
  font-weight: 500;
}

@keyframes settle {
  from { opacity: 0; transform: translateY(14px) scale(0.99); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .answer, .store-card, .item { animation: none; }
}

/* ---------- פוטר ---------- */

footer {
  border-top: 1px solid var(--line);
  padding: 20px 20px 28px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
}

footer .fine { margin-top: 4px; font-size: 0.75rem; }

/* ---------- דסקטופ ---------- */

@media (min-width: 720px) {
  .hero { padding-top: 44px; }
}
