:root {
  --bg: #f5f5f5;
  --surface: #fff;
  --brand: #1a6b3a;
  --brand-light: #e8f5ee;
  --accent: #e53935;
  --text: #212121;
  --muted: #757575;
  --border: #e0e0e0;
  --promo: #ff6f00;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,.1);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── header ── */
header {
  background: var(--brand);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow);
}
header h1 { font-size: 1.1rem; font-weight: 700; }
header .subtitle { font-size: .78rem; opacity: .85; margin-top: 1px; }

/* ── scanner section ── */
#scanner-section {
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

#video-wrap {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  aspect-ratio: 4/3;
  display: none;
}
#video-wrap.active { display: block; }

#preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-line {
  position: absolute;
  top: 50%;
  left: 8%;
  right: 8%;
  height: 2px;
  background: var(--accent);
  transform: translateY(-50%);
  animation: scan 2s ease-in-out infinite;
  pointer-events: none;
}
@keyframes scan {
  0%,100% { top: 30%; }
  50% { top: 70%; }
}

.btn {
  display: block;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
}
.btn:active { opacity: .8; }
.btn-primary { background: var(--brand); color: #fff; margin-top: 12px; }
.btn-secondary { background: var(--border); color: var(--text); margin-top: 8px; }

/* ── barcode input ── */
#manual-wrap {
  max-width: 480px;
  margin: 8px auto 0;
  display: flex;
  gap: 8px;
}
#barcode-input {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  direction: ltr;
  text-align: center;
}
#barcode-input:focus { outline: 2px solid var(--brand); }
#lookup-btn {
  padding: 12px 18px;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

/* ── status / error bar ── */
#status-bar {
  max-width: 480px;
  margin: 8px auto 0;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: .88rem;
  text-align: center;
  display: none;
}
#status-bar.info  { background: var(--brand-light); color: var(--brand); }
#status-bar.error { background: #fce4e4; color: #b71c1c; }

/* ── results ── */
#results {
  flex: 1;
  padding: 16px;
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
}

#product-name {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 12px;
  line-height: 1.4;
}

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

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 130px;
}
.card.not-sold { opacity: .55; }

.card-logo {
  font-size: .8rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .03em;
}

.card-regular {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.card-regular .currency { font-size: .85rem; font-weight: 400; margin-inline-start: 2px; }

.card-promo {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 4px;
}
.promo-price {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--promo);
}
.promo-desc {
  font-size: .75rem;
  color: var(--promo);
  line-height: 1.3;
}

.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 600;
}
.badge-club { background: #e3f2fd; color: #1565c0; }
.badge-new  { background: #fff3e0; color: #e65100; }

.not-sold-label {
  font-size: .9rem;
  color: var(--muted);
  margin-top: auto;
}

.not-found-note {
  font-size: .9rem;
  color: var(--muted);
  line-height: 1.5;
  padding: 8px 0;
}

/* ── footer ── */
footer {
  text-align: center;
  font-size: .75rem;
  color: var(--muted);
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
footer a { color: var(--brand); text-decoration: none; }

/* ── loading spinner ── */
.spinner {
  width: 20px; height: 20px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
  vertical-align: middle;
  margin-inline-end: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── responsive: wider screens get a centered column ── */
@media (min-width: 540px) {
  #scanner-section, #results { max-width: 520px; margin-inline: auto; }
}
