/* Cali Chatbot Styles - Dark Mode Support */

/* CSS Custom Properties für Theme-Switching */
:root {
    /* Light Mode (Default) */
    --chatbot-bg: #ffffff;
    --chatbot-text: #374151;
    --chatbot-border: #e5e7eb;
    --chatbot-shadow: rgba(0, 0, 0, 0.15);
    --chatbot-shadow-hover: rgba(0, 0, 0, 0.2);
    
    /* Messages */
    --bot-message-bg: #f3f4f6;
    --bot-message-text: #374151;
    --bot-message-border: #e5e7eb;
    --user-message-bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --user-message-text: #ffffff;
    
    /* Input */
    --input-bg: #ffffff;
    --input-border: #e5e7eb;
    --input-border-focus: #4F46E5;
    --input-text: #374151;
    --input-placeholder: #9ca3af;
    
    /* Quick Replies */
    --quick-reply-bg: #ffffff;
    --quick-reply-border: #e5e7eb;
    --quick-reply-hover-bg: #f9fafb;
    --quick-reply-hover-border: #d1d5db;
    --quick-reply-text: #374151;
    
    /* Header Gradient bleibt gleich */
    --header-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --trigger-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --trigger-gradient-active: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    
    /* Typing Indicator */
    --typing-bg: #f3f4f6;
    --typing-border: #e5e7eb;
    --typing-text: #6b7280;
    --typing-dot: #9ca3af;
}

/* Dark Mode Variables */
:root[data-theme="dark"] {
    --chatbot-bg: #1f2937;
    --chatbot-text: #f9fafb;
    --chatbot-border: #374151;
    --chatbot-shadow: rgba(0, 0, 0, 0.3);
    --chatbot-shadow-hover: rgba(0, 0, 0, 0.4);
    
    /* Messages */
    --bot-message-bg: #374151;
    --bot-message-text: #f9fafb;
    --bot-message-border: #4b5563;
    /* User message gradient bleibt gleich - sieht in dark gut aus */
    
    /* Input */
    --input-bg: #374151;
    --input-border: #4b5563;
    --input-border-focus: #6366f1;
    --input-text: #f9fafb;
    --input-placeholder: #9ca3af;
    
    /* Quick Replies */
    --quick-reply-bg: #374151;
    --quick-reply-border: #4b5563;
    --quick-reply-hover-bg: #4b5563;
    --quick-reply-hover-border: #6b7280;
    --quick-reply-text: #f9fafb;
    
    /* Typing Indicator */
    --typing-bg: #374151;
    --typing-border: #4b5563;
    --typing-text: #d1d5db;
    --typing-dot: #6b7280;
}

/* Auto Dark Mode - nur wenn kein data-theme gesetzt */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --chatbot-bg: #1f2937;
        --chatbot-text: #f9fafb;
        --chatbot-border: #374151;
        --chatbot-shadow: rgba(0, 0, 0, 0.3);
        --chatbot-shadow-hover: rgba(0, 0, 0, 0.4);
        
        /* Messages */
        --bot-message-bg: #374151;
        --bot-message-text: #f9fafb;
        --bot-message-border: #4b5563;
        
        /* Input */
        --input-bg: #374151;
        --input-border: #4b5563;
        --input-border-focus: #6366f1;
        --input-text: #f9fafb;
        --input-placeholder: #9ca3af;
        
        /* Quick Replies */
        --quick-reply-bg: #374151;
        --quick-reply-border: #4b5563;
        --quick-reply-hover-bg: #4b5563;
        --quick-reply-hover-border: #6b7280;
        --quick-reply-text: #f9fafb;
        
        /* Typing Indicator */
        --typing-bg: #374151;
        --typing-border: #4b5563;
        --typing-text: #d1d5db;
        --typing-dot: #6b7280;
    }
}

/* Screen Reader Only Content */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Skip Link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--chatbot-text);
    color: var(--chatbot-bg);
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
}

.skip-link:focus {
    top: 6px;
    opacity: 1;
    pointer-events: auto;
}

/* High Contrast Support */
@media (prefers-contrast: high) {
    .chatbot-trigger {
        border: 2px solid currentColor !important;
    }
    
    .quick-reply:focus {
        border: 3px solid currentColor !important;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .chatbot-trigger,
    .chatbot-widget,
    .chatbot-message,
    .quick-reply {
        transition: none !important;
        animation: none !important;
    }
    
    .typing-dot {
        animation: none !important;
    }
}

/* Base Container */
.chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Focus Styles */
.chatbot-trigger:focus {
    outline: 2px solid #4F46E5;
    outline-offset: 2px;
}

.chatbot-send:focus,
.chatbot-input:focus,
.quick-reply:focus {
    outline: 2px solid var(--input-border-focus);
    outline-offset: 1px;
}

/* Trigger Button */
.chatbot-trigger {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--trigger-gradient);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px var(--chatbot-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
}

.chatbot-trigger:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 25px var(--chatbot-shadow-hover);
}

