/* ============================================================
   TrueLabel v6 — style.css
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg:    #0d1f14; --bg2: #122a1b; --bg3: #163025;
  --gold:  #e8b86d; --goldd: #c49a4d;
  --text:  #f0ede8; --muted: #7fa090;
  --green: #4caf7a; --amber: #e8a03a; --red: #e85050;
  --r: 12px; --rs: 8px;
}
html, body { height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: 'Manrope', system-ui, sans-serif; font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
.gold { color: var(--gold); }

/* SPLASH */
#splash { position: fixed; inset: 0; z-index: 999; background: var(--bg); display: flex; align-items: center; justify-content: center; transition: opacity .5s; }
#splash.fade-out { opacity: 0; pointer-events: none; }
.splash-logo { text-align: center; }
.splash-icon { font-size: 60px; animation: pulse 1.6s ease-in-out infinite; }
#splash h1 { font-size: 34px; font-weight: 800; letter-spacing: -1px; margin: 10px 0 4px; }
#splash h1 span { color: var(--gold); }
#splash p { color: var(--muted); }
@keyframes pulse { 0%,100%{ transform:scale(1); } 50%{ transform:scale(1.1); } }

/* APP */
#app { position: fixed; inset: 0; display: flex; flex-direction: column; max-width: 480px; margin: 0 auto; }
#main-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); background: var(--bg); border-bottom: 1px solid var(--bg3); flex-shrink: 0; }
.logo-text { font-size: 20px; font-weight: 800; }
.icon-btn { background: none; border: none; cursor: pointer; font-size: 20px; padding: 6px 8px; border-radius: 8px; }
.icon-btn:active { background: var(--bg3); }

#tab-bar { display: flex; flex-shrink: 0; background: var(--bg2); border-bottom: 1px solid var(--bg3); }
.tab-btn { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 6px; background: none; border: none; border-bottom: 2px solid transparent; cursor: pointer; color: var(--muted); font-family: inherit; font-size: 11px; font-weight: 600; transition: color .15s, border-color .15s; }
.tab-btn.active { color: var(--gold); border-bottom-color: var(--gold); }
.tab-icon { font-size: 18px; line-height: 1; }

#screens { flex: 1; overflow: hidden; position: relative; }
.screen { position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* ════════════════════════════════════
   SCAN SCREEN
   
   Aufbau:
   #screen-scan (position:absolute, inset:0)
     #qr-reader-host  ← html5-qrcode rendert hier rein
     #scan-ui-overlay ← unser Overlay, per CSS über qr-reader-host gelegt
     #manual-area     ← feste Höhe unten

   qr-reader-host bekommt eine feste Höhe per JS.
   Das Overlay ist position:absolute und zeigt über dem Host.
════════════════════════════════════ */
#screen-scan {
  background: #000;
  /* overflow:hidden wichtig damit html5-qrcode nicht aus dem Rahmen fällt */
  overflow: hidden;
}

/* html5-qrcode rendert hier: Video + Canvas kommen rein */
#qr-reader-host {
  position: relative;
  width: 100%;
  /* Höhe wird per JS gesetzt */
  background: #111;
  overflow: hidden;
}

/* html5-qrcode erzeugt intern einen div mit id="qr-reader-host__scan_region"
   der das Video enthält. Wir stylen es so dass es den Container füllt. */
#qr-reader-host video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  display: block !important;
}

/* Die interne QR-Box (der grüne Rahmen von html5-qrcode) ausblenden —
   wir haben unseren eigenen Rahmen */
#qr-reader-host__scan_region > img,
#qr-reader-host__dashboard,
#qr-reader-host__header_message,
#qr-reader-host__status_span {
  display: none !important;
}

/* Unser Overlay: liegt über dem qr-reader-host */
#scan-ui-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  /* Höhe = gleiche wie qr-reader-host, wird per JS gesetzt */
  z-index: 10;
  pointer-events: none;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px;
  /* Vignette */
  background: linear-gradient(to bottom,
    rgba(0,0,0,0.3) 0%, transparent 18%,
    transparent 80%, rgba(0,0,0,0.3) 100%);
}

/* Scan-Rahmen */
#scan-frame-box {
  position: relative;
  width: min(72vw, 280px);
  height: min(45vw, 170px);
}
.c { position: absolute; width: 24px; height: 24px; border-color: var(--gold); border-style: solid; }
.c.tl { top:0; left:0;  border-width: 3px 0 0 3px; border-radius: 4px 0 0 0; }
.c.tr { top:0; right:0; border-width: 3px 3px 0 0; border-radius: 0 4px 0 0; }
.c.bl { bottom:0; left:0;  border-width: 0 0 3px 3px; border-radius: 0 0 0 4px; }
.c.br { bottom:0; right:0; border-width: 0 3px 3px 0; border-radius: 0 0 4px 0; }
#scan-line {
  position: absolute; left: 4px; right: 4px;
  height: 2px; background: var(--gold);
  box-shadow: 0 0 8px var(--gold);
  animation: scanline 2s ease-in-out infinite;
}
@keyframes scanline { 0%,100%{ top:6%; } 50%{ top:92%; } }

