/* WAB KI-Chatbot – Farben über --wab-cb-color (Standard: Primärfarbe des Grundlayouts) */
.wab-chatbot {
    --wab-cb-accent: var(--wab-cb-color, var(--wab-color-primary, #1f5fbf));
    --wab-cb-accent-text: var(--wab-color-primary-text, #fff);
    --wab-cb-bg: var(--wab-color-background, #fff);
    --wab-cb-text: var(--wab-color-text, #1f2328);
    --wab-cb-muted: color-mix(in srgb, var(--wab-cb-text) 60%, transparent);
    --wab-cb-border: var(--wab-color-border, #dde1e6);
    --wab-cb-bubble: var(--wab-color-light, #f3f5f7);
    --wab-cb-radius: 14px;
    font-family: var(--wab-font-main, inherit);
    font-size: 1rem;
    line-height: 1.5;
    color: var(--wab-cb-text);
}

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

.wab-chatbot svg {
    width: 1.25em;
    height: 1.25em;
    flex: none;
}

/* Schwebend */
.wab-chatbot--floating {
    position: fixed;
    z-index: 9990;
    bottom: 20px;
    right: 20px;
}

.wab-chatbot--floating.wab-chatbot--left {
    right: auto;
    left: 20px;
}

.wab-chatbot__launcher {
    display: flex;
    align-items: center;
    gap: .6em;
    min-height: 56px;
    padding: 0 18px;
    border: 0;
    border-radius: 999px;
    background: var(--wab-cb-accent);
    color: var(--wab-cb-accent-text);
    font: inherit;
    font-weight: var(--wab-font-weight-bold, 700);
    /* Heller Rand, damit die Schaltfläche auch vor einem Footer in derselben Farbe sichtbar bleibt */
    box-shadow: 0 0 0 3px rgb(255 255 255 / .85), 0 6px 24px rgb(0 0 0 / .25);
    cursor: pointer;
    transition: transform .15s ease;
}

.wab-chatbot__launcher:hover {
    transform: translateY(-2px);
}

.wab-chatbot__launcher svg {
    width: 26px;
    height: 26px;
}

.wab-chatbot--floating .wab-chatbot__panel {
    position: absolute;
    bottom: 0;
    right: 0;
    width: min(400px, calc(100vw - 40px));
    height: min(var(--wab-cb-height, 600px), calc(100vh - 40px));
    max-height: calc(100dvh - 40px);
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    transition: opacity .2s ease, transform .2s ease, visibility .2s;
    box-shadow: 0 12px 48px rgb(0 0 0 / .22);
}

.wab-chatbot--floating.wab-chatbot--left .wab-chatbot__panel {
    right: auto;
    left: 0;
}

.wab-chatbot--floating.is-open .wab-chatbot__panel {
    opacity: 1;
    visibility: visible;
    transform: none;
}

.wab-chatbot--floating.is-open .wab-chatbot__launcher {
    visibility: hidden;
}

@media (max-width: 520px) {
    .wab-chatbot--floating.is-open {
        inset: 0;
    }

    .wab-chatbot--floating .wab-chatbot__panel {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
    }

    .wab-chatbot__launcher-label {
        display: none;
    }

    .wab-chatbot__launcher {
        width: 56px;
        padding: 0;
        justify-content: center;
    }
}

/* Eingebettet */
.wab-chatbot--inline .wab-chatbot__panel {
    height: var(--wab-cb-height, 520px);
    max-width: 100%;
}

/* Fenster */
.wab-chatbot__panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--wab-cb-border);
    border-radius: var(--wab-cb-radius);
    background: var(--wab-cb-bg);
}

.wab-chatbot__header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: var(--wab-cb-accent);
    color: var(--wab-cb-accent-text);
}

.wab-chatbot__avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex: none;
    overflow: hidden;
    border-radius: 50%;
    background: rgb(255 255 255 / .2);
}

.wab-chatbot__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wab-chatbot__heading {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
    line-height: 1.25;
}

.wab-chatbot__heading span {
    font-size: .8em;
    opacity: .85;
}

.wab-chatbot__actions {
    display: flex;
    gap: 2px;
}

.wab-chatbot__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.wab-chatbot__icon:hover,
.wab-chatbot__icon:focus-visible {
    background: rgb(255 255 255 / .18);
}

.wab-chatbot__body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* Zustimmung */
.wab-chatbot__consent {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 12px;
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    font-size: .92em;
}

.wab-chatbot__consent-text p {
    margin: 0 0 .6em;
}

.wab-chatbot__consent-link {
    margin: 0;
}

.wab-chatbot__start {
    align-self: flex-start;
    padding: .65em 1.3em;
    border: 0;
    border-radius: 999px;
    background: var(--wab-cb-accent);
    color: var(--wab-cb-accent-text);
    font: inherit;
    font-weight: var(--wab-font-weight-bold, 700);
    cursor: pointer;
}

.wab-chatbot__start:disabled {
    opacity: .6;
    cursor: wait;
}

/* Verlauf */
.wab-chatbot__log {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    min-height: 0;
    padding: 14px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.wab-chatbot__msg {
    max-width: 88%;
    padding: 9px 13px;
    border-radius: var(--wab-cb-radius);
    font-size: .94em;
    overflow-wrap: anywhere;
}

.wab-chatbot__msg--assistant {
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    background: var(--wab-cb-bubble);
}

.wab-chatbot__msg--user {
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    background: var(--wab-cb-accent);
    color: var(--wab-cb-accent-text);
}

.wab-chatbot__msg.is-error {
    border: 1px solid #c62828;
    background: #fdecea;
    color: #8e1c1c;
}

.wab-chatbot__text > :first-child {
    margin-top: 0;
}

.wab-chatbot__text > :last-child {
    margin-bottom: 0;
}

.wab-chatbot__text p,
.wab-chatbot__text ul,
.wab-chatbot__text ol {
    margin: 0 0 .5em;
}

.wab-chatbot__text ul,
.wab-chatbot__text ol {
    padding-left: 1.3em;
}

.wab-chatbot__text a {
    color: inherit;
    text-decoration: underline;
}

.wab-chatbot__cite {
    margin-left: 1px;
    font-size: .72em;
}

.wab-chatbot__cite a {
    text-decoration: none !important;
    padding: 0 .3em;
    border-radius: 4px;
    background: color-mix(in srgb, var(--wab-cb-accent) 15%, transparent);
}

.wab-chatbot__sources {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--wab-cb-border);
    font-size: .8em;
}

.wab-chatbot__sources span {
    color: var(--wab-cb-muted);
}

.wab-chatbot__sources a {
    color: var(--wab-cb-accent);
}

.wab-chatbot__status {
    color: var(--wab-cb-muted);
    font-style: italic;
}

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

.wab-chatbot__dots i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--wab-cb-muted);
    animation: wab-cb-dot 1.2s infinite ease-in-out;
}

.wab-chatbot__dots i:nth-child(2) {
    animation-delay: .15s;
}

.wab-chatbot__dots i:nth-child(3) {
    animation-delay: .3s;
}

@keyframes wab-cb-dot {
    0%, 80%, 100% { opacity: .3; transform: scale(.8); }
    40% { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .wab-chatbot__dots i,
    .wab-chatbot__panel,
    .wab-chatbot__launcher {
        animation: none;
        transition: none;
    }
}

/* Vorschläge */
.wab-chatbot__suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 14px 10px;
}

.wab-chatbot__suggestions[hidden] {
    display: none;
}

.wab-chatbot__suggestion {
    padding: .4em .85em;
    border: 1px solid var(--wab-cb-accent);
    border-radius: 999px;
    background: transparent;
    color: var(--wab-cb-accent);
    font: inherit;
    font-size: .85em;
    cursor: pointer;
}

.wab-chatbot__suggestion:hover {
    background: color-mix(in srgb, var(--wab-cb-accent) 10%, transparent);
}

/* Eingabe */
.wab-chatbot__composer {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin: 0;
    padding: 10px 12px;
    border-top: 1px solid var(--wab-cb-border);
}

.wab-chatbot__composer textarea {
    flex: 1;
    min-height: 40px;
    max-height: 140px;
    margin: 0;
    padding: 9px 12px;
    border: 1px solid var(--wab-cb-border);
    border-radius: 20px;
    background: var(--wab-cb-bg);
    color: inherit;
    font: inherit;
    font-size: .94em;
    line-height: 1.4;
    resize: none;
}

.wab-chatbot__composer textarea:focus {
    outline: 2px solid var(--wab-cb-accent);
    outline-offset: -1px;
}

.wab-chatbot__send {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex: none;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--wab-cb-accent);
    color: var(--wab-cb-accent-text);
    cursor: pointer;
}

