/* Website-Chat
   Nur Widget-spezifische Styles. Bootstrap wird von der Website bereits geladen. */

.chatbot-root {
    --chatbot-dark: #2d444e;
    --chatbot-dark-2: #20343c;
    --chatbot-accent: #9a1e3e;
    --chatbot-gold: #dabe73;
    --chatbot-bg: #f4f1ea;
    --chatbot-text: #212529;
    --chatbot-muted: #6c757d;
    --chatbot-border: rgba(45, 68, 78, .18);
    --chatbot-shadow: 0 18px 45px rgba(0, 0, 0, .22);

    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 99999;
    font-family: 'Montserrat', var(--bs-font-sans-serif, Arial, Helvetica, sans-serif);
    font-size: 14px;
    line-height: 1.45;
    color: var(--chatbot-text);
}

.chatbot-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    border: 1px solid rgba(255, 255, 255, .18);
    background: var(--chatbot-dark);
    color: #fff;
    min-height: 46px;
    padding: 0 18px;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 10px 26px rgba(0, 0, 0, .24);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: .2px;
    transition: transform .18s ease, background-color .18s ease, box-shadow .18s ease;
}

.chatbot-toggle::before {
    content: '';
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--chatbot-gold);
    box-shadow: 0 0 0 4px rgba(218, 190, 115, .18);
}

.chatbot-toggle:hover,
.chatbot-toggle:focus-visible {
    background: var(--chatbot-dark-2);
    transform: translateY(-1px);
    box-shadow: 0 13px 32px rgba(0, 0, 0, .28);
}

.chatbot-toggle-hidden {
    display: none;
}

.chatbot-panel {
    width: 390px;
    max-width: calc(100vw - 32px);
    height: 590px;
    max-height: calc(100vh - 48px);
    background: #fff;
    border: 1px solid var(--chatbot-border);
    border-radius: 8px;
    box-shadow: var(--chatbot-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chatbot-panel-hidden {
    display: none;
}

.chatbot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--chatbot-dark);
    color: #fff;
    padding: 13px 15px;
    border-bottom: 3px solid var(--chatbot-gold);
}

.chatbot-heading {
    min-width: 0;
}

.chatbot-title {
    font-weight: 700;
    font-size: 16px;
    letter-spacing: .25px;
    line-height: 1.1;
}

.chatbot-subtitle {
    margin-top: 2px;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .72);
}

.chatbot-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .08);
    color: #fff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0 0 2px;
    transition: background-color .15s ease;
}

.chatbot-close:hover,
.chatbot-close:focus-visible {
    background: rgba(255, 255, 255, .18);
}

.chatbot-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    background:
        linear-gradient(180deg, rgba(244, 241, 234, .95), rgba(255, 255, 255, .96));
    scrollbar-width: thin;
    scrollbar-color: rgba(45, 68, 78, .35) transparent;
}

.chatbot-list::-webkit-scrollbar {
    width: 8px;
}

.chatbot-list::-webkit-scrollbar-thumb {
    background: rgba(45, 68, 78, .28);
    border-radius: 20px;
}

.chatbot-message {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
}

.chatbot-message-user {
    align-items: flex-end;
}

.chatbot-message-assistant {
    align-items: flex-start;
}

.chatbot-bubble {
    max-width: 88%;
    padding: 10px 12px;
    border-radius: 10px;
    line-height: 1.45;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    font-size: 13.5px;
}

.chatbot-message-user .chatbot-bubble {
    background: var(--chatbot-dark);
    color: #fff;
    border-bottom-right-radius: 3px;
    box-shadow: 0 5px 16px rgba(45, 68, 78, .18);
}

.chatbot-message-assistant .chatbot-bubble {
    background: #fff;
    color: var(--chatbot-text);
    border: 1px solid rgba(45, 68, 78, .13);
    border-left: 3px solid var(--chatbot-gold);
    border-bottom-left-radius: 3px;
    box-shadow: 0 5px 17px rgba(0, 0, 0, .055);
}

