/* ===========================================================================
   Kundenformular — Mobile First

   Bewusst eigenes CSS statt Tailwind-CDN oder Google Fonts: die Seite sagt
   dem Nutzer DSGVO-Konformität zu. Ein Font- oder CSS-Request an einen
   Drittanbieter überträgt seine IP-Adresse dorthin und macht die Zusage
   unwahr. Alles hier wird vom eigenen Server ausgeliefert.

   Optik nachgebaut nach der bewährten Vorgängerversion: große 16:9-Kacheln
   mit Icon in der Mitte, die nach dem Hochladen vom Bild ausgefüllt werden.
   =========================================================================== */

:root {
  --primary:   #061F40;
  --secondary: #F2F2F2;
  --accent:    #F25C05;
  --text:      #0D0D0D;
  --muted:     #6B7280;
  --border:    #E5E7EB;
  --field-bg:  #F9FAFB;
  --warn-bg:   #FEF3C7;
  --warn-bd:   #F59E0B;
  --ok:        #059669;
  --error:     #D1271B;
  --radius:    12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--secondary);
  line-height: 1.5;
  /* Kein Bounce beim Scrollen — fühlt sich mehr nach App an */
  overscroll-behavior-y: none;
  /* Verhindert das automatische Zoomen von iOS beim Fokus auf ein Feld */
  -webkit-text-size-adjust: 100%;
}

.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px 96px; }

/* --- Kopf ---------------------------------------------------------------- */
header {
  background: var(--primary);
  color: #fff;
  padding: 24px 16px;
  text-align: center;
}
header img { max-height: 48px; margin-bottom: 12px; }
header h1 { font-size: 1.5rem; margin: 0 0 10px; line-height: 1.25; }
header p  { margin: 3px 0; font-size: 0.875rem; opacity: .9; }

/* Der B2B-Hinweis ist kein Beiwerk: Privatkunden sollen gar nicht erst
   anfragen. Deshalb in der Signalfarbe statt in dezentem Weiß-transparent. */
.b2b-hint {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 14px;
  padding: 6px 14px;
  background: var(--accent);
  color: var(--primary);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}
.b2b-hint svg { width: 15px; height: 15px; flex: none; }

/* --- Karten -------------------------------------------------------------- */
.card {
  background: #fff;
  border-radius: var(--radius);
  padding: 22px 18px;
  margin-bottom: 16px;
}
.card h2 { font-size: 1.15rem; margin: 0 0 6px; }
.card .sub { color: var(--muted); font-size: 0.9rem; margin: 0 0 18px; line-height: 1.5; }

.req { color: var(--accent); }
.opt { font-weight: 400; color: var(--muted); }
hr { border: none; border-top: 1px solid var(--border); margin: 22px 0; }

/* --- Einzel- / Verbundanfrage -------------------------------------------- */
.mode-switch {
  display: flex;
  gap: 4px;
  background: #E5E7EB;
  border-radius: var(--radius);
  padding: 4px;
  margin: 20px 0 16px;
}
.mode-switch button {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 0.92rem; font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all .2s;
}
.mode-switch button.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
}

/* ===========================================================================
   Foto-Kacheln

   Icon und Beschriftung liegen INNERHALB der Kachel. Nach dem Hochladen legt
   sich das Bild als Hintergrund über die volle Fläche — der Kunde sieht sofort,
   was er hochgeladen hat, ohne dass darunter eine zweite Reihe Miniaturbilder
   entsteht.
   =========================================================================== */

.photo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  /* Luft zu den Feldern darunter — Kachel und Eingabefeld dürfen nicht
     aneinanderkleben, sonst wirkt die Karte gedrängt. */
  margin-bottom: 24px;
}
.photo-grid .wide { grid-column: 1 / -1; }
/* Das letzte Raster schließt die Karte ab — deren Innenabstand genügt */
.card > .photo-grid:last-child { margin-bottom: 0; }

.tile {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 2px dashed var(--primary);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px;
  font-family: inherit;
  transition: background .2s;
}
.tile:active { background: #F3F4F6; }

/* Obenansicht, Seiten und Zusatzbilder sind quadratisch — vier davon ergeben
   ein ruhiges 2×2-Raster unter dem breiten Typenschild. */
.tile.small { aspect-ratio: 1 / 1; }

.tile svg {
  width: 30px; height: 30px;
  color: var(--accent);
  flex: none;
}
.tile .tile-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
  text-align: center;
  line-height: 1.25;
}
.tile .tile-hint {
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.3;
  padding: 0 4px;
}

/* Das hochgeladene Bild füllt die Kachel vollständig aus */
.tile .preview {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  border-radius: 10px;
}
.tile.filled { border-style: solid; border-color: var(--border); }
.tile.filled svg,
.tile.filled .tile-label,
.tile.filled .tile-hint { display: none; }

