/* AI Chat Widget Styles */
#ai-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Toggle Button */
#ai-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
}

#ai-chat-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(102, 126, 234, 0.6);
}

#ai-chat-toggle.active {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
}

#ai-chat-toggle::before {
    content: "💬";
    transition: all 0.3s ease;
}

#ai-chat-toggle.active::before {
    content: "✕";
    transform: rotate(180deg);
}

/* Chat Container */
#ai-chat-container {
    position: absolute;
    bottom: 0px;
    right: 0;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#ai-chat-container.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chat-header .status {
    font-size: 12px;
    opacity: 0.8;
}

#ai-chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

#ai-chat-close:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Messages Area */
#ai-chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: #f8f9fa;
}

#ai-chat-messages::-webkit-scrollbar {
    width: 4px;
}

#ai-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

#ai-chat-messages::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 2px;
}

/* Message Styles */
.chat-message {
    margin-bottom: 16px;
    display: flex;
    animation: messageSlideIn 0.3s ease-out;
}

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

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

.message-content {
    max-width: 80%;
    position: relative;
}

.message-text {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.chat-message.user .message-text {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.bot .message-text {
    background: white;
    color: #333;
    border: 1px solid #e1e5e9;
    border-bottom-left-radius: 4px;
}

.chat-message.bot.error .message-text {
    background: #fee;
    border-color: #fcc;
    color: #c33;
}

.message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    text-align: right;
}

.chat-message.bot .message-time {
    text-align: left;
}

/* Typing Indicator */
.typing-indicator .message-text {
    padding: 16px;
    background: white;
    border: 1px solid #e1e5e9;
}

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

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #999;
    animation: typingDot 1.4s infinite ease-in-out;
}

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

@keyframes typingDot {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Input Area */
.chat-input-area {
    padding: 16px;
    background: white;
    border-top: 1px solid #e1e5e9;
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

#ai-chat-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    resize: none;
    min-height: 20px;
    max-height: 100px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease;
}

#ai-chat-input:focus {
    border-color: #667eea;
}

#ai-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 16px;
}

#ai-chat-send:hover {
    transform: scale(1.05);
}

#ai-chat-send:active {
    transform: scale(0.95);
}

/* Animations */
@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive Design */
@media (max-width: 480px) {
    #ai-chat-widget {
        bottom: 10px;
        right: 10px;
    }
    
    #ai-chat-container {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        right: -10px;
    }
    
    #ai-chat-toggle {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    #ai-chat-container {
        background: #2d3748;
    }
    
    #ai-chat-messages {
        background: #1a202c;
    }
    
    .chat-message.bot .message-text {
        background: #4a5568;
        color: #e2e8f0;
        border-color: #2d3748;
    }
    
    .chat-input-area {
        background: #2d3748;
        border-top-color: #4a5568;
    }
    
    #ai-chat-input {
        background: #4a5568;
        color: #e2e8f0;
        border-color: #2d3748;
    }
    
    #ai-chat-input:focus {
        border-color: #667eea;
    }
}