.chatbot-answer-line:last-child,
.chatbot-answer-list:last-child {
    margin-bottom: 0 !important;
}

.chatbot-answer-spacer {
    height: 6px;
}

.chatbot-answer-list {
    margin: 0 0 6px 0;
    padding-left: 18px !important;
}

.chatbot-answer-list li {
    margin-bottom: 4px;
}

.chatbot-inline-link {
    color: var(--chatbot-accent);
    font-weight: 600;
    text-decoration: none;
    border-bottom: 1px solid rgba(154, 30, 62, .35);
}

.chatbot-inline-link:hover,
.chatbot-inline-link:focus-visible {
    color: var(--chatbot-dark);
    border-bottom-color: var(--chatbot-dark);
}

/* Quellen bleiben intern/API-seitig erhalten, aber im Besucher-Frontend unsichtbar. */
.chatbot-sources {
    display: none !important;
}

.chatbot-feedback {
    max-width: 88%;
    margin-top: 6px;
    font-size: 12px;
    color: var(--chatbot-muted);
}

.chatbot-feedback-btn {
    border: 1px solid rgba(45, 68, 78, .16);
    background: #fff;
    color: var(--chatbot-dark);
    padding: 4px 8px;
    margin-right: 5px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1.3;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

.chatbot-feedback-btn:hover {
    background: var(--chatbot-bg);
    border-color: rgba(45, 68, 78, .28);
}

.chatbot-feedback-btn:disabled {
    opacity: .55;
    cursor: default;
}

.chatbot-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid rgba(45, 68, 78, .12);
    background: #fff;
}

.chatbot-input {
    flex: 1;
    min-height: 42px;
    max-height: 104px;
    resize: none;
    border: 1px solid rgba(45, 68, 78, .22);
    border-radius: 8px;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 13.5px;
    line-height: 1.35;
    outline: none;
    color: var(--chatbot-text);
    background: #fff;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.chatbot-input::placeholder {
    color: rgba(33, 37, 41, .48);
}

.chatbot-input:focus {
    border-color: rgba(154, 30, 62, .55);
    box-shadow: 0 0 0 .18rem rgba(154, 30, 62, .12);
}

.chatbot-send {
    min-height: 42px;
    border: 1px solid var(--chatbot-dark);
    background: var(--chatbot-dark);
    color: #fff;
    padding: 0 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 600;
    white-space: nowrap;
    transition: background-color .15s ease, border-color .15s ease, transform .15s ease;
}

.chatbot-send:hover,
.chatbot-send:focus-visible {
    background: var(--chatbot-accent);
    border-color: var(--chatbot-accent);
}

.chatbot-send:active {
    transform: translateY(1px);
}

.chatbot-send:disabled {
    opacity: .58;
    cursor: default;
    transform: none;
}

@media (max-width: 480px) {
    .chatbot-root {
        right: 10px;
        bottom: 10px;
        left: 10px;
    }

    .chatbot-toggle {
        float: right;
    }

    .chatbot-panel {
        width: 100%;
        height: calc(100vh - 20px);
        max-width: none;
        max-height: none;
        border-radius: 8px;
    }

    .chatbot-bubble {
        max-width: 94%;
    }

    .chatbot-form {
        padding: 10px;
    }
}

.chatbot-table-wrap {
    max-width: 100%;
    margin: 6px 0 8px;
}

.chatbot-table {
    margin-bottom: 0;
    font-size: 12.5px;
    background: #fff;
    border: 1px solid rgba(45, 68, 78, .12);
}

.chatbot-table th {
    background: rgba(244, 241, 234, .9);
    color: var(--chatbot-dark);
    font-weight: 600;
    white-space: nowrap;
}

.chatbot-table td,
.chatbot-table th {
    padding: 5px 7px !important;
    vertical-align: top;
}

