/* Lagerverwaltung - Mobile First */
:root {
  --bg: #1a1d23;
  --bg-card: #23262d;
  --accent: #4a9eff;
  --accent-hover: #6bb1ff;
  --danger: #e85d5d;
  --success: #4ade80;
  --text: #e8eaed;
  --text-muted: #9aa0a6;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 4px 20px rgba(0,0,0,0.3);
  --safe-top: env(safe-area-inset-top, 0);
  --safe-bottom: env(safe-area-inset-bottom, 0);
}

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

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

/* Startseite */
.start {
  min-height: 100dvh;
  padding: max(2rem, var(--safe-top)) 1.5rem max(3rem, var(--safe-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.start h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 2.5rem;
  letter-spacing: -0.02em;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  max-width: 320px;
}

.hint {
  margin-top: 2rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Buttons */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 1.5rem;
  font-size: 1.05rem;
  font-weight: 600;
  text-decoration: none;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.15s, background 0.2s;
  -webkit-tap-highlight-color: transparent;
  min-height: 52px;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover, .btn-primary:focus {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.1);
}

.btn-secondary:hover, .btn-secondary:focus {
  background: #2a2e36;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-success {
  background: var(--success);
  color: var(--bg);
}

/* Seiten-Layout */
.page {
  min-height: 100dvh;
  padding: max(0.5rem, var(--safe-top)) 1rem max(1rem, var(--safe-bottom));
  display: flex;
  flex-direction: column;
}

/* Scan-Seiten: Scanner priorisieren, weniger Padding oben */
.page--scan .page-header {
  margin-bottom: 0.75rem;
  flex-shrink: 0;
}

.page--scan .scanner-container {
  flex-shrink: 0;
}

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

.page-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
}

.back-link {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.5rem;
  -webkit-tap-highlight-color: transparent;
}

/* Scanner-Bereich – Mobile: volle Breite, ausreichend Höhe */
.scanner-container {
  position: relative;
  width: 100%;
  margin: 0 auto;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #000;
  /* Mobile: feste Mindesthöhe, damit Scan-Bereich voll sichtbar ist */
  min-height: 55vh;
  min-height: 55dvh;
  aspect-ratio: 4/3;
}

/* Desktop: max-width beibehalten */
@media (min-width: 500px) {
  .scanner-container {
    max-width: 400px;
  }
}

/* html5-qrcode interne Elemente: Container füllen */
#qr-reader {
  width: 100% !important;
  min-height: 100% !important;
  border: none !important;
  padding: 0 !important;
}

#qr-reader__scan_region {
  width: 100% !important;
  min-height: 100% !important;
  background: #000 !important;
}

#qr-reader__scan_region video,
#qr-reader video {
  width: 100% !important;
  height: 100% !important;
  min-height: 200px !important;
  object-fit: cover !important;
  display: block !important;
}

.scanner-status {
  text-align: center;
  padding: 0.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  flex-shrink: 0;
}

.scanner-status.scanning { color: var(--success); }

/* Ergebnis-Box */
.result-box {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.06);
}

.result-box .code { font-family: monospace; font-size: 1.1rem; word-break: break-all; }
.result-box .name { color: var(--text-muted); margin-top: 0.25rem; }

.result-with-img {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}
.result-img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
}

/* Sammelerfassung */
.scan-list {
  flex: 1;
  margin-top: 1rem;
  overflow-y: auto;
}

.scan-list-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 1rem;
  font-size: 0.95rem;
}

.scan-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  border: 1px solid rgba(255,255,255,0.06);
}

.scan-item-info { flex: 1; min-width: 0; }
.scan-item-code { font-family: monospace; font-size: 0.95rem; }
.scan-item-name { color: var(--text-muted); font-size: 0.85rem; }

.scan-item-amount {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.scan-item-amount input {
  width: 3.5rem;
  padding: 0.5rem;
  font-size: 1rem;
  text-align: center;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}

.scan-item-amount button {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: rgba(234,93,93,0.2);
  color: var(--danger);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

/* Review-Liste (gleiche Struktur wie scan-list) */
.review-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-bottom: 1rem;
}

/* Footer mit festem Button */
.page-footer {
  margin-top: auto;
  padding-top: 1rem;
}

/* Bestand */
.bestand-summary {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.bestand-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  border: 1px solid rgba(255,255,255,0.06);
}

/* 1:1 Bild-Bereich: max. 48px, Bild passt sich an */
.bestand-img-wrap {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(255,255,255,0.05);
}

.bestand-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  aspect-ratio: 1;
}

.bestand-img-placeholder {
  width: 100%;
  height: 100%;
  display: block;
  background: rgba(255,255,255,0.08);
}

.bestand-item .scan-item-info {
  flex: 1;
  min-width: 0;
}

.bestand-item .scan-item-name {
  color: var(--text);
  font-size: 0.95rem;
}

.bestand-item .scan-item-code {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 0.15rem;
}

.bestand-menge {
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--accent);
  min-width: 2.5rem;
  text-align: right;
}

.bestand-btn-delete {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border: none;
  border-radius: 8px;
  background: rgba(234,93,93,0.2);
  color: var(--danger);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.bestand-btn-delete:active {
  background: rgba(234,93,93,0.35);
}
