/* ============================================================
   PMS Chat Widget — CSS حرفه‌ای RTL v11.0
   طراحی مدرن الهام گرفته از WhatsApp/Telegram/iMessage
   
   تغییرات اصلی:
   - انیمیشن‌های نرم و روان (bouncy transitions)
   - کاهش سایز فونت و آیکون‌ها
   - حباب‌های پیام با گوشه تیز (pointed corner)
   - جداسازی پیام کاربر و ادمین در دو طرف
   - فیکس باگ وضعیت آنلاین/آفلاین
   - پشتیبانی کامل RTL برای فارسی
============================================================ */

/* ====== CSS Variables (متغیرهای سفارشی) ====== */
:root {
    --pms-color: #667eea;
    --pms-color-hover: #5a6fd6;
    --pms-color-light: rgba(102, 126, 234, 0.1);
    --pms-color-shadow: rgba(102, 126, 234, 0.25);
    
    /* رنگ‌های پیام */
    --pms-bot-bg: #ffffff;
    --pms-bot-text: #1a1a1a;
    --pms-bot-shadow: rgba(0, 0, 0, 0.08);
    --pms-user-bg: #667eea;
    --pms-user-text: #ffffff;
    --pms-user-shadow: rgba(102, 126, 234, 0.25);
    
    /* پس‌زمینه چت */
    --pms-chat-bg: #f5f6fa;
    --pms-chat-bg-pattern: linear-gradient(180deg, #f5f6fa 0%, #eef0f5 100%);
    
    /* وضعیت */
    --pms-online-color: #4ade80;
    --pms-online-glow: rgba(74, 222, 128, 0.4);
    --pms-offline-color: #9ca3af;
    --pms-offline-glow: rgba(156, 163, 175, 0.3);
    
    /* انیمیشن */
    --pms-transition-fast: 0.15s ease;
    --pms-transition-normal: 0.25s ease;
    --pms-transition-bouncy: cubic-bezier(0.34, 1.56, 0.64, 1);
    --pms-transition-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    
    /* فونت */
    --pms-font-family: Vazirmatn, -apple-system, BlinkMacSystemFont, 'Segoe UI', Tahoma, sans-serif;
    --pms-font-size-base: 13px;
    --pms-font-size-sm: 11px;
    --pms-font-size-md: 14px;
    --pms-font-size-lg: 15px;
    --pms-line-height: 1.5;
}

/* ============================================================
   کانتینر اصلی ویجت
============================================================ */
.pms-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99999;
    font-family: var(--pms-font-family);
    direction: rtl;
    font-size: var(--pms-font-size-base);
    line-height: var(--pms-line-height);
    --pms-color: #667eea;
}

.pms-chat-widget.pms-pos-left {
    right: auto;
    left: 20px;
}

/* ============================================================
   حباب دکمه چت (Floating Button)
   - کاهش سایز آیکون
   - انیمیشن نرم‌تر
============================================================ */
.pms-widget-bubble {
    width: 56px; /* کاهش از 60px */
    height: 56px; /* کاهش از 60px */
    border-radius: 50%;
    background: var(--pms-color);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2), 0 0 0 0 rgba(102, 126, 234, 0.4);
    transition: transform 0.4s var(--pms-transition-bouncy), 
                box-shadow 0.3s var(--pms-transition-smooth);
    position: relative;
    animation: pms-pulse-soft 2.5s infinite;
}

.pms-widget-bubble:hover {
    transform: scale(1.08) rotate(3deg);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25), 0 0 0 8px rgba(102, 126, 234, 0);
}

.pms-widget-bubble:active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
}

/* انیمیشن pulse نرم‌تر - کمتر مزاحم */
@keyframes pms-pulse-soft {
    0% {
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2), 0 0 0 0 rgba(102, 126, 234, 0.4);
    }
    70% {
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2), 0 0 0 18px rgba(102, 126, 234, 0);
    }
    100% {
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2), 0 0 0 0 rgba(102, 126, 234, 0);
    }
}

/* انیمیشن لرزش هنگام دریافت پیام جدید */
@keyframes pms-shake {
    0%, 100% { transform: translateX(0) rotate(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-3px) rotate(-2deg); }
    20%, 40%, 60%, 80% { transform: translateX(3px) rotate(2deg); }
}

.pms-widget-bubble.pms-shake {
    animation: pms-shake 0.5s ease-in-out;
}

