:root {
  --melitta-red: #c1272d;
  --melitta-red-dark: #9e1f24;
  --text-dark: #1a0f08;
  --text-brown: #5c4035;
  --text-muted: #8a7a6a;
  --bg-cream: #f8f5f2;
  --bg-white: #ffffff;
  --border-light: #e8ddd4;
  --gold-accent: #c9a870;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, "Segoe UI", sans-serif;
  background: var(--bg-cream);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 32px;
}

/* ===== גרסת דסקטופ: מיכל רחב ומרווח ===== */
.app-shell {
  width: 100%;
  max-width: 1080px;
  background: var(--bg-white);
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(26, 15, 8, 0.10);
  border: 1px solid var(--border-light);
  padding: 44px 56px 52px;
  position: relative;
}

/* לקובץ הלוגו יש שוליים לבנים מובנים - הגובה הקבוע + overflow קוצצים אותם */
.brand-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  height: 63px;
  overflow: hidden;
  margin-bottom: 18px;
}

.brand-logo {
  width: 175px;
  max-width: 100%;
  height: auto;
}

/* לוגו מותג משני בכותרת - ממודד לפי גובה כדי לשבת לצד לוגו המילטון */
.brand-header .brand-logo--secondary {
  width: auto;
  height: 40px;
}

.progress-dots {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 28px;
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--border-light);
  transition: background 0.25s ease;
}

.dot.active {
  background: var(--melitta-red);
}

.screen {
  display: none;
  animation: fade-in 0.3s ease;
}

.screen.active {
  display: block;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.screen-header {
  text-align: center;
  margin-bottom: 36px;
}

.screen-header h1 {
  font-size: 2rem;
  color: var(--text-dark);
  margin: 0 0 10px;
}

.screen-header p {
  color: var(--text-muted);
  margin: 0;
  font-size: 1.05rem;
}

/* ===== טופס: שתי עמודות בדסקטופ ===== */
.details-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 28px;
  max-width: 820px;
  margin: 0 auto;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0; /* מאפשר לשדות להצטמצם בתוך תא ה-grid */
}

/* שדות שנפרסים על כל הרוחב (חשבונית, כפתורים) */
.field-group--full,
.details-form .form-actions {
  grid-column: 1 / -1;
}

.field-group label {
  font-size: 0.95rem;
  color: var(--text-brown);
  font-weight: 600;
}

.field-group input {
  width: 100%;
  min-width: 0; /* מונע גלישה של input[type=file] שרוחבו המובנה גדול מהתא */
  padding: 13px 16px;
  border: 1.5px solid var(--border-light);
  border-radius: 6px;
  font-size: 1rem;
  background: var(--bg-white);
  outline: none;
  transition: border-color 0.2s ease;
}

.field-group input:focus {
  border-color: var(--melitta-red);
}

.field-group input.invalid {
  border-color: var(--melitta-red);
}

.error-msg {
  color: var(--melitta-red);
  font-size: 0.82rem;
  min-height: 1em;
}

.optional-tag {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.85rem;
}

/* בלוק רשת שיווק במסך בחירת המכונה.
   ברירת המחדל מוצג (עמידות): ה-JS מסתיר בטעינה עם is-hidden וחושף בבחירת מכונה.
   כך שאם קובץ אחד מוגש מהמטמון בגרסה ישנה - הבורר עדיין יופיע ולא ייעלם. */
.store-section {
  max-width: 820px;
  width: 100%;
  margin: 4px auto 8px;
}

.store-section.is-hidden {
  display: none;
}

/* בורר רשת שיווק */
.store-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}

.store-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 64px;
  padding: 10px 8px;
  background: var(--bg-white);
  border: 1.5px solid var(--border-light);
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.store-logo {
  max-width: 100%;
  max-height: 34px;
  object-fit: contain;
}

.store-tile:hover {
  transform: translateY(-2px);
  border-color: var(--gold-accent);
}

.store-tile.selected {
  border-color: var(--melitta-red);
  box-shadow: 0 6px 16px rgba(193, 39, 45, 0.18);
  background: var(--bg-cream);
}

.store-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.store-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-brown);
  text-align: center;
}

.store-other-input {
  width: 100%;
  min-width: 0;
  margin-top: 10px;
  padding: 12px 14px;
  border: 1.5px solid var(--border-light);
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  outline: none;
}

.store-other-input:focus {
  border-color: var(--melitta-red);
}

@media (max-width: 900px) {
  .store-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 560px) {
  .store-grid { grid-template-columns: repeat(2, 1fr); }
  .store-name { font-size: 0.72rem; }
}

