/* =======================================================================
   GEFÜHRTER CHATBOT – Styling
   Angeglichen an das Design-System der Website (Lenzen & Stolz):
   - Farben: Dunkelblau #0D1522 / #090F19, Akzent Terrakotta #AB5532
   - Typografie: Inter (Sans), Newsreader (Serif/Logo), JetBrains Mono (Labels)
   - Formsprache: scharfe Kanten, 1px-Linien, keine Glow-/Cyber-Effekte
   Eigenständiger Namespace #cbx-* damit nichts mit der Seite kollidiert.
   ======================================================================= */

#cbx-root {
  --cbx-bg: #0D1522;
  --cbx-bg2: #090F19;
  --cbx-bubble-bot: #0F1826;
  --cbx-line: #213045;
  --cbx-accent: #AB5532;
  --cbx-accent-soft: #C9785A;
  --cbx-text: #FFFFFF;
  --cbx-muted: #8FA1B6;
  --cbx-muted2: #7487A1;
  --cbx-body: #B4C4D6;
  --cbx-font: 'Inter', 'Helvetica Neue', system-ui, sans-serif;
  --cbx-serif: 'Newsreader', Georgia, serif;
  --cbx-mono: 'JetBrains Mono', 'Courier New', monospace;
  font-family: var(--cbx-font);
}

#cbx-root *,
#cbx-root *::before,
#cbx-root *::after { box-sizing: border-box; }

/* ---------- Launcher (Button unten rechts) ---------- */
#cbx-launcher {
  position: fixed; right: 26px; bottom: 26px; z-index: 95;
  width: 60px; height: 60px; border-radius: 2px; cursor: pointer;
  background: var(--cbx-bg);
  border: 1px solid var(--cbx-accent);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 20px rgba(171, 85, 50, 0.45), 0 8px 24px rgba(9, 15, 25, 0.4);
  transition: box-shadow .3s, opacity .25s;
  padding: 11px;
  animation: cbx-float 4s ease-in-out infinite;
}
#cbx-launcher:hover {
  box-shadow: 0 0 30px rgba(171, 85, 50, 0.7), 0 10px 28px rgba(9, 15, 25, 0.45);
  animation-play-state: paused;
}
@keyframes cbx-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}
#cbx-launcher.cbx-hidden { opacity: 0; pointer-events: none; transform: scale(.9); }
.cbx-launcher-pulse { display: none; }

/* ---------- Panel ---------- */
#cbx-panel {
  position: fixed; right: 26px; bottom: 26px; z-index: 95;
  width: 380px; max-width: calc(100vw - 32px);
  height: 600px; max-height: calc(100vh - 52px);
  border-radius: 2px; overflow: hidden;
  background: linear-gradient(170deg, var(--cbx-bg) 0%, var(--cbx-bg2) 100%);
  border: 1px solid var(--cbx-line);
  box-shadow: 0 30px 80px rgba(0,0,0,.5);
  display: flex; flex-direction: column;
  opacity: 0; transform: translateY(16px);
  pointer-events: none;
  transition: opacity .35s ease, transform .4s cubic-bezier(.16,1,.3,1);
}
#cbx-panel.cbx-open { opacity: 1; transform: translateY(0); pointer-events: auto; }

/* Akzentlinie oben – analog zur 3px-Linie im Seitenkopf */
#cbx-panel::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--cbx-accent); z-index: 3; pointer-events: none;
}

/* ---------- Header ---------- */
#cbx-header {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 16px 14px; position: relative;
  border-bottom: 1px solid var(--cbx-line);
  background: var(--cbx-bg);
}
.cbx-orb {
  width: 38px; height: 38px; border-radius: 2px; flex: 0 0 auto;
  background: var(--cbx-bubble-bot);
  border: 1px solid var(--cbx-line);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.cbx-title {
  color: var(--cbx-text); font-family: var(--cbx-serif);
  font-weight: 500; font-size: 18px; letter-spacing: -0.01em; line-height: 1;
}
.cbx-status {
  color: var(--cbx-muted2); font-family: var(--cbx-mono);
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.15em;
  display: flex; align-items: center; gap: 6px; margin-top: 5px;
}
.cbx-dot { width: 6px; height: 6px; border-radius: 50%; background: #34d399; }
#cbx-close {
  margin-left: auto; background: transparent; border: none; color: var(--cbx-muted);
  font-size: 24px; line-height: 1; cursor: pointer; transition: color .2s;
}
#cbx-close:hover { color: var(--cbx-text); }

/* ---------- Fortschrittsleiste ---------- */
#cbx-progress { height: 2px; background: rgba(255,255,255,.06); position: relative; z-index: 2; }
#cbx-progress-bar {
  height: 100%; width: 0%;
  background: var(--cbx-accent);
  transition: width .5s cubic-bezier(.16,1,.3,1);
}

/* ---------- Nachrichtenbereich ---------- */
#cbx-messages {
  flex: 1; overflow-y: auto; padding: 18px 16px 8px;
  display: flex; flex-direction: column; gap: 12px; position: relative; z-index: 2;
  scrollbar-width: thin; scrollbar-color: var(--cbx-line) transparent;
}
#cbx-messages::-webkit-scrollbar { width: 6px; }
#cbx-messages::-webkit-scrollbar-thumb { background: var(--cbx-line); }

.cbx-msg { display: flex; align-items: flex-end; gap: 8px; max-width: 100%; }
.cbx-msg.cbx-user { flex-direction: row-reverse; }
.cbx-avatar {
  width: 26px; height: 26px; border-radius: 2px; flex: 0 0 auto;
  background: var(--cbx-bubble-bot);
  border: 1px solid var(--cbx-line); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  padding: 2px;
}