/* Mobile Feinschliff: kompakter, nicht vollflächig */
@media (max-width: 575.98px) {
    .chatbot-root {
        right: 12px;
        bottom: 12px;
        left: auto;
        font-size: 13px;
    }

    .chatbot-toggle {
        min-height: 40px;
        padding: 0 14px;
        gap: 7px;
        font-size: 13px;
        box-shadow: 0 8px 22px rgba(0, 0, 0, .22);
    }

    .chatbot-toggle::before {
        width: 8px;
        height: 8px;
        box-shadow: 0 0 0 3px rgba(218, 190, 115, .16);
    }

    .chatbot-panel {
        width: min(360px, calc(100vw - 24px));
        height: min(520px, calc(100dvh - 92px));
        max-height: calc(100dvh - 92px);
        border-radius: 8px;
    }

    .chatbot-header {
        padding: 10px 12px;
        border-bottom-width: 2px;
    }

    .chatbot-title {
        font-size: 15px;
    }

    .chatbot-subtitle {
        font-size: 10px;
        margin-top: 1px;
    }

    .chatbot-close {
        width: 28px;
        height: 28px;
        font-size: 22px;
    }

    .chatbot-list {
        padding: 12px 10px;
    }

    .chatbot-message {
        margin-bottom: 9px;
    }

    .chatbot-bubble {
        max-width: 93%;
        padding: 8px 10px;
        font-size: 12.8px;
        line-height: 1.4;
        border-radius: 9px;
    }

    .chatbot-answer-list {
        padding-left: 16px !important;
    }

    .chatbot-answer-list li {
        margin-bottom: 3px;
    }

    .chatbot-feedback {
        max-width: 93%;
        font-size: 11.5px;
        margin-top: 4px;
    }

    .chatbot-feedback-btn {
        padding: 3px 7px;
        font-size: 11.5px;
    }

    .chatbot-form {
        gap: 6px;
        padding: 9px;
    }

    .chatbot-input {
        min-height: 38px;
        max-height: 82px;
        padding: 8px 10px;
        /* iOS/Chrome Mobile zoomen Eingabefelder unter 16px beim Fokus automatisch. */
        font-size: 16px;
        line-height: 1.25;
        border-radius: 7px;
        -webkit-text-size-adjust: 100%;
    }

    .chatbot-send {
        min-height: 38px;
        padding: 0 11px;
        font-size: 12.8px;
        border-radius: 7px;
    }


    .chatbot-form:focus-within {
        padding-bottom: max(9px, env(safe-area-inset-bottom));
    }

    .chatbot-table {
        font-size: 11.8px;
    }

    .chatbot-table td,
    .chatbot-table th {
        padding: 4px 5px !important;
    }
}

/* Sehr kleine Displays */
@media (max-width: 380px) {
    .chatbot-root {
        right: 8px;
        bottom: 8px;
    }

    .chatbot-panel {
        width: calc(100vw - 16px);
        height: min(500px, calc(100dvh - 76px));
        max-height: calc(100dvh - 76px);
    }

    .chatbot-toggle {
        min-height: 38px;
        padding: 0 12px;
        font-size: 12.5px;
    }
}


/* Statusanzeige beim Antworten */
.chatbot-message-status .chatbot-status-bubble {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--chatbot-muted);
    font-style: normal;
    max-width: max-content;
}

.chatbot-status-text {
    white-space: nowrap;
}

.chatbot-status-dots {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    transform: translateY(1px);
}

.chatbot-status-dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--chatbot-gold);
    opacity: .35;
    animation: chatbot-status-dot 1.15s infinite ease-in-out;
}

.chatbot-status-dots span:nth-child(2) {
    animation-delay: .15s;
}

.chatbot-status-dots span:nth-child(3) {
    animation-delay: .3s;
}