.file-hint {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.field-group input[type="file"] {
  padding: 11px 14px;
  font-size: 0.9rem;
  background: var(--bg-cream);
  cursor: pointer;
}

/* ===== כפתורים: ממורכזים ולא נמתחים לכל הרוחב ===== */
.form-actions {
  display: flex;
  gap: 14px;
  margin-top: 16px;
  justify-content: center;
}

.primary-button, .secondary-button {
  flex: 0 1 240px;
  padding: 14px 28px;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.2s ease, transform 0.1s ease;
}

.primary-button {
  background: var(--melitta-red);
  color: var(--bg-white);
}

.primary-button:not(:disabled):hover {
  background: var(--melitta-red-dark);
}

.primary-button:disabled {
  background: var(--border-light);
  color: var(--text-muted);
  cursor: not-allowed;
}

.primary-button:not(:disabled):active {
  transform: scale(0.98);
}

.secondary-button {
  background: var(--bg-cream);
  color: var(--text-brown);
  border: 1.5px solid var(--border-light);
}

.secondary-button:hover {
  border-color: var(--gold-accent);
}

.secondary-button:active {
  transform: scale(0.98);
}

/* ===== רשתות: 4 עמודות בדסקטופ ===== */
.machine-grid, .gift-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  padding: 4px 0 8px;
  margin-bottom: 20px;
}

/* 5 מתנות - שורה אחת בדסקטופ */
.gift-grid {
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
}

/* מתנה קבועה יחידה - כרטיס אחד ממורכז */
.gift-grid--single {
  grid-template-columns: minmax(0, 320px);
  justify-content: center;
}

/* מכונות בשורה אחת בדסקטופ (למשל 5 גווני Melitta Solo) */
.machine-grid--row {
  grid-template-columns: repeat(5, 1fr);
}

.machine-card, .gift-card {
  background: var(--bg-white);
  border: 2px solid var(--border-light);
  border-radius: 10px;
  padding: 22px 16px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.machine-card:hover, .gift-card:hover {
  transform: translateY(-4px);
  border-color: var(--gold-accent);
  box-shadow: 0 10px 24px rgba(26, 15, 8, 0.08);
}

.machine-card.selected, .gift-card.selected {
  border-color: var(--melitta-red);
  box-shadow: 0 10px 26px rgba(193, 39, 45, 0.18);
  background: var(--bg-cream);
}

.machine-card-image, .gift-card-image {
  width: 70%;
  aspect-ratio: 1;
  object-fit: contain;
  margin-bottom: 10px;
}

.machine-card-icon, .gift-icon {
  font-size: 3rem;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.machine-card h3, .gift-card h3 {
  font-size: 1.05rem;
  margin: 0 0 8px;
  color: var(--text-dark);
}

/* לכרטיסי המכונה אין שורת תיאור - מהדקים את הריווח */
.machine-card {
  padding: 18px 14px 16px;
}

.machine-card h3 {
  margin: 0;
}

.machine-card p, .gift-card p {
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--text-muted);
  margin: 0;
}

/* ===== מסך אישור ===== */
.confirm-panel {
  text-align: center;
  max-width: 620px;
  margin: 0 auto;
}

.confirm-icon {
  font-size: 3.5rem;
  margin-bottom: 12px;
}

.confirm-details {
  background: var(--bg-cream);
  border-radius: 10px;
  padding: 22px 28px;
  margin: 26px 0;
  text-align: right;
  border: 1px solid var(--border-light);
}

.confirm-details div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  font-size: 1rem;
  border-bottom: 1px solid var(--border-light);
}

.confirm-details div:last-child {
  border-bottom: none;
}

.confirm-details dt {
  color: var(--text-muted);
}

.confirm-details dd {
  margin: 0;
  font-weight: 600;
  color: var(--text-dark);
  overflow-wrap: anywhere;
}

/* ===== התאמה למסכים בינוניים (טאבלט) ===== */
@media (max-width: 900px) {
  body { padding: 32px 20px; }

  .app-shell {
    padding: 32px 28px 36px;
  }

  .screen-header h1 { font-size: 1.6rem; }

  .machine-grid, .gift-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }

  .details-form {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

/* ===== התאמה למסכים קטנים (מובייל) ===== */
@media (max-width: 560px) {
  body { padding: 20px 12px; }

  .app-shell {
    padding: 24px 18px 30px;
    border-radius: 12px;
  }

  .brand-header { height: 49px; gap: 14px; }
  .brand-logo { width: 133px; }
  .brand-header .brand-logo--secondary { height: 30px; }

  .screen-header { margin-bottom: 24px; }
  .screen-header h1 { font-size: 1.35rem; }
  .screen-header p { font-size: 0.95rem; }

  .machine-grid, .gift-grid { gap: 12px; }

  .machine-card, .gift-card { padding: 16px 12px 18px; }
  .machine-card h3, .gift-card h3 { font-size: 0.95rem; }
  .machine-card p, .gift-card p { font-size: 0.78rem; }

  .form-actions { flex-direction: column-reverse; }
  .primary-button, .secondary-button { flex: 1 1 auto; width: 100%; }

  /* מונע זום אוטומטי ב-iOS Safari - שדה קלט מתחת ל-16px גורם להגדלה בפוקוס */
  .field-group input,
  .field-group input[type="file"] {
    font-size: 16px;
  }

  /* פרטי האישור: תווית מעל הערך, כדי שערכים ארוכים (אימייל) לא יגלשו מהתיבה */
  .confirm-details {
    padding: 16px 18px;
  }

  .confirm-details div {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 9px 0;
    font-size: 0.95rem;
  }
}
