:root {
  --color-halal: #1f7a4d;
  --color-haram: #c0392b;
  --color-mashbooh: #d68910;
  --color-unknown: #6b7280;
  --color-bg: #f5f6f5;
  --color-card: #ffffff;
  --color-text: #1f2933;
  --color-muted: #6b7280;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  padding-bottom: 2rem;
}

.app-header {
  background: var(--color-halal);
  color: white;
  padding: 1.25rem 1rem 1.5rem;
  text-align: center;
  border-radius: 0 0 20px 20px;
}

.app-header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.app-logo {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  flex-shrink: 0;
}

.tagline {
  margin: 0;
  opacity: 0.9;
  font-size: 0.9rem;
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 1rem;
}

.card {
  background: var(--color-card);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.hidden {
  display: none !important;
}

#reader {
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

/* Bordo verde pulsante mentre la fotocamera sta cercando attivamente un
   codice a barre, cosi si vede a colpo d'occhio che la scansione e in corso
   (prima non c'era nessun segnale visivo di questo). */
#reader.scanning {
  outline: 3px solid var(--color-halal);
  outline-offset: 2px;
  animation: pulse-border 1.4s ease-in-out infinite;
}

@keyframes pulse-border {
  0%, 100% { outline-color: var(--color-halal); }
  50% { outline-color: #a8e6c1; }
}

.scan-hint {
  text-align: center;
  font-size: 0.8rem;
  color: var(--color-muted);
  margin: 0 0 0.75rem;
}

.scan-buttons {
  display: flex;
  gap: 0.5rem;
}

.btn-icon {
  flex: 0 0 auto;
  padding: 0.75rem 1rem;
}

.btn {
  flex: 1;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.btn:active {
  opacity: 0.8;
}

.btn-primary {
  background: var(--color-halal);
  color: white;
}

.btn-secondary {
  background: #e5e7eb;
  color: var(--color-text);
}

.or-divider {
  text-align: center;
  color: var(--color-muted);
  font-size: 0.85rem;
  margin: 1rem 0 0.5rem;
}

.scan-error {
  background: #fdecea;
  border-left: 4px solid var(--color-haram);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font-size: 0.9rem;
  margin: 0.75rem 0 0;
}

.manual-entry form {
  display: flex;
  gap: 0.5rem;
}

.manual-entry input {
  flex: 1;
  padding: 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  font-size: 1rem;
  min-width: 0;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 4px solid #e5e7eb;
  border-top-color: var(--color-halal);
  border-radius: 50%;
  margin: 0 auto 0.75rem;
  animation: spin 0.8s linear infinite;
}

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

#loading, .error-card {
  text-align: center;
}

.error-card {
  border: 1px solid var(--color-haram);
}

.error-card p {
  color: var(--color-haram);
  margin-top: 0;
}

.result-header {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
}

.result-header img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: 8px;
  background: #f0f0f0;
}

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

.result-header p {
  margin: 0.15rem 0 0;
  color: var(--color-muted);
  font-size: 0.9rem;
}

.verdict-badge {
  display: block;
  text-align: center;
  padding: 0.85rem;
  border-radius: 10px;
  font-size: 1.1rem;
  font-weight: 700;
  color: white;
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.verdict-badge.halal { background: var(--color-halal); }
.verdict-badge.haram { background: var(--color-haram); }
.verdict-badge.mashbooh { background: var(--color-mashbooh); }
.verdict-badge.unknown { background: var(--color-unknown); }

.result-message {
  background: #f3f4f6;
  border-radius: 10px;
  padding: 0.75rem;
  font-size: 0.9rem;
}

#flagged-section h3,
#clarifications-section h3 {
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

.reason-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}

.reason-list li {
  background: #fdecea;
  border-left: 4px solid var(--color-haram);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.reason-list li.mashbooh {
  background: #fdf3e3;
  border-left-color: var(--color-mashbooh);
}

.reason-list-info li {
  background: #eaf6ef;
  border-left-color: var(--color-halal);
}

.reason-list li strong {
  display: block;
  margin-bottom: 0.15rem;
  text-transform: capitalize;
}

#ingredients-details {
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--color-muted);
}

#ingredients-details summary {
  cursor: pointer;
  color: var(--color-text);
  font-weight: 600;
}

#photo-upload-section {
  background: #f3f4f6;
  border-radius: 10px;
  padding: 0.85rem;
  margin-bottom: 1rem;
}

#photo-upload-section p {
  margin-top: 0;
  font-size: 0.9rem;
}

#photo-upload-section input[type="file"] {
  display: block;
  margin-bottom: 0.6rem;
  width: 100%;
}

.photo-video,
.photo-preview {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 0.6rem;
  background: #000;
  display: block;
}

.disclaimer {
  font-size: 0.75rem;
  color: var(--color-muted);
  border-top: 1px solid #e5e7eb;
  padding-top: 0.75rem;
  margin-bottom: 1rem;
}

.app-footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--color-muted);
  padding: 1rem;
}