.wab-chatbot__send:disabled {
    opacity: .5;
    cursor: wait;
}

.wab-chatbot__note {
    margin: 0;
    padding: 0 12px 8px;
    color: var(--wab-cb-muted);
    font-size: .72em;
    text-align: center;
}

/* Kontaktformular */
.wab-chatbot__lead {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-self: stretch;
    margin: 0;
    padding: 12px;
    border: 1px solid var(--wab-cb-border);
    border-radius: var(--wab-cb-radius);
    font-size: .9em;
}

.wab-chatbot__lead-title {
    margin: 0 0 4px;
}

.wab-chatbot__lead label {
    font-weight: var(--wab-font-weight-bold, 700);
    font-size: .9em;
}

.wab-chatbot__lead input:not([type=checkbox]),
.wab-chatbot__lead textarea {
    width: 100%;
    margin: 0 0 6px;
    padding: 7px 10px;
    border: 1px solid var(--wab-cb-border);
    border-radius: 8px;
    background: var(--wab-cb-bg);
    color: inherit;
    font: inherit;
}

.wab-chatbot__lead .wab-chatbot__check {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    font-weight: normal;
    font-size: .85em;
}

.wab-chatbot__check input {
    margin-top: .25em;
}

.wab-chatbot__lead-hint {
    margin: 0;
    color: var(--wab-cb-muted);
    font-size: .8em;
}

.wab-chatbot__lead-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 6px;
}

.wab-chatbot__cancel {
    border: 0;
    background: none;
    color: var(--wab-cb-muted);
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
}

.wab-chatbot__error {
    margin: -2px 0 6px;
    color: #c62828;
    font-size: .85em;
}

.wab-chatbot__hp {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}
