/*
 * AXION IT – Regelbasierter FAQ-Chatbot Widget
 * Keine KI · Kein Machine Learning · Keine externen APIs
 * Alle Antworten stammen ausschließlich aus verifizierten Website-Inhalten.
 */

/* ═══════════════════════════════════════════════════════════════════════
   ROOT – Floating Widget Container
   Positioniert oberhalb des Microsoft Teams-FAB (60px + 12px Abstand)
   ═══════════════════════════════════════════════════════════════════════ */

#axchat-root {
    position: fixed;
    right: max(16px, env(safe-area-inset-right));
    bottom: calc(max(16px, env(safe-area-inset-bottom)) + 72px);
    z-index: 2147483000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

/* ═══════════════════════════════════════════════════════════════════════
   FAB – Floating Action Button
   ═══════════════════════════════════════════════════════════════════════ */

#axchat-fab {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #C9B99A;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    flex-shrink: 0;
}

#axchat-fab:hover {
    background: #B8A889;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

#axchat-fab:active {
    transform: translateY(0);
}

#axchat-fab:focus-visible {
    outline: 3px solid #C9B99A;
    outline-offset: 3px;
}

.axchat-fab-icon {
    width: 26px;
    height: 26px;
    fill: #fff;
    display: block;
    flex-shrink: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.axchat-fab-icon--close {
    display: none;
}

#axchat-root.axchat-is-open .axchat-fab-icon--chat {
    display: none;
}

#axchat-root.axchat-is-open .axchat-fab-icon--close {
    display: block;
}

/* ═══════════════════════════════════════════════════════════════════════
   TOOLTIP
   ═══════════════════════════════════════════════════════════════════════ */

#axchat-tooltip {
    position: absolute;
    right: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%) translateX(4px);
    background: #1A1A1A;
    color: #fff;
    font-size: 12.5px;
    font-weight: 500;
    padding: 5px 10px;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s ease;
}

#axchat-tooltip::after {
    content: '';
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-left-color: #1A1A1A;
}

#axchat-fab:hover #axchat-tooltip,
#axchat-fab:focus-visible #axchat-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) translateX(0);
}

/* ═══════════════════════════════════════════════════════════════════════
   CHAT WINDOW
   ═══════════════════════════════════════════════════════════════════════ */

#axchat-window {
    position: absolute;
    bottom: calc(100% + 12px);
    right: 0;
    width: 340px;
    max-height: 520px;
    background: #fff;
    border: 1px solid #E5E5E5;
    border-radius: 16px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transform: scale(0.92) translateY(8px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.22s ease, opacity 0.22s ease;
}

#axchat-window.axchat-open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* ═══════════════════════════════════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════════════════════════════════ */

#axchat-header {
    background: #C9B99A;
    padding: 13px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.axchat-hdr-avatar {
    width: 34px;
    height: 34px;
    background: rgba(255, 255, 255, 0.28);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
}

.axchat-hdr-info {
    flex: 1;
    min-width: 0;
}

.axchat-hdr-name {
    font-weight: 600;
    font-size: 13.5px;
    color: #1A1A1A;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.axchat-hdr-sub {
    font-size: 11.5px;
    color: rgba(26, 26, 26, 0.6);
    margin-top: 1px;
}

#axchat-close {
    background: none;
    border: none;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(26, 26, 26, 0.7);
    flex-shrink: 0;
    transition: background 0.15s ease;
    font-size: 16px;
    line-height: 1;
}

#axchat-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #1A1A1A;
}

#axchat-close:focus-visible {
    outline: 2px solid rgba(26, 26, 26, 0.5);
    outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════════════════
   MESSAGES LIST
   ═══════════════════════════════════════════════════════════════════════ */

#axchat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
}

#axchat-messages::-webkit-scrollbar {
    width: 4px;
}

#axchat-messages::-webkit-scrollbar-track {
    background: transparent;
}

#axchat-messages::-webkit-scrollbar-thumb {
    background: #E5E5E5;
    border-radius: 2px;
}

/* ═══════════════════════════════════════════════════════════════════════
   MESSAGE BUBBLES
   ═══════════════════════════════════════════════════════════════════════ */

.axchat-msg {
    display: flex;
    max-width: 92%;
    animation: axchat-fadein 0.18s ease;
}

.axchat-msg--bot {
    align-self: flex-start;
}

.axchat-msg--user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.axchat-msg__bubble {
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.55;
    word-break: break-word;
    word-wrap: break-word;
}