.chatbot-trigger.active {
    background: var(--trigger-gradient-active);
    transform: rotate(45deg);
}

/* Notification Badge */
.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border: 2px solid var(--chatbot-bg);
}

/* Main Widget */
.chatbot-widget {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 500px;
    background: var(--chatbot-bg);
    border-radius: 16px;
    box-shadow: 0 20px 60px var(--chatbot-shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--chatbot-border);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* Widget Header */
.chatbot-header {
    background: var(--header-gradient);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

.chatbot-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.chatbot-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chatbot-info p {
    margin: 0;
    font-size: 12px;
    opacity: 0.9;
}

/* Dark Mode Toggle Button */
.theme-toggle {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    color: white;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.theme-toggle:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 1px;
}

/* Messages Container */
.chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
    background: var(--chatbot-bg);
}

/* Message Styles */
.chatbot-message {
    display: flex;
    gap: 8px;
    max-width: 85%;
}

.chatbot-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chatbot-message.bot {
    align-self: flex-start;
}

.message-content {
    background: var(--bot-message-bg);
    color: var(--bot-message-text);
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    white-space: pre-line;
    word-wrap: break-word;
    position: relative;
    border: 1px solid var(--bot-message-border);
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.chatbot-message.user .message-content {
    background: var(--user-message-bg);
    color: var(--user-message-text);
    border-bottom-right-radius: 6px;
    border: none;
}

.chatbot-message.bot .message-content {
    border-bottom-left-radius: 6px;
}

/* Quick Replies */
.quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.quick-reply {
    background: var(--quick-reply-bg);
    border: 2px solid var(--quick-reply-border);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--quick-reply-text);
    font-weight: 500;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.quick-reply:hover {
    background: var(--quick-reply-hover-bg);
    border-color: var(--quick-reply-hover-border);
    transform: translateY(-1px);
}

.quick-reply:active {
    transform: translateY(0);
}

/* Typing Indicator */
.typing-indicator {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--typing-bg);
    border-radius: 18px;
    border-bottom-left-radius: 6px;
    max-width: 85%;
    border: 1px solid var(--typing-border);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.typing-text {
    font-size: 14px;
    color: var(--typing-text);
    transition: color 0.3s ease;
}

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

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--typing-dot);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
    transition: background-color 0.3s ease;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    40% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* Input Area */
.chatbot-input-area {
    padding: 16px 20px;
    border-top: 1px solid var(--chatbot-border);
    display: flex;
    gap: 12px;
    align-items: flex-end;
    background: var(--chatbot-bg);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.chatbot-input {
    flex: 1;
    border: 2px solid var(--input-border);
    border-radius: 20px;
    padding: 12px 16px;
    font-size: 14px;
    outline: none;
    resize: none;
    font-family: inherit;
    line-height: 1.4;
    max-height: 80px;
    background: var(--input-bg);
    color: var(--input-text);
    transition: all 0.3s ease;
}

.chatbot-input::placeholder {
    color: var(--input-placeholder);
}

.chatbot-input:focus {
    border-color: var(--input-border-focus);
}

.chatbot-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--trigger-gradient);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chatbot-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.chatbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .chatbot-container {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }
    
    .chatbot-widget {
        width: 100%;
        height: 70vh;
        bottom: 80px;
        right: 0;
        left: 0;
        margin: 0 10px;
        width: calc(100% - 20px);
    }
    
    .chatbot-trigger {
        position: fixed;
        bottom: 20px;
        right: 20px;
    }
    
    .quick-reply {
        min-height: 44px;
        padding: 12px 16px;
    }
    
    .chatbot-input {
        min-height: 44px;
    }
    
    .chatbot-send {
        width: 44px;
        height: 44px;
    }
    
    .theme-toggle {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
}

/* Message Animation */
@media (prefers-reduced-motion: no-preference) {
    .chatbot-message {
        animation: slideIn 0.3s ease-out;
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Theme transition für smooth switching */
* {
    transition-property: background-color, border-color, color;
    transition-duration: 0.3s;
    transition-timing-function: ease;
}