/* AI Chatbot Frontend Styles */

#ai-chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Chat Bubble */
#ai-chatbot-bubble {
    width: 60px;
    height: 60px;
    background: #007cba;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

#ai-chatbot-bubble:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

#ai-chatbot-bubble.chatbot-open {
    background: #666;
    transform: rotate(45deg);
}

#ai-chatbot-bubble svg {
    transition: transform 0.3s ease;
}

#ai-chatbot-bubble.chatbot-open svg {
    transform: rotate(-45deg);
}

/* Pulse animation for attention */
#ai-chatbot-bubble::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 50%;
    background: inherit;
    opacity: 0.7;
    animation: pulse 2s infinite;
    z-index: -1;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.7;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.3;
    }
    100% {
        transform: scale(1);
        opacity: 0.7;
    }
}

/* Chat Window */
#ai-chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e0e0e0;
}

/* Header */
#ai-chatbot-header {
    background: linear-gradient(135deg, #007cba 0%, #005a87 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 12px 12px 0 0;
}

#ai-chatbot-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

#ai-chatbot-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

#ai-chatbot-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Messages Container */
#ai-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f9f9f9;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#ai-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

#ai-chatbot-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

#ai-chatbot-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

#ai-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* Message Styles */
.chatbot-message {
    max-width: 85%;
    margin-bottom: 10px;
    animation: messageSlideIn 0.3s ease-out;
}

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

.user-message {
    align-self: flex-end;
    margin-left: auto;
}

.user-message .message-content {
    background: #007cba;
    color: white;
    padding: 12px 16px;
    border-radius: 18px 18px 4px 18px;
    box-shadow: 0 2px 4px rgba(0, 124, 186, 0.2);
}

.assistant-message {
    align-self: flex-start;
}

.assistant-message .message-content {
    background: white;
    color: #333;
    padding: 12px 16px;
    border-radius: 18px 18px 18px 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
}

/* Message sources */
.message-sources {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    color: #666;
    font-size: 12px;
}

.message-sources strong {
    color: #007cba;
}

/* Input Container */
#ai-chatbot-input-container {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    background: white;
    border-top: 1px solid #e0e0e0;
    gap: 10px;
}

#ai-chatbot-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 12px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

#ai-chatbot-input:focus {
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.1);
}

#ai-chatbot-send {
    background: #007cba;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

#ai-chatbot-send:hover {
    background: #005a87;
    transform: scale(1.05);
}

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

/* Loading Animation */
#ai-chatbot-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px;
    background: white;
    border-top: 1px solid #e0e0e0;
    color: #666;
    font-size: 14px;
}

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

.ai-chatbot-typing span {
    width: 6px;
    height: 6px;
    background: #007cba;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

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

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

/* Typing Indicator in Messages */
.typing-indicator .message-content {
    padding: 16px !important;
    background: white !important;
}

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

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #007cba;
    border-radius: 50%;
    animation: typingMessage 1.4s infinite ease-in-out both;
}

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

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

/* Mobile Responsiveness */
@media (max-width: 768px) {
    #ai-chatbot-container {
        bottom: 15px;
        right: 15px;
        left: 15px;
    }
    
    #ai-chatbot-window {
        position: fixed;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100% !important;
        height: calc(100vh - 100px) !important;
        border-radius: 12px 12px 0 0;
        max-height: 600px;
    }
    
    #ai-chatbot-bubble {
        position: fixed;
        bottom: 20px;
        right: 20px;
    }
    
    .chatbot-message {
        max-width: 90%;
    }
    
    #ai-chatbot-input-container {
        padding: 12px 15px;
    }
    
    #ai-chatbot-messages {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    #ai-chatbot-bubble {
        width: 50px;
        height: 50px;
    }
    
    #ai-chatbot-window {
        height: calc(100vh - 80px) !important;
    }
    
    #ai-chatbot-header {
        padding: 12px 15px;
    }
    
    #ai-chatbot-header h4 {
        font-size: 14px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    #ai-chatbot-window {
        background: #2c2c2c;
        border-color: #444;
    }
    
    #ai-chatbot-messages {
        background: #1e1e1e;
    }
    
    .assistant-message .message-content {
        background: #3a3a3a;
        color: #e0e0e0;
        border-color: #555;
    }
    
    #ai-chatbot-input-container {
        background: #2c2c2c;
        border-color: #444;
    }
    
    #ai-chatbot-input {
        background: #3a3a3a;
        color: #e0e0e0;
        border-color: #555;
    }
    
    #ai-chatbot-loading {
        background: #2c2c2c;
        color: #ccc;
        border-color: #444;
    }
}

/* Accessibility */
#ai-chatbot-container * {
    box-sizing: border-box;
}

#ai-chatbot-bubble:focus,
#ai-chatbot-send:focus,
#ai-chatbot-close:focus,
#ai-chatbot-input:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Smooth transitions */
* {
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

/* Welcome message styling */
.assistant-message:first-child .message-content {
    background: linear-gradient(135deg, #e3f2fd 0%, #f0f8ff 100%);
    border-color: #007cba;
}

/* Error message styling */
.error-message .message-content {
    background: #ffebee;
    color: #c62828;
    border-color: #ef5350;
}