/* === Chat Widget — fehlercode.io === */
.message-container {
    display: flex;
    align-items: flex-start;
    margin-bottom: 10px;
}
.chat-bubble {
    max-width: 85%;
    padding: 10px 15px;
    border-radius: 15px;
    position: relative;
    font-size: 14px;
    line-height: 1.5;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.chat-widget {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 460px;
    height: 620px;
    max-height: calc(100vh - 120px);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    overflow: hidden;
    transform: translateY(0);
    opacity: 1;
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1), opacity 0.3s cubic-bezier(0.4,0,0.2,1);
}
.chat-widget--closed {
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}
.chat-widget__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    flex-shrink: 0;
}
.chat-widget__header strong {
    font-size: 1.05rem;
}
.chat-agent-info {
    display: flex;
    align-items: center;
    gap: 10px;
}
.chat-agent-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
    position: relative;
}
.chat-online-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid #667eea;
    animation: online-pulse 2s ease-in-out infinite;
}
@keyframes online-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0.5); }
    50% { box-shadow: 0 0 0 4px rgba(34,197,94,0); }
}
.chat-agent-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}
.chat-agent-status {
    font-size: 0.75rem;
    opacity: 0.9;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.chat-status-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    background: #22c55e;
    border-radius: 50%;
}
.chat-widget__close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    font-size: 1.2rem;
}
.chat-widget__close:hover { opacity: 0.8; }
.chat-widget #chat-area {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding: 15px;
}
.chat-widget__footer {
    flex-shrink: 0;
    padding: 12px;
    border-top: 1px solid #e5e7eb;
    background: #fafafa;
}
.chat-widget__footer .input-group {
    border-radius: 12px;
    overflow: hidden;
}
.chat-widget__footer input {
    border: 1.5px solid #e2e8f0;
    font-size: 0.9rem;
    padding: 0.6rem 0.9rem;
}
.chat-widget__footer input:focus {
    box-shadow: 0 0 0 2px rgba(102,126,234,0.15);
    border-color: #667eea;
}
.chat-widget__footer .btn-send {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none;
    color: white;
    padding: 0 1rem;
    font-size: 1rem;
}
.chat-widget__footer .btn-send:hover {
    opacity: 0.9;
}

/* Messages */
.user-message {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    margin-left: auto;
    border-top-right-radius: 0;
}
.gpt-message {
    background: #f1f5f9;
    color: #0f172a;
    border-top-left-radius: 0;
}
.gpt-message p { margin: 0 0 0.4em; }
.gpt-message p:last-child { margin: 0; }
.gpt-message ul, .gpt-message ol { margin: 0.3em 0; padding-left: 1.2em; }
.gpt-message code {
    background: #e2e8f0;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.88em;
}
.gpt-message strong { font-weight: 700; }

.message-icon {
    width: 30px;
    height: 30px;
    margin-right: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
}
.bot-icon {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}
.user-icon {
    background: #e2e8f0;
    color: #64748b;
    margin-left: 8px;
    margin-right: 0;
}

/* Loading */
.loading-bubble {
    max-width: 70%;
    padding: 10px 15px;
    border-radius: 15px;
    background: #f1f5f9;
    position: relative;
    font-size: 14px;
    line-height: 1.4;
    margin-bottom: 10px;
    border-top-left-radius: 0;
    display: inline-block;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.loading-dots {
    display: inline-block;
    font-size: 18px;
    letter-spacing: 2px;
}
.loading-dots span {
    animation: blink 1.5s infinite;
    opacity: 0;
}
.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink {
    0%, 80%, 100% { opacity: 0; }
    40% { opacity: 1; }
}

/* FAB */
.chat-fab {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.chat-fab.is-hidden {
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
}
.fab-button {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 4px 14px rgba(102,126,234,0.35);
    cursor: pointer;
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.4rem;
}
.fab-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(102,126,234,0.5);
}
.fab-button:active { transform: scale(0.95); }
.fab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #22c55e;
    color: white;
    font-size: 11px;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}
.fab-label {
    background: white;
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
    box-shadow: 0 2px 12px rgba(0,0,0,0.1);
    white-space: nowrap;
    opacity: 0;
    transform: translateX(10px);
    transition: all 0.3s;
}
.fab-label--visible {
    opacity: 1;
    transform: translateX(0);
}

/* Mobile */
@media (max-width: 768px) {
    .chat-widget {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    .chat-fab { bottom: 16px; right: 16px; }
}
body.chat-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}
body.chat-open .chat-fab { display: none !important; }
