/* =============================================================
   הבית שלנו — עיצוב בסיס
   Mobile-first, RTL, מצב בהיר וכהה.
   ============================================================= */

:root {
  --brand:        #0d9488;
  --brand-ink:    #ffffff;
  --brand-soft:   #ccfbf1;

  --bg:           #f4f6f8;
  --surface:      #ffffff;
  --surface-2:    #f8fafc;
  --line:         #e2e8f0;

  --ink:          #14202e;
  --ink-2:        #475569;
  --ink-3:        #94a3b8;

  --danger:       #e11d48;
  --success:      #15803d;
  --warn:         #d97706;

  --radius:       14px;
  --radius-sm:    10px;
  --shadow:       0 1px 2px rgba(15, 32, 46, .06), 0 8px 24px rgba(15, 32, 46, .06);

  --tap:          48px;   /* גובה מינימלי לכל אלמנט שנוגעים בו */

  --safe-top:     env(safe-area-inset-top, 0px);
  --safe-bottom:  env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand:      #2dd4bf;
    --brand-ink:  #042f2e;
    --brand-soft: #134e4a;

    --bg:         #0b1220;
    --surface:    #131c2b;
    --surface-2:  #1a2436;
    --line:       #263349;

    --ink:        #e8eef6;
    --ink-2:      #a3b2c7;
    --ink-3:      #6b7d96;

    --danger:     #fb7185;
    --success:    #4ade80;
    --warn:       #fbbf24;

    --shadow:     0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

/* ---------- איפוס ---------- */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Hebrew",
        "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

h1, h2, h3, p { margin: 0; }

/* מונע זום אוטומטי באייפון כשנכנסים לשדה */
input, select, textarea { font-size: 16px; }

#app { min-height: 100%; display: flex; flex-direction: column; }

/* ---------- מסך פתיחה ---------- */

.boot {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
}

.boot__mark {
  width: 68px;
  height: 68px;
  border-radius: 20px;
  background: var(--brand);
  box-shadow: var(--shadow);
}

.spinner {
  width: 26px;
  height: 26px;
  border: 3px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
  * { transition: none !important; }
}

/* ---------- מסך התחברות ---------- */

.login {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: calc(24px + var(--safe-top)) 22px calc(24px + var(--safe-bottom));
  max-width: 420px;
  margin: 0 auto;
  width: 100%;
}

.login__brand {
  text-align: center;
  margin-bottom: 34px;
}

.login__mark {
  width: 64px;
  height: 64px;
  border-radius: 19px;
  background: var(--brand);
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  font-size: 30px;
  box-shadow: var(--shadow);
}

.login__title { font-size: 23px; font-weight: 700; letter-spacing: -.01em; }
.login__sub   { font-size: 14.5px; color: var(--ink-2); margin-top: 5px; }

/* ---------- שדות ---------- */

.field { margin-bottom: 16px; }

.field__label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 7px;
}

.input {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}

.input::placeholder { color: var(--ink-3); }

.input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);
}

.input--code {
  text-align: center;
  letter-spacing: .5em;
  padding-inline-start: .5em;   /* מאזן את הרווח הנוסף אחרי התו האחרון */
  font-size: 22px;
  font-weight: 600;
}

.field__hint { font-size: 12.5px; color: var(--ink-3); margin-top: 6px; }

/* ---------- כפתורים ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: var(--tap);
  padding: 13px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: var(--brand-ink);
  font-weight: 600;
  transition: opacity .15s, transform .06s;
}

.btn:active  { transform: scale(.985); }
.btn:disabled { opacity: .55; cursor: default; }

.btn--ghost {
  background: transparent;
  color: var(--ink-2);
  border-color: var(--line);
}

.btn--danger { background: transparent; color: var(--danger); border-color: var(--line); }

.btn__spinner {
  width: 17px;
  height: 17px;
  border: 2px solid color-mix(in srgb, var(--brand-ink) 35%, transparent);
  border-top-color: var(--brand-ink);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ---------- הודעת שגיאה בטופס ---------- */

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
  background: color-mix(in srgb, var(--danger) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  color: var(--danger);
}

/* ---------- מעטפת האפליקציה ---------- */

.shell { flex: 1; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + var(--safe-top)) 18px 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar__title { font-size: 18px; font-weight: 700; }
.topbar__sub   { font-size: 12.5px; color: var(--ink-2); }

.avatar {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  border: 0;
}

.main {
  flex: 1;
  padding: 18px 18px calc(28px + var(--safe-bottom));
  max-width: 620px;
  width: 100%;
  margin: 0 auto;
}

/* ---------- כרטיס ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.card__title { font-size: 15px; font-weight: 700; margin-bottom: 10px; }
.card__body  { font-size: 14.5px; color: var(--ink-2); }

.stack > * + * { margin-top: 10px; }

.muted { color: var(--ink-2); }
.small { font-size: 13px; }

/* מצב ריק */
.empty {
  text-align: center;
  padding: 46px 20px;
  color: var(--ink-2);
}
.empty__icon { font-size: 42px; margin-bottom: 12px; opacity: .8; }

/* ---------- הודעה צפה ---------- */

