/* Chat-Oberfläche (Button + Panel). Hintergründe und Entscheidungen:
   includes/external/chatbot/ENTWICKLERHINWEISE.md */

#usChat, #usChatBtn { font-family: Arial, Helvetica, sans-serif; box-sizing: border-box; }
#usChat *, #usChatBtn * { box-sizing: border-box; }

/* Auslöser unten rechts */
/* Runder Icon-Button ohne Beschriftung (08.08.2026). Feste Groesse statt Innenabstand,
   damit der Kreis exakt rund bleibt - mit padding waere er von der Icongroesse abhaengig. */
#usChatBtn {
  position: fixed; right: 18px; bottom: 18px; z-index: 9998;
  display: inline-flex; align-items: center; justify-content: center;
  width: 58px; height: 58px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
  background: linear-gradient(180deg, #f0a01e 0%, #E8970A 100%);
  color: #fff; font-size: 0; line-height: 0;
  box-shadow: 0 6px 18px rgba(232,151,10,.34), inset 0 1px 0 rgba(255,255,255,.18);
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
#usChatBtn:hover {
  background: linear-gradient(180deg, #e8970a 0%, #cf850a 100%);
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(232,151,10,.42), inset 0 1px 0 rgba(255,255,255,.18);
}
#usChatBtn:active { transform: translateY(0); box-shadow: 0 6px 18px rgba(0,0,0,.30); }
#usChatBtn svg { width: 26px; height: 26px; fill: currentColor; display: block; }
#usChatBtn.us-dezent { width: 50px; height: 50px; opacity: .88; }
#usChatBtn.us-dezent svg { width: 23px; height: 23px; }

/* Platz für den Zurück-nach-oben-Pfeil, solange der Auslöser sichtbar ist */
/* Abstand und Flucht der beiden Schaltflaechen (08.08.2026):
   Der Chat-Button ist 58px breit und sitzt 18px vom Rand - seine Mitte liegt also 47px
   vom rechten Rand. Der Pfeil ist 46px breit, braucht fuer dieselbe Mittelachse somit
   24px Abstand. Vertikal: 18 (unten) + 58 (Chat-Button) + 12 (Luft) = 88px.
   Vorher standen 72px hier - der Pfeil ueberlappte den Chat-Button fast. */
html.us-chat-da .to-top { bottom: 88px !important; right: 24px !important; }


/* Panel liegt über der Seite und verschiebt sie nicht */
#usChat {
  position: fixed; top: 0; right: 0; bottom: 0; width: 405px; max-width: 100%;
  z-index: 9999; background: #fff; display: none; flex-direction: column;
  box-shadow: -3px 0 22px rgba(0,0,0,.18);
}
#usChat.us-auf { display: flex; }
#usChatKopf {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; background: #1f1f1f; color: #fff; flex: 0 0 auto;
}
#usChatKopf strong { font-size: 15px; font-weight: bold; }
#usChatKopf .us-hinweis { font-size: 11px; opacity: .72; display: block; margin-top: 1px; }
#usChatZu {
  margin-left: auto; background: none; border: 0; color: #fff; cursor: pointer;
  font-size: 22px; line-height: 1; padding: 4px 8px;
}
#usChatKontext {
  padding: 9px 16px; background: #faf7f2; border-bottom: 1px solid #ecece8;
  font-size: 12px; color: #6a6a6a; flex: 0 0 auto;
}
#usChatVerlauf { flex: 1 1 auto; overflow-y: auto; padding: 16px; background: #f7f7f5; }
.us-msg { max-width: 88%; margin: 0 0 12px; padding: 10px 13px; border-radius: 12px;
          font-size: 13.5px; line-height: 19px; white-space: pre-wrap; }