/* ---------- Sokrates-Icon (Bild) ---------- */
.cbx-socrates { display: block; line-height: 0; }
.cbx-soc-img { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; }
.cbx-socrates-lg { width: 38px; height: 38px; }
.cbx-socrates-sm { width: 30px; height: 30px; }
.cbx-socrates-xs { width: 100%; height: 100%; }

/* beim Tippen pulsiert das Logo im Header dezent */
.cbx-thinking .cbx-socrates-sm { animation: cbx-soc-nod 1.2s ease-in-out infinite; }
@keyframes cbx-soc-nod {
  0%,100% { transform: scale(1); }
  50%     { transform: scale(1.08); }
}

.cbx-bubble {
  padding: 11px 14px; border-radius: 2px; font-size: 14px; line-height: 1.55;
  font-weight: 300;
  max-width: 270px; word-wrap: break-word; white-space: pre-wrap;
}
.cbx-bot .cbx-bubble {
  background: var(--cbx-bubble-bot); color: var(--cbx-body);
  border: 1px solid var(--cbx-line);
}
.cbx-user .cbx-bubble {
  background: var(--cbx-accent); color: #fff; font-weight: 400;
}

/* Einfade-Animation */
.cbx-in { animation: cbx-msg-in .4s cubic-bezier(.16,1,.3,1) both; }
@keyframes cbx-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Typing-Indikator */
.cbx-typing .cbx-bubble { display: flex; gap: 4px; align-items: center; padding: 14px; }
.cbx-typing i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--cbx-accent);
  display: inline-block; opacity: .5; animation: cbx-typing 1.2s infinite;
}
.cbx-typing i:nth-child(2) { animation-delay: .15s; }
.cbx-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes cbx-typing { 0%,60%,100%{transform:translateY(0);opacity:.45;} 30%{transform:translateY(-4px);opacity:1;} }

/* ---------- Eingabebereich ---------- */
#cbx-input-area { padding: 0 16px 12px; position: relative; z-index: 2; }
.cbx-options { display: flex; flex-direction: column; gap: 8px; }
.cbx-opt {
  text-align: left; padding: 12px 14px; border-radius: 2px; cursor: pointer;
  background: transparent; color: var(--cbx-body);
  border: 1px solid var(--cbx-line); font-size: 13.5px; font-weight: 300;
  font-family: inherit;
  transition: all .25s ease; position: relative; overflow: hidden;
  animation: cbx-opt-in .4s ease both;
}
@keyframes cbx-opt-in { from{opacity:0;transform:translateY(6px);} to{opacity:1;transform:translateY(0);} }
.cbx-opt::after {
  content: "→"; position: absolute; right: 14px; top: 50%; transform: translateY(-50%) translateX(6px);
  opacity: 0; color: var(--cbx-accent); transition: all .25s ease;
}
.cbx-opt:hover {
  border-color: var(--cbx-accent); color: var(--cbx-text);
  background: rgba(255,255,255,.02);
  padding-right: 32px;
}
.cbx-opt:hover::after { opacity: 1; transform: translateY(-50%) translateX(0); }

/* ---------- Lead-Formular ---------- */
.cbx-lead { display: flex; flex-direction: column; gap: 9px; animation: cbx-msg-in .4s ease both; }
.cbx-field {
  padding: 11px 13px; border-radius: 2px; font-size: 13.5px; font-weight: 300;
  font-family: inherit;
  background: rgba(255,255,255,.03); color: var(--cbx-text);
  border: 1px solid var(--cbx-line); transition: border-color .2s;
}
.cbx-field::placeholder { color: var(--cbx-muted2); }
.cbx-field:focus { outline: none; border-color: var(--cbx-accent); }
.cbx-consent { display: flex; gap: 8px; font-size: 11px; color: var(--cbx-muted); line-height: 1.5; align-items: flex-start; font-weight: 300; }
.cbx-consent input { margin-top: 2px; accent-color: var(--cbx-accent); }
.cbx-consent a { color: var(--cbx-accent-soft); }
.cbx-send {
  margin-top: 2px; padding: 13px; border-radius: 2px; cursor: pointer;
  background: var(--cbx-accent); color: #fff;
  border: 1px solid var(--cbx-accent);
  font-size: 11px; font-weight: 500; font-family: inherit;
  text-transform: uppercase; letter-spacing: 0.1em;
  transition: background .25s, border-color .25s;
}
.cbx-send:hover { background: #94492B; border-color: #94492B; }
.cbx-error { color: #fca5a5; font-size: 12px; min-height: 14px; font-weight: 300; }
.cbx-done {
  text-align: center; color: #34d399; font-weight: 500; font-size: 13px;
  padding: 10px; animation: cbx-msg-in .4s ease both;
}

/* ---------- Footer ---------- */
#cbx-footer {
  padding: 10px 16px; font-family: var(--cbx-mono);
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--cbx-muted2);
  text-align: center; border-top: 1px solid var(--cbx-line);
  background: var(--cbx-bg); position: relative; z-index: 2;
}
#cbx-footer a { color: var(--cbx-muted); text-decoration: underline; }
#cbx-footer a:hover { color: var(--cbx-text); }
.cbx-credit { margin-top: 3px; font-size: 8.5px; opacity: 0.6; }
.cbx-credit a { color: var(--cbx-muted); text-decoration: none; }
.cbx-credit a:hover { text-decoration: underline; }

/* ---------- Mobile ---------- */
@media (max-width: 460px) {
  #cbx-panel { right: 8px; bottom: 8px; height: calc(100vh - 16px); width: calc(100vw - 16px); }
  #cbx-launcher { right: 16px; bottom: 16px; }
}
