/* =====================================================================
   ZAUNTURA — Layout & Steuerung der 3D-Konfigurator-Seite (Konfigurator.html)
   Eigenständig; nutzt die Design-Tokens aus styles.css. Responsive:
   Desktop = 3D-Viewport + Steuer-Panel nebeneinander,
   Mobil   = 3D oben (feste Höhe) + Steuerung darunter scrollbar.
   ===================================================================== */

.kfg {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
}

/* ---- Kopfzeile -------------------------------------------------------- */
.kfg-top {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px clamp(14px, 4vw, 24px);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.kfg-top .back { color: var(--text-dim); text-decoration: none; font-size: 14px; white-space: nowrap; }
.kfg-top .back:hover { color: var(--text); }
.kfg-top .mid { display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-weight: 600; letter-spacing: .03em; }
.kfg-top .mid .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.kfg-top .lang { margin-left: auto; display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-pill); overflow: hidden; }
.kfg-top .lang button { border: 0; background: transparent; padding: 5px 12px; font-family: var(--font-display); font-size: 12px; font-weight: 600; color: var(--text-dim); cursor: pointer; }
.kfg-top .lang button.on { background: var(--accent); color: var(--accent-ink); }
.kfg-top .save { color: var(--text-dim); font-size: 12px; white-space: nowrap; }

/* ---- Hauptbereich ----------------------------------------------------- */
.kfg-main { flex: 1 1 auto; min-height: 0; display: flex; }

/* 3D-Viewport */
.kfg-view {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% 8%, #ffffff 0%, var(--bg) 55%, var(--bg-deep) 100%);
}
#kfg-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* Viewport-Overlays */
.vp-badge {
  position: absolute; top: 14px; left: 14px;
  display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px;
  font-family: var(--font-display); font-size: 12px; color: var(--text-dim);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--line); border-radius: var(--r-pill); padding: 6px 12px;
  backdrop-filter: blur(6px); pointer-events: none;
}
.vp-badge span + span::before { content: "·"; margin-right: 4px; color: var(--text-dim); opacity: .55; }
.vp-dims {
  position: absolute; top: 14px; right: 14px;
  font-size: 13px; color: var(--text); font-variant-numeric: tabular-nums;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px;
  backdrop-filter: blur(6px); pointer-events: none;
}
.vp-dims b { font-family: var(--font-display); }
.vp-hint {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-dim); pointer-events: none; white-space: nowrap;
}
.vp-actions { position: absolute; right: 14px; bottom: 14px; display: flex; gap: 8px; }
.vp-fallback { display: none; }
.kfg-view.no3d #kfg-canvas, .kfg-view.no3d .vp-hint, .kfg-view.no3d .vp-actions { display: none; }
.kfg-view.no3d .vp-fallback {
  display: flex; flex-direction: column; gap: 8px; align-items: center; justify-content: center;
  position: absolute; inset: 0; text-align: center; padding: 24px; color: var(--text-dim);
}

/* ---- Steuer-Panel ----------------------------------------------------- */
.kfg-panel {
  flex: 0 0 384px;
  display: flex; flex-direction: column; min-height: 0;
  border-left: 1px solid var(--line); background: var(--surface);
}
.kfg-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 22px; }
.kfg-h { margin: 0; font-family: var(--font-display); font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.kfg-sub { margin: 4px 0 0; color: var(--text-dim); font-size: 14px; }

.fld { display: flex; flex-direction: column; gap: 10px; }
.fld .lbl { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.fld .lbl .k { font-family: var(--font-display); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); }
.fld .lbl .v { font-size: 13px; color: var(--text); font-variant-numeric: tabular-nums; }

/* Segment-Buttons (Typ / Füllung) */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.seg button {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 6px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--text); font-family: var(--font-body);
  font-size: 12.5px; line-height: 1.1; cursor: pointer; transition: border-color .15s, background .15s, box-shadow .15s;
}
.seg.text { grid-template-columns: repeat(2, 1fr); }
.seg.text button { padding: 11px 10px; }
.seg button .ig svg { width: 30px; height: 22px; color: var(--steel); }
.seg button:hover { border-color: var(--accent); }
.seg button.on { border-color: var(--accent); background: rgba(var(--accent-glow), .12); box-shadow: inset 0 0 0 1px var(--accent); }
.seg button.on .ig svg { color: var(--text); }

/* Material */
.mats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mats button { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.mats button .sw { width: 22px; height: 22px; border-radius: 6px; flex: 0 0 auto; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.mats button .nm { font-size: 13px; }
.mats button:hover { border-color: var(--accent); }
.mats button.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

/* RAL-Farbfelder */
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches button { width: 30px; height: 30px; border-radius: 8px; border: 2px solid transparent; padding: 0; cursor: pointer; transition: transform .12s, box-shadow .12s; }
.swatches button:hover { transform: translateY(-2px); }
.swatches button.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }

/* Schieberegler */
.rng { -webkit-appearance: none; appearance: none; width: 100%; height: 4px; border-radius: 99px; background: var(--line); outline: none; }
.rng::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.rng::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); cursor: pointer; }

