/*
 * BlueStone Chat-Assistent
 * Übernimmt die Design-Tokens des BlueStone-Themes (--c-accent usw.),
 * bringt aber für jeden Wert einen identischen Rückfall mit, damit der
 * Chat auch unter jedem anderen Theme korrekt aussieht.
 */

.bschat {
  --bs-accent: var(--c-accent, #0057B8);
  --bs-accent-dark: var(--c-accent-dark, #00448C);
  --bs-dark: var(--c-dark, #061426);
  --bs-text: var(--c-text, #182432);
  --bs-muted: var(--c-muted, #5A6675);
  --bs-line: var(--c-line, #E4E9F0);
  --bs-soft: var(--c-bg-soft, #F5F7FA);
  --bs-tint: var(--c-tint, #EAF2FB);
  --bs-white: #fff;
  --bs-radius: var(--radius, 14px);
  --bs-radius-sm: var(--radius-sm, 10px);
  --bs-font: var(--f-body, 'Inter', 'Helvetica Neue', Arial, sans-serif);
  --bs-font-head: var(--f-head, 'Montserrat', 'Helvetica Neue', Arial, sans-serif);
  --bs-shadow: 0 18px 48px rgba(6, 20, 38, .18);

  position: fixed;
  z-index: 99990;
  bottom: 20px;
  font-family: var(--bs-font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--bs-text);
}

.bschat.is-right { right: 20px; }
.bschat.is-left  { left: 20px; }

.bschat *,
.bschat *::before,
.bschat *::after { box-sizing: border-box; }

.bschat .screen-reader-text {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------- Launcher */

.bschat__launcher {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 13px 20px 13px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--bs-accent);
  color: var(--bs-white);
  font-family: var(--bs-font-head);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--bs-shadow);
  transition: background .18s ease, transform .18s ease;
}

.bschat__launcher:hover { background: var(--bs-accent-dark); transform: translateY(-1px); }
.bschat__launcher:focus-visible { outline: 3px solid var(--bs-accent); outline-offset: 3px; }

.bschat__launcher-icon { display: inline-flex; }

.bschat.is-open .bschat__launcher { display: none; }

@media (max-width: 560px) {
  .bschat__launcher { padding: 14px; }
  .bschat__launcher-text { display: none; }
}

/* ------------------------------------------------------------- Panel */

.bschat__panel {
  display: flex;
  flex-direction: column;
  width: min(400px, calc(100vw - 32px));
  height: min(620px, calc(100vh - 120px));
  background: var(--bs-white);
  border-radius: var(--bs-radius);
  box-shadow: var(--bs-shadow);
  overflow: hidden;
  animation: bschat-in .22s ease both;
}

.bschat__panel[hidden] { display: none; }

@keyframes bschat-in {
  from { opacity: 0; transform: translateY(14px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .bschat__panel { animation: none; }
  .bschat__launcher { transition: none; }
}

@media (max-width: 560px) {
  .bschat { bottom: 12px; }
  .bschat.is-right { right: 12px; }
  .bschat.is-left  { left: 12px; }
  .bschat__panel {
    width: calc(100vw - 24px);
    height: min(78vh, calc(100vh - 90px));
  }
}

/* -------------------------------------------------------------- Kopf */

.bschat__head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 12px 14px 16px;
  background: var(--bs-dark);
  color: var(--bs-white);
  flex: 0 0 auto;
}

.bschat__avatar {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--bs-accent);
  font-family: var(--bs-font-head);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .5px;
}

.bschat__ident { display: flex; flex-direction: column; margin-right: auto; }
.bschat__ident strong { font-family: var(--bs-font-head); font-size: 15px; font-weight: 700; }

.bschat__status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  opacity: .8;
}

.bschat__status::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #4ADE80;
}

.bschat__icon-btn {
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: currentColor;
  cursor: pointer;
  opacity: .75;
  transition: opacity .15s ease, background .15s ease;
}

.bschat__icon-btn:hover { opacity: 1; background: rgba(255, 255, 255, .12); }
.bschat__icon-btn:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

/* ---------------------------------------------------------- Verlauf */

.bschat__log {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 16px 6px;
  background: var(--bs-soft);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bschat__msg {
  max-width: 88%;
  padding: 11px 14px;
  border-radius: var(--bs-radius-sm);
  animation: bschat-msg .2s ease both;
}

@keyframes bschat-msg {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .bschat__msg { animation: none; }
}

.bschat__msg--bot {
  align-self: flex-start;
  background: var(--bs-white);
  border: 1px solid var(--bs-line);
  border-bottom-left-radius: 4px;
}

.bschat__msg--user {
  align-self: flex-end;
  background: var(--bs-accent);
  color: var(--bs-white);
  border-bottom-right-radius: 4px;
}

.bschat__msg p { margin: 0 0 8px; }
.bschat__msg p:last-child { margin-bottom: 0; }
.bschat__msg a { color: inherit; text-decoration: underline; }
.bschat__msg--bot a { color: var(--bs-accent); font-weight: 600; }

.bschat__msg ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.bschat__msg li { margin-bottom: 4px; }

/* Tippanzeige */

.bschat__typing {
  display: inline-flex;
  gap: 4px;
  padding: 4px 0;
}

.bschat__typing span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--bs-muted);
  animation: bschat-blink 1.2s infinite ease-in-out;
}

.bschat__typing span:nth-child(2) { animation-delay: .18s; }
.bschat__typing span:nth-child(3) { animation-delay: .36s; }

@keyframes bschat-blink {
  0%, 60%, 100% { opacity: .25; transform: translateY(0); }
  30%           { opacity: 1;   transform: translateY(-3px); }
}

/* ------------------------------------------------- Preisschätzung */

.bschat__quote {
  margin-top: 6px;
  border-top: 1px solid var(--bs-line);
  padding-top: 10px;
}

.bschat__quote-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  padding: 3px 0;
}

.bschat__quote-row span:last-child { white-space: nowrap; font-variant-numeric: tabular-nums; }
.bschat__quote-row--off { color: var(--bs-accent); font-weight: 600; }

.bschat__quote-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--bs-line);
  font-family: var(--bs-font-head);
  font-weight: 800;
}

.bschat__quote-total strong { font-size: 21px; color: var(--bs-accent); white-space: nowrap; }
.bschat__quote-note { margin-top: 8px; font-size: 12.5px; color: var(--bs-muted); }

/* ------------------------------------------------------- Aktionen */

.bschat__actions {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bs-soft);
  border-top: 1px solid var(--bs-line);
  max-height: 46vh;
  overflow-y: auto;
}

