:root {
    --ai-primary: #8b5cf6;
    --ai-primary-hover: #7c3aed;
    --ai-surface: #ffffff;
    --ai-bg: #f8fafc;
    --ai-border: #e2e8f0;
    --ai-text: #1e293b;
    --ai-text-muted: #64748b;
    --ai-header-bg: #1e1b4b;
}

/* ==========================================
   Floating Widget & Pill Button (NEW UI)
   ========================================== */
#woo-ai-floating-widget {
    position: fixed !important;
    bottom: 25px !important;
    right: 25px !important;
    z-index: 999999 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-end !important;
    gap: 15px !important;
}

#woo-ai-trigger-btn {
    /* گرادیانت بنفش اختصاصی هوش مصنوعی */
    background: linear-gradient(135deg, #a855f7, #7e22ce) !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 40px !important;
    /* افزایش فضای داخلی (Padding) برای بزرگ‌تر شدن دکمه */
    padding: 16px 32px 16px 24px !important;
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    font-family: inherit !important;
    /* افزایش سایز فونت */
    font-size: 17px !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    /* هماهنگی رنگ سایه با بنفش جدید */
    box-shadow: 0 8px 25px rgba(147, 51, 234, 0.4) !important;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
}

#woo-ai-trigger-btn svg {
    width: 28px !important;
    height: 28px !important;
}

#woo-ai-trigger-btn:hover {
    transform: translateY(-4px) !important;
    box-shadow: 0 12px 30px rgba(147, 51, 234, 0.6) !important;
}

.woo-ai-trigger-text {
    white-space: nowrap !important;
    display: inline-block !important;
}

/* ==========================================
   Base Chat Box Wrapper
   ========================================== */
.woo-ai-chat-box {
    display: flex !important;
    flex-direction: column !important;
    background: var(--ai-surface) !important;
    border: 1px solid var(--ai-border) !important;
    border-radius: 20px !important;
    overflow: hidden !important;
    direction: rtl !important;
    text-align: right !important;
    font-family: IRANSans, Tahoma, system-ui, -apple-system, sans-serif !important;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.15) !important;
}

.woo-ai-chat-box *, .woo-ai-chat-box *::before, .woo-ai-chat-box *::after { 
    box-sizing: border-box !important; 
}

/* Reset ALL buttons to block theme overrides */
.woo-ai-chat-box button {
    appearance: none !important;
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Popup specific sizing */
.woo-ai-chat-box.popup { 
    width: 380px !important; 
    height: 600px !important; 
    max-height: calc(100vh - 100px) !important;
    border-radius: 24px !important; 
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0,0,0,0.05) !important;
    background: #f8fafc !important;
}

/* ==========================================
   Header
   ========================================== */
