/* ── Scanner card ── */
.scanner-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.scanner-camera-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
}

#scanner-reader { width: 100%; height: 100%; }
#scanner-reader video,
#scanner-reader canvas {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
}
#scanner-reader img { display: none; } /* hide the library's default camera-permission icon */

.scanner-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  color: var(--text-dim);
  pointer-events: none;
}
.scanner-placeholder.hidden { display: none; }

.scanner-scan-line {
  position: absolute;
  left: 6%;
  right: 6%;
  height: 2px;
  background: #ff3b30;
  box-shadow: 0 0 6px 1px rgba(255,59,48,0.7);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}
.scanner-scan-line.active {
  opacity: 1;
  animation: scanner-sweep 1.8s ease-in-out infinite;
}
@keyframes scanner-sweep {
  0%, 100% { top: 12%; }
  50%      { top: 88%; }
}

.scanner-camera-controls {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.scanner-camera-error {
  color: var(--red);
  font-size: 0.78rem;
  text-align: center;
  margin-top: 10px;
}
.scanner-camera-error:empty { display: none; }

.scanner-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 20px 0 14px;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.scanner-divider::before,
.scanner-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.scanner-manual-form {
  display: flex;
  gap: 8px;
  width: 100%;
}
.scanner-manual-form input {
  flex: 1;
  min-width: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.scanner-manual-form input:focus {
  border-color: var(--accent-border);
  box-shadow: var(--accent-glow);
}
.scanner-manual-form button {
  padding: 10px 16px;
}

/* ── Result ── */
.scanner-result {
  width: 100%;
  max-width: 420px;
}
.scanner-result:empty { display: none; }

.product-card {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  animation: scanner-fade-in 0.25s ease;
}
@keyframes scanner-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.product-card.status-message {
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.product-card.status-message i { font-size: 1.6rem; color: var(--text-dim); }

.product-image {
  width: 76px;
  height: 76px;
  flex-shrink: 0;
  border-radius: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: var(--text-dim);
  font-size: 1.4rem;
}
.product-image img { width: 100%; height: 100%; object-fit: contain; }

.product-info { min-width: 0; flex: 1; }
.product-info h3 { font-size: 1rem; margin-bottom: 2px; }
.product-brand { font-size: 0.82rem; color: var(--text-muted); }
.product-quantity { font-size: 0.76rem; color: var(--text-dim); margin-top: 1px; }

.product-tags { display: flex; align-items: center; gap: 8px; margin: 8px 0; }

.nutri-badge {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.8rem;
  color: #fff;
  text-transform: uppercase;
}
.nutri-a { background: #1e8f4e; }
.nutri-b { background: #7cb518; }
.nutri-c { background: #f2b705; color: #2b2100; }
.nutri-d { background: #ee8a1d; }
.nutri-e { background: #e6392b; }
.nutri-unknown { background: var(--text-dim); }

.nova-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 3px 9px;
}

.product-categories {
  font-size: 0.74rem;
  color: var(--text-dim);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-barcode {
  display: block;
  margin-top: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  color: var(--text-dim);
}

/* ── History ── */
.scanner-history { width: 100%; max-width: 420px; }
.scanner-history:empty { display: none; }

.scanner-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.scanner-history-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.scanner-history-clear {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  cursor: pointer;
  transition: color 0.2s;
}
.scanner-history-clear:hover { color: var(--red); }

.scanner-history-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.history-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 5px 12px 5px 5px;
  font-size: 0.76rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  max-width: 180px;
}
.history-chip:hover { border-color: var(--accent-border); color: var(--text); }

.history-chip-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-secondary);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: 0.68rem;
  color: var(--text-dim);
}
.history-chip-thumb img { width: 100%; height: 100%; object-fit: cover; }

.history-chip-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
