/* ===== AI Sales Assistant Chat Widget ===== */

#aisa-chat-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99999;
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
    direction: rtl;
}

/* ===== زر الشات (Bubble) ===== */
#aisa-chat-bubble {
    width: 65px;
    height: 65px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
}

#aisa-chat-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(102, 126, 234, 0.6);
}

.aisa-bubble-icon {
    font-size: 28px;
}

.aisa-bubble-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* تأثير الاهتزاز */
.aisa-bounce {
    animation: aisa-bounce 0.8s ease;
}

@keyframes aisa-bounce {
    0%, 100% { transform: translateY(0); }
    25% { transform: translateY(-15px); }
    50% { transform: translateY(0); }
    75% { transform: translateY(-8px); }
}

/* ===== نافذة الشات ===== */
#aisa-chat-window {
    width: 370px;
    max-width: calc(100vw - 40px);
    height: 500px;
    max-height: 70vh;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: absolute;
    bottom: 0;
    right: 0;
}

/* ===== رأس الشات ===== */
.aisa-chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.aisa-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.aisa-avatar {
    font-size: 32px;
}

.aisa-header-info strong {
    display: block;
    font-size: 16px;
}

.aisa-status {
    font-size: 12px;
    opacity: 0.9;
}

#aisa-chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

#aisa-chat-close:hover {
    opacity: 1;
}

/* ===== منطقة الرسائل ===== */
#aisa-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #f5f7fb;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ===== الرسالة ===== */
.aisa-message {
    display: flex;
    gap: 8px;
    max-width: 85%;
    animation: aisa-fadeIn 0.3s ease;
}

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

.aisa-msg-bot {
    align-self: flex-start;
}

.aisa-msg-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.aisa-msg-avatar {
    font-size: 24px;
    flex-shrink: 0;
    margin-top: 5px;
}

.aisa-msg-content {
    background: white;
    padding: 10px 14px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.aisa-msg-user .aisa-msg-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.aisa-msg-content p {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
}

.aisa-msg-time {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    opacity: 0.6;
}

/* ===== مؤشر الكتابة ===== */
.aisa-typing-dots {
    display: flex;
    gap: 4px;
    padding: 5px 0;
}

.aisa-typing-dots span {
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    animation: aisa-typing 1.4s infinite;
}

.aisa-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.aisa-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes aisa-typing {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1.2); }
}

/* ===== منطقة الإدخال ===== */
.aisa-chat-input-area {
    padding: 12px;
    background: white;
    border-top: 1px solid #eee;
    display: flex;
    gap: 8px;
}

#aisa-chat-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 25px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    direction: rtl;
    transition: border-color 0.3s;
}

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

#aisa-chat-send {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 25px;
    padding: 10px 20px;
    font-size: 14px;
    cursor: pointer;
    font-weight: bold;
    transition: transform 0.2s;
}

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

/* ===== ريسبونسف ===== */
@media (max-width: 480px) {
    #aisa-chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        max-height: none;
        bottom: -10px;
        right: -10px;
        border-radius: 12px;
    }
}
/* ===== أزرار الروابط في الشات ===== */
.aisa-link-button {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white !important;
    text-decoration: none !important;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    margin: 4px 2px;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.aisa-link-button:hover {
    transform: scale(1.05);
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.4);
    color: white !important;
}

.aisa-msg-user .aisa-link-button {
    background: rgba(255,255,255,0.3);
    border: 1px solid rgba(255,255,255,0.5);
}

.aisa-msg-text {
    line-height: 1.8;
}

.aisa-msg-text p {
    margin: 0;
}