/**
 * AI Assistant - Styles
 *
 * واجهة المساعد: زر عائم + نافذة المحادثة.
 * تعتمد على متغيرات CSS الموجودة في main.css (--primary-color, إلخ).
 * تدعم الوضع الداكن والفاتح واتجاهي RTL/LTR.
 */

/* ============================================================
   Variables (قيم افتراضية تتوافق مع نظام الألوان القائم)
   ============================================================ */
:root {
    --ai-primary:        #1a6fd4;
    --ai-primary-dark:   #1558a8;
    --ai-primary-light:  #e8f1fc;
    --ai-surface:        #ffffff;
    --ai-surface-alt:    #f4f6f9;
    --ai-border:         #dde3ec;
    --ai-text:           #1a202c;
    --ai-text-muted:     #6b7280;
    --ai-user-bubble:    #1a6fd4;
    --ai-user-text:      #ffffff;
    --ai-bot-bubble:     #f0f4fb;
    --ai-bot-text:       #1a202c;
    --ai-shadow:         0 8px 32px rgba(0, 0, 0, 0.12);
    --ai-shadow-btn:     0 4px 16px rgba(26, 111, 212, 0.4);
    --ai-radius:         16px;
    --ai-radius-sm:      8px;
    --ai-btn-size:       56px;
    --ai-z-index:        9999;
    --ai-transition:     0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --ai-primary:        #4a9eff;
    --ai-primary-dark:   #2e7de0;
    --ai-primary-light:  #1e3a5c;
    --ai-surface:        #1e2533;
    --ai-surface-alt:    #252d3d;
    --ai-border:         #2e3a52;
    --ai-text:           #e2e8f0;
    --ai-text-muted:     #94a3b8;
    --ai-user-bubble:    #2e7de0;
    --ai-user-text:      #ffffff;
    --ai-bot-bubble:     #252d3d;
    --ai-bot-text:       #e2e8f0;
    --ai-shadow:         0 8px 32px rgba(0, 0, 0, 0.4);
    --ai-shadow-btn:     0 4px 16px rgba(74, 158, 255, 0.35);
}

/* ============================================================
   Toggle Button (الزر العائم)
   ============================================================ */
.ai-toggle-btn {
    position: fixed;
    bottom: 90px; /* فوق زر WhatsApp */
    width: var(--ai-btn-size);
    height: var(--ai-btn-size);
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #1d4ed8); /* لون أزرق براند مضيء وجذاب */
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
    z-index: var(--ai-z-index);
    transition: background var(--ai-transition), transform var(--ai-transition), box-shadow var(--ai-transition);
    outline: none;
    overflow: visible !important; /* السماح للروبوت بالخروج خارج حدود الزر الدائري */
    
    /* دائماً على اليمين فوق زر واتساب */
    right: 24px !important;
    left: auto !important;
}

.ai-toggle-btn:hover {
    transform: scale(1.05) !important;
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.55) !important;
}

/* حالة المفتوح: يتحول إلى زر إغلاق أحمر دائري واشح */
.ai-toggle-btn.is-open {
    background: #ef4444 !important;
    box-shadow: var(--ai-shadow-btn) !important;
    overflow: hidden !important; /* إخفاء أي تداخل عند الإغلاق */
}

.ai-toggle-btn.is-open:hover {
    background: #dc2626 !important;
    transform: scale(1.08) !important;
}

.ai-toggle-btn svg {
    width: 26px;
    height: 26px;
    transition: transform var(--ai-transition), opacity var(--ai-transition);
}

/* أيقونة الإغلاق مخفية افتراضياً */
.ai-toggle-btn .ai-icon-close { display: none; }
.ai-toggle-btn .ai-icon-chat  { display: block; }

/* حالة مفتوح */
.ai-toggle-btn.is-open .ai-icon-chat  { display: none; }
.ai-toggle-btn.is-open .ai-icon-close { display: block; }

/* Badge (عدد الرسائل غير المقروءة) */
.ai-badge {
    position: absolute;
    top: -4px;
    width: 18px;
    height: 18px;
    background: #ef4444;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    animation: ai-badge-pulse 1.8s ease-in-out infinite;
}

[dir="rtl"] .ai-badge { left: -4px; right: auto; }
[dir="ltr"] .ai-badge { right: -4px; left: auto; }

.ai-badge[data-count="0"],
.ai-badge:empty { display: none; }

@keyframes ai-badge-pulse {
    0%, 100% { transform: scale(1); }
    50%       { transform: scale(1.15); }
}