.toast {
  position: fixed;
  inset-inline: 16px;
  bottom: calc(20px + var(--safe-bottom));
  z-index: 100;
  margin: 0 auto;
  max-width: 420px;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--bg);
  font-size: 14.5px;
  text-align: center;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity .22s, transform .22s;
}

.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast.is-error   { background: var(--danger); color: #fff; }

/* =============================================================
   רשימת הקניות
   ============================================================= */

/* מפנה מקום לשורת ההוספה הקבועה בתחתית */
.shell .main { padding-bottom: calc(96px + var(--safe-bottom)); }

/* ---------- פס התקדמות ---------- */

.progress {
  position: sticky;
  top: calc(62px + var(--safe-top));
  z-index: 9;
  height: 3px;
  background: var(--line);
}

.progress__fill {
  height: 100%;
  width: 0;
  background: var(--brand);
  transition: width .28s ease;
}

/* ---------- קבוצת קטגוריה ---------- */

.group { margin-bottom: 22px; }

.group__head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 2px 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
}

.group__icon { font-size: 15px; }

.group__count {
  margin-inline-start: auto;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 8px;
}

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

/* ---------- שורת מוצר ---------- */

.item {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 58px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  user-select: none;
  transition: background .12s;
}

.item:last-child { border-bottom: 0; }
.item:active     { background: var(--surface-2); }

.item:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

.item__check {
  flex: 0 0 auto;
  width: 25px;
  height: 25px;
  border: 2px solid var(--ink-3);
  border-radius: 50%;
  transition: background .15s, border-color .15s;
  position: relative;
}

.item__check::after {
  content: '';
  position: absolute;
  inset-inline-start: 7px;
  top: 3px;
  width: 6px;
  height: 11px;
  /* brand-ink ולא לבן: במצב כהה הרקע של הסימון בהיר, ולבן על בהיר לא נקרא */
  border: solid var(--brand-ink);
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) scale(0);
  transition: transform .15s;
}

.item__main { flex: 1; min-width: 0; }

.item__name {
  display: block;
  font-size: 16px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item__meta {
  display: block;
  font-size: 12.5px;
  color: var(--ink-2);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item__edit {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-3);
  font-size: 19px;
  line-height: 1;
}

.item__edit:active { background: var(--surface-2); }

/* מסומן */
.item.is-checked .item__check {
  background: var(--brand);
  border-color: var(--brand);
}
.item.is-checked .item__check::after { transform: rotate(45deg) scale(1); }
.item.is-checked .item__name {
  text-decoration: line-through;
  color: var(--ink-3);
  font-weight: 400;
}

/* ---------- מקטע "נקנו" ---------- */

.section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 2px 8px;
}

.section__toggle,
.section__link {
  border: 0;
  background: transparent;
  padding: 6px 2px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
}

.section__link { font-weight: 600; color: var(--danger); }

.group--checked .group__items { opacity: .72; }

/* ---------- סיום קנייה ---------- */

.finish { margin-top: 6px; }

/* =============================================================
   שורת ההוספה
   ============================================================= */

.addbar {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 20;
  padding: 10px 14px calc(10px + var(--safe-bottom));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.6) blur(12px);
  border-top: 1px solid var(--line);
}

.addbar__form {
  display: flex;
  gap: 9px;
  max-width: 620px;
  margin: 0 auto;
}

.addbar__input {
  flex: 1;
  min-width: 0;
  min-height: var(--tap);
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.addbar__input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent);
}

.addbar__btn {
  flex: 0 0 auto;
  width: var(--tap);
  height: var(--tap);
  border: 0;
  border-radius: 50%;
  background: var(--brand);
  color: var(--brand-ink);
  font-size: 26px;
  line-height: 1;
  padding: 0 0 3px;
}

.addbar__btn:active { transform: scale(.94); }

/* ---------- הצעות והשלמה ---------- */

.suggest {
  max-width: 620px;
  margin: 0 auto 9px;
}

.suggest__head {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-3);
  margin: 0 4px 6px;
}

.suggest__chips {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 3px;
  scrollbar-width: none;
}

.suggest__chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  padding: 9px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 14px;
  white-space: nowrap;
}

.chip:active { background: var(--brand-soft); border-color: var(--brand); }

/* =============================================================
   חלונית תחתית
   ============================================================= */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(6, 12, 22, .45);
  opacity: 0;
  transition: opacity .2s;
}

.sheet.is-open { opacity: 1; }

.sheet__panel {
  width: 100%;
  max-width: 620px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 10px 20px calc(20px + var(--safe-bottom));
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  transform: translateY(100%);
  transition: transform .24s cubic-bezier(.32, .72, 0, 1);
}

.sheet.is-open .sheet__panel { transform: translateY(0); }

.sheet__grip {
  width: 40px;
  height: 4px;
  margin: 0 auto 14px;
  border-radius: 999px;
  background: var(--line);
}

.sheet__title { font-size: 17px; font-weight: 700; margin-bottom: 14px; }

.sheet__actions { margin-top: 20px; display: grid; gap: 9px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

select.input {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%),
                    linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(14px) calc(50% + 1px), calc(19px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-inline-start: 34px;
}
