/* ==============================================================
   JUFINA – KBG Funnel Web App
   Clean, conversion-optimiert, mobile-first
============================================================== */

:root {
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-soft: rgba(37, 99, 235, 0.08);
  --color-success: #16a34a;
  --color-success-soft: rgba(22, 163, 74, 0.10);
  --color-danger: #dc2626;
  --color-danger-soft: #fef2f2;
  --color-text: #111827;
  --color-text-soft: #4b5563;
  --color-text-muted: #6b7280;
  --color-border: #e5e7eb;
  --color-border-input: #d1d5db;
  --color-bg: #f3f4f6;
  --color-card: #ffffff;
  --radius-card: 16px;
  --radius-input: 10px;
  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== Header ===== */
.app-header {
  background: #fff;
  border-bottom: 1px solid var(--color-border);
}
.app-header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 20px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.app-logo {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--color-text);
}
.app-logo img { height: 44px; width: auto; display: block; }

/* ===== Main Layout ===== */
.app-main {
  flex: 1 0 auto;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

/* ===== Intro ===== */
.intro { text-align: center; margin: 4px 0 20px; }
.intro h1 { font-size: 26px; font-weight: 700; margin-bottom: 6px; }
.intro p { font-size: 15px; color: var(--color-text-soft); }

/* ===== Progress ===== */
.progress-wrapper { max-width: 560px; margin: 0 auto 24px; }
.progress {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}
.progress-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  flex: 0 0 auto;
  cursor: default;
  -webkit-tap-highlight-color: transparent;
}
.progress-step.is-clickable { cursor: pointer; }
.progress-step.is-clickable:hover .progress-circle {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.18);
}
.progress-circle {
  width: 34px; height: 34px;
  border-radius: 999px;
  border: 2px solid #d0d5dd;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600;
  background: #fff; color: #667085;
  transition: transform 0.15s ease, box-shadow 0.15s ease,
              background-color 0.15s ease, border-color 0.15s ease;
}
.progress-label {
  margin-top: 6px;
  font-size: 13px;
  color: #667085;
  white-space: nowrap;
}
.progress-line {
  flex: 1 1 auto;
  height: 2px;
  background: #d0d5dd;
  margin: 17px 10px 0;
  min-width: 24px;
  max-width: 90px;
  transition: background-color 0.2s ease;
}
.progress-line.is-completed { background: var(--color-success); }

.progress-step.is-active .progress-circle {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: #fff;
}
.progress-step.is-active .progress-label { font-weight: 600; color: var(--color-text); }
.progress-step.is-completed .progress-circle {
  border-color: var(--color-success);
  background: var(--color-success);
  color: #fff;
}
.progress-step.is-completed .progress-label { font-weight: 500; color: #15803d; }

.progress-caption {
  margin-top: 12px;
  font-size: 13px;
  color: #9ca3af;
  text-align: center;
}

/* ===== Cards ===== */
.card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 28px;
}
.card-center { text-align: center; padding: 48px 28px; }
.card-head { margin-bottom: 20px; }
.card-head h2, .card h2 { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.card-head p { font-size: 14px; color: var(--color-text-soft); }

.step { animation: step-in 0.28s ease; }
@keyframes step-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== Loading / Error ===== */
.spinner {
  width: 36px; height: 36px;
  margin: 0 auto 16px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 14px; color: var(--color-text-muted); }

.error-icon {
  width: 48px; height: 48px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--color-danger-soft);
  color: var(--color-danger);
  font-size: 26px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
#screen-error p { font-size: 14px; color: var(--color-text-soft); margin-top: 8px; }

/* ===== Formulare ===== */
.form-row { margin-bottom: 16px; }
.form-row label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #374151;
}
.input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-input);
  border: 1px solid var(--color-border-input);
  font-size: 15px;
  font-family: inherit;
  color: var(--color-text);
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.input.input-error {
  border-color: var(--color-danger) !important;
  background-color: var(--color-danger-soft);
}
.input.input-error::placeholder { color: #b91c1c; }

.field-help { margin-top: 5px; font-size: 12px; color: var(--color-text-muted); }
.field-error {
  margin-top: 5px;
  font-size: 12px;
  color: var(--color-danger);
  display: none;
  line-height: 1.3;
}

.status-text {
  margin: 10px 0 0;
  font-size: 13px;
  font-weight: 500;
  color: #b91c1c;
  min-height: 0;
}
.status-text.is-info { color: var(--color-primary); }
.status-text.is-success { color: var(--color-success); }

/* ===== Buttons ===== */
.btn-primary, .btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}
.btn-primary {
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.35);
}
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-secondary { background: #e5e7eb; color: var(--color-text); }
.btn-secondary:hover { background: #d1d5db; }
.btn-secondary:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary:active, .btn-secondary:active { transform: translateY(1px); box-shadow: none; }
.btn-block { width: 100%; }

.actions-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 20px;
}
.actions-row .btn-primary { flex: 2 1 auto; }
.actions-row .btn-secondary { flex: 1 1 auto; }

.link-btn {
  background: none;
  border: none;
  color: var(--color-primary);
  padding: 0;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
}
.link-btn:hover { color: var(--color-primary-hover); }

/* ===== PDF-Vorschau ===== */
.pdf-preview-wrapper {
  margin: 0 0 20px;
  padding: 10px;
  border-radius: 12px;
  background: #f9fafb;
  border: 1px solid var(--color-border);
  overflow: auto;
  max-height: 72vh;
  position: relative;
}
.pdf-loading {
  font-size: 13px;
  color: var(--color-text-muted);
  text-align: center;
  padding: 40px 0;
}
#vollmacht-canvas { width: 100%; height: auto; display: block; }

/* ===== Vollmacht: Daten-Toggle ===== */
.sign-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  margin-bottom: 18px;
  border-radius: 10px;
  background: var(--color-success-soft);
  border: 1px solid rgba(22, 163, 74, 0.25);
}
.sign-toggle-hint { font-size: 13px; font-weight: 500; color: #15803d; }

/* ===== Signatur-Pad ===== */
.sign-pad-block { margin-top: 20px; }
.pad-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #374151;
}
.signature-pad-wrapper {
  width: 100%;
  height: 180px;
  border-radius: var(--radius-input);
  border: 1px dashed var(--color-border-input);
  background: #fff;
  overflow: hidden;
  touch-action: none;
}
#signature-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