.axchat-msg--bot .axchat-msg__bubble {
    background: #F5F5F5;
    border-bottom-left-radius: 4px;
    color: #1A1A1A;
}

.axchat-msg--user .axchat-msg__bubble {
    background: #C9B99A;
    border-bottom-right-radius: 4px;
    color: #1A1A1A;
}

.axchat-msg__bubble a {
    color: #7A6A50;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.axchat-msg__bubble a:hover {
    color: #5A4A30;
}

.axchat-msg__bubble ul {
    margin: 6px 0 2px 0;
    padding-left: 16px;
}

.axchat-msg__bubble li {
    margin-bottom: 3px;
}

.axchat-msg__bubble strong {
    font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════════════════
   QUICK REPLY BUTTONS
   ═══════════════════════════════════════════════════════════════════════ */

.axchat-quickreplies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-self: flex-start;
    max-width: 100%;
    animation: axchat-fadein 0.22s ease;
}

.axchat-qr-btn {
    font-size: 11px;
    font-family: inherit;
    padding: 3px 9px;
    border: 1px solid #C9B99A;
    background: #fff;
    color: #7A6A50;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    white-space: nowrap;
    line-height: 1.3;
}

.axchat-qr-btn:hover {
    background: #C9B99A;
    color: #1A1A1A;
}

.axchat-qr-btn:focus-visible {
    outline: 2px solid #C9B99A;
    outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════════════════
   TYPING INDICATOR
   ═══════════════════════════════════════════════════════════════════════ */

.axchat-typing {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: #F5F5F5;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    animation: axchat-fadein 0.18s ease;
}

.axchat-typing span {
    width: 6px;
    height: 6px;
    background: #AAAAAA;
    border-radius: 50%;
    animation: axchat-bounce 1.2s infinite ease-in-out;
}

.axchat-typing span:nth-child(2) { animation-delay: 0.2s; }
.axchat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes axchat-bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40%           { transform: translateY(-5px); }
}

@keyframes axchat-fadein {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════════════════════════════════
   INPUT BAR
   ═══════════════════════════════════════════════════════════════════════ */

#axchat-inputbar {
    border-top: 1px solid #E5E5E5;
    padding: 10px 12px;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
    background: #fff;
}

#axchat-input {
    flex: 1;
    min-width: 0;
    border: 1px solid #E5E5E5;
    border-radius: 20px;
    padding: 7px 13px;
    font-size: 13.5px;
    font-family: inherit;
    resize: none;
    outline: none;
    line-height: 1.45;
    max-height: 80px;
    overflow-y: auto;
    background: #FAFAFA;
    color: #1A1A1A;
    transition: border-color 0.15s ease, background 0.15s ease;
}

#axchat-input:focus {
    border-color: #C9B99A;
    background: #fff;
}

#axchat-input::placeholder {
    color: #AAAAAA;
}

#axchat-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #C9B99A;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s ease, transform 0.1s ease;
}

#axchat-send:hover {
    background: #B8A889;
}

#axchat-send:active {
    transform: scale(0.92);
}

#axchat-send:focus-visible {
    outline: 2px solid #C9B99A;
    outline-offset: 2px;
}

#axchat-send svg {
    width: 16px;
    height: 16px;
    fill: #fff;
    display: block;
}

/* ═══════════════════════════════════════════════════════════════════════
   ACCESSIBILITY – Screen Reader Only
   ═══════════════════════════════════════════════════════════════════════ */

.axchat-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ═══════════════════════════════════════════════════════════════════════
   MOBILE ADJUSTMENTS (max-width: 480px)
   ═══════════════════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
    #axchat-root {
        right: max(12px, env(safe-area-inset-right));
        bottom: calc(max(12px, env(safe-area-inset-bottom)) + 66px);
    }

    /* FAB ausblenden wenn Chat offen – Header-X-Button reicht auf Mobile */
    #axchat-root.axchat-is-open #axchat-fab {
        display: none;
    }

    /* Fenster löst sich vom FAB und wird als Vollbild-Overlay positioniert */
    #axchat-window {
        position: fixed;
        bottom: calc(max(12px, env(safe-area-inset-bottom)) + 72px);
        left: 10px;
        right: 10px;
        width: auto;
        max-height: calc(100dvh - 100px);
        max-height: calc(100vh - 100px); /* Fallback */
        border-radius: 16px;
        transform-origin: bottom center;
    }
}

@media (max-width: 360px) {
    #axchat-window {
        left: 6px;
        right: 6px;
        max-height: calc(100dvh - 90px);
        max-height: calc(100vh - 90px);
    }
}
