/*
 * Hilfe- und Live-Chat (additional/dashboard/kb-chat.php, Logik kb-chat.js): schwebendes Chat-Fenster unten rechts wie
 * bei üblichen Live-Chat-Widgets, gleich auf Website (Bootstrap) und im Kundenbereich (Metronic). Farben aus der Marke
 * (--bs-primary), hell/dunkel über die Variablen des Themes. Auf dem Handy füllt das Fenster den Bildschirm.
 */
.kbw { --kbw-primary: var(--bs-primary, #0d6efd); --kbw-bg: var(--bs-body-bg, #fff); --kbw-fg: var(--bs-body-color, #212529);
       --kbw-soft: var(--bs-tertiary-bg, var(--bs-gray-100, #f5f7fb)); --kbw-muted: var(--bs-secondary-color, #6c757d);
       --kbw-line: var(--bs-border-color, #e4e6ef); --kbw-radius: 18px; font-size: 14px; line-height: 1.45; }
[data-bs-theme="dark"] .kbw { --kbw-soft: rgba(255, 255, 255, .05); }

.kbw-launcher { position: fixed; right: 24px; bottom: 24px; z-index: 1084; width: 60px; height: 60px; border: 0; border-radius: 50%;
                background: var(--kbw-primary); color: #fff; box-shadow: 0 8px 24px rgba(0, 0, 0, .22); display: flex; align-items: center;
                justify-content: center; cursor: pointer; transition: transform .2s ease, box-shadow .2s ease; }
.kbw-launcher:hover { transform: scale(1.06); box-shadow: 0 10px 28px rgba(0, 0, 0, .28); }
.kbw-launcher:focus-visible { outline: 3px solid var(--kbw-primary); outline-offset: 3px; }
.kbw-launcher svg { width: 28px; height: 28px; transition: transform .2s ease, opacity .2s ease; }
.kbw-launcher .kbw-ico-close { position: absolute; opacity: 0; transform: rotate(-90deg); }
.kbw-open .kbw-launcher .kbw-ico-chat { opacity: 0; transform: rotate(90deg); }
.kbw-open .kbw-launcher .kbw-ico-close { opacity: 1; transform: none; }
.kbw-launcher[data-raise] { bottom: 124px; }
.kbw-unread { position: absolute; top: -2px; right: -2px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
              background: #f1416c; color: #fff; font-size: 12px; font-weight: 700; line-height: 20px; border: 2px solid var(--kbw-bg); }

.kbw-window { position: fixed; right: 24px; bottom: 100px; z-index: 1085; width: 380px; height: min(640px, calc(100vh - 124px));
              display: flex; flex-direction: column; overflow: hidden; border-radius: var(--kbw-radius); background: var(--kbw-bg);
              color: var(--kbw-fg); box-shadow: 0 16px 48px rgba(0, 0, 0, .22); opacity: 0; visibility: hidden;
              transform: translateY(16px) scale(.98); transform-origin: bottom right; transition: opacity .2s ease, transform .2s ease, visibility 0s .2s; }
.kbw-open .kbw-window { opacity: 1; visibility: visible; transform: none; transition: opacity .2s ease, transform .2s ease; }
.kbw-launcher[data-raise] ~ .kbw-window { bottom: 200px; height: min(640px, calc(100vh - 224px)); }

.kbw-head { background: linear-gradient(135deg, var(--kbw-primary), color-mix(in srgb, var(--kbw-primary) 70%, #000)); color: #fff; padding: 16px 16px 18px; }
.kbw-head-row { display: flex; align-items: center; gap: 12px; }
.kbw-head h2 { font-size: 16px; font-weight: 700; margin: 0; color: #fff; }
.kbw-status { font-size: 12.5px; opacity: .92; display: flex; align-items: center; gap: 6px; }
.kbw-dot { width: 8px; height: 8px; border-radius: 50%; background: #a1a5b7; flex-shrink: 0; }
.kbw-dot.is-online { background: #50cd89; box-shadow: 0 0 0 3px rgba(80, 205, 137, .3); }
.kbw-head-actions { margin-left: auto; display: flex; gap: 4px; }
.kbw-icon-btn { border: 0; background: transparent; color: #fff; width: 34px; height: 34px; border-radius: 50%; display: flex;
                align-items: center; justify-content: center; cursor: pointer; opacity: .9; }
.kbw-icon-btn:hover, .kbw-icon-btn:focus-visible { background: rgba(255, 255, 255, .18); opacity: 1; }
.kbw-icon-btn svg { width: 18px; height: 18px; }
.kbw-end { border: 1px solid rgba(255, 255, 255, .5); background: transparent; color: #fff; border-radius: 14px; font-size: 12px; padding: 3px 10px; cursor: pointer; }
.kbw-end:hover { background: rgba(255, 255, 255, .15); }
.kbw-avatars { display: flex; }
.kbw-avatars .kbw-av { border: 2px solid rgba(255, 255, 255, .85); }
.kbw-avatars .kbw-av + .kbw-av { margin-left: -10px; }

.kbw-av { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
          background: var(--kbw-primary); color: #fff; font-weight: 700; font-size: 13px; }
.kbw-av svg { width: 17px; height: 17px; }
.kbw-av-lg { width: 40px; height: 40px; font-size: 15px; }
.kbw-av-team { background: #7239ea; }

.kbw-body { flex: 1; overflow-y: auto; padding: 16px 14px 8px; background: var(--kbw-soft); scroll-behavior: smooth; }
.kbw-row { display: flex; align-items: flex-end; gap: 8px; margin-bottom: 12px; animation: kbw-in .25s ease both; }
.kbw-row.is-me { justify-content: flex-end; }
.kbw-msg { max-width: 80%; padding: 10px 13px; border-radius: 16px 16px 16px 4px; background: var(--kbw-bg); color: var(--kbw-fg);
           box-shadow: 0 1px 2px rgba(0, 0, 0, .08); overflow-wrap: anywhere; }
.is-me .kbw-msg { background: var(--kbw-primary); color: #fff; border-radius: 16px 16px 4px 16px; }
.kbw-msg a { color: var(--kbw-primary); }
.kbw-text { white-space: pre-line; }
.kbw-meta { font-size: 11.5px; color: var(--kbw-muted); margin-bottom: 3px; }
.is-me .kbw-meta { color: rgba(255, 255, 255, .8); }
.kbw-note { text-align: center; font-size: 12px; color: var(--kbw-muted); margin: 6px 12px 14px; }
.kbw-note span { display: inline-block; background: var(--kbw-bg); border-radius: 12px; padding: 4px 10px; box-shadow: 0 1px 2px rgba(0, 0, 0, .06); }
.kbw-small { font-size: 12.5px; color: var(--kbw-muted); }
.kbw-msg ul { margin: 4px 0 0; padding-left: 18px; }

.kbw-typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.kbw-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--kbw-muted); opacity: .5; animation: kbw-blink 1.2s infinite ease-in-out; }
.kbw-typing i:nth-child(2) { animation-delay: .15s; }
.kbw-typing i:nth-child(3) { animation-delay: .3s; }

.kbw-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 12px 40px; }
.kbw-chip { border: 1px solid var(--kbw-primary); color: var(--kbw-primary); background: var(--kbw-bg); border-radius: 16px; padding: 5px 12px;
            font-size: 13px; cursor: pointer; text-decoration: none; display: inline-block; line-height: 1.3; }
.kbw-chip:hover, .kbw-chip:focus-visible { background: var(--kbw-primary); color: #fff; }
.kbw-btn { border: 0; background: var(--kbw-primary); color: #fff; border-radius: 16px; padding: 6px 14px; font-size: 13px; font-weight: 600;
           cursor: pointer; text-decoration: none; display: inline-block; }
.kbw-btn:hover { color: #fff; filter: brightness(1.08); }
.kbw-btn:disabled { opacity: .5; cursor: default; }
.kbw-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.kbw-form label { display: block; font-size: 12.5px; font-weight: 600; margin: 8px 0 3px; }
.kbw-input { width: 100%; border: 1px solid var(--kbw-line); background: var(--kbw-bg); color: var(--kbw-fg); border-radius: 10px; padding: 7px 10px; font-size: 14px; }
.kbw-input:focus { outline: none; border-color: var(--kbw-primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--kbw-primary) 20%, transparent); }
.kbw-captcha { display: flex; gap: 8px; align-items: center; }
.kbw-captcha img { width: 128px; height: 40px; border-radius: 8px; flex-shrink: 0; background: var(--kbw-soft); }
.kbw-captcha .kbw-icon-btn { color: var(--kbw-muted); }
.kbw-check { display: flex; gap: 8px; align-items: flex-start; margin: 10px 0; font-size: 12.5px; }
.kbw-check input { margin-top: 3px; }
.kbw-error { color: #f1416c; font-size: 12.5px; margin-bottom: 8px; }

.kbw-stars { display: flex; gap: 4px; margin: 6px 0 8px; }
.kbw-star { border: 0; background: transparent; padding: 0 2px; font-size: 26px; line-height: 1; color: #d0d4dd; cursor: pointer; transition: transform .1s ease; }
.kbw-star.is-on { color: #ffc700; }
.kbw-star:hover { transform: scale(1.15); }

.kbw-foot { border-top: 1px solid var(--kbw-line); padding: 10px 12px; background: var(--kbw-bg); }
.kbw-compose { display: flex; align-items: center; gap: 8px; background: var(--kbw-soft); border-radius: 22px; padding: 4px 4px 4px 14px; }
.kbw-compose input { flex: 1; border: 0; background: transparent; color: var(--kbw-fg); font-size: 14px; padding: 8px 0; min-width: 0; }
.kbw-compose input:focus { outline: none; }
.kbw-compose:focus-within { box-shadow: 0 0 0 2px color-mix(in srgb, var(--kbw-primary) 35%, transparent); }
.kbw-send { width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--kbw-primary); color: #fff; display: flex;
            align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
.kbw-send svg { width: 17px; height: 17px; }
.kbw-hint { font-size: 11.5px; color: var(--kbw-muted); text-align: center; margin-top: 6px; }

@keyframes kbw-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes kbw-blink { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .kbw *, .kbw-window, .kbw-launcher svg { animation: none !important; transition: none !important; } }
.a11y-motion .kbw *, .a11y-motion .kbw-window { animation: none !important; transition: none !important; }

@media (max-width: 575.98px) {
    .kbw-window, .kbw-launcher[data-raise] ~ .kbw-window { inset: 0; width: auto; height: auto; border-radius: 0; bottom: 0; }
    .kbw-open .kbw-launcher { display: none; }
    .kbw-launcher { right: 16px; bottom: 16px; }
}
.kbw-msg a.kbw-btn, .kbw-msg a.kbw-btn:hover { color: #fff; text-decoration: none; }
.kbw-msg a.kbw-chip { text-decoration: none; }
.kbw-msg a.kbw-chip:hover { color: #fff; }
.kbw-end { white-space: nowrap; }
