/* ============================================================
   Nachbrand AI Chat – Frontend Chat-Styles
   ============================================================ */

/* ── Wrapper (enthält Button + Fenster) ─────────────────── */
#nbac-wrapper {
    position: fixed;
    z-index: 99999;
    font-family: system-ui, -apple-system, sans-serif;
    --nbac-radius: 12px;
}

/* ── Chat-Button ─────────────────────────────────────────── */
#nbac-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    border: none;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    line-height: 1;
    transition: transform .2s ease, box-shadow .2s ease, opacity .15s;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
    /* Farben & Stil kommen per JS als inline-Stil */
}

/* Hover-Animationen */
#nbac-toggle-btn.nbac-hover-grow:hover {
    transform: scale(1.08);
}

#nbac-toggle-btn.nbac-hover-glow:hover {
    box-shadow: 0 0 0 4px rgba(255, 255, 255, .35), 0 4px 20px rgba(0, 0, 0, .3);
}

#nbac-toggle-btn.nbac-hover-shake:hover {
    animation: nbac-shake .4s ease;
}

@keyframes nbac-shake {

    0%,
    100% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-4px);
    }

    40% {
        transform: translateX(4px);
    }

    60% {
        transform: translateX(-3px);
    }

    80% {
        transform: translateX(3px);
    }
}

/* Stil-Varianten */
#nbac-toggle-btn.nbac-style-rounded {
    border-radius: 8px;
}

#nbac-toggle-btn.nbac-style-pill {
    border-radius: 99px;
}

#nbac-toggle-btn.nbac-style-square {
    border-radius: 0;
}

/* Position-Varianten */
#nbac-wrapper.nbac-pos-bottom-right {
    bottom: 24px;
    right: 24px;
}

#nbac-wrapper.nbac-pos-bottom-left {
    bottom: 24px;
    left: 24px;
}

#nbac-wrapper.nbac-pos-middle-right {
    bottom: 50%;
    right: 24px;
    transform: translateY(50%);
}

#nbac-wrapper.nbac-pos-middle-left {
    bottom: 50%;
    left: 24px;
    transform: translateY(50%);
}

/* ── Chat-Fenster ────────────────────────────────────────── */
#nbac-chat-window {
    position: absolute;
    bottom: calc(100% + 12px);
    right: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Größe, Farben, Schatten kommen per JS als inline-Stil */
    transition: opacity .2s ease, transform .2s ease;
    transform-origin: bottom right;
    /* Nie breiter als der Viewport */
    max-width: calc(100vw - 16px);
    box-sizing: border-box;
}

#nbac-chat-window[hidden] {
    display: none;
}

#nbac-chat-window.nbac-shadow-light {
    box-shadow: 0 4px 12px rgba(0, 0, 0, .18);
}

#nbac-chat-window.nbac-shadow-medium {
    box-shadow: 0 8px 28px rgba(0, 0, 0, .28);
}

#nbac-chat-window.nbac-shadow-heavy {
    box-shadow: 0 12px 40px rgba(0, 0, 0, .42);
}

/* Minimiert-Ansicht */
#nbac-chat-window.nbac-minimized #nbac-messages,
#nbac-chat-window.nbac-minimized #nbac-input-area {
    display: none;
}

/* ── Header ──────────────────────────────────────────────── */
#nbac-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: rgba(0, 0, 0, .18);
    flex-shrink: 0;
}

#nbac-chat-title {
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nbac-header-actions {
    display: flex;
    gap: 6px;
}

.nbac-header-actions button {
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 4px 6px;
    border-radius: 4px;
    opacity: .75;
    transition: opacity .15s, background .15s;
}

.nbac-header-actions button:hover {
    opacity: 1;
    background: rgba(255, 255, 255, .15);
}

/* ── Nachrichten-Bereich ─────────────────────────────────── */
#nbac-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

/* Scrollbar */
#nbac-messages::-webkit-scrollbar {
    width: 5px;
}

#nbac-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .2);
    border-radius: 4px;
}

