/* ==========================================================================
   Hannelore — Frontend-Flyout
   Brand-Farben aus DESIGN.md (Primary #29BD98, Dark #0C1E21, Surface #20232B)
   Bexon-konsistenter Blur-Overlay analog .body-overlay (backdrop-filter: blur)
   ========================================================================== */

#ehnes-hannelore {
    --eh-primary:    #29BD98;
    --eh-primary-2:  #00A88C;
    --eh-dark:       #0C1E21;
    --eh-surface:    #20232B;
    --eh-text:       #15293A;
    --eh-text-muted: #5a6875;
    --eh-border:     #C9D2CD;
    --eh-bg-soft:    #F4F5F7;
    --eh-radius:     16px;
    --eh-radius-sm:  12px;

    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    font-family: 'Ubuntu', system-ui, -apple-system, "Segoe UI", sans-serif;
    color: var(--eh-text);
}

/* Trigger-Bubble */
.ehnes-hannelore__bubble {
    position: fixed;
    bottom: 28px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px 12px 14px;
    background: var(--eh-primary);
    color: #fff;
    border: 0;
    border-radius: 50px;
    font: 600 15px/1 'Ubuntu', sans-serif;
    cursor: pointer;
    box-shadow: 0 10px 28px rgba(12, 30, 33, 0.18);
    pointer-events: auto;
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.ehnes-hannelore--right .ehnes-hannelore__bubble { right: 28px; }
.ehnes-hannelore--left  .ehnes-hannelore__bubble { left:  28px; }

.ehnes-hannelore__bubble:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 36px rgba(12, 30, 33, 0.25);
    background: var(--eh-primary-2);
}
.ehnes-hannelore__bubble-icon {
    width: 28px; height: 28px;
    display: inline-grid; place-items: center;
    background: var(--eh-dark);
    border-radius: 50%;
}
.ehnes-hannelore__bubble-icon svg { width: 16px; height: 16px; color: #fff; }

/* Overlay (Bexon-Pattern) */
.ehnes-hannelore__overlay {
    position: fixed;
    inset: 0;
    z-index: 1;
    background: rgba(12, 30, 33, 0.35);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity .25s ease;
    pointer-events: none;
}
#ehnes-hannelore[data-state="open"] .ehnes-hannelore__overlay {
    opacity: 1;
    pointer-events: auto;
}

/* Panel */
.ehnes-hannelore__panel {
    position: fixed;
    top: 0; bottom: 0;
    z-index: 2;
    width: min(440px, 100vw);
    background: #fff;
    box-shadow: -10px 0 40px rgba(12, 30, 33, .18);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform .3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
}
.ehnes-hannelore--right .ehnes-hannelore__panel { right: 0; }
.ehnes-hannelore--left  .ehnes-hannelore__panel { left: 0; transform: translateX(-100%); box-shadow: 10px 0 40px rgba(12, 30, 33, .18); }

#ehnes-hannelore[data-state="open"] .ehnes-hannelore__panel {
    transform: translateX(0);
}

/* Header */
.ehnes-hannelore__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--eh-border);
    background: linear-gradient(180deg, #f9fbfa 0%, #fff 100%);
}
.ehnes-hannelore__avatar {
    width: 42px; height: 42px;
    border-radius: 50%;
    background: var(--eh-primary);
    color: #fff;
    display: grid; place-items: center;
    font: 700 18px/1 'Ubuntu', sans-serif;
}
.ehnes-hannelore__head-text { flex: 1; min-width: 0; }
.ehnes-hannelore__title {
    font: 600 17px/1.2 'Ubuntu', sans-serif;
    margin: 0 0 2px;
    color: var(--eh-text);
}
.ehnes-hannelore__subtitle {
    margin: 0;
    font-size: 12px;
    color: var(--eh-text-muted);
}
.ehnes-hannelore__close {
    background: transparent;
    border: 0;
    width: 36px; height: 36px;
    border-radius: 50%;
    color: var(--eh-text-muted);
    display: grid; place-items: center;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.ehnes-hannelore__close:hover { background: var(--eh-bg-soft); color: var(--eh-text); }
.ehnes-hannelore__close svg { width: 18px; height: 18px; }

/* Body */
.ehnes-hannelore__body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--eh-bg-soft);
    scroll-behavior: smooth;
}
.ehnes-hannelore__loading {
    text-align: center;
    color: var(--eh-text-muted);
    padding: 40px 0;
}