.bschat__actions:empty { display: none; }

.bschat__chip {
  padding: 9px 14px;
  border: 1px solid var(--bs-accent);
  border-radius: 999px;
  background: var(--bs-white);
  color: var(--bs-accent);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}

.bschat__chip:hover { background: var(--bs-accent); color: var(--bs-white); }
.bschat__chip:focus-visible { outline: 2px solid var(--bs-accent); outline-offset: 2px; }

.bschat__chip--ghost { border-color: var(--bs-line); color: var(--bs-muted); }
.bschat__chip--ghost:hover { background: var(--bs-muted); border-color: var(--bs-muted); color: var(--bs-white); }

.bschat__chip--solid { background: var(--bs-accent); color: var(--bs-white); }
.bschat__chip--solid:hover { background: var(--bs-accent-dark); border-color: var(--bs-accent-dark); }

.bschat__chip--full { width: 100%; text-align: center; }

.bschat__chip--rich {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-radius: var(--bs-radius-sm);
  padding: 11px 14px;
}

.bschat__chip--rich small { font-weight: 400; font-size: 12.5px; opacity: .75; }

/* Mehrfachauswahl */

.bschat__multi {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.bschat__check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 13px;
  border: 1px solid var(--bs-line);
  border-radius: var(--bs-radius-sm);
  background: var(--bs-white);
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}

.bschat__check:hover { border-color: var(--bs-accent); }
.bschat__check:has(input:checked) { border-color: var(--bs-accent); background: var(--bs-tint); }
.bschat__check:focus-within { outline: 2px solid var(--bs-accent); outline-offset: 2px; }

.bschat__check input { margin: 3px 0 0; accent-color: var(--bs-accent); flex: 0 0 auto; }
.bschat__check span { display: flex; flex-direction: column; gap: 1px; font-size: 14px; }
.bschat__check b { font-weight: 600; }
.bschat__check small { color: var(--bs-muted); font-size: 12.5px; }

/* Formularfelder im Aktionsbereich */

.bschat__field {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.bschat__field label { font-size: 13px; font-weight: 600; color: var(--bs-muted); }

.bschat__field input,
.bschat__field textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--bs-line);
  border-radius: var(--bs-radius-sm);
  background: var(--bs-white);
  font-family: inherit;
  font-size: 15px;
  color: var(--bs-text);
}

.bschat__field input:focus,
.bschat__field textarea:focus {
  outline: 0;
  border-color: var(--bs-accent);
  box-shadow: 0 0 0 3px rgba(0, 87, 184, .14);
}

.bschat__field textarea { resize: vertical; min-height: 68px; }

.bschat__consent {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  width: 100%;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--bs-muted);
  cursor: pointer;
}

.bschat__consent input { margin: 2px 0 0; accent-color: var(--bs-accent); flex: 0 0 auto; }
.bschat__consent a { color: var(--bs-accent); }

.bschat__error {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--bs-radius-sm);
  background: #FDECEC;
  border: 1px solid #F5C2C2;
  color: #9B1C1C;
  font-size: 13.5px;
}

/* Honeypot – nur für Bots sichtbar */
.bschat__hp {
  position: absolute !important;
  left: -9999px;
  opacity: 0;
  height: 0;
  width: 0;
  overflow: hidden;
}

/* ------------------------------------------------------- Eingabe */

.bschat__composer {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 12px 16px 14px;
  background: var(--bs-white);
  border-top: 1px solid var(--bs-line);
}

.bschat__composer input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 11px 14px;
  border: 1px solid var(--bs-line);
  border-radius: 999px;
  background: var(--bs-soft);
  font-family: inherit;
  font-size: 15px;
  color: var(--bs-text);
}

.bschat__composer input:focus {
  outline: 0;
  border-color: var(--bs-accent);
  background: var(--bs-white);
  box-shadow: 0 0 0 3px rgba(0, 87, 184, .14);
}

.bschat__send {
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 50%;
  background: var(--bs-accent);
  color: var(--bs-white);
  cursor: pointer;
  transition: background .15s ease;
}

.bschat__send:hover { background: var(--bs-accent-dark); }
.bschat__send:focus-visible { outline: 3px solid var(--bs-accent); outline-offset: 2px; }
.bschat__send[disabled] { opacity: .5; cursor: default; }