/* Beschriftung über dem Bild, damit erkennbar bleibt, was es zeigt */
.tile.filled .preview::after {
  content: attr(data-label);
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 6px 10px;
  background: linear-gradient(transparent, rgba(6,31,64,.85));
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 0 0 10px 10px;
}

/* Pflichtfeld ohne Bild */
.tile.required-missing { border-color: var(--warn-bd); background: var(--warn-bg); }

.tile .delete-btn {
  position: absolute;
  top: 8px; right: 8px;
  width: 32px; height: 32px;
  border: none; border-radius: 50%;
  background: var(--error);
  color: #fff;
  font-size: 15px; line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
  z-index: 2;
}

.tile .uploading {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(6,31,64,.6);
  color: #fff;
  font-size: 0.8rem; font-weight: 600;
  border-radius: 10px;
  z-index: 3;
}

/* ===========================================================================
   Eingabefelder
   =========================================================================== */

.grid { display: grid; grid-template-columns: 1fr; gap: 14px; margin-bottom: 14px; }

/* Zwei Spalten auch auf dem Handy — die Werte sind kurz, und paarweise
   nebeneinander (Spannung/Kapazität, Gewicht/Baujahr) wirkt das Formular
   deutlich aufgeräumter als eine lange Kolonne. */
.grid.two { grid-template-columns: 1fr 1fr; }

/* Firma braucht Platz, die PLZ nicht */
.grid.company-zip { grid-template-columns: 2fr 1fr; }

.field label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--field-bg);
  color: var(--text);
  /* 16px verhindert, dass iOS beim Fokus in das Feld hineinzoomt */
  font-size: 16px;
  font-family: inherit;
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary);
  background: #fff;
  outline: none;
  box-shadow: 0 0 0 3px rgba(6,31,64,.1);
}
.field textarea { resize: vertical; }

/* Gelb = von der Erkennung nicht sicher gelesen. Das Lastenheft verlangt,
   dass solche Felder sichtbar zur Prüfung auffordern. */
.field.uncertain input, .field.uncertain select {
  background: var(--warn-bg);
  border-color: var(--warn-bd);
}
.field .flag {
  display: none;
  font-size: 0.75rem;
  color: #92400E;
  margin-top: 4px;
}
.field.uncertain .flag { display: block; }

/* Kurz grün aufblitzen, wo gerade automatisch etwas eingetragen wurde —
   der sichtbare Beleg, dass die Erkennung etwas getan hat. */