.woo-ai-chat-header {
    background: linear-gradient(to right, #1e1b4b, #312e81) !important;
    padding: 16px 20px !important;
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    border-bottom: none !important;
    height: auto !important;
    min-height: 72px !important;
}

.woo-ai-header-info { 
    display: flex !important; 
    flex-direction: row !important;
    align-items: center !important; 
    gap: 12px !important; 
}

.woo-ai-avatar {
    width: 42px !important; 
    height: 42px !important; 
    min-width: 42px !important;
    border-radius: 50% !important; 
    background: linear-gradient(135deg, #8b5cf6, #ec4899) !important;
    display: flex !important; 
    align-items: center !important; 
    justify-content: center !important; 
    color: #ffffff !important;
    box-shadow: 0 4px 10px rgba(139, 92, 246, 0.4) !important;
}

.woo-ai-avatar svg { width: 22px !important; height: 22px !important; }

.woo-ai-header-text {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 4px !important;
}

.woo-ai-title { 
    font-weight: 700 !important; 
    font-size: 14px !important; 
    color: #ffffff !important; 
    line-height: 1 !important;
}

.woo-ai-status { 
    font-size: 11px !important; 
    color: #10b981 !important; 
    font-weight: 500 !important; 
    display: flex !important;
    align-items: center !important;
    line-height: 1 !important;
}

.woo-ai-status::before {
    content: '' !important; 
    display: inline-block !important; 
    width: 6px !important; 
    height: 6px !important; 
    background: #10b981 !important; 
    border-radius: 50% !important; 
    margin-left: 5px !important; 
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.6) !important;
}

.woo-ai-header-actions { 
    display: flex !important; 
    flex-direction: row !important;
    gap: 8px !important; 
    align-items: center !important; 
}

.woo-ai-header-actions button {
    background: transparent !important;
    color: #cbd5e1 !important;
    width: 34px !important;
    height: 34px !important;
    border-radius: 8px !important;
    transition: 0.2s !important;
}

.woo-ai-header-actions button:hover { 
    background: rgba(255, 255, 255, 0.1) !important; 
    color: #ffffff !important; 
}

/* ==========================================
   Chat Body
   ========================================== */
.woo-ai-chat-body { 
    flex: 1 !important; 
    padding: 24px 20px !important; 
    background-color: #f8fafc !important;
    background-image: radial-gradient(#e2e8f0 1px, transparent 1px) !important;
    background-size: 20px 20px !important;
    overflow-y: auto !important; 
    display: flex !important; 
    flex-direction: column !important; 
    gap: 16px !important; 
}

.woo-ai-chat-body::-webkit-scrollbar { width: 5px; }
.woo-ai-chat-body::-webkit-scrollbar-thumb { background-color: #cbd5e1; border-radius: 10px; }

.woo-ai-msg { 
    max-width: 88% !important; 
    padding: 14px 18px !important; 
    font-size: 14px !important; 
    line-height: 1.6 !important; 
    position: relative !important; 
    word-break: break-word !important;
    white-space: pre-wrap !important;
    animation: fadeInMsg 0.3s ease-out forwards !important;
}

.woo-ai-msg.bot { 
    background: #ffffff !important; 
    color: #1e293b !important; 
    border-radius: 4px 20px 20px 20px !important; 
    border: 1px solid rgba(0,0,0,0.04) !important;
    align-self: flex-start !important; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.03) !important; 
}

.woo-ai-msg.user { 
    background: linear-gradient(135deg, #8b5cf6, #6366f1) !important; 
    color: #ffffff !important; 
    border-radius: 20px 4px 20px 20px !important; 
    align-self: flex-end !important; 
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.2) !important; 
}

/* ==========================================
   Footer Input Area (Glassmorphism)
   ========================================== */
.woo-ai-chat-footer { 
    display: flex !important; 
    flex-direction: row !important;
    padding: 16px 20px !important; 
    gap: 12px !important; 
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(10px) !important;
    border-top: 1px solid #e2e8f0 !important;
    align-items: center !important; 
}

.woo-ai-chat-footer input { 
    flex: 1 !important; 
    height: 48px !important; 
    padding: 0 20px !important; 
    border: 1px solid transparent !important; 
    border-radius: 24px !important; 
    background: #f1f5f9 !important; 
    outline: none !important; 
    font-size: 14px !important; 
    color: var(--ai-text) !important;
    margin: 0 !important;
    box-shadow: none !important;
    transition: all 0.2s ease !important;
}

.woo-ai-chat-footer input:focus { 
    background: #ffffff !important;
    border-color: #8b5cf6 !important;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1) !important;
}

.woo-ai-send-btn, .woo-ai-mic-btn {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    border-radius: 50% !important;
    transition: all 0.2s ease !important;
}

.woo-ai-send-btn { 
    background: var(--ai-primary) !important; 
    color: #ffffff !important; 
    box-shadow: 0 4px 10px rgba(139, 92, 246, 0.3) !important; 
}

.woo-ai-send-btn:hover { 
    background: var(--ai-primary-hover) !important; 
    transform: scale(1.05) !important; 
}

.woo-ai-mic-btn { 
    background: #f1f5f9 !important; 
    color: var(--ai-text-muted) !important; 
}

.woo-ai-mic-btn:hover { 
    background: #e2e8f0 !important; 
    color: var(--ai-primary) !important; 
}

.woo-ai-mic-btn.recording { 
    color: #ef4444 !important; 
    background: #fef2f2 !important; 
    animation: pulse-red 1.5s infinite !important; 
}

/* ==========================================
   Captcha Screen
   ========================================== */
.woo-ai-captcha-screen { 
    flex: 1 !important; 
    display: flex !important; 
    flex-direction: column !important; 
    align-items: center !important; 
    justify-content: center !important; 
    padding: 30px 20px !important; 
    background: var(--ai-bg) !important; 
}
.woo-ai-captcha-icon { color: var(--ai-primary) !important; margin-bottom: 15px !important; }
.woo-ai-captcha-title { font-size: 13px !important; font-weight: 600 !important; color: var(--ai-text) !important; margin-bottom: 15px !important; text-align: center !important; }
.woo-ai-captcha-question { font-size: 24px !important; font-weight: 800 !important; color: var(--ai-primary) !important; letter-spacing: 3px !important; margin-bottom: 20px !important; direction: ltr !important; }
.woo-ai-captcha-form-row { display: flex !important; flex-direction: row !important; gap: 8px !important; width: 100% !important; max-width: 260px !important; }
.woo-ai-captcha-input { flex: 1 !important; padding: 12px !important; border: 2px solid var(--ai-border) !important; border-radius: 12px !important; text-align: center !important; font-size: 16px !important; font-weight: bold !important; outline: none !important; }
.woo-ai-captcha-btn { background: var(--ai-header-bg) !important; color: #ffffff !important; padding: 0 20px !important; border-radius: 12px !important; font-weight: 600 !important; height: 46px !important; }

/* ==========================================
   Typing Indicator & Animations
   ========================================== */
.woo-ai-typing { display: flex !important; align-items: center !important; gap: 4px !important; padding: 18px 20px !important; }
.woo-ai-dot { width: 6px !important; height: 6px !important; background-color: var(--ai-primary) !important; border-radius: 50% !important; animation: ai-bounce 1.4s infinite ease-in-out both !important; }
.woo-ai-dot:nth-child(1) { animation-delay: -0.32s !important; }
.woo-ai-dot:nth-child(2) { animation-delay: -0.16s !important; }

@keyframes fadeInMsg {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes ai-bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }
@keyframes pulse-red { 0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); } 70% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); } 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); } }

/* ==========================================
   Responsive & Bug Fixes
   ========================================== */
@media (max-width: 480px) {
    #woo-ai-floating-widget {
        bottom: 15px !important;
        right: 15px !important;
    }
    .woo-ai-chat-box.popup { 
        width: calc(100vw - 30px) !important; 
        height: 75vh !important; 
    }
}

/* حل مشکل تداخل نمایش المان‌های مخفی شده توسط جاوااسکریپت و PHP */
.woo-ai-chat-box [style*="display: none"] {
    display: none !important;
}