/* ============================================================
   Chat Window (نافذة المحادثة)
   ============================================================ */
.ai-window {
    position: fixed;
    bottom: 160px;
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 180px);
    background: var(--ai-surface);
    border: 1px solid var(--ai-border);
    border-radius: var(--ai-radius);
    box-shadow: var(--ai-shadow);
    z-index: var(--ai-z-index);
    display: flex;
    flex-direction: column;
    overflow: hidden;

    /* الحالة الافتراضية: مخفية */
    opacity: 0;
    transform: translateY(16px) scale(0.96);
    pointer-events: none;
    transition:
        opacity var(--ai-transition),
        transform var(--ai-transition);
}

.ai-window {
    right: 24px !important;
    left: auto !important;
}

/* حالة مفتوح */
.ai-window.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ---- Header ---- */
.ai-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--ai-primary);
    color: #fff;
    flex-shrink: 0;
}

.ai-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-header-avatar svg {
    width: 20px;
    height: 20px;
    color: #fff;
}

.ai-header-info {
    flex: 1;
    min-width: 0;
}

.ai-header-name {
    font-weight: 700;
    font-size: 14px;
    line-height: 1.3;
}

.ai-header-status {
    font-size: 11px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 5px;
}

.ai-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    animation: ai-status-blink 2.5s ease-in-out infinite;
}

@keyframes ai-status-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

.ai-header-actions {
    display: flex;
    gap: 4px;
}

.ai-header-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: var(--ai-radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--ai-transition);
}

.ai-header-btn:hover {
    background: rgba(255, 255, 255, 0.28);
}

.ai-header-btn svg {
    width: 15px;
    height: 15px;
}

/* ---- Messages Area ---- */
.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.ai-messages::-webkit-scrollbar { width: 4px; }
.ai-messages::-webkit-scrollbar-track { background: transparent; }
.ai-messages::-webkit-scrollbar-thumb {
    background: var(--ai-border);
    border-radius: 2px;
}

/* ---- Message Bubble ---- */
.ai-message {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    animation: ai-message-in 0.22s ease-out;
}

@keyframes ai-message-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* رسائل المستخدم (يمين في RTL) */
.ai-message.user {
    flex-direction: row-reverse;
}

.ai-message-bubble {
    max-width: 78%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.55;
    word-break: break-word;
}

/* فقاعة المستخدم */
.ai-message.user .ai-message-bubble {
    background: var(--ai-user-bubble);
    color: var(--ai-user-text);
    border-bottom-right-radius: 4px;
}

[dir="rtl"] .ai-message.user .ai-message-bubble {
    border-bottom-right-radius: 16px;
    border-bottom-left-radius: 4px;
}

/* فقاعة المساعد */
.ai-message.assistant .ai-message-bubble {
    background: var(--ai-bot-bubble);
    color: var(--ai-bot-text);
    border-bottom-left-radius: 4px;
}

[dir="rtl"] .ai-message.assistant .ai-message-bubble {
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 4px;
}

/* فقاعة الخطأ (رسائل الفشل والأعطال) */
.ai-message.assistant.is-error .ai-message-bubble {
    background: #fef9ec;
    color: #92400e;
    border: 1px solid #fde68a;
}

[data-theme="dark"] .ai-message.assistant.is-error .ai-message-bubble {
    background: #2d1f0a;
    color: #fcd34d;
    border-color: #78350f;
}

/* الوقت */
.ai-message-time {
    font-size: 10.5px;
    color: var(--ai-text-muted);
    padding: 0 4px;
    flex-shrink: 0;
    align-self: flex-end;
    margin-bottom: 2px;
}

/* ---- Typing Indicator ---- */
.ai-typing {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    animation: ai-message-in 0.22s ease-out;
}

.ai-typing-bubble {
    background: var(--ai-bot-bubble);
    padding: 12px 16px;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    display: flex;
    gap: 5px;
    align-items: center;
}

[dir="rtl"] .ai-typing-bubble {
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 4px;
}

.ai-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ai-text-muted);
    animation: ai-typing-bounce 1.2s ease-in-out infinite;
}

.ai-typing-dot:nth-child(2) { animation-delay: 0.18s; }
.ai-typing-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes ai-typing-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
    40%           { transform: translateY(-6px); opacity: 1; }
}

/* ---- Welcome Message ---- */
.ai-welcome {
    text-align: center;
    padding: 20px 12px;
}

