/**
 * AI Chat Widget Styles
 * Kompakt, mobil-optimiert, UTF-8 safe
 */

/* === FLOATING BUTTON === */
.chat-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 30px;
    background: #4f46e5;
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 9998;
    padding: 0;
}

.chat-toggle:hover {
    background: #4338ca;
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.5);
}

.chat-toggle.chat-toggle-open {
    transform: scale(0.9);
}

.chat-toggle svg {
    width: 28px;
    height: 28px;
}

/* Badge */
.chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: white;
    font-size: 12px;
    font-weight: bold;
    width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

/* === CHAT PANEL === */
.chat-panel {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 550px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    overflow: hidden;
}

/* === HEADER === */
.chat-header {
    background: #4f46e5;
    color: white;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-header-left svg {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chat-title {
    font-weight: 600;
    font-size: 15px;
}

.chat-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-language-select {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 13px;
    cursor: pointer;
    outline: none;
}

.chat-language-select option {
    background: #4f46e5;
    color: white;
}

.chat-btn-icon {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    line-height: 1;
    transition: background 0.2s;
}

.chat-btn-icon:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* === MESSAGES === */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.chat-message {
    display: flex;
    margin-bottom: 4px;
}

.chat-message-user {
    justify-content: flex-end;
}

.chat-message-bot {
    justify-content: flex-start;
}

.chat-message-content {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.chat-message-user .chat-message-content {
    background: #4f46e5;
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message-bot .chat-message-content {
    background: white;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

.chat-message-error .chat-message-content {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

/* === TYPING INDICATOR === */
.chat-typing {
    padding: 0 16px 8px 16px;
    display: flex;
    gap: 4px;
    align-items: center;
}

.chat-typing span {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.chat-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* === INPUT AREA === */
.chat-input-area {
    padding: 12px 16px;
    background: white;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 120px;
    min-height: 40px;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: #4f46e5;
}

.chat-input::placeholder {
    color: #9ca3af;
}

.chat-send-btn {
    background: #4f46e5;
    color: white;
    border: none;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.chat-send-btn:hover:not(:disabled) {
    background: #4338ca;
    transform: scale(1.05);
}

.chat-send-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    opacity: 0.5;
}

.chat-send-btn svg {
    width: 18px;
    height: 18px;
}

/* === MOBILE RESPONSIVE === */
@media (max-width: 480px) {
    .chat-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }
    
    .chat-toggle {
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
    }
    
    .chat-toggle svg {
        width: 24px;
        height: 24px;
    }
}

/* === FIRMEN-BEREICH (grünes Theme) === */
[data-area="firmen"] .chat-toggle {
    background: #10b981;
}

[data-area="firmen"] .chat-toggle:hover {
    background: #059669;
}

[data-area="firmen"] .chat-header {
    background: #10b981;
}

[data-area="firmen"] .chat-message-user .chat-message-content {
    background: #10b981;
}

[data-area="firmen"] .chat-input:focus {
    border-color: #10b981;
}

[data-area="firmen"] .chat-send-btn {
    background: #10b981;
}

[data-area="firmen"] .chat-send-btn:hover:not(:disabled) {
    background: #059669;
}

/* === ANIMATIONS === */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-panel {
    animation: slideIn 0.3s ease-out;
}