.us-bot  { background: #fff; border: 1px solid #ececec; color: #1f1f1f; }
.us-user { background: #1f1f1f; color: #fff; margin-left: auto; }
.us-quellen { margin: -6px 0 12px; font-size: 12.5px; }
.us-quellen a { display: inline-block; margin: 3px 6px 0 0; padding: 5px 10px;
                background: #fff; border: 1px solid #E8970A; border-radius: 14px;
                color: #b8760a; text-decoration: none; }
.us-quellen a:hover { background: #E8970A; color: #fff; }
.us-quellen a.us-karte { display: flex; gap: 10px; align-items: center; width: 100%;
                         box-sizing: border-box; margin: 0 0 7px; padding: 7px;
                         border-color: #e6e6e2; border-radius: 10px; color: #222; }
.us-quellen a.us-karte:hover { background: #fffaf2; border-color: #E8970A; color: #222; }
.us-karte img { width: 56px; height: 56px; flex: 0 0 56px; object-fit: cover;
                border-radius: 7px; background: #f4f4f2; }
.us-k-name { display: block; font-size: 12.5px; line-height: 1.3; font-weight: 600; }
.us-k-info { display: block; font-size: 11.5px; line-height: 1.35; color: #777; margin-top: 2px; }
#usChatStart { padding: 2px 0 6px; }
#usChatStart button {
  display: block; width: 100%; text-align: left; margin: 0 0 7px;
  padding: 11px 13px; background: #fff; border: 1px solid #e2e2de; border-radius: 10px;
  font-size: 13.5px; color: #1f1f1f; cursor: pointer;
}
#usChatStart button:hover { border-color: #E8970A; color: #b8760a; }
#usChatFuss { flex: 0 0 auto; padding: 11px; border-top: 1px solid #ececec; background: #fff; }
#usChatForm { display: flex; gap: 8px; }
#usChatEingabe {
  flex: 1 1 auto; padding: 11px 13px; border: 1px solid #d8d8d4; border-radius: 10px;
  font-size: 14px; font-family: inherit;
}
#usChatEingabe:focus { outline: none; border-color: #E8970A; }
#usChatSenden {
  flex: 0 0 auto; padding: 0 17px; border: 0; border-radius: 10px;
  background: #E8970A; color: #fff; font-size: 14px; font-weight: bold; cursor: pointer;
}
#usChatSenden:disabled { background: #d8d8d4; cursor: default; }
/* Wartehinweis: drei pulsierende Punkte in einer Botblase */
.us-tippt { display: inline-flex; align-items: center; gap: 5px;
            margin: 0 0 12px; padding: 12px 15px; border-radius: 12px;
            background: #fff; border: 1px solid #ececec; }
.us-tippt i { display: block; width: 7px; height: 7px; border-radius: 50%;
              background: #b6b6b0; animation: usPunkt 1.25s ease-in-out infinite; }
.us-tippt i:nth-child(2) { animation-delay: .18s; }
.us-tippt i:nth-child(3) { animation-delay: .36s; }
@keyframes usPunkt {
  0%, 70%, 100% { opacity: .28; transform: translateY(0); }
  35%           { opacity: 1;   transform: translateY(-3px); }
}
/* Nur für Vorleseprogramme - der Punktrhythmus sagt ihnen nichts. */
.us-nurlesen { position: absolute; width: 1px; height: 1px; overflow: hidden;
               clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
/* Wer Bewegung abbestellt hat, bekommt den Hinweis ohne Animation. */
@media (prefers-reduced-motion: reduce) {
  .us-tippt i { animation: none; opacity: .55; }
}

/* Bewertung je Antwort */
.us-bew { margin: -7px 0 12px; font-size: 12px; color: #9a9a96; display: flex;
          align-items: center; gap: 6px; }
.us-bew button { border: 1px solid #d8d8d4; background: #fff; border-radius: 8px;
                 padding: 4px 11px; font-size: 20px; cursor: pointer; line-height: 1.15; }
.us-bew button:hover { border-color: #E8970A; background: #fffaf2; }
.us-bew.us-fertig { color: #1a7f37; }

/* Menschprüfung: kein border-radius am Widget selbst */
.us-nachweis { margin: -4px 0 12px; padding: 11px 12px; background: #fff;
               border: 1px solid #e6e6e2; border-radius: 10px; font-size: 13px; }
.us-nachweis p { margin: 0 0 9px; color: #555; line-height: 17px; }

/* Übergabe an einen Mitarbeiter */
.us-ueb { margin: -4px 0 12px; padding: 11px 12px; background: #fff; border: 1px solid #e6e6e2;
          border-radius: 10px; font-size: 13px; }
.us-ueb input { width: 100%; margin: 7px 0; padding: 8px 10px; border: 1px solid #d8d8d4;
                border-radius: 8px; font-size: 13.5px; font-family: inherit; }
.us-ueb button { background: #1f1f1f; color: #fff; border: 0; border-radius: 8px;
                 padding: 8px 14px; font-size: 13px; font-weight: bold; cursor: pointer; }
.us-ueb button:hover { background: #E8970A; }
.us-ueb .us-fehler { color: #b42318; margin-top: 6px; }

@media (max-width: 767px) {
  /* ⚠️ 08.08.2026: padding/font-size stammten vom fruehereren TEXT-Button und sind seit
     dem reinen Icon-Button gegenstandslos. bottom:60px liess den Pfeil den Chat-Button
     ueberlappen: 12 (unten) + 58 (Button) = 70 > 60. Richtig sind 12 + 58 + 12 Luft = 82.
     right 18 statt 12, damit beide Mitten fluchten (12 + 29 = 41; 41 - 23 = 18). */
  #usChatBtn { right: 12px; bottom: 12px; }
  html.us-chat-da .to-top { bottom: 82px !important; right: 18px !important; }
  #usChat { width: 100%; left: 0; }
  #usChatZu { font-size: 26px; order: -1; margin-left: 0; margin-right: 4px; }
  #usChatKopf { padding: 12px 12px; }
}

/* Sehr schmale Schirme (08.08.2026): beide Schaltflaechen kleiner. Steht bewusst NACH der
   767er-Regel oben - bei gleicher Spezifitaet gewinnt die spaetere, sonst bliebe sie wirkungslos.
   Rechnung: 12 + 52 + 12 = 76 Hoehe; Mitte 12 + 26 = 38, Pfeil 42 breit -> 38 - 21 = 17. */
@media only screen and (max-width: 480px) {
  #usChatBtn { width: 52px; height: 52px; }
  #usChatBtn svg { width: 23px; height: 23px; }
  #usChatBtn.us-dezent { width: 46px; height: 46px; }
  html.us-chat-da .to-top { width: 42px !important; height: 42px !important;
                            bottom: 76px !important; right: 17px !important; }
}

/* Kurzhinweis links neben dem Button (08.08.2026). Erscheint nur bei Maus-Hover und
   Tastatur-Fokus; auf Touch-Geraeten gibt es kein Hover, dort bleibt er aus - deshalb
   traegt der Button zusaetzlich ein aria-label. */
#usChatBtn::after {
  content: attr(data-tip);
  position: absolute; right: calc(100% + 12px); top: 50%; transform: translateY(-50%) translateX(6px);
  background: #1f1f1f; color: #fff; font-size: 13px; line-height: 18px; font-weight: normal;
  white-space: normal; width: max-content; max-width: 260px; text-align: left;
  padding: 9px 13px; border-radius: 10px; box-shadow: 0 8px 22px rgba(0,0,0,.22);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .18s ease, transform .18s ease, visibility .18s;
}
#usChatBtn:hover::after, #usChatBtn:focus-visible::after {
  opacity: 1; visibility: visible; transform: translateY(-50%) translateX(0);
}
/* Kein Platz daneben: unterhalb von 600px waere der Hinweis abgeschnitten. */
@media only screen and (max-width: 600px) {
  #usChatBtn::after { display: none; }
}
