/* AI Chatbot Styles - WhatsApp Theme */
#ai-chatbot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

#chatbot-toggle {
    width: 60px;
    height: 60px;
    background: #25D366; /* WhatsApp green */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(37, 211, 102, 0.3);
    transition: all 0.3s ease;
    border: none;
    overflow: hidden;
}

.whatsapp-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
    transition: all 0.3s ease;
}

#chatbot-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(37, 211, 102, 0.4);
}

#chatbot-toggle:hover .whatsapp-icon {
    transform: scale(1.1);
}

#chatbot-container {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* WhatsApp Header */
#chatbot-header {
    background: #075E54; /* WhatsApp dark green */
    color: white;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 60px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.profile-pic {
    width: 40px;
    height: 40px;
    background: #128C7E;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.assistant-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.header-info {
    flex: 1;
}

.header-info h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
    color: white;
    line-height: 1.2;
}

.status {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    display: block;
    margin-top: 2px;
}

#chatbot-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#chatbot-close:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* WhatsApp Chat Background */
#chatbot-messages {
    flex: 1;
    background: #E5DDD5; /* WhatsApp chat background */
    background-image: 
        radial-gradient(circle at 25% 25%, rgba(255,255,255,0.1) 1px, transparent 1px),
        radial-gradient(circle at 75% 75%, rgba(255,255,255,0.1) 1px, transparent 1px);
    background-size: 20px 20px;
    padding: 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Message Styling */
.user-message, .bot-message {
    display: flex;
    max-width: 85%;
    margin-bottom: 8px;
}

.user-message {
    align-self: flex-end;
}

.bot-message {
    align-self: flex-start;
}

.message-content {
    position: relative;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    max-width: 100%;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}

/* User (sent) messages - green bubbles */
.user-message .message-content {
    background: #DCF8C6; /* WhatsApp sent message green */
    color: #333;
    padding: 8px 12px 18px 12px; /* Extra bottom padding for time */
    margin-left: 50px;
}

/* Add message tail for user messages */
.user-message .message-content::after {
    content: '';
    position: absolute;
    right: -8px;
    bottom: 5px;
    width: 0;
    height: 0;
    border-left: 8px solid #DCF8C6;
    border-bottom: 8px solid transparent;
    border-top: 8px solid transparent;
}

/* Bot (received) messages - white bubbles */
.bot-message .message-content {
    background: white;
    color: #333;
    padding: 8px 12px 18px 12px; /* Extra bottom padding for time */
    margin-right: 50px;
}

/* Add message tail for bot messages */
.bot-message .message-content::before {
    content: '';
    position: absolute;
    left: -8px;
    bottom: 5px;
    width: 0;
    height: 0;
    border-right: 8px solid white;
    border-bottom: 8px solid transparent;
    border-top: 8px solid transparent;
}

.message-text {
    margin-bottom: 4px;
}

.message-time {
    font-size: 11px;
    color: #666;
    position: absolute;
    bottom: 4px;
    right: 8px;
    font-weight: 400;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: white;
    border-radius: 8px;
    font-size: 14px;
    color: #666;
    max-width: 85%;
    align-self: flex-start;
    margin-right: 50px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
    position: relative;
}

.typing-indicator::before {
    content: '';
    position: absolute;
    left: -8px;
    bottom: 5px;
    width: 0;
    height: 0;
    border-right: 8px solid white;
    border-bottom: 8px solid transparent;
    border-top: 8px solid transparent;
}

.typing-dots {
    display: flex;
    gap: 3px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: #666;
    border-radius: 50%;
    animation: typing 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 typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* WhatsApp Input Area */
#chatbot-input-area {
    display: flex;
    padding: 12px;
    background: white;
    gap: 8px;
    align-items: flex-end;
}

#chatbot-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    resize: none;
    min-height: 20px;
    max-height: 100px;
    font-family: inherit;
    color: #333 !important;
    background-color: white !important;
}

#chatbot-input:focus {
    border-color: #25D366;
}

#chatbot-input::placeholder {
    color: #888 !important;
    opacity: 1 !important;
}

#chatbot-send {
    background: #25D366;
    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;
}

#chatbot-send:hover {
    background: #128C7E;
    transform: scale(1.05);
}

#chatbot-send:active {
    transform: scale(0.95);
}

/* Links Section */
.message-links {
    margin-top: 8px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
}

.links-header {
    font-size: 11px;
    font-weight: 500;
    color: #666;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.message-links a {
    display: block;
    margin: 4px 0;
    padding: 8px 12px;
    background: #25D366;
    color: white !important;
    text-decoration: none !important;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    text-align: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.message-links a:hover {
    background: #128C7E;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    #ai-chatbot-widget {
        bottom: 10px;
        right: 10px;
    }
    
    #chatbot-container {
        width: calc(100vw - 20px);
        height: 70vh;
        bottom: 70px;
        right: -10px;
    }
    
    #chatbot-toggle {
        width: 50px;
        height: 50px;
    }
    
    .whatsapp-icon {
        width: 28px;
        height: 28px;
    }
    
    .user-message .message-content,
    .bot-message .message-content {
        max-width: 90%;
    }
    
    .user-message {
        max-width: 90%;
    }
    
    .bot-message {
        max-width: 90%;
    }
}

/* Scrollbar Styling */
#chatbot-messages::-webkit-scrollbar {
    width: 4px;
}

#chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

#chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
}

#chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Handle markdown content */
.message-content strong {
    font-weight: 600;
}

.message-content em {
    font-style: italic;
}

.message-content code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}