/* =============================================================
   app.css – Velutina Meldung PWA
   Mobile-First, iOS-optimiert
   ============================================================= */

/* ── Reset & Custom Properties ─────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Sicherstellen, dass [hidden] immer gewinnt gegen display:flex/block etc. */
[hidden] { display: none !important; }

:root {
  --orange:       #e8a000;
  --orange-dark:  #c47e00;
  --orange-light: #fff3cd;
  --bg:           #f4f6f0;
  --card-bg:      #ffffff;
  --text:         #212529;
  --text-muted:   #6c757d;
  --border:       #dee2e6;
  --radius:       12px;
  --radius-sm:    8px;
  --shadow:       0 2px 12px rgba(0,0,0,.08);
  --red:          #dc3545;
  --green:        #28a745;

  /* iOS safe areas */
  --safe-top:    env(safe-area-inset-top,    0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left,   0px);
  --safe-right:  env(safe-area-inset-right,  0px);
}

html {
  -webkit-text-size-adjust: 100%; /* iOS: kein Auto-Zoom */
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100dvh;          /* dvh: Dynamic Viewport Height */
  padding-bottom: calc(24px + var(--safe-bottom));
}

/* ── App-Shell ───────────────────────────────────────────────── */
#app {
  max-width: 520px;
  margin: 0 auto;
}

/* ── Header ──────────────────────────────────────────────────── */
.app-header {
  background: linear-gradient(135deg, var(--orange) 0%, var(--orange-dark) 100%);
  color: #fff;
  padding: calc(16px + var(--safe-top)) 20px 20px;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 520px;
  margin: 0 auto;
}

.header-icon {
  font-size: 36px;
  line-height: 1;
}

.header-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: .3px;
}

.header-sub {
  font-size: 13px;
  opacity: .85;
  margin-top: 2px;
}

/* ── Main Content ────────────────────────────────────────────── */
.main-content {
  padding: 16px 12px;
}

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 16px;
  margin-bottom: 14px;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--orange-dark);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--orange-light);
}

.required { color: var(--red); }

.hint {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
  margin-top: -6px;
}

/* ── Felder ──────────────────────────────────────────────────── */
.field {
  margin-bottom: 14px;
}
.field:last-child { margin-bottom: 0; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
  letter-spacing: .2px;
}

/* Alle Inputs + Selects: font-size 16px verhindert iOS Auto-Zoom */
input[type="text"],
input[type="tel"],
input[type="email"],
input[type="number"],
input[type="date"],
select,
textarea {
  display: block;
  width: 100%;
  font-size: 16px;           /* iOS: kein Zoom-Bug */
  font-family: inherit;
  color: var(--text);
  background: #fafafa;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  line-height: 1.4;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color .15s, box-shadow .15s;
  /* Touch-Action: kein 300ms Delay */
  touch-action: manipulation;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(232,160,0,.2);
  background: #fff;
}

input.field-error,
select.field-error {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(220,53,69,.15);
}

.field-error-msg {
  font-size: 12px;
  color: var(--red);
  margin-top: 4px;
}

/* Datum – Extra-Padding, damit iOS-Kalendericon nicht überlappt */
input[type="date"] {
  padding-right: 36px;
}

/* ── Select-Wrapper (Pfeil-Icon) ─────────────────────────────── */
.select-wrapper {
  position: relative;
}
.select-wrapper::after {
  content: '▾';
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-muted);
  font-size: 14px;
}
.select-wrapper select {
  padding-right: 36px;
}

/* ── Fundort: Entweder-Oder-Blöcke ──────────────────────────── */
.location-block {
  transition: opacity .2s, filter .2s;
}
.location-block.disabled {
  opacity: .4;
  pointer-events: none;
  filter: grayscale(0.4);
  user-select: none;
}
.location-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.location-block-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-light);
  letter-spacing: .01em;
}
.btn-reset-location {
  background: none;
  border: 1.5px solid #dc3545;
  color: #dc3545;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: background .15s, color .15s;
  touch-action: manipulation;
}
.btn-reset-location:active {
  background: #dc3545;
  color: #fff;
}
.location-or-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 14px 0;
  color: #aaa;
  font-size: 13px;
  font-weight: 600;
}
.location-or-divider::before,
.location-or-divider::after {
  content: '';
  flex: 1;
  border-top: 1px solid #e0e0e0;
}
.location-or-divider span {
  padding: 0 10px;
}

