/* AI Chatbot Styles */
.ai-chatbot-container {
    max-width: 400px;
    margin: 20px auto;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    display: flex;
    flex-direction: column;
}

/* Header */
.ai-chatbot-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-chatbot-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-chatbot-title h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.ai-chatbot-icon {
    font-size: 20px;
}

.ai-chatbot-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #4caf50;
}

.status-indicator.online {
    background-color: #4caf50;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* Messages Area */
.ai-chatbot-messages {
    height: 300px;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    flex-grow: 1;
    scroll-behavior: smooth;
}

.message {
    display: flex;
    margin-bottom: 15px;
    align-items: flex-start;
    gap: 10px;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px);
    animation: messageSlideIn 0.4s ease-out forwards;
}

@keyframes messageSlideIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user-message {
    flex-direction: row-reverse;
    animation: messageSlideInUser 0.3s ease-out forwards;
}

@keyframes messageSlideInUser {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.ai-message .message-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.user-message .message-avatar {
    background: #007cba;
    color: white;
}

.error-message .message-avatar {
    background: #dc3545;
    color: white;
}

.message-content {
    max-width: 70%;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.user-message .message-content {
    align-items: flex-end;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    position: relative;
    max-width: 280px;
    line-height: 1.5;
}

.ai-message .message-bubble {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.user-message .message-bubble {
    background: linear-gradient(135deg, #007cba 0%, #0056b3 100%);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.error-message .message-bubble {
    background: #dc3545;
    color: white;
    border-bottom-left-radius: 4px;
}

.message-bubble p {
    margin: 0;
    line-height: 1.4;
    font-size: 14px;
}

.message-time {
    font-size: 11px;
    color: #666;
    margin-top: 2px;
}

.user-message .message-time {
    text-align: right;
}

/* Typing Indicator */
.typing-dots {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #999;
    animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Enhanced Chat Experience Improvements */

/* Improved floating button with better animations */
#ai-chatbot-floating-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    animation: floatingPulse 4s infinite;
}

#ai-chatbot-floating-btn:hover {
    transform: scale(1.15) rotate(5deg);
    box-shadow: 0 8px 30px rgba(102, 126, 234, 0.7);
}

#ai-chatbot-floating-btn:active {
    transform: scale(0.95);
}

@keyframes floatingPulse {
    0%, 100% {
        box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
        transform: translateY(0px);
    }
    25% {
        transform: translateY(-2px);
    }
    50% {
        box-shadow: 0 6px 25px rgba(102, 126, 234, 0.6);
        transform: translateY(0px);
    }
    75% {
        transform: translateY(-1px);
    }
}

/* Enhanced chat window animations */
#ai-chatbot-floating-box {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    height: 500px;
    border-radius: 15px;
    background: white;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.2);
    z-index: 999;
    transform: scale(0.8) translateY(20px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

#ai-chatbot-floating-box.show {
    transform: scale(1) translateY(0px);
    opacity: 1;
}

/* Floating Chat Header */
#ai-chatbot-floating-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 15px 15px 0 0;
}

.chatbot-title {
    font-weight: 600;
    font-size: 16px;
}

#ai-chatbot-floating-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 20px;
    line-height: 1;
    padding: 5px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s ease;
}

#ai-chatbot-floating-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Input area for floating chat */
.ai-chatbot-input-area {
    display: flex;
    align-items: center;
    padding: 15px;
    background: white;
    border-top: 1px solid #e0e0e0;
    border-radius: 0 0 15px 15px;
    gap: 8px;
}

/* Fix for floating box initial state */
#ai-chatbot-floating-box {
    display: none !important;
}

#ai-chatbot-floating-box.show {
    display: block !important;
}

/* Improved typing indicator with better positioning */
.ai-chatbot-typing {
    display: none;
    padding: 10px 20px;
    background: #f8f9fa;
    border-top: 1px solid #e0e0e0;
    position: relative;
    z-index: 10;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: #666;
    font-style: italic;
}

/* Enhanced message animations - these enhance the existing .message styles */

/* Send button improvements */
#ai-chatbot-send {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50%;
    color: white;
    width: 40px;
    height: 40px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
}

#ai-chatbot-send:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

#ai-chatbot-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Input field improvements */
#ai-chatbot-input {
    border: 1px solid #ddd;
    border-radius: 25px;
    padding: 12px 16px;
    flex-grow: 1;
    outline: none;
    transition: all 0.2s ease;
    font-size: 14px;
}

#ai-chatbot-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Better link styling in messages */
.ai-chatbot-urls {
    margin-top: 8px;
    padding: 12px;
    background: #f0f2f5;
    border-radius: 8px;
    border-left: 3px solid #667eea;
}

.ai-chatbot-urls ul {
    margin: 5px 0 0 0;
    padding-left: 16px;
}

.ai-chatbot-urls a {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.ai-chatbot-urls a:hover {
    color: #764ba2;
    text-decoration: underline;
}

/* Status indicator improvements */
.status-indicator.online {
    background-color: #4caf50;
    animation: statusPulse 2s infinite;
}

@keyframes statusPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.1);
    }
}

/* Welcome message styling */
.ai-chatbot-welcome-message {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    padding: 15px;
    margin: 10px;
    border-radius: 10px;
    border-left: 4px solid #667eea;
}

/* Product Action Buttons */
.ai-chatbot-product-action {
    display: inline-block;
    padding: 8px 16px;
    margin: 4px 8px 4px 0;
    border: none;
    border-radius: 20px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-chatbot-product-action.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.ai-chatbot-product-action.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    color: white;
    text-decoration: none;
}

.ai-chatbot-product-action.btn-secondary {
    background: #6c757d;
    color: white;
}

.ai-chatbot-product-action.btn-secondary:hover {
    background: #5a6268;
    color: white;
    text-decoration: none;
}

.ai-chatbot-product-action.btn-success {
    background: #28a745;
    color: white;
}

.ai-chatbot-product-action.btn-danger {
    background: #dc3545;
    color: white;
}

.ai-chatbot-product-action:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Product Display in Messages */
.ai-chatbot-product {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    margin: 10px 0;
}

.ai-chatbot-product h4 {
    margin: 0 0 8px 0;
    color: #333;
    font-size: 16px;
}

.ai-chatbot-product .price {
    font-weight: bold;
    color: #28a745;
    font-size: 18px;
    margin: 8px 0;
}

.ai-chatbot-product .description {
    color: #666;
    margin: 8px 0;
    font-size: 14px;
}

.ai-chatbot-product .actions {
    margin-top: 12px;
}

/* Responsive improvements */
@media (max-width: 480px) {
    #ai-chatbot-floating-box {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        right: 10px;
        bottom: 80px;
    }
    
    #ai-chatbot-floating-btn {
        bottom: 15px;
        right: 15px;
        width: 55px;
        height: 55px;
        font-size: 22px;
    }
}