@keyframes filled {
  0%   { background: #D1FAE5; border-color: var(--ok); }
  100% { background: var(--field-bg); border-color: var(--border); }
}
.field.just-filled input,
.field.just-filled select { animation: filled 1.8s ease-out; }
@media (prefers-reduced-motion: reduce) {
  .field.just-filled input,
  .field.just-filled select { animation: none; }
}

/* --- Reiter bei Verbundanfrage ------------------------------------------- */
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs.sticky-tabs {
  position: sticky; top: 0; z-index: 20;
  background: var(--secondary);
  padding: 10px 0; margin: 0 0 12px;
}
.tab {
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  font-size: 0.88rem; font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.add-battery {
  width: 100%;
  padding: 15px;
  margin-bottom: 16px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--primary);
  font-size: 0.95rem; font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

/* Überleitung zu den weiteren Bildern, innerhalb derselben Karte */
.more-photos {
  margin: 24px 0 12px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

/* Meldung der Erkennung — steht zwischen Typenschild und Feldern. Den Abstand
   liefern bereits .photo-grid oben und .msg unten; hier nur leicht zurück-
   nehmen, damit die Meldung nicht in der Luft hängt. */
#analyzeBox:not(:empty) { margin-top: -10px; }

/* Der Rückruf-Kasten hebt sich ab, damit klar ist: das Telefonfeld gehört
   zur Checkbox darüber und erscheint nur mit ihr. */
.callback-box {
  margin-top: 4px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.callback-box .check { margin-bottom: 0; }
.callback-box .field { margin-top: 12px; }

.how-link { text-align: center; margin: 16px 0 0; }
.how-link button {
  background: none; border: none;
  padding: 6px;
  color: var(--primary);
  font-family: inherit; font-size: 0.9rem;
  text-decoration: underline;
  cursor: pointer;
}

/* --- Checkboxen ---------------------------------------------------------- */
.check {
  display: flex; gap: 12px;
  align-items: flex-start;
  margin-bottom: 16px;
  font-size: 0.88rem;
  line-height: 1.5;
}
.check input {
  width: 22px; height: 22px;
  flex: none; margin-top: 1px;
  accent-color: var(--primary);
  border-radius: 4px;
}
.check a { color: var(--primary); }

/* Werbe- und Rechtshinweise kleiner als die Bedienelemente — sie müssen
   lesbar sein, sollen aber nicht mit dem Formular um Aufmerksamkeit ringen.
   Gilt nicht für „Bitte um Rückruf": das ist eine Auswahl, kein Kleingedrucktes. */
.check.legal {
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--muted);
  margin-bottom: 12px;
}
.check.legal input { width: 20px; height: 20px; }

/* Honeypot: für Menschen unsichtbar, für Bots ein verlockendes Feld.
   Kein display:none — manche Bots ignorieren das gezielt. */
.hp {
  position: absolute !important;
  left: -9999px !important;
  width: 1px; height: 1px;
  overflow: hidden;
}

/* --- Buttons ------------------------------------------------------------- */
button.primary, button.secondary {
  padding: 15px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem; font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform .1s, background .2s;
}
button.primary   { background: var(--accent); color: #fff; box-shadow: 0 4px 12px rgba(242,92,5,.25); }
button.primary:active { transform: scale(.97); }
button.secondary { background: #fff; color: var(--primary); border: 1px solid var(--border); }
button:disabled  { opacity: .5; cursor: not-allowed; box-shadow: none; }

button.submit { width: 100%; margin-top: 22px; padding: 17px; font-size: 1.05rem; }

/* --- Meldungen ----------------------------------------------------------- */
.msg {
  padding: 13px 15px;
  border-radius: 10px;
  margin-bottom: 14px;
  font-size: 0.9rem;
  line-height: 1.5;
}
.msg.error { background: #FEE2E2; color: #991B1B; }
.msg.info  { background: #DBEAFE; color: #1E40AF; }
.msg.warn  { background: var(--warn-bg); color: #92400E; }

.spinner {
  width: 22px; height: 22px; flex: none;
  border: 3px solid #BFDBFE;
  border-top-color: #2563EB;
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* ===========================================================================
   Overlays

   Schließen ausschließlich über die Schaltflächen — kein Klick daneben, kein
   Escape. Sonst gehen Eingaben verloren, wenn jemand versehentlich danebentippt.
   =========================================================================== */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(6,31,64,.94);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.overlay.hidden { display: none; }
.overlay-inner { text-align: center; color: #fff; max-width: 440px; }
.overlay-inner.box {
  background: #fff; color: var(--text);
  border-radius: var(--radius);
  padding: 28px 22px;
  text-align: left;
}
.overlay-inner h2, .overlay-inner h3 { margin: 16px 0 8px; }
.overlay-inner p { margin: 8px 0; line-height: 1.55; }

.spinner.big {
  width: 48px; height: 48px;
  border-width: 4px;
  border-color: rgba(255,255,255,.3);
  border-top-color: #fff;
  margin: 0 auto;
}

.warn-icon {
  width: 46px; height: 46px;
  border-radius: 50%;
  background: var(--warn-bg);
  color: #92400E;
  font-size: 1.7rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}
.warn-seen {
  font-size: 0.87rem;
  color: var(--muted);
  background: var(--secondary);
  border-radius: 8px;
  padding: 11px 13px;
}
.warn-question { font-weight: 600; margin-top: 16px !important; }

.overlay-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; }
.overlay-actions button { width: 100%; }
@media (min-width: 480px) { .overlay-actions { flex-direction: row-reverse; } }
.overlay-actions.single { flex-direction: column; }

/* --- Ablauf in vier Schritten -------------------------------------------- */
.overlay-inner.how {
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}
.overlay-inner.how h3 { margin: 0 0 18px; font-size: 1.15rem; }

.steps { list-style: none; margin: 0; padding: 0; }
.steps li {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 16px;
}
.steps strong {
  display: block;
  font-size: 0.95rem;
  margin-bottom: 2px;
}
.steps div {
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--muted);
}

.step-icon {
  flex: none;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(242,92,5,.12);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.step-icon svg { width: 20px; height: 20px; }

.how-note {
  margin: 4px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--muted);
}

.done-icon {
  width: 76px; height: 76px;
  border-radius: 50%;
  background: var(--ok);
  color: #fff;
  font-size: 2.5rem;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto;
}
.overlay.done .number {
  display: inline-block;
  margin-top: 18px; padding: 11px 22px;
  background: rgba(255,255,255,.15);
  border-radius: 8px;
  font-weight: 700; letter-spacing: .5px;
}
.overlay.done button { margin-top: 24px; }

.hidden { display: none !important; }

footer {
  text-align: center;
  padding: 24px 16px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}
