/* AI Chat Widget Styling - High-End Minimalist Aesthetic */
.ai-chat-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 3000;
}

/* Floating Button */
.ai-chat-btn {
    width: 60px;
    height: 60px;
    background: var(--primary-color, #2C3B30);
    color: white;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(44, 59, 48, 0.3);
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.ai-chat-btn:hover {
    transform: scale(1.1) rotate(5deg);
    background: var(--primary-light, #3d5142);
}

/* Chat Window */
.ai-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 580px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(0,0,0,0.05);
}

.ai-chat-window.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Header */
.ai-chat-header {
    background: var(--primary-color, #2C3B30);
    color: white;
    padding: 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-chat-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.ai-avatar {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    object-fit: cover;
    border: 1px solid rgba(255,255,255,0.2);
}

.ai-chat-status-text h4 {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.status-online {
    font-size: 10px;
    color: #a8e6cf;
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0.8;
}

.status-online::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #a8e6cf;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(168, 230, 207, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 5px rgba(168, 230, 207, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(168, 230, 207, 0); }
}

.close-ai-chat {
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    font-size: 18px;
    width: 30px;
    height: 30px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.3s;
}

.close-ai-chat:hover {
    background: rgba(255,255,255,0.2);
}

/* Messages Area */
.ai-chat-messages {
    flex: 1;
    padding: 25px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: #fdfdfd;
}

.message {
    max-width: 85%;
    padding: 14px 18px;
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.6;
    animation: fadeIn 0.4s ease;
}

.ai-message {
    background: #f0f0f0;
    color: #444;
    align-self: flex-start;
}

.user-message {
    background: var(--primary-color, #2C3B30);
    color: white;
    align-self: flex-end;
}

/* Input Area */
.ai-chat-input-area {
    padding: 20px;
    border-top: 1px solid #f5f5f5;
    display: flex;
    gap: 12px;
    background: white;
}

.ai-chat-input-area input {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid #eee;
    border-radius: 4px;
    font-size: 13px;
    outline: none;
    transition: 0.3s;
}

.ai-chat-input-area input:focus {
    border-color: var(--primary-color, #2C3B30);
}

#ai-send-btn {
    background: var(--primary-color, #2C3B30);
    color: white;
    border: none;
    width: 42px;
    height: 42px;
    border-radius: 4px;
    cursor: pointer;
    transition: 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#ai-send-btn:hover {
    background: var(--primary-light, #3d5142);
}

/* RTL Support */
[dir="rtl"] .ai-chat-widget {
    left: 30px;
    right: auto;
}

[dir="rtl"] .ai-chat-window {
    left: 0;
    right: auto;
}


/* Mobile Responsiveness */
@media (max-width: 480px) {
    .ai-chat-widget {
        bottom: 20px;
        right: 20px;
    }
    
    [dir="rtl"] .ai-chat-widget {
        left: 20px;
        right: auto;
    }

    .ai-chat-window {
        width: calc(100vw - 40px);
        height: 80vh;
        bottom: 80px;
    }

    .ai-chat-btn {
        width: 55px;
        height: 55px;
        font-size: 22px;
    }
}

/* كل رسالة تأخذ اتجاه لغتها: الرد الإنجليزي يبدأ من اليسار حتى لو كان الموقع بالعربي */
.message p {
    unicode-bidi: plaintext;
}

/* إخفاء زر الشات عندما تكون السلة مفتوحة، حتى لا يغطي زر "إتمام الطلب" */
.ai-chat-widget {
    transition: opacity 0.3s ease;
}
body:has(.cart-sidebar.active) .ai-chat-widget {
    opacity: 0;
    pointer-events: none;
}

/* Product links inside assistant replies */
.ai-message .ai-link {
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* Keep phone numbers on one line */
.ai-message bdi {
    white-space: nowrap;
}
