:root {
  --halal-color:   #16a34a;
  --halal-bg:      #dcfce7;
  --kosher-color:  #2563eb;
  --kosher-bg:     #dbeafe;
  --likely-color:  #b45309;
  --likely-bg:     #fef3c7;
  --unknown-color: #6b7280;
  --unknown-bg:    #f3f4f6;
  --border:        #e2e8f0;
  --surface:       #ffffff;
  --text:          #1e293b;
  --muted:         #64748b;
  --radius:        12px;
  --shadow:        0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f1f5f9;
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Layout ── */
.container {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ── Header ── */
header {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
  color: #fff;
  padding: 2.5rem 0 2rem;
  margin-bottom: 2rem;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.header-logo {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}

header h1 {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 0.4rem;
}

header p {
  color: #94a3b8;
  font-size: 0.95rem;
  max-width: 560px;
}

@media (max-width: 520px) {
  .header-logo { width: 54px; height: 54px; }
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}

/* ── Scanner ── */
.scanner-card label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.6rem;
}

textarea {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
  transition: border-color 0.15s;
  color: var(--text);
  background: #fafafa;
}

textarea:focus {
  outline: none;
  border-color: #3b82f6;
  background: #fff;
}

.actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

button {
  padding: 0.6rem 1.6rem;
  border-radius: 8px;
  border: none;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

button:active { transform: scale(0.98); }

#scanBtn {
  background: #1e293b;
  color: #fff;
}

#scanBtn:hover { background: #334155; }

.btn-secondary {
  background: transparent;
  color: var(--muted);
  border: 2px solid var(--border);
}

.btn-secondary:hover { border-color: #94a3b8; color: var(--text); }

.btn-photo {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: #1e3a5f;
  color: #e0f2fe;
  border: none;
}

.btn-photo:hover { background: #1e4976; }
.btn-photo:disabled { opacity: 0.55; cursor: default; }

/* ── Photo source pop-up menu ── */
.photo-menu-wrap {
  position: relative;
  display: inline-flex;
}

.photo-menu {
  position: absolute;
  bottom: calc(100% + 8px); /* open upward above the button */
  left: 50%;
  transform: translateX(-50%);
  min-width: 190px;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.13);
  list-style: none;
  margin: 0;
  padding: 6px 0;
  z-index: 200;
}

.photo-menu[hidden] { display: none !important; }

.photo-menu li {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.65rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text);
  transition: background 0.15s;
}

.photo-menu li:hover { background: #f1f5f9; }

.photo-menu li + li {
  border-top: 1px solid #e2e8f0;
}

/* ── Image preview ── */
.image-preview-wrap {
  position: relative;
  margin-top: 0.85rem;
  max-width: 100%;
}

/* Ensure CSS display doesn't override the HTML hidden attribute */
.image-preview-wrap[hidden],
.ocr-status[hidden] { display: none !important; }

.image-preview-thumb {
  display: block;
  max-height: 180px;
  max-width: 100%;
  border-radius: 8px;
  border: 2px solid var(--border);
  object-fit: contain;
  background: #f8fafc;
}

.clear-image-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 50%;
  background: #475569;
  color: #fff;
  font-size: 0.7rem;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.15s;
}

.clear-image-btn:hover { background: #1e293b; }

/* ── OCR status ── */
.ocr-status {
  margin-top: 0.7rem;
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  min-height: 1.4rem;
}

.ocr-status strong { color: var(--text); }

.hint {
  margin-top: 0.9rem;
  font-size: 0.83rem;
  color: var(--muted);
  line-height: 1.5;
}

/* ── Data status bar ── */
.data-status {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.9rem 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
  font-size: 0.875rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-height: 3rem;
}

.data-status:empty { display: none; }

.status-ok   { color: var(--halal-color); font-weight: 600; }
.status-warn { color: var(--likely-color); font-weight: 600; }

.upload-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.4rem;
  width: 100%;
}

input[type="file"] { display: none; }

.btn-upload {
  display: inline-block;
  padding: 0.35rem 0.9rem;
  background: #f1f5f9;
  border: 2px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
}

.btn-upload:hover { background: #e2e8f0; }

/* ── Results ── */
.results-heading {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.8rem;
}

/* ── Result card ── */
.result-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  border-left: 5px solid var(--border);
}

.result-card.halal-confirmed { border-left-color: var(--halal-color); }
.result-card.halal-likely    { border-left-color: #86efac; }
.result-card.kosher-likely   { border-left-color: var(--kosher-color); }

.result-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
}

.code-chip {
  font-family: 'Courier New', monospace;
  font-size: 1rem;
  font-weight: 700;
  background: #f1f5f9;
  border: 1px solid var(--border);
  padding: 0.2rem 0.7rem;
  border-radius: 6px;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.badges {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.7rem;
  border-radius: 100px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-halal-confirmed { background: var(--halal-bg); color: var(--halal-color); }
.badge-halal-likely    { background: var(--likely-bg); color: var(--likely-color); }
.badge-kosher          { background: var(--kosher-bg); color: var(--kosher-color); }
.badge-unknown         { background: var(--unknown-bg); color: var(--unknown-color); }

.est-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.2rem;
}

.est-details {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-top: 0.6rem;
}

.detail-row {
  display: flex;
  gap: 0.75rem;
  font-size: 0.875rem;
  align-items: baseline;
}

.detail-label {
  min-width: 90px;
  font-weight: 600;
  color: #475569;
  flex-shrink: 0;
}

.detail-value { color: var(--text); }

.country-note {
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: #f8fafc;
  border-radius: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}

.verify-bar {
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.verify-bar strong { color: var(--text); }

.verify-bar a {
  color: #3b82f6;
  text-decoration: none;
  font-weight: 500;
}

.verify-bar a:hover { text-decoration: underline; }

.verify-sep { color: var(--border); }

/* Error / not found */
.error-card {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  padding: 1.1rem 1.4rem;
  color: #b91c1c;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

/* ── Spinner ── */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid #cbd5e1;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  vertical-align: middle;
  margin-right: 0.4rem;
}

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

/* ── Page nav ── */
.page-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}

.nav-link.active {
  background: #1e293b;
  color: #fff;
}

.nav-link:not(.active) {
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--border);
  box-shadow: var(--shadow);
}

.nav-link:not(.active):hover { border-color: #94a3b8; }

/* ── Footer ── */
footer {
  margin-top: 3rem;
  padding: 1.75rem 0 2.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: #94a3b8;
}

footer a { color: #64748b; }

/* ── Mobile ── */
@media (max-width: 520px) {
  header h1 { font-size: 1.5rem; }
  .result-top { flex-direction: column; }
  .detail-row { flex-direction: column; gap: 0.1rem; }
  .detail-label { min-width: unset; }
}

/* ── PWA Install Banner ── */
#pwa-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  padding: 0.75rem 1rem;
  background: #0f172a;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.25);
  transform: translateY(110%);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#pwa-banner.pwa-banner--visible {
  transform: translateY(0);
}

.pwa-banner-inner {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.pwa-banner-logo {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  flex-shrink: 0;
}

.pwa-banner-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.pwa-banner-text strong {
  color: #f1f5f9;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pwa-banner-text span {
  color: #94a3b8;
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* iOS share icon inline */
.pwa-share-icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  vertical-align: -2px;
  margin: 0 1px;
}

.pwa-install-btn {
  padding: 0.5rem 1.1rem;
  background: #16a34a;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s;
}

.pwa-install-btn:hover { background: #15803d; }

.pwa-dismiss-btn {
  background: transparent;
  border: none;
  color: #64748b;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.25rem 0.35rem;
  flex-shrink: 0;
  line-height: 1;
  transition: color 0.15s;
}

.pwa-dismiss-btn:hover { color: #94a3b8; }

@media (max-width: 520px) {
  .pwa-banner-text span { display: none; }
  .pwa-install-btn { padding: 0.5rem 0.85rem; }
}

/* ── Submit info bar (on result cards) ── */
.submit-info-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  margin-top: 0.5rem;
  background: #eef4fb;
  border-top: 2px solid #bfd4ec;
  border-radius: 0 0 10px 10px;
  font-size: 0.85rem;
  color: #334155;
  font-weight: 500;
}

.submit-info-btn {
  background: #1e3a5f;
  border: none;
  border-radius: 6px;
  padding: 0.4rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.submit-info-btn:hover {
  background: #1e4976;
}

/* ── Submission modal ── */
.submit-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.submit-overlay[hidden] { display: none !important; }

.submit-modal {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.75rem;
}

.submit-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.submit-modal-header h2 {
  font-size: 1.15rem;
  margin: 0;
}

.submit-modal-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: #94a3b8;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  line-height: 1;
  border-radius: 4px;
  transition: color 0.15s;
}

.submit-modal-close:hover { color: var(--text); }

.submit-intro {
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 1.25rem;
}

.sform-row {
  margin-bottom: 1rem;
}

.sform-row label,
.sform-fieldset legend {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--text);
}

.sform-req { color: #ef4444; }

.sform-row input[type="text"],
.sform-row input[type="url"],
.sf-proof-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  box-sizing: border-box;
  transition: border-color 0.15s;
}

.sform-row input:focus,
.sf-proof-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30,58,95,0.1);
}

.sform-fieldset {
  border: none;
  padding: 0;
  margin: 0;
}

.sform-radios {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.sform-radio {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.sform-link-row {
  margin-bottom: 0.4rem;
}

.sform-add-link {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.82rem;
  cursor: pointer;
  padding: 0;
  margin-top: 0.25rem;
  font-family: inherit;
}

.sform-add-link:hover { text-decoration: underline; }

.sform-status {
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.sform-status[hidden] { display: none !important; }

.sform-status--info    { background: #f0f9ff; color: #0369a1; }
.sform-status--success { background: #f0fdf4; color: #15803d; }
.sform-status--error   { background: #fef2f2; color: #dc2626; }

.submit-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1rem;
}

@media (max-width: 520px) {
  .submit-modal { padding: 1.25rem; }
  .submit-info-bar { flex-direction: column; align-items: flex-start; gap: 0.4rem; }
}

/* ── Submit CTA block (slaughterhouses page) ── */
.submit-cta {
  margin: 2.5rem 0 1rem;
  padding: 1.25rem 1.5rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.submit-cta p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.submit-cta-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1.2rem;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.submit-cta-btn:hover { background: #1e4976; }

/* ── Honeypot (spam trap — hidden from real users) ── */
.sform-honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}