/* آیکون حباب - کاهش سایز */
.pms-bubble-icon {
    font-size: 22px; /* کاهش از 26px */
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.pms-bubble-icon svg {
    display: block;
    width: 26px; /* کاهش از 30px */
    height: 22px; /* کاهش از 26px */
}

/* نشانگر تعداد پیام‌های خوانده نشده */
.pms-bubble-badge {
    position: absolute;
    top: -5px;
    left: -5px;
    background: #d63638;
    color: #fff;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 10px; /* کاهش از 11px */
    font-weight: 700;
    min-width: 17px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(214, 54, 56, 0.35);
    animation: pms-badge-pop 0.3s var(--pms-transition-bouncy);
    line-height: 1.4;
}

@keyframes pms-badge-pop {
    0% { transform: scale(0); }
    50% { transform: scale(1.25); }
    100% { transform: scale(1); }
}

/* ============================================================
   ✅ v11.10.5: دکمه «بازگشت به بالا» (Scroll to Top)
   - توسط JS به body منتقل میشه برای position:fixed صحیح
   - موقعیت: سمت داخل حباب (به سمت مرکز صفحه)
   - انیمیشن: فید این/اوت وقتی پنل باز/بسته میشه
   - افکت ژله‌ای (Jelly) روی هاور
============================================================ */

/* Wrapper داخل ویجت - مخفی میشه، دکمه به body منتقل میشه */
.pms-scroll-top-wrapper {
    display: none !important;
}

/* 
 * دکمه اصلی - position:fixed مستقل
 * تمام موقعیت‌ها توسط JS تنظیم میشن
 */
.pms-scroll-top {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    background: var(--pms-color, #667eea);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.15);
    border: none;
    position: fixed;
    /* موقعیت پیش‌فرض - توسط JS آپدیت میشه */
    bottom: 33px;
    right: 84px;
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
    z-index: 99998;
    /* ✅ v11.10.5: فقط transform و opacity برای انیمیشن نمایش/مخفی */
    transition: 
        transform 0.45s cubic-bezier(0.68, -0.55, 0.265, 1.55),
        opacity 0.35s ease;
    transform-origin: center center;
    overflow: hidden;
}

/* حالت visible - نمایش دکمه (وقتی اسکرول شده) */
.pms-scroll-top.pms-scroll-top-visible {
    transform: scale(1);
    opacity: 1;
    pointer-events: auto;
}

/* ✅ v11.10.5: حالت مخفی (وقتی پنل چت بازه) - فید اوت */
.pms-scroll-top.pms-scroll-top-hidden {
    transform: scale(0.8) !important;
    opacity: 0 !important;
    pointer-events: none !important;
    /* فید اوت نرم */
    transition: 
        transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.25s ease;
}

/* افکت ژله‌ای (Jelly) روی هاور */
.pms-scroll-top:hover {
    transform: scale(1.1) rotate(-5deg) !important;
    box-shadow: 0 5px 18px rgba(0, 0, 0, 0.2);
}

.pms-scroll-top:hover svg {
    animation: pms-jelly-bounce 0.6s ease infinite;
}

@keyframes pms-jelly-bounce {
    0%, 100% { transform: translateY(0) scale(1); }
    25% { transform: translateY(-4px) scale(1.1); }
    50% { transform: translateY(0) scale(1); }
    75% { transform: translateY(-2px) scale(1.05); }
}

.pms-scroll-top:active {
    transform: scale(0.92) rotate(0deg) !important;
    transition-duration: 0.1s;
}

/* آیکون فلش */
.pms-scroll-top svg {
    display: block;
    width: 16px;
    height: 16px;
    fill: currentColor;
    transition: transform 0.3s ease;
}

/* ============================================================
   تنظیمات نمایش بر اساس دستگاه
   - desktop: >1024px
   - tablet: 768-1024px  
   - mobile: <768px
============================================================ */

@media (min-width: 1025px) {
    .pms-scroll-top:not(.pms-st-desktop) { display: none !important; }
}
@media (min-width: 769px) and (max-width: 1024px) {
    .pms-scroll-top:not(.pms-st-tablet) { display: none !important; }
}
@media (max-width: 768px) {
    .pms-scroll-top:not(.pms-st-mobile) { display: none !important; }
    
    /* سایز و موقعیت کوچکتر در موبایل */
    .pms-scroll-top {
        width: 27px;
        height: 27px;
        bottom: 28px;
        right: 72px;
    }
    
    .pms-scroll-top svg {
        width: 14px;
        height: 14px;
    }
}

/* ============================================================
   پنل چت (Chat Panel)
   - انیمیشن باز/بسته شدن نرم و bounce
============================================================ */
.pms-widget-panel {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 370px;
    max-width: calc(100vw - 40px);
    height: 540px;
    max-height: calc(100vh - 40px);
    flex-direction: column;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18), 
                0 0 0 1px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    opacity: 0;
    transform: scale(0.92) translateY(16px);
    pointer-events: none;
    transition: opacity 0.35s var(--pms-transition-smooth), 
                transform 0.4s var(--pms-transition-bouncy);
}

/* حالت باز */
.pms-widget-panel.pms-open {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
}

/* حالت بسته شدن */
.pms-widget-panel.pms-closing {
    opacity: 0;
    transform: scale(0.92) translateY(16px);
    pointer-events: none;
}

.pms-pos-left .pms-widget-panel {
    right: auto;
    left: 0;
}

/* ============================================================
   هدر پنل (Header)
   - فیکس باگ وضعیت آنلاین/آفلاین
   - کاهش سایز آواتار
============================================================ */
.pms-panel-header {
    padding: 14px 18px 14px 48px; /* padding-left بیشتر برای دکمه X */
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--pms-color) 0%, #7c8ff0 100%);
    position: relative;
    overflow: hidden;
}

/* افکت گرادیان متحرک در هدر */
.pms-panel-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent 40%,
        rgba(255, 255, 255, 0.08) 50%,
        transparent 60%
    );
    animation: pms-header-shimmer 4s infinite linear;
    pointer-events: none;
}

@keyframes pms-header-shimmer {
    0% { transform: translateX(-100%) rotate(0deg); }
    100% { transform: translateX(100%) rotate(0deg); }
}

.pms-panel-title {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 1;
}

/* آواتار هدر - کاهش از 40px به 38px */
.pms-panel-avatar {
    width: 36px; /* کاهش از 40px */
    height: 36px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.35);
    object-fit: cover;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s var(--pms-transition-bouncy);
}

.pms-panel-avatar:hover {
    transform: scale(1.05);
}

/* ============================================================
   ✅ v11.10: سیستم آواتار stack شده ادمین‌های آنلاین
============================================================ */

/* کانتینر آواتارها */
.pms-avatar-stack {
    position: relative;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}

/* آواتار اصلی (سایت/پشتیبانی) */
.pms-avatar-main {
    position: relative;
    z-index: 3;
}

/* آواتارهای ادمین‌های آنلاین - حالت stack شده */
.pms-avatar-online {
    position: absolute;
    width: 28px; /* کمی کوچکتر */
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--pms-color, #667eea);
    object-fit: cover;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    z-index: 1;
}

