/*
 * Fahrschul-Bot — Frontend
 * Die Farbe wird aus den Plugin-Einstellungen gesetzt (--fsb-akzent).
 * Die Fallback-Werte hier greifen nur, falls das fehlschlägt.
 */

/*
 * WICHTIG: Diese Standardwerte stehen bewusst auf :root und NICHT auf
 * .fsb-panel. Eine Klasse hätte eine höhere Spezifität als :root — die im
 * Backend eingestellte Farbe käme dann nie an. Die Einstellung wird als
 * :root:root ausgegeben und gewinnt damit gegen diesen Block.
 */
:root {
  --fsb-akzent:        #1f4e79;
  --fsb-akzent-dunkel: #16395a;
  --fsb-akzent-hell:   #e8f0f8;
  --fsb-text:          #1a1a1a;
  --fsb-text-leise:    #5f6b76;
  --fsb-flaeche:       #ffffff;
  --fsb-flaeche-leise: #f4f6f8;
  --fsb-rand:          #dde3e9;
  --fsb-fokus:         #ffb400;
}

/* --- Der Button unten rechts ------------------------------------------- */

.fsb-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147483000;
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  padding: 13px 19px;
  border: 0;
  border-radius: 999px;
  background: var(--fsb-akzent);
  color: #fff;
  font: 600 15px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  box-shadow: 0 6px 22px rgba(0, 0, 0, .22);
  cursor: pointer;
  transition: transform .15s, background .15s;
}
.fsb-launcher:hover { background: var(--fsb-akzent-dunkel); transform: translateY(-2px); }
.fsb-launcher:focus-visible { outline: 3px solid var(--fsb-fokus); outline-offset: 3px; }
.fsb-launcher[hidden] { display: none; }

/* --- Button im Fließtext (Shortcode) ----------------------------------- */

.fsb-inline-button {
  display: inline-block;
  padding: 11px 20px;
  border: 0;
  border-radius: 10px;
  background: var(--fsb-akzent, #1f4e79);
  color: #fff;
  font: 600 15px/1.3 inherit;
  cursor: pointer;
}
.fsb-inline-button:hover { background: var(--fsb-akzent-dunkel, #16395a); }

/* --- Das Chatfenster ---------------------------------------------------- */

.fsb-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147483001;
  display: flex;
  flex-direction: column;
  width: 390px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 40px);
  overflow: hidden;
  border: 1px solid var(--fsb-rand);
  border-radius: 16px;
  background: var(--fsb-flaeche);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .26);
  color: var(--fsb-text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.fsb-panel[hidden] { display: none; }
.fsb-panel *, .fsb-panel *::before, .fsb-panel *::after { box-sizing: border-box; }

.fsb-kopf {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 15px 16px;
  background: var(--fsb-akzent);
  color: #fff;
}
.fsb-kopf-text { flex: 1; min-width: 0; }
.fsb-kopf b { display: block; font-size: 16px; }
.fsb-hinweis { display: block; margin-top: 2px; font-size: 12px; opacity: .85; }

.fsb-schliessen {
  flex: none;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
}
.fsb-schliessen:hover { background: rgba(255, 255, 255, .3); }
.fsb-schliessen:focus-visible { outline: 2px solid var(--fsb-fokus); outline-offset: 2px; }

.fsb-verlauf {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--fsb-flaeche-leise);
}

/* --- Nachrichten -------------------------------------------------------- */

.fsb-bot,
.fsb-nutzer {
  max-width: 88%;
  padding: 11px 14px;
  border-radius: 14px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.fsb-bot {
  align-self: flex-start;
  border: 1px solid var(--fsb-rand);
  border-bottom-left-radius: 4px;
  background: var(--fsb-flaeche);
}
.fsb-nutzer {
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  background: var(--fsb-akzent);
  color: #fff;
}
.fsb-bot p { margin: 0 0 8px; }
.fsb-bot p:last-child { margin-bottom: 0; }
.fsb-bot ul, .fsb-bot ol { margin: 8px 0; padding-left: 20px; }
.fsb-bot li { margin-bottom: 5px; }
.fsb-bot a { color: var(--fsb-akzent); font-weight: 600; }
.fsb-bot img { max-width: 100%; height: auto; }

.fsb-titel { display: block; margin-bottom: 6px; font-weight: 700; }
.fsb-fussnote {
  display: block;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--fsb-rand);
  color: var(--fsb-text-leise);
  font-size: 12px;
}

/* --- Auswahl-Buttons ---------------------------------------------------- */

.fsb-optionen {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-self: flex-start;
  max-width: 100%;
}
.fsb-option {
  margin: 0;
  padding: 9px 14px;
  border: 1px solid var(--fsb-akzent);
  border-radius: 999px;
  background: var(--fsb-akzent-hell);
  color: var(--fsb-akzent);
  font: 600 14px/1.3 inherit;
  text-align: left;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.fsb-option:hover { background: var(--fsb-akzent); color: #fff; }
.fsb-option:focus-visible { outline: 3px solid var(--fsb-fokus); outline-offset: 2px; }

/* --- Kontakt-Buttons ---------------------------------------------------- */

.fsb-kontakt { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.fsb-kontakt a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 15px;
  border-radius: 10px;
  background: var(--fsb-akzent);
  color: #fff !important;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.fsb-kontakt a:hover { background: var(--fsb-akzent-dunkel); }

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

.fsb-fuss { border-top: 1px solid var(--fsb-rand); background: var(--fsb-flaeche); }
.fsb-eingabe { display: flex; gap: 8px; margin: 0; padding: 11px; }
.fsb-eingabe input {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 11px 13px;
  border: 1px solid var(--fsb-rand);
  border-radius: 10px;
  background: var(--fsb-flaeche);
  color: inherit;
  font: 15px inherit;
}
.fsb-eingabe input:focus {
  border-color: transparent;
  outline: 2px solid var(--fsb-akzent);
  outline-offset: -1px;
}
.fsb-senden {
  flex: none;
  margin: 0;
  padding: 0 17px;
  border: 0;
  border-radius: 10px;
  background: var(--fsb-akzent);
  color: #fff;
  font: 600 15px inherit;
  cursor: pointer;
}
.fsb-senden:hover { background: var(--fsb-akzent-dunkel); }
.fsb-senden:focus-visible { outline: 3px solid var(--fsb-fokus); outline-offset: 2px; }

.fsb-rechtszeile {
  margin: 0;
  padding: 0 13px 10px;
  color: var(--fsb-text-leise);
  font-size: 11.5px;
  line-height: 1.45;
}
.fsb-rechtszeile a { color: var(--fsb-text-leise); }

/* --- Handy -------------------------------------------------------------- */

@media (max-width: 520px) {
  .fsb-panel {
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border: 0;
    border-radius: 0;
  }
  .fsb-launcher { right: 14px; bottom: 14px; padding: 12px 17px; }
}

@media (prefers-reduced-motion: reduce) {
  .fsb-launcher { transition: none; }
}