/* ── Geolocation-Button ──────────────────────────────────────── */
.btn-geo {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--orange-light);
  color: #856404;
  border: 1.5px solid #ffc107;
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  margin-bottom: 14px;
  transition: background .15s;
}
.btn-geo:active {
  background: #ffe69c;
}
.btn-geo.loading {
  opacity: .7;
  pointer-events: none;
}
.btn-icon {
  font-size: 18px;
}

/* Geo-Status-Banner */
.geo-status {
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 12px;
}
.geo-status.success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}
.geo-status.error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

/* ── PLZ-Prüfungs-Hinweis ────────────────────────────────────── */
.plz-hint {
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  margin-top: 6px;
}
.plz-hint.success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}
.plz-hint.warn {
  background: #fff3cd;
  color: #664d03;
  border: 1px solid #ffc107;
}
.plz-hint.info {
  background: #cfe2ff;
  color: #084298;
  border: 1px solid #b6d4fe;
}

/* ── Ort-Dropdown (PLZ mit mehreren Orten) ───────────────────── */
.ort-dropdown {
  width: 100%;
  padding: 10px 12px;
  font-size: 16px;
  border: 1.5px solid #ffc107;
  border-radius: var(--radius-sm);
  background: #fffbf0;
  color: var(--text);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23856404' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  margin-top: 4px;
}

/* ── Pflicht-Legende ─────────────────────────────────────────── */
.pflicht-legende {
  font-size: 13px;
  color: var(--text-light);
  margin: -8px 0 8px;
  padding: 0 4px;
}
.pflicht-legende .required { color: var(--red); font-weight: 700; }

/* ── Sicherheitshinweis ──────────────────────────────────────── */
.safety-hint {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: #fff3cd;
  border: 2px solid #ffc107;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.safety-hint-icon {
  font-size: 22px;
  flex-shrink: 0;
  margin-top: 1px;
}
.safety-hint p {
  font-size: 14px;
  line-height: 1.55;
  color: #664d03;
  margin: 0;
}
.safety-hint strong {
  color: #5c3d00;
}

/* ── Info-Button ─────────────────────────────────────────────── */
.btn-info-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 16px 20px;
  margin-bottom: 16px;
  background: var(--orange-light);
  border: 2px solid var(--orange);
  border-radius: var(--radius);
  color: var(--orange-dark);
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: background .15s, box-shadow .15s;
}
.btn-info-link:active {
  background: #fde9a0;
  box-shadow: none;
}
.btn-info-icon {
  font-size: 22px;
  flex-shrink: 0;
}

/* ── Foto-Upload ─────────────────────────────────────────────── */
.file-input-hidden {
  position: absolute;
  left: -9999px;
  opacity: 0;
}

.foto-slot {
  margin-bottom: 12px;
}
.foto-slot:last-of-type { margin-bottom: 0; }

.upload-label {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f0f4ff;
  border: 2px dashed #99b4f0;
  border-radius: var(--radius-sm);
  padding: 18px 16px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  color: #3a5fb0;
  margin-bottom: 10px;
  touch-action: manipulation;
  transition: background .15s;
}
.upload-label-optional {
  background: #f8f9fa;
  border-color: var(--border);
  color: var(--text-light);
  font-weight: 500;
}
.upload-label:active,
.upload-label-optional:active {
  background: #dce8ff;
}
.upload-icon { font-size: 22px; }

.foto-preview {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  display: block;
  margin-bottom: 8px;
}

.btn-remove {
  background: none;
  border: none;
  color: var(--red);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
  touch-action: manipulation;
}

/* ── Submit-Button ───────────────────────────────────────────── */
.submit-area {
  padding: 0 0 8px;
}