/* موقعیت آواتارهای آنلاین - از چپ به راست stack میشن (چون RTL) */
.pms-avatar-online:nth-child(2) {
    left: -8px;
    top: 4px;
    z-index: 2;
}

.pms-avatar-online:nth-child(3) {
    left: -16px;
    top: 4px;
    z-index: 1;
}

.pms-avatar-online:nth-child(4) {
    left: -24px;
    top: 4px;
    z-index: 0;
}

/* هاور روی آواتارهای آنلاین - بزرگ شدن و آوردن جلو */
.pms-avatar-online:hover {
    transform: scale(1.2) translateY(-4px);
    z-index: 10 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* آواتار ادمینی که با کاربر چت میکنه - حالت فعال */
.pms-avatar-online.is-active {
    border-color: #4ade80;
    box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.4),
                0 2px 8px rgba(0, 0, 0, 0.2);
    animation: pms-active-avatar-pulse 2s infinite ease-in-out;
}

@keyframes pms-active-avatar-pulse {
    0%, 100% { 
        box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.4),
                    0 2px 8px rgba(0, 0, 0, 0.2);
    }
    50% { 
        box-shadow: 0 0 0 5px rgba(74, 222, 128, 0.25),
                    0 2px 12px rgba(0, 0, 0, 0.25);
    }
}