/* Nachrichtenblase Basis */
.nbac-msg {
    max-width: 82%;
    padding: 9px 13px;
    border-radius: 14px;
    line-height: 1.5;
    word-break: break-word;
    animation: nbac-fade-in .2s ease;
}

@keyframes nbac-fade-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Bot-Nachricht (links) */
.nbac-msg-bot {
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

/* Nutzer-Nachricht (rechts) */
.nbac-msg-user {
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* Tipp-Animation */
.nbac-msg-typing {
    align-self: flex-start;
    padding: 10px 14px;
}

.nbac-typing-dots {
    display: flex;
    gap: 5px;
}

.nbac-typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    opacity: .5;
    animation: nbac-bounce .9s infinite ease-in-out;
}

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

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

@keyframes nbac-bounce {

    0%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* ── Eingabebereich ──────────────────────────────────────── */
#nbac-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid rgba(255, 255, 255, .1);
    flex-shrink: 0;
}

#nbac-user-input {
    flex: 1;
    resize: none;
    border: none;
    outline: none;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: inherit;
    font-family: inherit;
    line-height: 1.45;
    max-height: 120px;
    overflow-y: auto;
    color: inherit;
}

#nbac-user-input::placeholder {
    opacity: .5;
}

#nbac-send-btn {
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: .85;
    transition: opacity .15s, background .15s;
    flex-shrink: 0;
}

#nbac-send-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, .15);
}

#nbac-send-btn:disabled {
    opacity: .4;
    cursor: default;
}

/* ── Mobile: Bottom Sheet ────────────────────────────────── */
@media (max-width: 767px) {
    #nbac-wrapper {
        left: 0 !important;
        right: 0 !important;
        bottom: 16px !important;
        box-sizing: border-box;
        /* Wrapper ist jetzt full-width → Button per Flex ausrichten */
        display: flex;
        justify-content: flex-end;
        /* Standard: rechts */
        padding: 0 16px;
    }

    /* Bei "links"-Positionen: Button nach links */
    #nbac-wrapper.nbac-pos-bottom-left,
    #nbac-wrapper.nbac-pos-middle-left {
        justify-content: flex-start;
    }

    /* Das Fenster: fixed, volle Breite via left+right (umgeht JS inline width!) */
    #nbac-chat-window {
        position: fixed !important;
        bottom: 0 !important;
        left: 8px !important;
        right: 8px !important;
        width: auto !important;
        /* überschreibt JS-inline width */
        max-width: none !important;
        height: 60vh !important;
        border-radius: 16px 16px 12px 12px !important;
        transform: none !important;
        box-sizing: border-box !important;
        /* iPhone safe-area (Home-Indicator) */
        padding-bottom: env(safe-area-inset-bottom, 0px) !important;
    }

    #nbac-wrapper.nbac-pos-middle-right,
    #nbac-wrapper.nbac-pos-middle-left {
        transform: none;
        bottom: 16px;
    }

    /* Eingabebereich: relative, damit Button absolut positionierbar */
    #nbac-input-area {
        position: relative;
        display: block;
        /* kein Flex mehr – Button wird absolut */
        padding: 10px 12px 12px;
        flex-shrink: 0;
    }

    /* Textarea füllt die volle Breite, Platz rechts für den Button */
    #nbac-user-input {
        width: 100% !important;
        box-sizing: border-box;
        padding-right: 48px;
        /* Platz für den Send-Button */
        min-height: 44px;
        max-height: 100px;
    }

    /* Send-Button: absolut, unten rechts in der Textarea */
    #nbac-send-btn {
        position: absolute;
        bottom: 16px;
        right: 16px;
        width: 36px;
        height: 36px;
        padding: 6px;
        border-radius: 50%;
        background: rgba(255, 255, 255, .15) !important;
        opacity: 1;
    }

    /* Toggle-Button auf Mobile kompakter */
    #nbac-toggle-btn {
        padding: 10px 14px;
        font-size: 14px;
    }
}