.sponsor-note {
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}
.sponsor-note a {
  color: var(--orange-dark);
  font-weight: 600;
  text-decoration: none;
}
.sponsor-note a:hover { text-decoration: underline; }

.sponsor-logo {
  height: 28px;
  width: auto;
  vertical-align: middle;
  margin: 0 2px;
  display: inline-block;
}

.impressum-note {
  margin-top: 8px;
  font-size: 13px;
  text-align: center;
}
.impressum-note a {
  color: var(--text-muted);
  text-decoration: underline;
}

.btn-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  background: var(--orange);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 16px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .3px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background .15s, transform .1s;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.btn-submit:active {
  background: var(--orange-dark);
  transform: scale(.98);
}
.btn-submit:disabled {
  opacity: .65;
  pointer-events: none;
}

/* Spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 14px;
  margin-bottom: 14px;
}
.alert-error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

/* ── Danke-Overlay ───────────────────────────────────────────── */
.overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
  padding-bottom: calc(24px + var(--safe-bottom));
}

.overlay-card {
  background: #fff;
  border-radius: 20px;
  padding: 36px 28px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,.2);
  animation: popIn .3s cubic-bezier(.34,1.56,.64,1);
}
@keyframes popIn {
  from { opacity: 0; transform: scale(.85); }
  to   { opacity: 1; transform: scale(1); }
}

.overlay-icon {
  font-size: 54px;
  margin-bottom: 12px;
}
.overlay-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}
.overlay-text {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 24px;
}
.overlay-text strong { color: var(--text); }

/* ── Upload-Overlay ──────────────────────────────────────────── */
.upload-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(0,0,0,.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  padding: 24px;
}

.upload-overlay-card {
  background: #fff;
  border-radius: 20px;
  padding: 40px 32px;
  max-width: 340px;
  width: 100%;
  text-align: center;
  box-shadow: 0 10px 50px rgba(0,0,0,.3);
}

.upload-overlay-spinner {
  width: 52px;
  height: 52px;
  border: 5px solid rgba(90,150,50,.2);
  border-top-color: var(--green, #5a9632);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto 20px;
}

.upload-overlay-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px;
}

.upload-overlay-sub {
  font-size: 14px;
  color: var(--text-muted, #666);
  margin: 0;
  min-height: 1.4em;
}

/* ── Offline-Banner ──────────────────────────────────────────── */
.offline-banner {
  position: fixed;
  bottom: calc(0px + var(--safe-bottom));
  left: 0;
  right: 0;
  background: #343a40;
  color: #fff;
  text-align: center;
  padding: 12px 16px;
  font-size: 13px;
  z-index: 500;
}

/* ── Responsiv: größere Bildschirme / Tablets ─────────────────── */
@media (min-width: 480px) {
  .main-content { padding: 20px 20px; }
  .card { padding: 24px 20px; }
  .header-title { font-size: 26px; }
}

/* ════════════════════════════════════════════════════════════════
   KI-Scan – Styles
   ════════════════════════════════════════════════════════════════ */

/* ── KI-Scan-Button ──────────────────────────────────────────── */
.btn-ai-scan {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(135deg, #1a6b3a 0%, #0d4a28 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 15px 16px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .2px;
  cursor: pointer;
  touch-action: manipulation;
  margin-bottom: 16px;
  transition: opacity .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn-ai-scan:active { opacity: .82; }
.btn-ai-scan .btn-icon { font-size: 20px; }

/* ── AI-Scan-Modal (Bottom-Sheet auf Mobil) ──────────────────── */
.ai-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .80);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1200;
  padding: 0;
}
@media (min-width: 520px) {
  .ai-modal { align-items: center; padding: 20px; }
}

.ai-modal-inner {
  background: #fff;
  border-radius: 24px 24px 0 0;
  padding: 18px 16px calc(20px + var(--safe-bottom));
  width: 100%;
  max-width: 520px;
  max-height: 92dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
}
@media (min-width: 520px) {
  .ai-modal-inner {
    border-radius: 20px;
    padding-bottom: 20px;
  }
}

/* Modal-Handle (visueller Griff) */
.ai-modal-inner::before {
  content: '';
  display: block;
  width: 36px;
  height: 4px;
  background: #d1d5db;
  border-radius: 2px;
  margin: 0 auto 16px;
}
@media (min-width: 520px) {
  .ai-modal-inner::before { display: none; }
}

/* ── Modal-Header ────────────────────────────────────────────── */
.ai-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.ai-modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.ai-modal-close {
  background: #f0f0f0;
  border: none;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.ai-modal-close:active { background: #ddd; }

/* ── Kamera-Fenster ──────────────────────────────────────────── */
.ai-camera-wrap {
  position: relative;
  width: 100%;
  /* quadratisches Seitenverhältnis */
  aspect-ratio: 1 / 1;
  background: #111;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 14px;
}
.ai-camera-wrap video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Fadenkreuz-Rahmen */
.ai-viewfinder {
  position: absolute;
  inset: 14%;
  border: 2px solid rgba(255, 255, 255, .55);
  border-radius: 10px;
  pointer-events: none;
}
/* Eck-Markierungen */
.ai-viewfinder::before,
.ai-viewfinder::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  border-style: solid;
  border-color: #fff;
}
.ai-viewfinder::before {
  top: -2px; left: -2px;
  border-width: 3px 0 0 3px;
  border-radius: 5px 0 0 0;
}
.ai-viewfinder::after {
  bottom: -2px; right: -2px;
  border-width: 0 3px 3px 0;
  border-radius: 0 0 5px 0;
}

/* Pulsierender Scan-Indikator */
.ai-scan-indicator {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 10px;
  height: 10px;
  background: #ef4444;
  border-radius: 50%;
  animation: ai-pulse 1.2s ease-in-out infinite;
}
@keyframes ai-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .4; transform: scale(.7); }
}