#scan-hint {
  color: rgba(255,255,255,0.92); font-size: 13px; font-weight: 600;
  background: rgba(0,0,0,0.65); padding: 5px 16px; border-radius: 20px;
  max-width: 90%; text-align: center;
}

/* Manual-Area */
#manual-area {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 12px 14px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: var(--bg2);
  border-top: 1px solid var(--bg3);
  z-index: 10;
}
.or-text { text-align: center; color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.manual-row { display: flex; gap: 8px; }
.manual-row input { flex: 1; padding: 10px 12px; background: var(--bg3); border: 1px solid rgba(232,184,109,0.2); border-radius: var(--rs); color: var(--text); font-family: inherit; font-size: 15px; outline: none; }
.manual-row input:focus { border-color: var(--gold); }
.btn-gold { padding: 10px 16px; background: var(--gold); color: var(--bg); font-family: inherit; font-weight: 700; font-size: 14px; border: none; border-radius: var(--rs); cursor: pointer; white-space: nowrap; }
.btn-gold:active { background: var(--goldd); }

/* RESULT */
#screen-result { background: var(--bg); }
#result-placeholder, #result-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; gap: 14px; padding: 24px; color: var(--muted); text-align: center; }
.ph-icon { font-size: 52px; opacity: 0.6; }
.spinner { width: 44px; height: 44px; border: 3px solid var(--bg3); border-top-color: var(--gold); border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#loading-text { color: var(--muted); font-size: 14px; }
#loading-steps { font-size: 12px; color: var(--muted); text-align: center; }
.lstep { padding: 2px 0; }
.lstep.done { color: var(--green); }
.lstep.active { color: var(--gold); }

#product-hero { display: flex; gap: 12px; padding: 14px; background: var(--bg2); border-bottom: 1px solid var(--bg3); }
#product-image { width: 76px; height: 76px; flex-shrink: 0; object-fit: contain; border-radius: var(--rs); background: var(--bg3); }
#product-header-info { flex: 1; min-width: 0; }
#product-name { font-size: 16px; font-weight: 700; line-height: 1.3; }
.brand-text { color: var(--gold); font-size: 13px; margin-top: 3px; }
.barcode-text { color: var(--muted); font-size: 11px; font-family: monospace; }
.cat-badge { display: inline-block; margin-top: 5px; padding: 2px 8px; border-radius: 12px; background: var(--bg3); color: var(--muted); font-size: 11px; }

#truelabel-score-card { margin: 12px; background: var(--bg2); border-radius: var(--r); padding: 14px; border: 1px solid rgba(232,184,109,0.2); }
.score-main { display: flex; gap: 14px; align-items: center; }
.score-ring { position: relative; width: 88px; height: 88px; flex-shrink: 0; }
.score-ring svg { width: 100%; height: 100%; }
.score-number { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 800; color: var(--gold); }
.score-breakdown { flex: 1; display: flex; flex-direction: column; gap: 7px; }
.score-item { display: flex; align-items: center; gap: 6px; }
.score-cat { font-size: 11px; color: var(--muted); width: 66px; flex-shrink: 0; }
.score-bar-wrap { flex: 1; height: 5px; background: var(--bg3); border-radius: 3px; overflow: hidden; }
.score-bar { height: 100%; background: var(--gold); border-radius: 3px; width: 0; transition: width .9s ease; }
.score-val { font-size: 11px; font-weight: 700; width: 18px; text-align: right; }
.score-verdict { margin-top: 10px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--bg3); padding-top: 9px; }

#report-sections { padding: 0 10px 4px; }
.report-section { background: var(--bg2); border-radius: var(--r); margin-bottom: 8px; overflow: hidden; border: 1px solid var(--bg3); }
.sec-hdr { display: flex; align-items: center; justify-content: space-between; padding: 12px 13px; cursor: pointer; }
.sec-hdr:active { background: var(--bg3); }
.sec-title { font-size: 14px; font-weight: 700; }
.sec-chev { color: var(--muted); font-size: 14px; transition: transform .2s; }
.sec-chev.open { transform: rotate(180deg); }
.sec-body { display: none; padding: 0 13px 13px; }
.sec-body.open { display: block; }

.info-row { display: flex; justify-content: space-between; align-items: flex-start; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.05); gap: 10px; }
.info-row:last-child { border-bottom: none; }
.info-lbl { font-size: 12px; color: var(--muted); flex-shrink: 0; min-width: 90px; padding-top: 2px; }
.info-val { font-size: 13px; font-weight: 500; text-align: right; line-height: 1.5; }
.info-val.muted { color: var(--muted); font-style: italic; font-weight: 400; }