/* Automatik-Schalter */
.tgl { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tgl .tt { font-weight: 600; font-size: 14px; }
.tgl .ts { color: var(--text-dim); font-size: 12px; }
#autoTgl { position: relative; width: 46px; height: 26px; border: 0; border-radius: 99px; background: var(--line); cursor: pointer; transition: background .2s; flex: 0 0 auto; }
#autoTgl::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: left .2s; }
#autoTgl.on { background: var(--teal); }
#autoTgl.on::after { left: 23px; }

/* Fuß: Preis + CTA */
.kfg-foot { flex: 0 0 auto; border-top: 1px solid var(--line); background: var(--surface); padding: 16px 24px; }
.kfg-foot .kfg-price { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.kfg-price .pl { color: var(--text-dim); font-size: 13px; }
.kfg-price .pv { font-family: var(--font-display); font-weight: 600; font-size: 20px; font-variant-numeric: tabular-nums; }
.kfg-foot .btn { width: 100%; justify-content: center; }
.kfg-foot .note { margin: 8px 0 0; color: var(--text-dim); font-size: 11px; text-align: center; }

/* ---- Anfrage-Modal ---------------------------------------------------- */
/* Basis-Overlay: standardmäßig versteckt, sichtbar via .open (von der UI-JS). */
.modal { position: fixed; inset: 0; z-index: 1000; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal.open { display: flex; }
.modal-bg { position: absolute; inset: 0; background: rgba(10, 12, 14, .55); backdrop-filter: blur(3px); }
.modal-card {
  position: relative; z-index: 1; width: 100%; max-width: 460px; max-height: 90dvh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
  padding: 26px 24px; box-shadow: 0 24px 64px rgba(0, 0, 0, .32);
}
.modal-card h3 { margin: 0 0 6px; font-family: var(--font-display); font-size: 20px; font-weight: 600; }
.modal-card .lead { margin: 0; color: var(--text-dim); font-size: 14px; line-height: 1.55; }
.mx {
  position: absolute; top: 12px; right: 12px; width: 34px; height: 34px;
  border: 0; border-radius: 50%; background: var(--surface-2); color: var(--text-dim);
  font-size: 15px; line-height: 1; cursor: pointer;
}
.mx:hover { color: var(--text); background: var(--line); }
#sendBtn { width: 100%; justify-content: center; }
.modal-ok { text-align: center; padding: 8px 0 4px; }
.modal-ok .ck { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 50%; background: var(--teal); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 28px; }

.modal .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0; }
.modal .fin { display: flex; flex-direction: column; gap: 5px; }
.modal .fin.full { grid-column: 1 / -1; }
.modal .fin label { font-family: var(--font-display); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); }
.modal .fin input { height: 44px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 0 12px; font-size: 16px; color: var(--text); }
.modal .fin input:focus { outline: none; border-color: var(--accent); }
.modal .spec { display: grid; gap: 6px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); font-size: 13px; }
.modal .spec .row { display: flex; justify-content: space-between; gap: 12px; }
.modal .spec .row .k { color: var(--text-dim); }
.modal .spec .row .v { font-weight: 600; text-align: right; }

/* =====================================================================
   Mobil: 3D oben mit fester Höhe, Steuerung darunter scrollbar
   ===================================================================== */
@media (max-width: 820px) {
  .kfg-main { flex-direction: column; }
  .kfg-view { flex: 0 0 44vh; height: 44vh; }
  .kfg-panel { flex: 1 1 auto; border-left: 0; border-top: 1px solid var(--line); }
  .kfg-top .save { display: none; }
  .kfg-scroll { padding: 16px; gap: 18px; }

  /* Footer kompakt: Preis + CTA in einer Zeile, Rechtshinweis raus. */
  .kfg-foot { display: flex; align-items: center; gap: 12px; padding: 10px 14px; }
  .kfg-foot .kfg-price { flex: 0 0 auto; flex-direction: column; align-items: flex-start; gap: 0; margin: 0; }
  .kfg-price .pl { font-size: 10px; line-height: 1.2; }
  .kfg-price .pv { font-size: 17px; }
  .kfg-foot .btn { width: auto; flex: 1 1 auto; min-width: 0; padding: 11px 14px; font-size: 14px; white-space: nowrap; }
  .kfg-foot .note { display: none; }

  .vp-hint { display: none; }
  .vp-badge, .vp-dims { font-size: 11px; padding: 5px 9px; }
  .modal .form-grid { grid-template-columns: 1fr; }

  /* Aktionsleiste verdeckt sonst zu viel der kleinen 3D-Vorschau:
     kompakte „Tor öffnen"-Pille + „Zurücksetzen" nur als Icon. */
  .vp-actions { right: 10px; bottom: 10px; gap: 6px; }
  .vp-actions .btn { padding: 7px 12px; font-size: 12px; line-height: 1; }
  #resetBtn { width: 34px; height: 34px; padding: 0; font-size: 0; }
  #resetBtn::before { content: "\21BA"; font-size: 17px; line-height: 1; }
}

@media (max-width: 380px) {
  .seg { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .seg button { padding: 10px 4px; font-size: 11.5px; }
}