/* ── Ergebnis-Bereich ────────────────────────────────────────── */
.ai-result {
  margin-bottom: 12px;
  text-align: center;
}

.ai-result-label {
  font-size: 16px;
  font-weight: 700;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: #f4f6f0;
  color: var(--text);
  margin-bottom: 8px;
  transition: background .25s, color .25s;
  line-height: 1.35;
}
.ai-result-label.ai-velutina {
  background: #fde8e8;
  color: #b91c1c;
}
.ai-result-label.ai-crabro {
  background: #dcfce7;
  color: #166534;
}
.ai-result-label.ai-other {
  background: #fef9c3;
  color: #854d0e;
}
.ai-result-label.ai-low {
  background: #f1f5f9;
  color: #64748b;
}

/* Konfidenz-Balken */
.ai-confidence-bar-wrap {
  height: 10px;
  background: #e9ecef;
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 6px;
}
.ai-confidence-bar {
  height: 100%;
  border-radius: 5px;
  transition: width .35s ease, background .35s ease;
  min-width: 4px;
}

.ai-result-sub {
  font-size: 13px;
  color: var(--text-muted);
  min-height: 1.4em;
}

/* ── Modell-Hinweis (wenn Modell fehlt) ──────────────────────── */
.ai-model-hint {
  background: #fffbeb;
  border: 1.5px solid #f59e0b;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 13px;
  color: #78350f;
  line-height: 1.55;
}
.ai-model-hint strong { color: #92400e; }
.ai-model-hint ol {
  margin: 6px 0 0 16px;
  padding: 0;
}
.ai-model-hint ol li { margin-bottom: 3px; }
.ai-model-hint a { color: #92400e; }

/* ── Aktions-Buttons ─────────────────────────────────────────── */
.ai-action-btns {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  background: #6c757d;
  color: #fff;
  border: none;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-appearance: none;
  appearance: none;
  transition: background .15s;
  box-sizing: border-box;
}
.btn-secondary:active { background: #5a6268; }

/* ── Disclaimer ──────────────────────────────────────────────── */
.ai-disclaimer {
  font-size: 11.5px;
  color: #9ca3af;
  text-align: center;
  margin-top: 8px;
  font-style: italic;
  line-height: 1.5;
}