.badge { display: inline-flex; align-items: center; gap: 3px; padding: 3px 8px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-green  { background: rgba(76,175,122,0.15);  color: var(--green); }
.badge-orange { background: rgba(232,160,58,0.15);  color: var(--amber); }
.badge-red    { background: rgba(232,80,80,0.15);   color: var(--red); }
.badge-gray   { background: var(--bg3); color: var(--muted); }
.badge-gray-sm { font-size: 11px; padding: 1px 6px; border-radius: 10px; background: var(--bg3); color: var(--muted); font-weight: 500; }

.ai-note { margin-top: 8px; padding: 7px 10px; background: rgba(232,184,109,0.07); border-left: 3px solid rgba(232,184,109,0.35); border-radius: 0 6px 6px 0; font-size: 12px; color: var(--muted); line-height: 1.6; }
.ai-note strong { color: var(--gold); }
.ai-note a { color: var(--gold); }

.source-row { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px 10px 10px; }
.source-tag { padding: 2px 8px; border-radius: 12px; background: var(--bg3); color: var(--muted); font-size: 11px; }
.disclaimer-box { margin: 4px 10px 8px; padding: 9px 11px; background: rgba(255,255,255,0.04); border-radius: var(--rs); font-size: 11px; color: var(--muted); line-height: 1.6; }
.action-row { display: flex; gap: 8px; padding: 0 10px 80px; }
.btn-outline { flex: 1; padding: 11px; background: none; border: 1px solid rgba(232,184,109,0.3); border-radius: var(--rs); color: var(--gold); font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn-outline:active { background: rgba(232,184,109,0.08); }

/* HISTORY */
#screen-history { padding: 10px 10px 80px; }
#history-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; gap: 12px; color: var(--muted); text-align: center; }
#history-list { list-style: none; display: flex; flex-direction: column; gap: 7px; }
.history-item { display: flex; align-items: center; gap: 10px; background: var(--bg2); border-radius: var(--r); padding: 9px 11px; cursor: pointer; border: 1px solid var(--bg3); }
.history-item:active { background: var(--bg3); }
.history-thumb { width: 44px; height: 44px; object-fit: contain; border-radius: var(--rs); background: var(--bg3); flex-shrink: 0; }
.history-info { flex: 1; min-width: 0; }
.history-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-meta { font-size: 11px; color: var(--muted); }
.history-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.history-score { font-size: 16px; font-weight: 800; }
.score-good { color: var(--green); }
.score-mid  { color: var(--amber); }
.score-bad  { color: var(--red); }
.history-del { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; padding: 4px; }

/* MODAL */
.modal { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,0.75); display: flex; align-items: flex-end; }
.modal-content { width: 100%; max-width: 480px; margin: 0 auto; background: var(--bg2); border-radius: var(--r) var(--r) 0 0; max-height: 85vh; overflow-y: auto; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 15px 16px 12px; border-bottom: 1px solid var(--bg3); position: sticky; top: 0; background: var(--bg2); }
.modal-header h3 { font-size: 17px; font-weight: 700; }
.modal-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 14px; }
.setting-group { display: flex; flex-direction: column; gap: 7px; }
.setting-label { font-size: 13px; font-weight: 700; }
.setting-group input[type="password"], .setting-group select { padding: 10px 12px; background: var(--bg3); border: 1px solid rgba(255,255,255,0.1); border-radius: var(--rs); color: var(--text); font-family: inherit; font-size: 14px; outline: none; width: 100%; }
.setting-group input:focus, .setting-group select:focus { border-color: var(--gold); }
.setting-group small { font-size: 11px; color: var(--muted); }
.setting-divider { height: 1px; background: var(--bg3); }
.checkbox-row { display: flex; flex-direction: column; gap: 9px; }
.checkbox-row label { display: flex; align-items: center; gap: 9px; font-size: 13px; cursor: pointer; }
.checkbox-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--gold); }
.btn-danger { padding: 11px; background: rgba(232,80,80,0.12); border: 1px solid rgba(232,80,80,0.4); border-radius: var(--rs); color: var(--red); font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer; width: 100%; }

/* TOAST */
#toast { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); background: var(--bg3); color: var(--text); padding: 9px 18px; border-radius: 20px; font-size: 14px; font-weight: 500; box-shadow: 0 4px 20px rgba(0,0,0,.4); z-index: 300; white-space: nowrap; animation: tin .2s ease; }
@keyframes tin { from { opacity:0; transform: translateX(-50%) translateY(8px); } }
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-thumb { background: var(--bg3); border-radius: 2px; }