/* Consent-Screen */
.ehnes-hannelore__consent { padding: 8px 4px; }
.ehnes-hannelore__consent h3 {
    font: 600 16px/1.3 'Ubuntu', sans-serif;
    margin: 0 0 12px;
}
.ehnes-hannelore__consent p {
    font-size: 14px;
    line-height: 1.55;
    color: var(--eh-text-muted);
    margin: 0 0 18px;
}
.ehnes-hannelore__consent a { color: var(--eh-primary-2); text-decoration: underline; }
.ehnes-hannelore__consent-actions {
    display: flex; gap: 8px; flex-wrap: wrap;
}
.ehnes-hannelore__btn {
    padding: 12px 20px;
    border: 0;
    border-radius: 50px;
    font: 600 14px/1 'Ubuntu', sans-serif;
    cursor: pointer;
    transition: background .15s, color .15s, transform .15s;
}
.ehnes-hannelore__btn--primary {
    background: var(--eh-primary);
    color: #fff;
}
.ehnes-hannelore__btn--primary:hover { background: var(--eh-primary-2); transform: translateY(-1px); }
.ehnes-hannelore__btn--ghost {
    background: transparent;
    color: var(--eh-text);
    border: 1px solid var(--eh-border);
}
.ehnes-hannelore__btn--ghost:hover { background: #fff; }

/* Messages */
.ehnes-hannelore__messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.ehnes-hannelore__msg {
    max-width: 85%;
    padding: 12px 14px;
    border-radius: var(--eh-radius-sm);
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}
.ehnes-hannelore__msg--bot {
    background: #fff;
    border: 1px solid var(--eh-border);
    align-self: flex-start;
    border-top-left-radius: 4px;
}
.ehnes-hannelore__msg--user {
    background: var(--eh-primary);
    color: #fff;
    align-self: flex-end;
    border-top-right-radius: 4px;
}
.ehnes-hannelore__msg p { margin: 0 0 8px; }
.ehnes-hannelore__msg p:last-child { margin: 0; }
.ehnes-hannelore__msg ul, .ehnes-hannelore__msg ol { margin: 6px 0; padding-left: 22px; }
.ehnes-hannelore__msg a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.ehnes-hannelore__msg--bot a { color: var(--eh-primary-2); }

.ehnes-hannelore__sources {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed var(--eh-border);
    font-size: 12px;
    color: var(--eh-text-muted);
}
.ehnes-hannelore__sources strong { color: var(--eh-text); display: block; margin-bottom: 4px; }
.ehnes-hannelore__sources a { display: block; color: var(--eh-primary-2); text-decoration: none; padding: 2px 0; }
.ehnes-hannelore__sources a:hover { text-decoration: underline; }

/* Typing-Indicator */
.ehnes-hannelore__typing {
    display: inline-flex; gap: 4px; padding: 12px 16px;
    background: #fff; border: 1px solid var(--eh-border);
    border-radius: var(--eh-radius-sm);
    align-self: flex-start;
}
.ehnes-hannelore__typing span {
    width: 6px; height: 6px;
    background: var(--eh-text-muted);
    border-radius: 50%;
    animation: ehnes-typing 1.4s ease-in-out infinite;
}
.ehnes-hannelore__typing span:nth-child(2) { animation-delay: .2s; }
.ehnes-hannelore__typing span:nth-child(3) { animation-delay: .4s; }
@keyframes ehnes-typing {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30%           { opacity: 1;   transform: translateY(-4px); }
}

/* Footer (Eingabe) */
.ehnes-hannelore__footer {
    padding: 14px 16px 16px;
    border-top: 1px solid var(--eh-border);
    background: #fff;
}
.ehnes-hannelore__form {
    display: flex; gap: 8px; align-items: flex-end;
}
.ehnes-hannelore__input {
    flex: 1;
    padding: 12px 14px;
    border: 1px solid var(--eh-border);
    border-radius: var(--eh-radius-sm);
    font: 400 14px/1.4 'Ubuntu', sans-serif;
    color: var(--eh-text);
    resize: none;
    max-height: 120px;
    background: #fff;
    transition: border-color .15s;
}
.ehnes-hannelore__input:focus {
    outline: none;
    border-color: var(--eh-primary);
}
.ehnes-hannelore__send {
    width: 44px; height: 44px;
    border: 0;
    border-radius: 50%;
    background: var(--eh-primary);
    color: #fff;
    display: grid; place-items: center;
    cursor: pointer;
    transition: background .15s, transform .15s;
    flex-shrink: 0;
}
.ehnes-hannelore__send:hover { background: var(--eh-primary-2); transform: translateY(-1px); }
.ehnes-hannelore__send:disabled {
    background: var(--eh-border);
    cursor: not-allowed;
    transform: none;
}
.ehnes-hannelore__send svg { width: 18px; height: 18px; }
.ehnes-hannelore__disclaimer {
    margin: 8px 2px 0;
    font-size: 11px;
    color: var(--eh-text-muted);
    text-align: center;
}

/* Mobile */
@media (max-width: 600px) {
    .ehnes-hannelore__panel { width: 100vw; }
    .ehnes-hannelore--right .ehnes-hannelore__bubble { right: 16px; bottom: 16px; }
    .ehnes-hannelore--left  .ehnes-hannelore__bubble { left:  16px; bottom: 16px; }
    .ehnes-hannelore__bubble-label { display: none; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .ehnes-hannelore__panel,
    .ehnes-hannelore__overlay,
    .ehnes-hannelore__bubble,
    .ehnes-hannelore__btn { transition: none; }
}

/* ==========================================================================
   Floating-Stack Koordination (Desktop + Mobile)
   Hannelore-Bubble ankert unten rechts; Bexon Back-to-Top und
   Pojo-Accessibility-Widget werden darueber gestapelt damit nichts
   ueberlappt. !important ist noetig weil die Drittplugins ihre eigenen
   inline/specificity-Styles setzen.
   ========================================================================== */

/* Bexon Back-to-Top: ueber Hannelore-Bubble */
#tj-back-to-top,
#tj-back-to-top.active {
    bottom: 96px !important;
    inset-inline-end: 28px !important;
    right: 28px !important;
}

/* Pojo-Accessibility Widget-Trigger: ueber Back-to-Top */
.ally-widget-trigger {
    bottom: 172px !important;
    right: 28px !important;
    inset-inline-end: 28px !important;
}

@media (max-width: 600px) {
    #tj-back-to-top,
    #tj-back-to-top.active {
        bottom: 78px !important;
        right: 16px !important;
        inset-inline-end: 16px !important;
    }
    .ally-widget-trigger {
        bottom: 140px !important;
        right: 16px !important;
        inset-inline-end: 16px !important;
    }
}