/* ===== Kreditvertrag ===== */
.benefit-list {
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
}
.benefit-list li {
  position: relative;
  padding-left: 26px;
  font-size: 14px;
  color: var(--color-text-soft);
  margin-bottom: 8px;
}
.benefit-list li::before {
  content: "✓";
  position: absolute;
  left: 0; top: 0;
  color: var(--color-success);
  font-weight: 700;
}

#scan-status-overlay {
  position: fixed;
  left: 12px; bottom: 12px;
  z-index: 9999;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font: 14px/1.3 var(--font);
  max-width: 85vw;
  display: none;
}

/* ===== Abschluss ===== */
.card-done { text-align: center; padding: 40px 28px; }
.done-icon { margin-bottom: 16px; }
.done-icon-circle {
  stroke: var(--color-success);
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  animation: done-stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}
.done-icon-check {
  stroke: var(--color-success);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: done-stroke 0.35s cubic-bezier(0.65, 0, 0.45, 1) 0.55s forwards;
}
@keyframes done-stroke { to { stroke-dashoffset: 0; } }

.card-done h2 { font-size: 24px; margin-bottom: 8px; }
#done-lead { font-size: 15px; color: var(--color-text-soft); margin-bottom: 18px; }

.done-summary {
  list-style: none;
  margin: 0 auto 20px;
  padding: 0;
  max-width: 420px;
  text-align: left;
}
.done-summary li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 8px;
  border-radius: 10px;
  background: var(--color-success-soft);
  border: 1px solid rgba(22, 163, 74, 0.2);
  font-size: 14px;
  color: #166534;
}
.done-summary li.is-skipped {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}
.done-summary li .mark { font-weight: 700; flex: 0 0 auto; }
.done-note { font-size: 13px; color: var(--color-text-muted); }

/* ===== Footer ===== */
.legal-footer {
  flex-shrink: 0;
  text-align: center;
  padding: 20px 12px 28px;
  border-top: 1px solid var(--color-border);
  background: #f9fafb;
}
.legal-footer-inner {
  max-width: 900px;
  margin: 0 auto;
  font-size: 13px;
  line-height: 1.5;
  color: var(--color-text-muted);
}
.legal-footer-inner p { margin: 0 0 4px; }
.legal-footer-inner a { color: inherit; text-decoration: underline; }

/* ===== Dev-Panel ===== */
#dev-panel {
  position: fixed;
  right: 12px; bottom: 12px;
  z-index: 10000;
  font-family: var(--font);
}
#dev-panel-toggle {
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  background: #111827;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.3);
}
#dev-panel-body {
  position: absolute;
  right: 0; bottom: 44px;
  width: 320px;
  max-width: calc(100vw - 24px);
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.2);
  padding: 16px;
}
#dev-panel-body h3 { font-size: 14px; margin-bottom: 6px; }
.dev-note { font-size: 12px; color: var(--color-text-muted); margin-bottom: 6px; }
.dev-deal { font-size: 12px; color: var(--color-text-soft); margin-bottom: 10px; }
.dev-deal code { background: var(--color-bg); padding: 1px 6px; border-radius: 6px; }
.dev-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12.5px;
  color: var(--color-text-soft);
  margin-bottom: 8px;
  cursor: pointer;
}
.dev-check input { margin-top: 2px; }
.dev-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.dev-actions .btn-primary, .dev-actions .btn-secondary {
  min-height: 38px;
  padding: 8px 14px;
  font-size: 13px;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .app-main { padding: 16px 12px 40px; }
  .app-header-inner { padding: 12px 16px; }
  .app-logo { font-size: 19px; }
  .app-logo img { height: 36px; }
  .intro h1 { font-size: 22px; }
  .intro p { font-size: 14px; }
  .card { padding: 20px 16px; border-radius: 14px; }
  .card-center, .card-done { padding: 32px 20px; }
  .input { font-size: 16px; }  /* verhindert iOS-Zoom */
  .progress-circle { width: 32px; height: 32px; font-size: 13px; }
  .progress-label { font-size: 11.5px; }
  .progress-line { margin-top: 16px; min-width: 12px; }
  .signature-pad-wrapper { height: 150px; }
  .pdf-preview-wrapper { max-height: 64vh; }
  .actions-row { flex-direction: column-reverse; }
  .actions-row .btn-primary, .actions-row .btn-secondary { width: 100%; }
}
