/* KI-Chatberater – Widget (nur auf /drucker-kopierer eingebunden) */

.hwt-chat-fab {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1085;
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 50%;
    background: var(--color-accent, #e8860a);
    color: #fff;
    font-size: 1.6rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .28);
    transition: transform .15s ease, background .15s ease;
}
.hwt-chat-fab:hover { background: var(--color-accent-hover, #c97209); transform: translateY(-2px); }
.hwt-chat-fab.is-open { display: none; }

/* Teaser-Sprechblase neben dem FAB */
.hwt-chat-teaser {
    position: fixed;
    right: 92px;
    bottom: 28px;
    z-index: 1084;
    max-width: 260px;
    background: var(--color-bg-elevated, #fff);
    color: var(--color-text-body, #1e2a38);
    border: 1px solid var(--color-border, #dde3ea);
    border-radius: 14px;
    padding: 11px 30px 11px 14px;
    font-size: .88rem;
    line-height: 1.4;
    box-shadow: 0 8px 28px rgba(0, 0, 0, .18);
    cursor: pointer;
    opacity: 0;
    transform: translateY(8px) scale(.96);
    transition: opacity .22s ease, transform .22s ease;
}
.hwt-chat-teaser.show {
    opacity: 1;
    transform: translateY(0) scale(1);
    animation: hwtChatPop .55s ease 1;
}
.hwt-chat-teaser:hover { transform: translateY(-2px) scale(1.02); }
@keyframes hwtChatPop {
    0%   { transform: translateY(0) scale(1); }
    30%  { transform: translateY(-4px) scale(1.04); }
    60%  { transform: translateY(0)    scale(.98); }
    100% { transform: translateY(0)    scale(1); }
}
.hwt-chat-teaser::after {
    content: '';
    position: absolute;
    right: -7px; bottom: 18px;
    width: 0; height: 0;
    border-top: 7px solid transparent;
    border-bottom: 7px solid transparent;
    border-left: 7px solid var(--color-bg-elevated, #fff);
}
.hwt-chat-teaser-close {
    position: absolute;
    top: 4px; right: 4px;
    width: 22px; height: 22px;
    border: none; background: transparent;
    color: var(--color-text-muted, #5a6a7a);
    font-size: 1.05rem; line-height: 1;
    cursor: pointer; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}
.hwt-chat-teaser-close:hover {
    background: var(--color-bg-soft, #f4f6f9);
    color: var(--color-text-body, #1e2a38);
}

.hwt-chat-panel {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1086;
    width: 380px;
    max-width: calc(100vw - 24px);
    height: 560px;
    max-height: calc(100vh - 32px);
    display: none;
    flex-direction: column;
    background: var(--color-bg-elevated, #fff);
    color: var(--color-text-body, #1e2a38);
    border: 1px solid var(--color-border, #dde3ea);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .30);
    overflow: hidden;
}
.hwt-chat-panel.is-open { display: flex; }

.hwt-chat-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--color-primary, #1a3a5c), var(--color-primary-dark, #102540));
    color: #fff;
}
.hwt-chat-head .hwt-chat-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .15);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; flex-shrink: 0;
}
.hwt-chat-head .hwt-chat-title { font-weight: 700; font-size: .98rem; line-height: 1.2; }
.hwt-chat-head .hwt-chat-sub   { font-size: .76rem; opacity: .8; }
.hwt-chat-close {
    margin-left: auto;
    background: transparent; border: none; color: #fff;
    font-size: 1.2rem; cursor: pointer; opacity: .85; padding: 4px 6px;
}
.hwt-chat-close:hover { opacity: 1; }

.hwt-chat-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--color-bg-soft, #f4f6f9);
}

.hwt-chat-msg {
    max-width: 85%;
    padding: 9px 13px;
    border-radius: 14px;
    font-size: .9rem;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: normal;
}
.hwt-chat-msg a { color: inherit; text-decoration: underline; }
.hwt-chat-msg.bot {
    align-self: flex-start;
    background: var(--color-bg-elevated, #fff);
    color: var(--color-text-body, #1e2a38);
    border: 1px solid var(--color-border, #dde3ea);
    border-bottom-left-radius: 4px;
}
.hwt-chat-msg.user {
    align-self: flex-end;
    background: var(--color-accent, #e8860a);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.hwt-chat-msg.error {
    align-self: flex-start;
    background: var(--color-danger-bg, #fef2f2);
    color: var(--color-danger-text, #991b1b);
    border: 1px solid var(--color-danger-border, #fecaca);
    border-bottom-left-radius: 4px;
}

.hwt-chat-consent {
    background: var(--color-bg-elevated, #fff);
    border: 1px solid var(--color-border, #dde3ea);
    border-radius: 14px;
    padding: 14px 16px;
    font-size: .86rem;
    line-height: 1.5;
    color: var(--color-text-body, #1e2a38);
}
.hwt-chat-consent p { margin: 0 0 10px; }
.hwt-chat-consent-link { font-size: .8rem; }
.hwt-chat-consent a { color: var(--color-accent, #e8860a); }
.hwt-chat-consent-btn {
    width: 100%;
    border: none;
    border-radius: 10px;
    background: var(--color-accent, #e8860a);
    color: #fff;
    font-weight: 600;
    padding: 10px 14px;
    cursor: pointer;
    margin-top: 4px;
}
.hwt-chat-consent-btn:hover { background: var(--color-accent-hover, #c97209); }

/* Übergabe-Formular (Lead-Erfassung nach [HANDOFF]) */
.hwt-chat-handoff {
    align-self: stretch;
    background: var(--color-bg-elevated, #fff);
    border: 1px solid var(--color-border, #dde3ea);
    border-radius: 14px;
    padding: 14px 14px 12px;
    margin-top: 4px;
}
.hwt-chat-handoff-title {
    font-weight: 600;
    font-size: .85rem;
    margin-bottom: 8px;
    color: var(--color-text-body, #1e2a38);
}
.hwt-chat-handoff-input {
    display: block;
    width: 100%;
    padding: 7px 10px;
    margin-bottom: 6px;
    font-size: .85rem;
    border: 1px solid var(--color-border, #dde3ea);
    border-radius: 8px;
    background: var(--color-bg, #fff);
    color: var(--color-text-body, #1e2a38);
    font-family: inherit;
}
.hwt-chat-handoff-input:focus {
    outline: none;
    border-color: var(--color-accent, #e8860a);
}
.hwt-chat-handoff-btn {
    width: 100%;
    border: none;
    border-radius: 10px;
    background: var(--color-accent, #e8860a);
    color: #fff;
    font-weight: 600;
    padding: 9px 14px;
    cursor: pointer;
    margin-top: 4px;
    font-size: .9rem;
}
.hwt-chat-handoff-btn:hover:not(:disabled) { background: var(--color-accent-hover, #c97209); }
.hwt-chat-handoff-btn:disabled { opacity: .6; cursor: default; }
.hwt-chat-handoff-msg {
    font-size: .8rem;
    margin-top: 6px;
}
.hwt-chat-handoff-success {
    align-self: flex-start;
    background: var(--color-success-bg, #f0fdf4);
    color: var(--color-success-text, #166534);
    border: 1px solid var(--color-success-border, #bbf7d0);
    border-radius: 12px;
    padding: 10px 13px;
    font-size: .88rem;
    line-height: 1.4;
}

.hwt-chat-typing {
    align-self: flex-start;
    display: inline-flex;
    gap: 4px;
    padding: 11px 14px;
    background: var(--color-bg-elevated, #fff);
    border: 1px solid var(--color-border, #dde3ea);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}
.hwt-chat-typing span {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--color-text-muted, #5a6a7a);
    opacity: .5;
    animation: hwtChatBlink 1.2s infinite ease-in-out both;
}
.hwt-chat-typing span:nth-child(2) { animation-delay: .2s; }
.hwt-chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes hwtChatBlink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: .9; } }

.hwt-chat-foot {
    flex: 0 0 auto;
    border-top: 1px solid var(--color-border, #dde3ea);
    background: var(--color-bg-elevated, #fff);
    padding: 10px 12px;
}
.hwt-chat-inputrow { display: flex; align-items: flex-end; gap: 8px; }
.hwt-chat-input {
    flex: 1 1 auto;
    resize: none;
    max-height: 110px;
    border: 1px solid var(--color-border, #dde3ea);
    border-radius: 10px;
    background: var(--color-bg, #fff);
    color: var(--color-text-body, #1e2a38);
    padding: 9px 11px;
    font-size: .9rem;
    line-height: 1.4;
    font-family: inherit;
}
.hwt-chat-input:focus { outline: none; border-color: var(--color-accent, #e8860a); }
.hwt-chat-send {
    flex: 0 0 auto;
    width: 40px; height: 40px;
    border: none; border-radius: 10px;
    background: var(--color-accent, #e8860a);
    color: #fff; font-size: 1.05rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s ease;
}
.hwt-chat-send:hover:not(:disabled) { background: var(--color-accent-hover, #c97209); }
.hwt-chat-send:disabled { opacity: .5; cursor: default; }
.hwt-chat-note {
    margin: 7px 2px 0;
    font-size: .68rem;
    line-height: 1.35;
    color: var(--color-text-muted, #5a6a7a);
    text-align: center;
}
.hwt-chat-note a { color: inherit; text-decoration: underline; }

@media (max-width: 480px) {
    .hwt-chat-panel { right: 12px; left: 12px; bottom: 12px; width: auto; height: calc(100vh - 24px); }
    .hwt-chat-fab  { right: 14px; bottom: 14px; }
    .hwt-chat-teaser { right: 14px; bottom: 86px; max-width: calc(100vw - 28px); }
    .hwt-chat-teaser::after { display: none; }
}