.ai-welcome-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--ai-primary-light);
    color: var(--ai-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.ai-welcome-icon svg { width: 26px; height: 26px; }

.ai-welcome-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--ai-text);
    margin-bottom: 6px;
}

.ai-welcome-subtitle {
    font-size: 12.5px;
    color: var(--ai-text-muted);
    line-height: 1.6;
}

/* ---- Suggestions (اقتراحات البداية) ---- */
.ai-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin-top: 14px;
}

.ai-suggestion-btn {
    background: var(--ai-surface-alt);
    border: 1px solid var(--ai-border);
    color: var(--ai-text);
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 20px;
    cursor: pointer;
    transition: background var(--ai-transition), border-color var(--ai-transition);
    font-family: inherit;
}

.ai-suggestion-btn:hover {
    background: var(--ai-primary-light);
    border-color: var(--ai-primary);
    color: var(--ai-primary);
}

/* ---- Input Area ---- */
.ai-input-area {
    padding: 12px 14px;
    border-top: 1px solid var(--ai-border);
    background: var(--ai-surface);
    flex-shrink: 0;
}

.ai-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--ai-surface-alt);
    border: 1.5px solid var(--ai-border);
    border-radius: 24px;
    padding: 8px 8px 8px 14px;
    transition: border-color var(--ai-transition);
}

[dir="rtl"] .ai-input-row {
    padding: 8px 14px 8px 8px;
}

.ai-input-row:focus-within {
    border-color: var(--ai-primary);
}

.ai-input {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    outline: none;
    font-size: 13.5px;
    font-family: inherit;
    color: var(--ai-text);
    line-height: 1.5;
    min-height: 20px;
    max-height: 120px;
    overflow-y: auto;
}

.ai-input::placeholder {
    color: var(--ai-text-muted);
}

.ai-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--ai-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background var(--ai-transition), transform var(--ai-transition);
}

.ai-send-btn:hover:not(:disabled) {
    background: var(--ai-primary-dark);
    transform: scale(1.06);
}

.ai-send-btn:disabled {
    background: var(--ai-border);
    cursor: not-allowed;
}

.ai-send-btn svg {
    width: 17px;
    height: 17px;
}

/* اقلب أيقونة الإرسال في RTL */
[dir="rtl"] .ai-send-btn svg {
    transform: scaleX(-1);
}

/* ---- Error Toast ---- */
.ai-error-toast {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    font-size: 12.5px;
    padding: 8px 12px;
    border-radius: var(--ai-radius-sm);
    margin-top: 8px;
    display: none;
}

.ai-error-toast.is-visible { display: block; }

[data-theme="dark"] .ai-error-toast {
    background: #3b1515;
    border-color: #7f1d1d;
    color: #fca5a5;
}

/* ============================================================
   Phase 3: Markdown Content Styles
   ============================================================ */

/* ---- Code Block (``` ... ```) ---- */
.ai-message-bubble .ai-code-block {
    background: #0f172a;
    color: #e2e8f0;
    border-radius: var(--ai-radius-sm);
    padding: 10px 12px;
    margin: 6px 0;
    overflow-x: auto;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.6;
    white-space: pre;
    direction: ltr;
    text-align: left;
}

[data-theme="dark"] .ai-message-bubble .ai-code-block {
    background: #0a0f1a;
    border: 1px solid #1e2a3a;
}

.ai-message-bubble .ai-code-block code {
    background: none;
    padding: 0;
    font-size: inherit;
    color: inherit;
}

/* ---- Inline Code (`...`) ---- */
.ai-message-bubble .ai-code-inline {
    background: rgba(0, 0, 0, 0.08);
    border-radius: 4px;
    padding: 1px 5px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 12px;
    color: #be185d;
    direction: ltr;
    display: inline;
}

[data-theme="dark"] .ai-message-bubble .ai-code-inline {
    background: rgba(255, 255, 255, 0.1);
    color: #f9a8d4;
}

/* ---- Lists ---- */
.ai-message-bubble .ai-list {
    margin: 6px 0;
    padding-inline-start: 18px;
    list-style: disc;
}

.ai-message-bubble .ai-list li {
    margin-bottom: 3px;
    line-height: 1.55;
}

/* ---- Bold / Italic ---- */
.ai-message-bubble strong { font-weight: 700; }
.ai-message-bubble em     { font-style: italic; opacity: 0.9; }

/* ============================================================
   Phase 3: Send Button Loading State
   ============================================================ */