/* شمارنده تعداد ادمین‌های آنلاین (اگر بیشتر از ۳ تا باشن) */
.pms-online-count-badge {
    position: absolute;
    left: -24px;
    top: 4px;
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--pms-color, #667eea);
    z-index: 5;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* نام - ثابت */
.pms-panel-name {
    font-size: var(--pms-font-size-lg);
    font-weight: 600;
    letter-spacing: -0.01em;
}

/* ============================================================
   سیستم وضعیت (Status System)
   ✅ FIX: برطرف کردن تناقض آنلاین/آفلاین
   ✅ نمایش در یک خط: چراغ + متن آنلاین/آفلاین
============================================================ */

/* کانتینر وضعیت - نمایش افقی (inline) */
.pms-panel-status {
    font-size: var(--pms-font-size-sm);
    display: flex;
    flex-direction: row; /* تغییر از column به row */
    align-items: center; /* وسط‌چین عمودی */
    gap: 6px; /* فاصله بین چراغ و متن */
    position: relative;
    z-index: 1;
}

/* نقطه وضعیت */
.pms-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

/* متن وضعیت - در یک خط با چراغ */
.pms-status-text {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0;
}

/* ====== حالت آنلاین ====== */
.pms-panel-status.is-online .pms-status-dot {
    background: var(--pms-online-color);
    box-shadow: 0 0 10px var(--pms-online-glow),
                0 0 4px var(--pms-online-color);
    animation: pms-online-pulse 2.5s infinite ease-in-out;
}

.pms-panel-status.is-online {
    color: rgba(255, 255, 255, 0.95);
}

@keyframes pms-online-pulse {
    0%, 100% { 
        box-shadow: 0 0 8px var(--pms-online-glow),
                    0 0 4px var(--pms-online-color);
        opacity: 1;
    }
    50% { 
        box-shadow: 0 0 14px var(--pms-online-glow),
                    0 0 8px var(--pms-online-color);
        opacity: 0.85;
    }
}

/* ====== حالت آفلاین ====== */
.pms-panel-status.is-offline .pms-status-dot {
    background: var(--pms-offline-color);
    box-shadow: none;
    animation: none;
}

.pms-panel-status.is-offline {
    color: rgba(255, 255, 255, 0.7);
}

/* پیام آفلاین - فقط در حالت آفلاین و در خط بعدی */
.pms-status-offline-msg {
    font-size: 9px;
    color: rgba(255, 255, 255, 0.5);
    display: none; /* پیش‌فرض مخفی */
    position: absolute;
    top: 100%;
    left: 0; /* شروع از چپ - هم‌راست با چراغ */
    white-space: nowrap;
}

.pms-panel-status.is-offline .pms-status-offline-msg {
    display: block;
    animation: pms-fade-in 0.3s ease;
}

/* مخفی کردن متن آفلاین وقتی آنلاین هستیم */
.pms-panel-status.is-online .pms-status-offline-msg {
    display: none !important;
}

@keyframes pms-fade-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* استایل قدیمی status dot برای سازگاری */
.pms-panel-status:not(.is-online):not(.is-offline) .pms-status-dot {
    background: #4ade80;
    box-shadow: 0 0 8px #4ade80;
    animation: pms-status-blink-legacy 2s infinite;
}

@keyframes pms-status-blink-legacy {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

/* ============================================================
   دکمه بستن (Close Button)
   - وسط‌چین در دایره
   - موقعیت: گوشه چپ بالا، هم‌راست با عنوان
============================================================ */
.pms-panel-close {
    background: rgba(255, 255, 255, 0.18);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center; /* وسط‌چین عمودی */
    justify-content: center; /* وسط‌چین افقی */
    transition: background 0.2s ease, 
                transform 0.35s var(--pms-transition-bouncy);
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
    position: absolute; /* تغییر به absolute برای موقعیت دقیق */
    top: 10px; /* فاصله از بالا */
    left: 12px; /* فاصله از چپ */
    z-index: 10;
}

.pms-panel-close:hover {
    background: rgba(255, 255, 255, 0.32);
    transform: rotate(90deg) scale(1.08);
}

.pms-panel-close:active {
    transform: rotate(90deg) scale(0.92);
}

/* ============================================================
   بدنه پیام‌ها (Message Body)
   - پس‌زمینه گرادیان نرم
   - اسکرولبار سفارشی
   - فضای بیشتر بین پیام‌ها
============================================================ */
.pms-panel-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px; /* افزایش از 14px */
    background: var(--pms-chat-bg-pattern);
    display: flex;
    flex-direction: column;
    gap: 8px; /* افزایش از 4px */
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* اسکرولبار سفارشی - نازک و گرد */
.pms-panel-body::-webkit-scrollbar {
    width: 4px; /* کاهش از 5px */
}

.pms-panel-body::-webkit-scrollbar-track {
    background: transparent;
}

.pms-panel-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 10px;
    transition: background 0.2s ease;
}

.pms-panel-body::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* Firefox scrollbar */
.pms-panel-body {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}

/* ============================================================
   دکمه بارگذاری بیشتر (Load More)
============================================================ */
.pms-load-more-btn {
    align-self: center;
    background: var(--pms-color-light);
    color: var(--pms-color);
    border: 1px solid rgba(102, 126, 234, 0.25);
    border-radius: 20px; /* گردتر */
    padding: 7px 18px;
    font-size: var(--pms-font-size-sm);
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 10px;
    transition: all 0.25s var(--pms-transition-smooth);
    font-family: inherit;
    letter-spacing: 0.01em;
}

.pms-load-more-btn:hover {
    background: rgba(102, 126, 234, 0.18);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

.pms-load-more-btn:active {
    transform: translateY(0);
}

/* ============================================================
   گروه پیام (Message Group)
   - افزایش فاصله بین گروه‌ها
   - تراز پایین
   - انیمیشن ورود
============================================================ */
.pms-msg-group {
    display: flex;
    gap: 8px; /* افزایش از 8px */
    align-items: flex-end;
    margin-bottom: 8px; /* افزایش از 2px */
    animation: pms-msg-enter 0.35s var(--pms-transition-smooth) both;
}

/* انیمیشن ورود پیام */
@keyframes pms-msg-enter {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* گروه ادمین (Bot) - راست در RTL */
.pms-msg-group.pms-group-bot {
    flex-direction: row; /* آواتار راست، حباب چپ */
}

/* گروه کاربر (User) - چپ در RTL */
.pms-msg-group.pms-group-user {
    flex-direction: row-reverse; /* آواتار چپ، حباب راست */
}

/* ============================================================
   آواتار پیام (Message Avatar)
   - افزایش اندازه برای وضوح بهتر
   - حاشیه نرم
============================================================ */
.pms-msg-avatar {
    width: 32px; /* افزایش از 28px */
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: linear-gradient(135deg, #e0e0e0 0%, #f5f5f5 100%);
    border: 2px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s var(--pms-transition-bouncy);
}

.pms-msg-avatar:hover {
    transform: scale(1.08);
    z-index: 2;
}

/* فضای خالی جایگزین آواتار */
.pms-msg-avatar-spacer {
    width: 32px; /* هم‌اندازه آواتار */
    flex-shrink: 0;
}

/* ============================================================
   محتوای پیام (Message Content)
   - افزایش حداکثر عرض
   - انیمیشن hover
============================================================ */
.pms-msg-content {
    display: flex;
    flex-direction: column;
    gap: 4px; /* افزایش از 3px */
    max-width: 80%; /* افزایش از 75% */
    min-width: 0;
}

/* ============================================================
   حباب پیام ادمین (Bot Message)
   - سفید با گوشه تیز سمت راست (به سمت آواتار)
   - سایه نرم
============================================================ */
.pms-msg-bot {
    padding: 10px 14px; /* افزایش padding */
    border-radius: 16px 16px 16px 4px; /* گوشه تیز پایین-چپ در RTL = به سمت آواتار راست */
    background: var(--pms-bot-bg);
    font-size: var(--pms-font-size-base);
    line-height: var(--pms-line-height);
    color: var(--pms-bot-text);
    box-shadow: 0 1px 3px var(--pms-bot-shadow);
    word-wrap: break-word;
    overflow-wrap: break-word;
    align-self: flex-start;
    position: relative;
    transition: transform 0.2s var(--pms-transition-bouncy),
                box-shadow 0.2s ease;
}

.pms-msg-bot:hover {
    transform: scale(1.015) translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
}

/* ============================================================
   حباب پیام کاربر (User Message)
   - بنفش با گوشه تیز سمت چپ (به سمت آواتار)
   - سایه رنگی
============================================================ */
.pms-msg-user {
    padding: 10px 14px; /* افزایش padding */
    border-radius: 16px 16px 4px 16px; /* گوشه تیز پایین-راست در RTL = به سمت آواتار چپ */
    background: var(--pms-user-bg);
    color: var(--pms-user-text);
    font-size: var(--pms-font-size-base);
    line-height: var(--pms-line-height);
    word-wrap: break-word;
    overflow-wrap: break-word;
    align-self: flex-end;
    box-shadow: 0 2px 6px var(--pms-user-shadow);
    position: relative;
    transition: transform 0.2s var(--pms-transition-bouncy),
                box-shadow 0.2s ease;
}

.pms-msg-user:hover {
    transform: scale(1.015) translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.35);
}

/* پیام دارای تصویر */
.pms-msg-has-image {
    padding: 5px;
    border-radius: 16px;
    overflow: hidden;
}

.pms-msg-has-image img {
    border-radius: 12px;
    display: block;
    max-width: 100%;
    height: auto;
}

/* ============================================================
   تیک وضعیت پیام (Message Ticks)
   - سبک تلگرام/WhatsApp
============================================================ */
.pms-msg-tick-wrap {
    display: flex;
    align-items: center;
    margin-top: 3px;
    padding: 0 3px;
    line-height: 1;
    gap: 2px;
}

/* تیک پیام‌های کاربر - راست‌چین */
.pms-msg-group.pms-group-user .pms-msg-tick-wrap {
    justify-content: flex-end;
}

/* تیک پیام‌های ادمین - چپ‌چین */
.pms-msg-group.pms-group-bot .pms-msg-tick-wrap {
    justify-content: flex-start;
}

.pms-msg-tick {
    font-size: 9px;
    line-height: 1;
    pointer-events: none;
    user-select: none;
    letter-spacing: -0.5px;
    transition: color 0.2s ease;
}

.pms-tick-sent { color: rgba(255, 255, 255, 0.65); }
.pms-tick-delivered { color: rgba(255, 255, 255, 0.75); }
.pms-tick-seen { color: #93c5fd; font-weight: 700; }

/* تیک برای پیام‌های ادمین (رنگ تیره) */
.pms-msg-group.pms-group-bot .pms-tick-sent { color: #b0b0b0; }
.pms-msg-group.pms-group-bot .pms-tick-delivered { color: #a0a0a0; }
.pms-msg-group.pms-group-bot .pms-tick-seen { color: var(--pms-color); font-weight: 700; }

/* ============================================================
   کارت محصول (Product Card)
   - سایه بهتر
   - hover نرم‌تر
   - گردی بیشتر
============================================================ */
.pms-msg-product-card {
    width: 300px;
    max-width: 100%;
    background: #fff;
    border-radius: 16px; /* افزایش از 15px */
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: row;
    text-decoration: none;
    transition: all 0.3s var(--pms-transition-smooth);
    color: inherit;
}

.pms-msg-product-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    transform: translateY(-3px);
}

.pms-card-img-wrap {
    padding: 10px;
    flex-shrink: 0;
}

.pms-card-img-wrap img {
    width: 80px;
    height: 80px;
    border-radius: 12px; /* افزایش از 10px */
    object-fit: cover;
    display: block;
    background: #f9f9f9;
    transition: transform 0.3s var(--pms-transition-bouncy);
}

.pms-msg-product-card:hover .pms-card-img-wrap img {
    transform: scale(1.05);
}

.pms-card-info {
    padding: 10px 10px 10px 0;
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.pms-card-name {
    font-size: var(--pms-font-size-md); /* کاهش از 14px */
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1.35;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.pms-card-price-row {
    font-size: var(--pms-font-size-sm);
    margin-bottom: 2px;
}

.pms-card-price-regular {
    color: #999;
    text-decoration: line-through;
}

.pms-card-price-toman {
    color: #666;
    font-size: 10px;
}

.pms-card-price-sale {
    color: #00a32a;
    font-weight: 700;
}

.pms-card-price-current {
    color: #1a1a1a;
    font-weight: 700;
}

.pms-card-stock {
    margin-top: auto;
    font-size: var(--pms-font-size-sm);
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 8px; /* افزایش از 6px */
    align-self: flex-start;
}

.pms-card-stock-in {
    background: #e6f9e6;
    color: #00a32a;
}

.pms-card-stock-out {
    background: #fee;
    color: #d63638;
}

/* متن اختصاصی همراه کارت محصول */
.pms-product-custom-text {
    margin-top: 8px;
    padding: 8px 12px;
    background: linear-gradient(135deg, #f0f7ff 0%, #e8f4ff 100%);
    border-right: 3px solid #2271b1; /* RTL: border-right */
    border-radius: 0 10px 10px 0; /* RTL */
    font-size: var(--pms-font-size-sm);
    color: #1565c0;
    line-height: var(--pms-line-height);
}

/* ============================================================
   فرم مهمان (Guest Form)
============================================================ */
.pms-guest-form {
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    background: linear-gradient(180deg, #fafafa 0%, #f5f5f5 100%);
    border-top: 1px solid #eee;
    display: none;
    animation: pms-slide-up 0.3s var(--pms-transition-bouncy);
}

@keyframes pms-slide-up {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pms-guest-form input {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid #e0e0e0;
    border-radius: 12px; /* افزایش از 10px */
    font-size: var(--pms-font-size-base);
    outline: none;
    font-family: inherit;
    transition: all 0.2s ease;
    background: #fff;
}

.pms-guest-form input:focus {
    border-color: var(--pms-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.pms-guest-form input::placeholder {
    color: #aaa;
}

.pms-guest-form button {
    color: #fff;
    border: none;
    border-radius: 12px; /* افزایش از 10px */
    padding: 11px;
    font-size: var(--pms-font-size-md);
    cursor: pointer;
    font-weight: 600;
    font-family: inherit;
    background: var(--pms-color);
    transition: all 0.2s var(--pms-transition-smooth);
}

.pms-guest-form button:hover {
    background: var(--pms-color-hover);
    transform: translateY(-1px);
}

.pms-guest-form button:active {
    transform: translateY(0);
}

/* ============================================================
   ناحیه ورودی (Input Area)
   - گردی بیشتر
   - فاصله بهتر
   - focus state بهبود یافته
============================================================ */
.pms-panel-input {
    display: flex;
    padding: 12px; /* افزایش از 10px */
    gap: 10px; /* افزایش از 8px */
    border-top: 1px solid #eee;
    background: #fafafa;
    flex-shrink: 0;
    align-items: center;
}

/* wrapper برای input + attach */
.pms-input-wrap {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.pms-input-wrap input {
    width: 100%;
    padding: 11px 18px; /* افزایش padding */
    border: 1.5px solid #e0e0e0;
    border-radius: 24px; /* افزایش از 22px - گردتر */
    font-size: var(--pms-font-size-md); /* افزایش از 13px */
    outline: none;
    font-family: inherit;
    transition: all 0.25s var(--pms-transition-smooth);
    background: #fff;
}

.pms-input-wrap input:focus {
    border-color: var(--pms-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.12);
}

.pms-input-wrap input:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
    opacity: 0.65;
}

.pms-input-wrap input::placeholder {
    color: #bbb;
}

/* attach button موقعیت */
.pms-input-wrap .pms-input-btn-attach {
    position: static;
    flex-shrink: 0;
}

/* ============================================================
   دکمه‌های ورودی (Input Buttons)
   - کاهش سایز
   - transiton نرم‌تر
============================================================ */
.pms-input-btn {
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 38px; /* کاهش از 40px */
    height: 38px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s var(--pms-transition-bouncy);
    flex-shrink: 0;
    background: var(--pms-color);
    padding: 0;
}

.pms-input-btn:hover {
    opacity: 0.88;
    transform: scale(1.07);
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.35);
}

.pms-input-btn:active {
    transform: scale(0.94);
}

.pms-input-btn:disabled {
    opacity: 0.38;
    cursor: not-allowed;
    transform: none;
}

.pms-input-btn:disabled:hover {
    box-shadow: none;
    opacity: 0.38;
}

.pms-input-btn svg {
    width: 20px; /* کاهش از 24px */
    height: 20px;
    fill: #fff;
    display: block;
}

/* دکمه attach - استایل متمایز */
.pms-input-btn-attach {
    background: rgba(0, 0, 0, 0.05);
    border: 1.5px solid transparent;
}

.pms-input-btn-attach svg {
    width: 20px;
    height: 20px;
    fill: #777;
}

.pms-input-btn-attach:hover {
    background: var(--pms-color-light);
    border-color: rgba(102, 126, 234, 0.2);
    transform: scale(1.07);
    box-shadow: none;
}

.pms-input-btn-attach:hover svg {
    fill: var(--pms-color);
}

/* ============================================================
   مودال‌های شناور (ارسال عکس + ارسال کارت محصول)
   - نمایش بالای پنل چت
   - غیرفعال کردن دکمه‌ها هنگام باز بودن
============================================================ */

/* Overlay - پس‌زمینه تیره */
.pms-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.pms-modal-overlay.pms-modal-open {
    opacity: 1;
    visibility: visible;
}

/* کانتینر مودال */
.pms-modal {
    background: #fff;
    border-radius: 16px;
    width: 90%;
    max-width: 360px;
    max-height: 80%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    transform: translateY(20px) scale(0.95);
    transition: transform 0.3s var(--pms-transition-bouncy);
}

.pms-modal-overlay.pms-modal-open .pms-modal {
    transform: translateY(0) scale(1);
}

/* هدر مودال */
.pms-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.pms-modal-title {
    margin: 0;
    font-size: var(--pms-font-size-md);
    font-weight: 600;
    color: var(--pms-bot-text);
}

.pms-modal-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    line-height: 1;
    transition: all 0.2s ease;
}

.pms-modal-close:hover {
    background: rgba(0, 0, 0, 0.08);
    color: #333;
}

/* بدنه مودال */
.pms-modal-body {
    padding: 16px 18px;
    overflow-y: auto;
    flex: 1;
}

/* فوتر مودال */
.pms-modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 12px 18px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

/* دکمه‌های مودال */
.pms-modal-btn {
    padding: 8px 20px;
    border-radius: 10px;
    font-size: var(--pms-font-size-base);
    font-weight: 500;
    font-family: var(--pms-font-family);
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.pms-modal-btn-cancel {
    background: rgba(0, 0, 0, 0.06);
    color: #666;
}

.pms-modal-btn-cancel:hover {
    background: rgba(0, 0, 0, 0.1);
}

.pms-modal-btn-send {
    background: var(--pms-color);
    color: #fff;
}

.pms-modal-btn-send:hover {
    background: var(--pms-color-hover);
    transform: translateY(-1px);
}

/* دکمه ارسال غیرفعال (قبل از انتخاب محصول) */
.pms-modal-btn-send:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

.pms-modal-btn-send:disabled:hover {
    background: #ccc;
    transform: none;
}

/* ============================================================
   مودال ارسال عکس - اجزای خاص
============================================================ */

/* ناحیه Dropzone */
.pms-modal-dropzone {
    border: 2px dashed rgba(102, 126, 234, 0.35);
    border-radius: 12px;
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
    background: rgba(102, 126, 234, 0.03);
}

.pms-modal-dropzone:hover,
.pms-modal-dropzone.pms-dropzone-active {
    border-color: var(--pms-color);
    background: rgba(102, 126, 234, 0.08);
}

.pms-modal-dropzone svg {
    margin-bottom: 10px;
}

.pms-modal-dropzone p {
    margin: 0;
    color: #888;
    font-size: var(--pms-font-size-sm);
}

/* پیش‌نمایش عکس */
.pms-modal-preview {
    margin-top: 14px;
    text-align: center;
}

.pms-modal-preview img {
    max-width: 100%;
    max-height: 180px;
    border-radius: 10px;
    object-fit: cover;
}

/* فیلد متن (کپشن) */
.pms-modal-caption {
    margin-top: 14px;
}

.pms-modal-caption textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 10px;
    font-family: var(--pms-font-family);
    font-size: var(--pms-font-size-base);
    resize: vertical;
    min-height: 50px;
    box-sizing: border-box;
    direction: rtl;
}

.pms-modal-caption textarea:focus {
    outline: none;
    border-color: var(--pms-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

/* ============================================================
   مودال ارسال کارت محصول - اجزای خاص
============================================================ */

/* جستجوی محصول */
.pms-modal-search {
    margin-bottom: 12px;
}

.pms-modal-search input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 10px;
    font-family: var(--pms-font-family);
    font-size: var(--pms-font-size-base);
    box-sizing: border-box;
    direction: rtl;
}

.pms-modal-search input:focus {
    outline: none;
    border-color: var(--pms-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

/* لیست محصولات */
.pms-modal-product-list {
    max-height: 250px;
    overflow-y: auto;
}

.pms-modal-loading {
    text-align: center;
    color: #999;
    padding: 20px;
    margin: 0;
    font-size: var(--pms-font-size-sm);
}

/* آیتم محصول در لیست */
.pms-modal-product-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px 10px 36px; /* padding-left بیشتر برای علامت انتخاب */
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative; /* برای ::after */
}

.pms-modal-product-item:hover {
    background: var(--pms-color-light);
    border-color: var(--pms-color);
}

/* ✅ حالت انتخاب شده - هایلایت سبز */
.pms-modal-product-item.is-selected {
    background: #f0fdf4;
    border-color: #22c55e;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

.pms-modal-product-item.is-selected::after {
    content: '✓';
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    background: #22c55e;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
}

.pms-modal-product-item img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 8px;
    background: #f5f5f5;
}

.pms-modal-product-item-info {
    flex: 1;
    min-width: 0;
}

.pms-modal-product-item-title {
    font-size: var(--pms-font-size-base);
    font-weight: 500;
    color: var(--pms-bot-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pms-modal-product-item-price {
    font-size: var(--pms-font-size-sm);
    color: #059669;
    font-weight: 600;
    margin-top: 2px;
}

/* ============================================================
   Drag & Drop State
============================================================ */
.pms-widget-panel.pms-drag-over {
    box-shadow: 0 0 0 3px var(--pms-color), 
                0 16px 48px rgba(0, 0, 0, 0.18) !important;
}

.pms-widget-panel.pms-drag-over .pms-panel-body::after {
    content: '🖼 عکس را اینجا رها کنید';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--pms-color);
    color: #fff;
    padding: 14px 28px;
    border-radius: 14px;
    font-size: var(--pms-font-size-md);
    font-weight: 600;
    pointer-events: none;
    z-index: 10;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.35);
    animation: pms-drag-hint 0.4s var(--pms-transition-bouncy);
}

@keyframes pms-drag-hint {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.pms-widget-panel.pms-drag-over .pms-panel-body {
    position: relative;
}

/* ============================================================
   Overlay (پس‌زمینه تاریک هنگام باز بودن پنل)
============================================================ */
.pms-widget-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 99998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s var(--pms-transition-smooth);
}

.pms-widget-overlay.pms-overlay-active {
    opacity: 1;
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.03);
}

/* ============================================================
   چت تمام‌صفحه (Full Page Chat)
============================================================ */
.pms-chat-fullpage {
    max-width: 700px;
    margin: 20px auto;
    height: calc(100vh - 100px);
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    direction: rtl;
    font-family: var(--pms-font-family);
}

.pms-chat-fullpage .pms-widget-panel {
    position: static;
    width: 100%;
    height: 100%;
    max-height: none;
    box-shadow: none;
    border-radius: 0;
    display: flex !important;
    opacity: 1;
    transform: none;
}

/* ============================================================
   موبایل Responsive (@media max-width: 768px)
   - تمام عرض صفحه
   - فونت‌های کمی کوچکتر
   - لمسی دوستانه (min 44px)
============================================================ */
@media (max-width: 768px) {
    :root {
        --pms-font-size-base: 13px;
        --pms-font-size-sm: 11px;
        --pms-font-size-md: 14px;
        --pms-font-size-lg: 14px;
    }
    
    .pms-chat-widget {
        width: 100vw !important;
        max-width: none !important;
        right: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        z-index: 99999999 !important;
    }
    
    .pms-widget-panel {
        position: fixed !important;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 82vh !important; /* افزایش کمی */
        max-height: 400px !important;
        border-radius: 20px 20px 0 0 !important; /* فقط گوشه‌های بالا گرد */
        z-index: 99999999 !important;
    }
    
    .pms-widget-bubble {
        position: fixed;
        bottom: 16px;
        right: 16px;
        width: 54px; /* کاهش */
        height: 54px;
        z-index: 99999999 !important;
    }
    
    /* ✅ v11.10.6: اگر حباب سمت چپ باشه در موبایل هم سمت چپ بمونه */
    .pms-pos-left .pms-widget-bubble {
        left: 16px;
        right: auto;
    }
    
    /* دکمه بازگشت به بالا در موبایل - حذف شد */
    
    .pms-widget-overlay {
        z-index: 99999998 !important;
    }
    
    .pms-msg-product-card {
        width: 100%;
        max-width: 100%;
    }
    
    /* بدنه پیام‌ها در موبایل */
    .pms-widget-panel .pms-panel-body {
        flex: 1;
        min-height: 0;
        -webkit-overflow-scrolling: touch;
        padding: 12px; /* کاهش از 16px */
    }
    
    /* هدر در موبایل */
    .pms-widget-panel .pms-panel-header {
        padding: 12px 14px;
        flex-shrink: 0;
    }
    
    .pms-widget-panel .pms-panel-avatar {
        width: 34px;
        height: 34px;
    }
    
    /* ✅ v11.10: آواتارهای آنلاین در موبایل */
    .pms-widget-panel .pms-avatar-stack {
        width: 34px;
        height: 34px;
    }
    
    .pms-widget-panel .pms-avatar-online {
        width: 24px;
        height: 24px;
    }
    
    .pms-widget-panel .pms-avatar-online:nth-child(2) {
        left: -6px;
        top: 5px;
    }
    
    .pms-widget-panel .pms-avatar-online:nth-child(3) {
        left: -12px;
        top: 5px;
    }
    
    .pms-widget-panel .pms-avatar-online:nth-child(4) {
        left: -18px;
        top: 5px;
    }
    
    .pms-widget-panel .pms-online-count-badge {
        width: 20px;
        height: 20px;
        font-size: 9px;
        left: -18px;
        top: 5px;
    }
    
    .pms-widget-panel .pms-panel-name {
        font-size: var(--pms-font-size-md);
    }
    
    /* ناحیه تایپ در موبایل */
    .pms-widget-panel .pms-panel-input {
        flex-shrink: 0;
        padding: 10px; /* کاهش */
    }
    
    /* wrapper در موبایل */
    .pms-widget-panel .pms-input-wrap {
        flex: 1;
        position: relative;
    }
    
    .pms-widget-panel .pms-input-wrap input {
        font-size: 16px !important; /* جلوگیری از zoom iOS */
        padding: 10px 14px 10px 42px !important;
        border-radius: 22px;
    }
    
    /* آیکون attach در موبایل */
    .pms-widget-panel .pms-input-wrap .pms-input-btn-attach {
        position: absolute !important;
        left: 6px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        width: 34px !important;
        height: 34px !important;
        background: transparent !important;
        z-index: 2;
    }
    
    .pms-widget-panel .pms-input-wrap .pms-input-btn-attach:hover {
        background: transparent !important;
        opacity: 0.7;
    }
    
    .pms-widget-panel .pms-input-wrap .pms-input-btn-attach svg {
        width: 18px;
        height: 18px;
        fill: #999;
    }
    
    /* دکمه‌ها در موبایل - حداقل 44px برای لمس */
    .pms-widget-panel .pms-input-btn:not(.pms-input-btn-attach) {
        width: 38px;
        height: 38px;
    }
    
    .pms-widget-panel .pms-input-btn:not(.pms-input-btn-attach) svg {
        width: 18px;
        height: 18px;
    }
    
    /* آواتار پیام در موبایل */
    .pms-msg-avatar {
        width: 30px;
        height: 30px;
    }
    
    .pms-msg-avatar-spacer {
        width: 30px;
    }
    
    /* حباب‌ها در موبایل */
    .pms-msg-bot,
    .pms-msg-user {
        padding: 9px 12px;
        max-width: 85%;
    }

    /* مودال‌ها در موبایل */
    .pms-modal {
        width: 95%;
        max-height: 85%;
        border-radius: 14px;
    }

    .pms-modal-header {
        padding: 12px 14px;
    }

    .pms-modal-body {
        padding: 12px 14px;
    }

    .pms-modal-dropzone {
        padding: 24px 16px;
    }

    .pms-modal-dropzone svg {
        width: 36px;
        height: 36px;
    }
}

/* ============================================================
   Admin: auto-grow textarea + hide footer
============================================================ */
body.toplevel_page_pms-chat-inbox #wpfooter {
    display: none !important;
}

.pms-chat-reply-textarea {
    resize: vertical;
    min-height: 60px;
    max-height: 180px;
}

/* ============================================================
 * PHASE 4: Offline Detection & Message Queue Styles
 * ============================================================ */

/* نوتیفیکیشن وضعیت آفلاین */
#pms-offline-notice {
    animation: pms-slideDown 0.35s var(--pms-transition-bouncy);
}

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

/* تیک وضعیت "queued" (در صف انتظار) */
.pms-tick-queued {
    color: #ff9800 !important;
    font-style: italic;
}

.pms-msg-content[data-status="queued"] .pms-msg-user {
    opacity: 0.82;
    border: 1px dashed #ff9800;
}

/* indicator تعداد پیام‌های صف‌شده */
#pms-queue-indicator {
    animation: pms-pulse-queue 2s infinite;
}

@keyframes pms-pulse-queue {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 2px 5px rgba(255, 107, 107, 0.4);
    }
    50% {
        transform: scale(1.08);
        box-shadow: 0 2px 10px rgba(255, 107, 107, 0.6);
    }
}

/* حالت تاریک برای نوتیفیکیشن آفلاین */
[data-theme="dark"] #pms-offline-notice,
.pms-widget-panel.dark #pms-offline-notice {
    background: #3d3415;
    color: #ffe082;
    border-bottom-color: #ff9800;
}

/* ============================================================
 * PHASE 4: Guest Info Badge Styles (Admin)
 * ============================================================ */

/* برچسب نوع مهمان */
.pms-guest-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: var(--pms-font-size-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.pms-guest-badge.new {
    background: #e3f2fd;
    color: #1565c0;
}

.pms-guest-badge.returning {
    background: #fff3e0;
    color: #e65100;
}

.pms-guest-badge.loyal {
    background: #e8f5e9;
    color: #2e7d32;
}

.pms-guest-badge.offline {
    background: #fce4ec;
    color: #c62828;
}

/* اطلاعات دستگاه مهمان */
.pms-guest-device-info {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 5px;
    font-size: var(--pms-font-size-sm);
    color: #666;
}

.pms-guest-device-info span {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 8px;
    background: #f5f5f5;
    border-radius: 6px;
}

/* ============================================================
   Utility Classes & Helpers
============================================================ */

/* مخفی کردن بصری (برای screen readers نگه می‌دارد) */
.pms-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* انیمیشن loading dots */
.pms-loading-dots {
    display: inline-flex;
    gap: 4px;
}

.pms-loading-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    animation: pms-dot-bounce 1.4s infinite both;
}

.pms-loading-dots span:nth-child(1) { animation-delay: 0s; }
.pms-loading-dots span:nth-child(2) { animation-delay: 0.16s; }
.pms-loading-dots span:nth-child(3) { animation-delay: 0.32s; }

@keyframes pms-dot-bounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Typing indicator */
.pms-typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 14px;
    background: var(--pms-bot-bg);
    border-radius: 16px 16px 16px 4px;
    box-shadow: 0 1px 3px var(--pms-bot-shadow);
}

.pms-typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #bbb;
    animation: pms-typing 1.4s infinite both;
}

.pms-typing-indicator span:nth-child(1) { animation-delay: 0s; }
.pms-typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.pms-typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes pms-typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* ============================================================
   Print Styles
============================================================ */
@media print {
    .pms-chat-widget,
    .pms-widget-bubble,
    .pms-widget-overlay {
        display: none !important;
    }
}