@keyframes chatbot-status-dot {
    0%, 80%, 100% {
        opacity: .3;
        transform: translateY(0);
    }
    40% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .chatbot-status-dots span {
        animation: none;
        opacity: .75;
    }
}

/* UI-Polish: Verlauf, Icons, Beta-Status und Leeren-Button */
.chatbot-root {
    --chatbot-header-gradient: linear-gradient(135deg, var(--chatbot-dark) 0%, #355662 58%, var(--chatbot-accent) 135%);
    --chatbot-soft-gradient: linear-gradient(180deg, rgba(244, 241, 234, .94) 0%, rgba(255, 255, 255, .98) 58%, rgba(244, 241, 234, .72) 100%);
}

.chatbot-toggle {
    background: var(--chatbot-header-gradient);
    gap: 8px;
}

.chatbot-toggle::before {
    content: none;
}

.chatbot-toggle i,
.chatbot-title-icon,
.chatbot-header-btn i,
.chatbot-send i,
.chatbot-footer-note i {
    line-height: 1;
    flex: 0 0 auto;
}

.chatbot-toggle i {
    font-size: 15px;
    color: var(--chatbot-gold);
}

.chatbot-toggle-label {
    display: inline-block;
}

.chatbot-panel {
    background: var(--chatbot-soft-gradient);
}

.chatbot-header {
    background: var(--chatbot-header-gradient);
    border-bottom: 3px solid var(--chatbot-gold);
    gap: 12px;
}

.chatbot-heading {
    flex: 1 1 auto;
}

.chatbot-title-row {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 8px;
}

.chatbot-title-icon {
    color: var(--chatbot-gold);
    font-size: 16px;
}

.chatbot-title {
    min-width: 0;
}

.chatbot-beta-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 18px;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(218, 190, 115, .18);
    border: 1px solid rgba(218, 190, 115, .62);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    line-height: 1;
}

.chatbot-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}

.chatbot-header-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 50%;
    background: rgba(255, 255, 255, .08);
    color: #fff;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    transition: background-color .15s ease, border-color .15s ease, transform .15s ease;
}

.chatbot-header-btn:hover,
.chatbot-header-btn:focus-visible {
    background: rgba(255, 255, 255, .18);
    border-color: rgba(255, 255, 255, .22);
    transform: translateY(-1px);
}

.chatbot-clear:hover,
.chatbot-clear:focus-visible {
    color: var(--chatbot-gold);
}

.chatbot-close {
    font-size: 14px;
    padding: 0;
}

.chatbot-list {
    background: var(--chatbot-soft-gradient);
}

.chatbot-message-assistant .chatbot-bubble {
    background: rgba(255, 255, 255, .96);
}

.chatbot-form {
    background: rgba(255, 255, 255, .96);
    backdrop-filter: blur(5px);
}

.chatbot-send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
}

.chatbot-send i {
    font-size: 13px;
}

.chatbot-footer-note {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    padding: 8px 12px 10px;
    border-top: 1px solid rgba(45, 68, 78, .1);
    background: rgba(244, 241, 234, .86);
    color: rgba(33, 37, 41, .68);
    font-size: 11.5px;
    line-height: 1.35;
}

.chatbot-footer-note i {
    color: var(--chatbot-accent);
    margin-top: 2px;
}

.chatbot-root-beta .chatbot-panel {
    border-color: rgba(218, 190, 115, .42);
}

@media (max-width: 575.98px) {
    .chatbot-header-actions {
        gap: 5px;
    }

    .chatbot-header-btn {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    .chatbot-title-row {
        gap: 7px;
    }

    .chatbot-beta-badge {
        padding: 2px 6px;
        font-size: 9px;
    }

    .chatbot-footer-note {
        padding: 7px 9px 8px;
        font-size: 10.8px;
    }

    .chatbot-send-label {
        display: none;
    }

    .chatbot-send {
        width: 42px;
        padding: 0;
    }
}