.ai-send-btn.is-loading {
    background: var(--ai-border);
    cursor: not-allowed;
    position: relative;
}

.ai-send-btn.is-loading svg {
    opacity: 0;
}

.ai-send-btn.is-loading::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: ai-spin 0.7s linear infinite;
}

@keyframes ai-spin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   Phase 3: Character Counter
   ============================================================ */
.ai-char-count {
    display: block;
    font-size: 10.5px;
    color: var(--ai-text-muted);
    text-align: end;
    margin-top: 4px;
    transition: color var(--ai-transition);
    min-height: 14px;
}

.ai-char-count.is-warning { color: #d97706; }
.ai-char-count.is-danger  { color: #dc2626; font-weight: 600; }

/* ============================================================
   Phase 3: Restored Messages (من الجلسة السابقة)
   ============================================================ */
.ai-message.is-restored {
    opacity: 0.88;
    animation: none; /* لا animation عند الاستعادة */
}

/* ============================================================
   Phase 3: Welcome Screen Transition
   ============================================================ */
.ai-welcome {
    transition: opacity 0.2s ease, transform 0.2s ease;
}

/* ============================================================
   Phase 3: Messages Area fade-in
   ============================================================ */
.ai-messages {
    transition: opacity 0.2s ease;
}

/* ============================================================
   Phase 4: Correct Stacking with WhatsApp Button
   زر المساعد يظهر أعلى زر WhatsApp بمسافة آمنة
   ============================================================ */

/*
  زر WhatsApp يجلس عند bottom: 24px
  زر المساعد يجلس عند bottom: 90px (فوقه بـ 66px)
  النافذة تبدأ من bottom: 160px (فوق الزر بـ 70px)
*/
.ai-toggle-btn {
    bottom: 90px;
}

.ai-window {
    bottom: 160px;
}

/* ============================================================
   Phase 4: Mobile Full-Screen Experience
   ============================================================ */

/* منع تمرير الصفحة عند فتح المساعد على الموبايل */
body.ai-body-lock {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* Overlay خلف النافذة على الموبايل */
@media (max-width: 640px) {
    .ai-window.is-open::before {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: -1;
        animation: ai-fade-in 0.2s ease;
    }

    @keyframes ai-fade-in {
        from { opacity: 0; }
        to   { opacity: 1; }
    }

    .ai-window {
        /* نافذة كاملة الشاشة على الموبايل */
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        bottom: 0;
        left: 0 !important;
        right: 0 !important;
        border-radius: 0;
        border: none;
    }

    /* الزر يتصغر قليلاً على الموبايل */
    .ai-toggle-btn {
        width: 50px;
        height: 50px;
        bottom: 84px;
    }

    [dir="rtl"] .ai-toggle-btn { left: 16px; right: auto; }
    [dir="ltr"] .ai-toggle-btn { right: 16px; left: auto; }

    /* Header أعلى قليلاً على الموبايل لتجنب notch */
    .ai-header {
        padding-top: max(14px, env(safe-area-inset-top));
    }

    /* حقل الإدخال أكبر على الموبايل لراحة اللمس */
    .ai-input {
        font-size: 16px; /* يمنع zoom على iOS */
    }

    /* الأزرار أكبر للمس */
    .ai-send-btn {
        width: 42px;
        height: 42px;
    }

    .ai-header-btn {
        width: 36px;
        height: 36px;
    }

    /* تصغير الكود على الهاتف */
    .ai-message-bubble .ai-code-block {
        font-size: 11px;
        padding: 8px;
    }
}

/* ============================================================
   Phase 4: Tablet (641px - 1024px)
   ============================================================ */
@media (min-width: 641px) and (max-width: 1024px) {
    .ai-window {
        width: 340px;
        height: 500px;
    }
}

/* ============================================================
   Responsive: Desktop (الوضع الافتراضي الذي كان موجوداً)
   ============================================================ */
@media (max-width: 480px) {
    /* تأكيد القواعد للشاشات الصغيرة جداً */
    .ai-message-bubble {
        max-width: 88%;
    }
}

/* ============================================================
   Phase 4: Accessibility
   ============================================================ */

/* Focus visible واضح */
.ai-toggle-btn:focus-visible,
.ai-send-btn:focus-visible,
.ai-header-btn:focus-visible,
.ai-suggestion-btn:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.ai-input:focus-visible {
    outline: none; /* مُعالج بـ border-color على الـ row */
}

/* High Contrast Mode */
@media (forced-colors: active) {
    .ai-toggle-btn,
    .ai-send-btn {
        border: 2px solid ButtonText;
    }

    .ai-message-bubble {
        border: 1px solid ButtonText;
    }
}

/* ---- Links inside bubble ---- */
.ai-message-bubble .ai-link {
    color: #1a6fd4; /* Default blue */
    text-decoration: underline;
    font-weight: 600;
    transition: color var(--ai-transition);
}

.ai-message-bubble .ai-link:hover {
    color: #1558a8;
}

.ai-message.user .ai-message-bubble .ai-link {
    color: #ffffff;
    text-decoration: underline;
}

[data-theme="dark"] .ai-message-bubble .ai-link {
    color: #60a5fa;
}

[data-theme="dark"] .ai-message-bubble .ai-link:hover {
    color: #93c5fd;
}

/* Pulse Glow Animation for Floating Toggle Button */
@keyframes ai-pulse-glow {
    0% {
        box-shadow: 0 0 0 0 rgba(26, 111, 212, 0.5), var(--ai-shadow-btn);
    }
    70% {
        box-shadow: 0 0 0 12px rgba(26, 111, 212, 0), var(--ai-shadow-btn);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(26, 111, 212, 0), var(--ai-shadow-btn);
    }
}

.ai-toggle-btn.ai-pulse-active {
    animation: ai-pulse-glow 2s infinite;
}

/* Speech Welcome Bubble */
.ai-welcome-bubble {
    position: fixed;
    bottom: 155px;
    z-index: calc(var(--ai-z-index) - 1);
    background: var(--ai-surface);
    border: 1px solid var(--ai-border);
    border-radius: 12px;
    padding: 12px 14px;
    box-shadow: var(--ai-shadow);
    max-width: 270px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--ai-text);
    display: flex;
    flex-direction: column;
    gap: 4px;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

.ai-welcome-bubble.is-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.ai-welcome-bubble {
    right: 24px !important;
    left: auto !important;
    transform-origin: bottom right;
}

/* Little tail for the speech bubble */
.ai-welcome-bubble::after {
    content: '';
    position: absolute;
    bottom: -6px;
    width: 10px;
    height: 10px;
    background: var(--ai-surface);
    border-right: 1px solid var(--ai-border);
    border-bottom: 1px solid var(--ai-border);
    transform: rotate(45deg);
    right: 20px !important;
    left: auto !important;
}

.ai-welcome-bubble-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10.5px;
    font-weight: 700;
    color: var(--ai-primary);
}

.ai-welcome-bubble-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: var(--ai-text-muted);
    padding: 0 4px;
    line-height: 1;
    transition: color var(--ai-transition);
}

.ai-welcome-bubble-close:hover {
    color: #ef4444;
}

.ai-welcome-bubble-body {
    cursor: pointer;
}

/* Interactive Robot Icon Animations */
.ai-robot-icon {
    position: absolute;
    width: 62px !important; /* أكبر من الزر الدائري (50px) */
    height: 62px !important;
    left: -6px; /* توسيط أفقي للروبوت الأكبر حجماً */
    top: -12px; /* جعله يبرز للأعلى خارج الدائرة */
    z-index: 2;
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    animation: ai-robot-float 3s ease-in-out infinite;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.25));
}

/* Hover: scale up and full 360° spin! */
.ai-toggle-btn:hover .ai-robot-icon {
    transform: scale(1.08) rotate(360deg);
}

/* Robot Hand Waving (around shoulder point x=40, y=40) */
@keyframes ai-robot-wave {
    0%, 100% { transform: rotate(0deg); }
    30% { transform: rotate(-25deg); }
    70% { transform: rotate(20deg); }
}

.ai-robot-arm-wave {
    transform-origin: 40px 40px;
    animation: ai-robot-wave 1.6s ease-in-out infinite;
}

/* Robot Eyes Blinking */
@keyframes ai-robot-blink {
    0%, 95%, 100% { transform: scaleY(1); }
    97.5% { transform: scaleY(0.1); }
}

.ai-robot-eye {
    transform-origin: center;
    animation: ai-robot-blink 4.5s linear infinite;
}

/* Robot Floating effect */
@keyframes ai-robot-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .ai-window,
    .ai-toggle-btn,
    .ai-welcome-bubble,
    .ai-message,
    .ai-typing-dot,
    .ai-status-dot,
    .ai-robot-icon,
    .ai-robot-arm-wave,
    .ai-robot-eye {
        animation: none !important;
        transition: none !important;
    }
}
