/* تعریف متغیرهای رنگی - محدود شده به کانتینر افزونه برای جلوگیری از تداخل با سایت */
.tamambaha-factor-container {
    --background-color: #f9f9f9;
    --text-color: #333;
    --container-bg: #ffffff;
    --input-bg: #f0f0f0;
    --input-border: #e0e0e0;
    --input-text: #1a1a1a;
    --btn-bg: #3a3a3a;
    --btn-color: #e0e0e0;
    --btn-hover: #4a4a4a;
    --message-user-bg: #e9f5ff;
    --message-bot-bg: #f2f2f2;
    --message-user-text: #1a1a1a;
    --message-bot-text: #1a1a1a;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --file-preview-bg: #f0f0f0;
    --disclaimer-bg: #f7f7f8;
    --disclaimer-text: #666666;
    --quick-reply-bg: #f5f5f5;
    --quick-reply-text: #333333;
    --quick-reply-border: #dddddd;
    --quick-reply-hover-bg: #ebebeb;
    --suggestions-border: #eee;
    --suggestions-text: #333;
    --suggestions-hover-bg: #f0f0f0;
    --suggestions-bg: #f8f9fa;
    --suggestions-bg-dark: #343a40;
    --btn-hover-light: #e9ecef;
    --btn-hover-dark: #4a4a4a;
}

/* حالت تاریک برای افزونه - فقط روی کانتینر افزونه اعمال می‌شود */
.tamambaha-factor-container.dark-theme-active {
    --background-color: #121212;
    --text-color: #f0f0f0;
    --container-bg: #1e1e1e;
    --input-bg: #2a2a2a;
    --input-border: #444444;
    --input-text: #e6e6e6;
    --btn-bg: #3a5fad;
    --btn-color: #ffffff;
    --btn-hover: #4b6fc1;
    --message-user-bg: #234360;
    --message-bot-bg: #2a2a2a;
    --message-user-text: #e6e6e6;
    --message-bot-text: #e6e6e6;
    --shadow-color: rgba(0, 0, 0, 0.5);
    --file-preview-bg: #2a2a2a;
    --disclaimer-bg: #1a1a1a;
    --disclaimer-text: #b0b0b0;
    --quick-reply-bg: #2a2a2a;
    --quick-reply-text: #e6e6e6;
    --quick-reply-border: #3a3a3a;
    --quick-reply-hover-bg: #3a3a3a;
    --suggestions-border: #444444;
    --suggestions-text: #e6e6e6;
    --suggestions-hover-bg: #3a3a3a;
    --suggestions-bg: #232323;
    --btn-hover-light: #3a3a3a;
    --btn-hover-dark: #4b6fc1;
    --dark-border: #3a3a3a;
    --dark-input-bg: #2a2a2a;
    --dark-text: #e6e6e6;
    --dark-bg-light: #232323;
    --dark-border-light: #333333;
    --dark-hover: #383838;
    --table-header-bg: #232323;
    --table-row-hover: rgba(255, 255, 255, 0.08);
    --table-border: #3a3a3a;
    --cell-highlight: #2c4060;
}

/* حالت روشن برای افزونه */
.tamambaha-factor-container.light-theme-active {
    --background-color: #f9f9f9;
    --text-color: #333;
    --container-bg: #ffffff;
    --input-bg: #f0f0f0;
    --input-border: #e0e0e0;
    --input-text: #1a1a1a;
    --btn-bg: #e0e0e0;
    --btn-color: #333;
    --btn-hover: #d0d0d0;
    --message-user-bg: #e9f5ff;
    --message-bot-bg: #f2f2f2;
    --message-user-text: #1a1a1a;
    --message-bot-text: #1a1a1a;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --file-preview-bg: #f0f0f0;
    --disclaimer-bg: #f7f7f8;
    --disclaimer-text: #666666;
    --quick-reply-bg: #f5f5f5;
    --quick-reply-text: #333333;
    --quick-reply-border: #dddddd;
    --quick-reply-hover-bg: #ebebeb;
    --suggestions-border: #e0e0e0;
    --suggestions-text: #333333;
    --suggestions-hover-bg: #f0f0f0;
    --suggestions-bg: #ffffff;
    --btn-hover-light: #e9ecef;
    --btn-hover-dark: #4a4a4a;
}

/* استایل‌های اصلی - body styles removed to prevent interfering with main site */
/* The body styles were causing conflicts with the particle background system */
/*
body {
    font-family: 'Peyda', Tahoma, Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    height: 100vh;
    direction: rtl;
    transition: background-color 0.3s ease, color 0.3s ease;
}
*/

/* اضافه کردن کلاس‌های جدید برای چت بات - همه چیز درون کانتینر افزونه محدود می‌شود */
.tamambaha-factor-container {
    font-family: 'Peyda', Tahoma, Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    direction: rtl;
    /* انیمیشن نرم برای تغییر theme */
    transition: 
        background-color 0.3s ease,
        color 0.3s ease,
        border-color 0.3s ease,
        box-shadow 0.3s ease;
    /* Reset some body styles locally if needed, otherwise handled by scoping */
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    height: auto;
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 9999;
    pointer-events: none; /* اجازه کلیک روی سایت اصلی */
    width: 100%;
    font-size: 14px;
    opacity: 0; /* شروع با حالت مخفی */
    animation: fadeIn 0.3s ease 0.5s forwards; /* نمایش با تاخیر */
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* اضافه کردن transition به عناصر UI برای تغییر نرم theme */
.tamambaha-factor-container * {
    transition: 
        background-color 0.3s ease,
        color 0.3s ease,
        border-color 0.3s ease,
        box-shadow 0.3s ease;
}

/* اضافه کردن transition مخصوص برای input ها - فقط داخل کانتینر افزونه */
.tamambaha-factor-container input,
.tamambaha-factor-container textarea,
.tamambaha-factor-container button,
.tamambaha-factor-container select {
    transition: 
        background-color 0.3s ease,
        color 0.3s ease,
        border-color 0.3s ease,
        box-shadow 0.3s ease,
        opacity 0.3s ease;
}

/* حالت تاریک برای کانتینر */
.tamambaha-factor-container.dark-theme-active {
    --background-color: #121212;
    --text-color: #f0f0f0;
    --container-bg: #1e1e1e;
    --input-bg: #2a2a2a;
    --input-border: #444444;
    --input-text: #e6e6e6;
    --btn-bg: #3a5fad;
    --btn-color: #ffffff;
    --btn-hover: #4b6fc1;
    --message-user-bg: #234360;
    --message-bot-bg: #2a2a2a;
    --message-user-text: #e6e6e6;
    --message-bot-text: #e6e6e6;
    --shadow-color: rgba(0, 0, 0, 0.5);
    --file-preview-bg: #2a2a2a;
    --disclaimer-bg: #1a1a1a;
    --disclaimer-text: #b0b0b0;
    --suggestions-border: #444444;
    --suggestions-text: #e6e6e6;
    --suggestions-hover-bg: #3a3a3a;
    --suggestions-bg: #232323;
    --dark-border: #3a3a3a;
    --dark-input-bg: #2a2a2a;
    --dark-text: #e6e6e6;
    --dark-bg-light: #232323;
    --dark-border-light: #333333;
    --dark-hover: #383838;
    --table-header-bg: #232323;
    --table-row-hover: rgba(255, 255, 255, 0.08);
    --table-border: #3a3a3a;
    --cell-highlight: #2c4060;
    transition: background-color 0.4s ease, color 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease;
}

.tamambaha-factor-container.dark-theme-active .gpt-style-container {
    background-color: var(--background-color);
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
}

.tamambaha-factor-container.dark-theme-active .factor-content-section {
    background-color: var(--background-color);
    border-bottom: 1px solid var(--dark-border);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.tamambaha-factor-container.dark-theme-active .factor-header {
    background-color: var(--container-bg);
    border-bottom: 1px solid var(--dark-border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* جلوگیری از تاثیر استایل‌های چت بات روی محتوای سایت */
.tamambaha-factor-container * {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    color: inherit;
}

/* اعمال استایل‌های رنگ فقط به محتوای داخل چت بات */
.tamambaha-factor-container .bot-message .message-content * {
    color: var(--message-bot-text) !important;
}

.tamambaha-factor-container .user-message .message-content * {
    color: var(--message-user-text) !important;
}

/* Animated selection effect for rows in dark mode */
@keyframes darkRowHighlight {
    0% { background-color: var(--table-row-hover); }
    50% { background-color: rgba(58, 95, 173, 0.15); }
    100% { background-color: var(--table-row-hover); }
}

.tamambaha-factor-container.dark-theme-active .pre-invoice-table tbody tr:active {
    animation: darkRowHighlight 0.5s ease;
}

.tamambaha-factor-container .gpt-style-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    position: relative;
    background-color: transparent;
    pointer-events: auto; /* اجازه کلیک روی اجزای چت بات */
    width: 100%;
}

/* استایل بخش تاریخچه چت - اکنون قابل جمع شدن */
.tamambaha-factor-container .factor-content-section {
    position: relative;
    background-color: var(--background-color);
    z-index: 1000;
    box-shadow: 0 2px 10px var(--shadow-color);
    transition: max-height 0.3s ease, background-color 0.3s ease;
    max-height: 70vh;
    overflow: hidden;
    border-bottom: 1px solid var(--input-border);
    pointer-events: auto;
    width: 100%;
}

/* حالت باز */
.tamambaha-factor-container .factor-content-section.expanded {
    max-height: 70vh;
}

/* حالت بسته */
.tamambaha-factor-container .factor-content-section.collapsed {
    max-height: 50px !important; /* فقط هدر را نشان می‌دهد */
    overflow: hidden !important;
}

/* هدر بخش چت */
.tamambaha-factor-container .factor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background-color: var(--container-bg);
    cursor: pointer;
    height: 50px;
    box-sizing: border-box;
    border-bottom: 1px solid var(--input-border);
    position: sticky;
    top: 0;
    z-index: 1001;
    width: 100%;
    transition: background-color 0.3s ease;
}

/* تغییر رنگ هدر هنگام هاور برای نمایش قابلیت کلیک */
.tamambaha-factor-container .factor-header:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

.tamambaha-factor-container.dark-theme-active .factor-header:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

.tamambaha-factor-container .factor-header-left {
    display: flex !important;
    align-items: center !important;
    gap: 10px;
    flex: 1 !important;
    min-height: 40px !important;
    margin-left: 60px; /* فضای کافی برای دکمه مینیمایز در سمت چپ */
    pointer-events: none; /* جلوگیری از تداخل با دکمه مینیمایز */
}

/* فعال کردن مجدد pointer-events برای محتوای داخل factor-header-left */
.tamambaha-factor-container .factor-header-left * {
    pointer-events: auto;
}

/* دکمه بستن fullscreen - فقط در حالت fullscreen نمایش داده می‌شود */
.tamambaha-factor-container .fullscreen-close-btn {
    display: none; /* به طور پیش فرض مخفی */
    position: absolute;
    top: 15px;
    left: 15px; /* سمت چپ برای RTL */
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    font-size: 24px;
    cursor: pointer;
    z-index: 10000;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    pointer-events: auto; /* اطمینان از کلیک پذیری */
}

.tamambaha-factor-container .fullscreen-close-btn:hover {
    background-color: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

.tamambaha-factor-container .fullscreen-close-btn:active {
    transform: scale(0.95);
}

/* نمایش دکمه فقط در حالت fullscreen */
.tamambaha-factor-container:fullscreen .fullscreen-close-btn,
.tamambaha-factor-container:-webkit-full-screen .fullscreen-close-btn,
.tamambaha-factor-container:-moz-full-screen .fullscreen-close-btn,
.tamambaha-factor-container:-ms-fullscreen .fullscreen-close-btn {
    display: flex !important;
}

/* استایل بهتر برای dark theme در fullscreen */
.tamambaha-factor-container.dark-theme-active .fullscreen-close-btn {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
}

.tamambaha-factor-container.dark-theme-active .fullscreen-close-btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

/* جلوگیری از مداخله آیکون با کلیک دکمه fullscreen */
.tamambaha-factor-container .fullscreen-close-btn i {
    pointer-events: none; /* کلیک‌ها از آیکون به دکمه parent منتقل می‌شوند */
}

/* دکمه مینیمایز پیش فاکتور */
.tamambaha-factor-container .minimize-preinvoice-btn {
    display: flex;
    position: absolute;
    top: 50%; /* در وسط نوار از نظر عمودی */
    transform: translateY(-50%); /* برای center کردن دقیق */
    left: 15px; /* سمت چپ */
    background-color: rgba(58, 95, 173, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 18px;
    cursor: pointer;
    z-index: 10002; /* بالاتر از factor-header که z-index: 1001 دارد */
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    pointer-events: auto !important; /* اطمینان از کلیک‌پذیری */
}

.tamambaha-factor-container .minimize-preinvoice-btn:hover {
    background-color: rgba(58, 95, 173, 1);
    transform: translateY(-50%) scale(1.1); /* حفظ center و افزودن scale */
}

.tamambaha-factor-container .minimize-preinvoice-btn:active {
    transform: translateY(-50%) scale(0.95); /* حفظ center و کاهش scale */
}

/* جلوگیری از مداخله آیکون با کلیک دکمه */
.tamambaha-factor-container .minimize-preinvoice-btn i {
    pointer-events: none; /* کلیک‌ها از آیکون به دکمه parent منتقل می‌شوند */
}

/* استایل بهتر برای dark theme */
.tamambaha-factor-container.dark-theme-active .minimize-preinvoice-btn {
    background-color: rgba(255, 255, 255, 0.15);
    color: white;
}

.tamambaha-factor-container.dark-theme-active .minimize-preinvoice-btn:hover {
    background-color: rgba(255, 255, 255, 0.25);
}

/* بهینه‌سازی برای موبایل */
@media (max-width: 768px) {
    .tamambaha-factor-container .minimize-preinvoice-btn {
        top: 50%; /* در وسط نوار از نظر عمودی */
        transform: translateY(-50%); /* برای center کردن دقیق */
        left: 10px;
        width: 42px;
        height: 42px;
        font-size: 20px;
    }
    
    .tamambaha-factor-container .minimize-preinvoice-btn:hover {
        transform: translateY(-50%) scale(1.1); /* حفظ center و افزودن scale */
    }
    
    .tamambaha-factor-container .minimize-preinvoice-btn:active {
        transform: translateY(-50%) scale(0.95); /* حفظ center و کاهش scale */
    }
    
    .tamambaha-factor-container .factor-header-left {
        margin-left: 55px; /* فضای کافی برای دکمه مینیمایز در موبایل */
    }
}

/* اطمینان از عدم تداخل دکمه با header */
.tamambaha-factor-container:fullscreen .factor-header,
.tamambaha-factor-container:-webkit-full-screen .factor-header,
.tamambaha-factor-container:-moz-full-screen .factor-header,
.tamambaha-factor-container:-ms-fullscreen .factor-header {
    cursor: default; /* در fullscreen هدر کلیک پذیر نباشد */
}

/* بهینه‌سازی برای موبایل */
@media (max-width: 768px) {
    .tamambaha-factor-container .fullscreen-close-btn {
        top: 10px;
        left: 10px;
        width: 50px;
        height: 50px;
        font-size: 26px;
    }
}

.tamambaha-factor-container .toggle-content-btn {
    background: none;
    border: none;
    font-size: 16px;
    color: var(--text-color);
    cursor: pointer;
    transition: transform 0.3s ease, color 0.3s ease;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tamambaha-factor-container .toggle-content-btn:focus {
    outline: none;
}

.tamambaha-factor-container .factor-content-section.collapsed .toggle-content-btn i {
    transform: rotate(180deg);
}


/* News Ticker Styles - scoped to plugin container */
.tamambaha-factor-container .news-ticker-container {
    flex: 1;
    overflow: hidden !important;
    position: relative;
    max-width: calc(100% - 40px);
    height: 30px !important;
    background: transparent !important;
    display: flex !important; /* همیشه نمایش داده شود */
    align-items: center !important;
    margin-right: 10px;
    min-height: 30px !important;
    z-index: 1 !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* فقط در حالت minimized مخفی شود */
.tamambaha-factor-container.factor-minimized .news-ticker-container {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

.tamambaha-factor-container.dark-theme-active .news-ticker-container {
    background: transparent !important;
}

.tamambaha-factor-container .news-ticker-wrapper {
    width: 100% !important;
    height: 100% !important;
    position: relative !important;
    overflow: hidden !important;
    display: flex !important;
    align-items: center !important;
}

.tamambaha-factor-container .news-ticker {
    white-space: nowrap;
    position: absolute;
    top: 0;
    left: 0; /* همیشه داخل دید باشد حتی اگر انیمیشن خاموش باشد */
    height: 100%;
    min-width: 100%;
    display: flex;
    align-items: center;
    animation: tickerMoveRTL 60s linear infinite;
    -webkit-animation: tickerMoveRTL 60s linear infinite;
    direction: rtl;
    padding: 0;
    will-change: transform;
    -webkit-transform: translateZ(0); /* فعال‌سازی hardware acceleration */
    transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    /* جلوگیری از تغییر سرعت در حین انیمیشن */
    animation-timing-function: linear !important;
    -webkit-animation-timing-function: linear !important;
}

/* حرکت از چپ به راست */
@keyframes tickerMoveRTL {
    0% {
        transform: translateX(-50%);
        -webkit-transform: translateX(-50%);
    }
    100% {
        transform: translateX(0);
        -webkit-transform: translateX(0);
    }
}

/* سازگاری بهتر برای موبایل‌های قدیمی */
@-webkit-keyframes tickerMoveRTL {
    0% {
        -webkit-transform: translateX(-50%);
        transform: translateX(-50%);
    }
    100% {
        -webkit-transform: translateX(0);
        transform: translateX(0);
    }
}

/* سازگاری: اگر جایی هنوز از نام قدیمی استفاده شد */
@keyframes tickerTranslate {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* اگر کاربر reduce motion فعال کرده باشد، به صورت پیش‌فرض انیمیشن را حذف کن 
   اما اگر کلاس force-ticker-motion روی کانتینر باشد، انیمیشن را نگه‌دار */
@media (prefers-reduced-motion: reduce) {
    .tamambaha-factor-container:not(.force-ticker-motion) .news-ticker {
        animation: none !important;
        transform: translateX(0) !important;
    }
    .tamambaha-factor-container.force-ticker-motion .news-ticker {
        animation: tickerMoveRTL 60s linear infinite !important;
    }
}

.tamambaha-factor-container .news-item {
    color: var(--text-color);
    font-size: 13px;
    font-weight: 500;
    margin-left: 50px;
    white-space: nowrap;
    display: inline-block;
    font-family: 'Peyda', Tahoma, sans-serif;
    letter-spacing: 0.3px;
    text-shadow: none;
}

.tamambaha-factor-container.dark-theme-active .news-item {
    color: #e0e0e0;
}

.tamambaha-factor-container .news-item:first-child {
    margin-left: 0;
}

/* Icon before news items */
.tamambaha-factor-container .news-item::before {
    content: "📢";
    margin-left: 8px;
    font-size: 12px;
}

/* Different icons for different news types */
.news-item.urgent::before {
    content: "🔥";
}

.news-item.info::before {
    content: "ℹ️";
}

.news-item.update::before {
    content: "🔄";
}

.news-item.promo::before {
    content: "🎉";
}

/* Hover effect - فقط برای دستگاه‌هایی که واقعاً hover دارند */
@media (hover: hover) and (pointer: fine) {
    .news-ticker-container:hover .news-ticker {
        animation-play-state: paused;
        -webkit-animation-play-state: paused;
    }
}

/* Responsive design */
@media (max-width: 767px) {
    .news-ticker-container {
        max-width: calc(100% - 20px);
        height: 25px;
        margin-right: 5px;
    }
    
    .news-item {
        font-size: 12px;
        margin-left: 30px;
    }
}

/* Loading state */
.news-ticker.loading .news-item {
    opacity: 0.7;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.7;
    }
    50% {
        opacity: 1;
    }
}

.tamambaha-factor-container .factor-header {
    min-height: 50px !important;
}

/* Fallback برای مرورگرهای قدیمی که animation پشتیبانی نمی‌کنند */
@supports not (animation: tickerMoveRTL 25s linear infinite) {
    .tamambaha-factor-container .news-ticker {
        left: auto !important;
        right: 0 !important;
        position: relative !important;
        animation: none !important;
        -webkit-animation: none !important;
        transform: none !important;
        -webkit-transform: none !important;
    }
}

/* اضافه کردن border برای debug (حذف کنید اگر نیازی نیست) */
/*
.tamambaha-factor-container .news-ticker {
    border: 1px solid red !important;
}
.tamambaha-factor-container .news-ticker-container {
    border: 1px solid blue !important;
}
*/

/* استایل بخش ورودی - ثابت در پایین */
.tamambaha-factor-container .input-section {
    position: relative;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--background-color);
    padding: 15px 20px 20px;
    z-index: 1000;
    display: flex;
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
    pointer-events: auto;
    transition: background-color 0.3s ease, border-top-color 0.3s ease;
}

.tamambaha-factor-container .input-container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

.tamambaha-factor-container .input-area-wrapper {
    display: flex;
    position: relative;
    background-color: var(--input-bg);
    border-radius: 12px;
    padding: 8px 10px;
    box-shadow: 0 2px 6px var(--shadow-color);
    align-items: center;
    width: 100%;
    box-sizing: border-box;
    transition: all 0.3s ease;
    border: 1px solid var(--input-border);
}

.tamambaha-factor-container .input-area-wrapper:focus-within {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    border-color: var(--input-border);
}

.tamambaha-factor-container .main-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 16px 8px 10px;
    font-size: 14px;
    color: var(--input-text);
    font-family: 'Peyda', sans-serif;
    transition: color 0.3s ease, height 0.1s ease;
    resize: none;
    max-height: 120px;
    height: 36px !important;
    min-height: 36px !important;
    overflow-y: auto;
    outline: none;
    line-height: 1.4;
    box-sizing: border-box;
}

.tamambaha-factor-container .main-input::placeholder {
    color: var(--input-text);
    opacity: 0.6;
    transition: color 0.3s ease;
}

.tamambaha-factor-container .main-input:focus {
    outline: none;
    box-shadow: none;
}

/* اطمینان از اعمال متغیرهای دارک مود به اینپوت */
.tamambaha-factor-container.dark-theme-active .input-area-wrapper {
    background-color: var(--input-bg);
}

.tamambaha-factor-container.dark-theme-active .main-input {
    color: var(--input-text);
}

.tamambaha-factor-container.dark-theme-active .main-input::placeholder {
    color: var(--input-text);
    opacity: 0.5;
}

.tamambaha-factor-container .file-upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6e6e6e;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.tamambaha-factor-container .file-upload-btn:hover {
    color: #1a73e8;
    background-color: rgba(26, 115, 232, 0.1);
}

.tamambaha-factor-container .send-btn {
    background-color: #000000; /* مشکی برای حالت روز */
    color: white; /* سفید برای آیکون در حالت روز */
    border: none;
    border-radius: 50% !important;
    width: 35px !important;
    height: 35px !important;
    min-width: 35px !important;
    min-height: 35px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    overflow: hidden !important;
    padding: 0 !important;
}

.tamambaha-factor-container.dark-theme-active .send-btn {
    background-color: white; /* سفید برای حالت تاریک */
    color: #000000; /* مشکی برای آیکون در حالت تاریک */
}

.tamambaha-factor-container .send-btn:hover {
    background-color: #333333; /* حالت هاور برای دکمه مشکی */
    opacity: 0.9;
}

.tamambaha-factor-container.dark-theme-active .send-btn:hover {
    background-color: #f0f0f0; /* حالت هاور برای دکمه سفید */
    opacity: 0.9;
}

.tamambaha-factor-container .send-btn i {
    font-size: 14px;
}

.tamambaha-factor-container .copyright-text {
    text-align: center;
    font-size: 12px;
    color: var(--text-color);
    opacity: 0.7;
    padding: 0 10px;
    transition: color 0.3s ease, opacity 0.8s ease;
}

.tamambaha-factor-container.dark-theme-active .copyright-text {
    color: var(--text-color);
}

.tamambaha-factor-container .action-btn {
    background-color: rgba(234, 234, 234, 0.85);
    color: #202124;
    border: none;
    border-radius: 18px;
    padding: 8px 16px;
    margin-right: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    font-family: 'Peyda', sans-serif;
    font-size: 14px;
    transition: background-color 0.3s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.tamambaha-factor-container .action-btn i {
    margin-left: 8px;
    font-size: 16px;
}

.tamambaha-factor-container .action-btn:hover {
    background-color: rgba(220, 220, 220, 0.95);
}

/* متن دیسکلیمر در پایین */
.tamambaha-factor-container .gpt-disclaimer {
    display: none;
}

.tamambaha-factor-container .disclaimer-text {
    display: none;
}


.tamambaha-factor-container .user-message {
    align-self: flex-end;
}

.tamambaha-factor-container .bot-message {
    align-self: flex-start;
}

.tamambaha-factor-container .message-content {
    border-radius: 15px;
    padding: 12px 18px;
    position: relative;
    box-shadow: 0 2px 4px var(--shadow-color);
    transition: background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
    word-wrap: break-word;
    text-align: justify;
}

.tamambaha-factor-container .user-message .message-content {
    background-color: var(--message-user-bg);
    color: var(--message-user-text);
    border-bottom-right-radius: 5px;
    text-align: justify;
    font-family: 'Peyda', Tahoma, Arial, sans-serif !important;
}

.tamambaha-factor-container .bot-message .message-content {
    background-color: var(--message-bot-bg);
    color: var(--message-bot-text);
    border-bottom-left-radius: 5px;
    text-align: justify;
    line-height: 1.5;
}

.tamambaha-factor-container .typing-indicator .message-content {
    display: flex;
    align-items: center;
    background-color: transparent !important; /* پس زمینه شفاف */
    box-shadow: none !important; /* حذف سایه */
    padding: 8px 12px !important; /* پدینگ کمتر */
}

.tamambaha-factor-container .typing-indicator .message-content p {
    margin: 0 0 10px 0;
    text-align: justify;
}

.tamambaha-factor-container .typing-indicator .message-content p:last-child {
    margin-bottom: 0;
}

/* نمایش فایل آپلود شده */
.tamambaha-factor-container .file-upload-indicator {
    display: flex;
    align-items: center;
}

.tamambaha-factor-container .file-upload-indicator i {
    margin-left: 8px;
    font-size: 18px;
}

.tamambaha-factor-container .file-preview {
    background-color: var(--file-preview-bg);
    padding: 10px;
    border-radius: 5px;
    font-family: monospace;
    white-space: pre-wrap;
    overflow-x: auto;
    max-height: 150px;
    overflow-y: auto;
}

/* پاسخگویی */
@media (max-width: 768px) {
    .tamambaha-factor-container .input-area-wrapper {
        flex-wrap: wrap;
    }
    
    .tamambaha-factor-container .action-btn {
        margin-bottom: 8px;
        font-size: 13px;
        padding: 6px 12px;
    }
    
    .tamambaha-factor-container .factor-content-section {
        padding-bottom: 0;
    }
    
    .tamambaha-factor-container .factor-content-section.collapsed {
        max-height: 50px !important;
        min-height: 50px;
        overflow: hidden !important;
        padding-bottom: 0;
    }
}

/* PDF container and preview */
.tamambaha-factor-container .pdf-container {
    width: 100%;
    height: 400px;
    margin: 10px 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px var(--shadow-color);
}

.tamambaha-factor-container .pdf-preview {
    width: 100%;
    height: 100%;
    border: none;
    background-color: var(--file-preview-bg);
}

.tamambaha-factor-container .pdf-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.tamambaha-factor-container .pdf-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background-color: var(--btn-bg);
    color: var(--btn-color);
    border-radius: 4px;
    text-decoration: none;
    font-size: 14px;
    transition: background-color 0.2s ease;
}

.tamambaha-factor-container .pdf-action-btn:hover {
    background-color: var(--btn-hover);
    text-decoration: none;
}

.tamambaha-factor-container .pdf-action-btn i {
    font-size: 14px;
}

/* تصویر */
.tamambaha-factor-container .image-container {
    display: flex;
    justify-content: center;
    overflow: hidden;
    margin: 10px 0;
}

.tamambaha-factor-container .image-preview {
    max-width: 100%;
    border-radius: 8px;
    box-shadow: 0 2px 8px var(--shadow-color);
}

/* Scrollbar Styles */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: rgba(100, 100, 100, 0.5);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 100, 100, 0.7);
}

/* برای تمام مرورگرها و ویندوز */
@media screen and (min-width: 992px) {
    .tamambaha-factor-container .input-container {
        width: 100%;
    }
    
    .tamambaha-factor-container .input-section {
        display: flex;
        justify-content: center;
    }
}

/* مخصوص ویندوز */
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
    .tamambaha-factor-container,
    .tamambaha-factor-container .gpt-style-container,
    .tamambaha-factor-container .factor-content-section,
    .tamambaha-factor-container .factor-header,
    .tamambaha-factor-container .input-section,
    .tamambaha-factor-container .input-container,
    .tamambaha-factor-container .input-area-wrapper {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* برای موبایل */
@media screen and (max-width: 767px) {
    .tamambaha-factor-container .input-container {
        width: 100%;
        max-width: 100%;
        padding: 0;
    }
    
    .tamambaha-factor-container .input-section {
        padding: 10px 0;
    }
    
    .tamambaha-factor-container .input-area-wrapper {
        border-radius: 0;
    }

    .tamambaha-factor-container .factor-content-section.collapsed {
        max-height: 50px !important;
        min-height: 50px;
        height: 50px;
        overflow: hidden !important;
    }
    
    .tamambaha-factor-container .send-btn {
        width: 35px !important;
        height: 35px !important;
        min-width: 35px !important;
        min-height: 35px !important;
        border-radius: 50% !important;
        padding: 0 !important;
        aspect-ratio: 1/1 !important;
    }
}

/* برای تبلت و دسکتاپ */
@media screen and (min-width: 768px) {
    .tamambaha-factor-container .input-container {
        max-width: 800px;
        width: 90%;
    }
}

/* بخش تماس - استایل جدید و مدرن */
.tamambaha-factor-container .footer-content {
    position: relative;
    min-height: 45px;
    margin-top: 12px;
    margin-bottom: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.tamambaha-factor-container .copyright-text {
    text-align: center;
    font-size: 12px;
    color: var(--text-color);
    opacity: 0.7;
    padding: 0 10px;
    transition: color 0.3s ease, opacity 0.8s ease;
    width: 100%;
}

/* استایل دکمه‌های ارتباطی */
.tamambaha-factor-container .contact-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    width: 100%;
    position: relative;
}

/* استایل دکمه تماس موبایل */
.tamambaha-factor-container .mobile-call-btn {
    background-color: transparent !important;
    display: flex;
    border-radius: 18px !important;
    box-shadow: 0 2px 8px rgba(60, 64, 67, 0.15);
    transition: all 0.3s ease;
    width: auto !important;
    height: auto !important;
    padding: 6px 14px !important;
    border: 1px solid var(--text-color) !important;
    gap: 6px;
}

.tamambaha-factor-container .mobile-call-btn .btn-icon i {
    color: #4CAF50 !important;
}

.tamambaha-factor-container .mobile-call-btn .btn-label {
    color: var(--text-color) !important;
}

.tamambaha-factor-container .mobile-call-btn:hover {
    background-color: transparent !important;
    color: var(--text-color) !important;
    border: 1px solid var(--text-color) !important;
}

/* استایل متن تماس در دسکتاپ */
.tamambaha-factor-container .call-text-desktop {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background-color: var(--container-bg);
    padding: 8px 12px;
    border-radius: 12px;
    box-shadow: 0 3px 10px rgba(60, 64, 67, 0.15);
    transition: all 0.3s ease;
    border: 1px solid rgba(60, 64, 67, 0.08);
}

.tamambaha-factor-container.dark-theme-active .call-text-desktop {
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.tamambaha-factor-container .call-text-desktop .btn-icon {
    font-size: 14px;
    color: #4CAF50;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tamambaha-factor-container .call-text-desktop span {
    font-size: 13px;
    color: var(--text-color);
}

.tamambaha-factor-container .phone-number-link {
    color: #4CAF50;
    text-decoration: none;
    font-weight: bold;
    font-size: 13px;
    transition: color 0.3s ease;
    background-color: transparent !important;
}

.tamambaha-factor-container .phone-number-link:hover {
    text-decoration: underline;
    background-color: transparent !important;
}

/* استایل جدید برای دکمه‌های تماس */
.tamambaha-factor-container .contact-btn {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    text-decoration: none;
    font-size: 16px;
    transition: all 0.3s ease;
    box-shadow: 0 3px 8px rgba(60, 64, 67, 0.2);
    position: relative;
    overflow: hidden;
}

.tamambaha-factor-container.dark-theme-active .contact-btn {
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
}

.tamambaha-factor-container .contact-btn:hover {
    transform: none !important;
    box-shadow: 0 3px 8px rgba(60, 64, 67, 0.2) !important;
}

.tamambaha-factor-container.dark-theme-active .contact-btn:hover {
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35) !important;
}

/* افکت موج هنگام کلیک */
.tamambaha-factor-container .contact-btn::after {
    content: '';
    display: block;
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
    background-image: radial-gradient(circle, rgba(255, 255, 255, 0.4) 10%, transparent 10.01%);
    background-repeat: no-repeat;
    background-position: 50%;
    transform: scale(10, 10);
    opacity: 0;
    transition: transform 0.5s, opacity 0.5s;
}

.tamambaha-factor-container .contact-btn:active::after {
    transform: scale(0, 0);
    opacity: 0.3;
    transition: 0s;
}

/* رنگ‌های دکمه‌ها */
.tamambaha-factor-container .whatsapp-btn {
    background-color: #25D366;
}

.tamambaha-factor-container .telegram-btn {
    background-color: #0088cc;
}

.tamambaha-factor-container .webkomak-btn {
    background-color: #0d64ca;
}

/* تنظیمات دسکتاپ برای دکمه تماس */
@media (min-width: 768px) {
    .tamambaha-factor-container .mobile-call-btn {
        display: none;
    }
    
    .tamambaha-factor-container .call-text-desktop {
        display: flex;
    }
    
    .tamambaha-factor-container .contact-buttons {
        gap: 18px;
    }
}

/* ChatGPT-like pill style for WhatsApp and Telegram buttons */
.tamambaha-factor-container .contact-btn.whatsapp-btn,
.tamambaha-factor-container .contact-btn.telegram-btn,
.tamambaha-factor-container .contact-btn.webkomak-btn {
    width: auto !important;
    height: auto !important;
    border-radius: 18px !important;
    padding: 6px 14px;
    font-size: 14px;
    font-family: 'Peyda', sans-serif;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background-color: transparent !important; /* بی‌رنگ */
    border: 1px solid var(--text-color) !important; /* خط دور دکمه */
    color: var(--text-color) !important; /* رنگ آیکون همسان با متن */
}

.tamambaha-factor-container .contact-btn.whatsapp-btn i,
.tamambaha-factor-container .contact-btn.telegram-btn i,
.tamambaha-factor-container .contact-btn.webkomak-btn i {
    font-size: 16px;
}

/* حذف تغییر سایز در هاور دکمه‌های تماس */
.tamambaha-factor-container .contact-btn:hover {
    transform: none !important;
    box-shadow: 0 3px 8px rgba(60, 64, 67, 0.2) !important;
}

.tamambaha-factor-container.dark-theme-active .contact-btn:hover {
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35) !important;
}

/* حذف تغییر رنگ‌بندی در هاور دکمه‌های واتساپ و تلگرام */
.tamambaha-factor-container .contact-btn.whatsapp-btn:hover,
.tamambaha-factor-container .contact-btn.telegram-btn:hover,
.tamambaha-factor-container .contact-btn.webkomak-btn:hover,
.tamambaha-factor-container .mobile-call-btn:hover {
    background-color: transparent !important;
    color: var(--text-color) !important;
    border: 1px solid var(--text-color) !important;
}

/* حفظ رنگ سبز آیکون تلفن در هاور */
.tamambaha-factor-container .mobile-call-btn:hover .btn-icon i {
    color: #4CAF50 !important;
}

/* تضمین نمایش رنگ صحیح آیکون تماس با تمام بها (headset) */
.tamambaha-factor-container .call-text-desktop .btn-icon i.fa-headset {
    color: #4CAF50 !important;
    font-size: 14px !important;
}

/* حفظ رنگ آیکون headset در هاور */
.tamambaha-factor-container .call-text-desktop:hover .btn-icon i.fa-headset {
    color: #4CAF50 !important;
}

/* حفظ رنگ‌های اختصاصی آیکون‌های تماس در برابر استایل‌های عمومی */
.tamambaha-factor-container .call-text-desktop .btn-icon i,
.tamambaha-factor-container .call-text-desktop .btn-icon i.fa-headset,
.tamambaha-factor-container .call-text-desktop .btn-icon i.fa-solid {
    color: #4CAF50 !important;
    font-size: 14px !important;
}

/* اطمینان از حفظ رنگ در حالت تاریک */
.tamambaha-factor-container.dark-theme-active .call-text-desktop .btn-icon i,
.tamambaha-factor-container.dark-theme-active .call-text-desktop .btn-icon i.fa-headset {
    color: #4CAF50 !important;
}

/* حفظ رنگ متن در هاور */
.tamambaha-factor-container .mobile-call-btn:hover .btn-label,
.tamambaha-factor-container .contact-btn.whatsapp-btn:hover .btn-label,
.tamambaha-factor-container .contact-btn.telegram-btn:hover .btn-label,
.tamambaha-factor-container .contact-btn.webkomak-btn:hover .btn-label {
    color: var(--text-color) !important;
}

.tamambaha-factor-container .btn-label {
    font-size: 13px;
    font-weight: 500;
}

/* استایل برای دکمه‌های پاسخ سریع (Quick Reply) */
.tamambaha-factor-container .quick-reply-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.tamambaha-factor-container .quick-reply-btn {
    background-color: var(--quick-reply-bg);
    color: var(--quick-reply-text);
    border: 1px solid var(--quick-reply-border);
    padding: 6px 12px;
    border-radius: 16px;
    font-family: 'Peyda', sans-serif;
    font-size: 13px;
    cursor: pointer;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.tamambaha-factor-container .quick-reply-btn:hover {
    background-color: var(--quick-reply-hover-bg);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.tamambaha-factor-container.dark-theme-active .quick-reply-btn {
    background-color: var(--quick-reply-bg);
    color: var(--quick-reply-text);
    border-color: var(--quick-reply-border);
}

.tamambaha-factor-container.dark-theme-active .quick-reply-btn:hover {
    background-color: var(--quick-reply-hover-bg);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
} 

/* Style for stop button */
.tamambaha-factor-container .send-btn.stop-button {
    background-color: white;
    color: #000000;
}

.tamambaha-factor-container .send-btn.stop-button:hover {
    background-color: #f0f0f0;
}

.tamambaha-factor-container.dark-theme-active .send-btn.stop-button {
    background-color: white;
    color: #000000;
}

.tamambaha-factor-container.dark-theme-active .send-btn.stop-button:hover {
    background-color: #f0f0f0;
}

/* Animation for typing effect - cursor blink */
@keyframes blink-cursor {
    0%, 100% { border-right-color: transparent; }
    50% { border-right-color: var(--text-color); }
}

/* Style for bot messages with typing animation - cursor removed */
.tamambaha-factor-container .bot-message .message-content p.typing {
    display: inline-block;
}

/* استایل برای محتوای Markdown */
.tamambaha-factor-container .bot-message .message-content {
    line-height: 1.5;
    font-family: 'Peyda', Tahoma, Arial, sans-serif !important; /* اطمینان از استفاده صحیح فونت */
}

/* اطمینان از اینکه همه المان‌های داخل پیام فونت صحیح را دارند */
.tamambaha-factor-container .bot-message .message-content *:not(code):not(pre) {
    font-family: 'Peyda', Tahoma, Arial, sans-serif !important;
}

/* استایل برای عناوین در Markdown */
.tamambaha-factor-container .bot-message .message-content h1,
.tamambaha-factor-container .bot-message .message-content h2,
.tamambaha-factor-container .bot-message .message-content h3,
.tamambaha-factor-container .bot-message .message-content h4,
.tamambaha-factor-container .bot-message .message-content h5,
.tamambaha-factor-container .bot-message .message-content h6 {
    margin-top: 10px;
    margin-bottom: 8px;
    font-weight: bold;
    color: var(--text-color);
}

.tamambaha-factor-container .bot-message .message-content h1 {
    font-size: 20px;
}

.tamambaha-factor-container .bot-message .message-content h2 {
    font-size: 18px;
}

.tamambaha-factor-container .bot-message .message-content h3 {
    font-size: 16px;
}

/* استایل برای لیست‌ها */
.tamambaha-factor-container .bot-message .message-content ul,
.tamambaha-factor-container .bot-message .message-content ol {
    margin-top: 8px;
    margin-bottom: 8px;
    padding-right: 25px;
    padding-left: 0;
    text-align: justify;
}

.tamambaha-factor-container .bot-message .message-content ul li,
.tamambaha-factor-container .bot-message .message-content ol li {
    margin-bottom: 5px;
    text-align: justify;
}

/* استایل برای لینک‌ها */
.tamambaha-factor-container .bot-message .message-content a {
    color: #2575fc;
    text-decoration: none;
    border-bottom: 1px solid rgba(37, 117, 252, 0.3);
    transition: color 0.2s ease, border-bottom-color 0.2s ease;
}

.tamambaha-factor-container .bot-message .message-content a:hover {
    color: #6a11cb;
    border-bottom-color: rgba(106, 17, 203, 0.5);
}

/* استایل برای حالت تاریک لینک‌ها */
.tamambaha-factor-container.dark-theme-active .bot-message .message-content a {
    color: #5f9fff;
    border-bottom-color: rgba(95, 159, 255, 0.4);
}

.tamambaha-factor-container.dark-theme-active .bot-message .message-content a:hover {
    color: #8e68d8;
    border-bottom-color: rgba(142, 104, 216, 0.6);
}

/* استایل برای متن‌های کد */
.tamambaha-factor-container .bot-message .message-content code {
    font-family: monospace;
    background-color: rgba(0, 0, 0, 0.05);
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 0.9em;
}

.tamambaha-factor-container.dark-theme-active .bot-message .message-content code {
    background-color: rgba(255, 255, 255, 0.1);
}

/* استایل برای بلوک‌های کد */
.tamambaha-factor-container .bot-message .message-content pre {
    background-color: rgba(0, 0, 0, 0.05);
    padding: 10px;
    border-radius: 5px;
    overflow-x: auto;
    margin: 10px 0;
}

.tamambaha-factor-container.dark-theme-active .bot-message .message-content pre {
    background-color: rgba(255, 255, 255, 0.1);
}

.tamambaha-factor-container .bot-message .message-content pre code {
    background-color: transparent;
    padding: 0;
    display: block;
    overflow-x: auto;
}

/* استایل برای نقل‌قول‌ها */
.tamambaha-factor-container .bot-message .message-content blockquote {
    border-right: 3px solid #ddd;
    margin: 10px 0;
    padding: 5px 15px;
    color: var(--text-color);
    opacity: 0.9;
    text-align: justify;
}

.tamambaha-factor-container.dark-theme-active .bot-message .message-content blockquote {
    border-right-color: #555;
}

/* تنظیم استایل برای پیشنهادات سایز */
.autocomplete-header {
    padding: 10px 15px;
    font-weight: 600;
    background-color: var(--suggestions-bg, #f8f9fa);
    border-bottom: 1px solid var(--suggestions-border, #e9ecef);
    color: var(--suggestions-text, #343a40);
    text-align: right;
    font-size: 14px;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

.tamambaha-factor-container.dark-theme-active .autocomplete-header {
    background-color: var(--suggestions-bg, #343a40);
    border-bottom-color: var(--suggestions-border, #495057);
    color: var(--suggestions-text, #f8f9fa);
}

/* Styling for the container that holds suggestions */
#suggestions-container {
    display: flex;
    flex-direction: column;
    background-color: var(--suggestions-bg, #fff);
    border: 1px solid var(--suggestions-border, #e0e0e0);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-height: 300px;
    overflow-y: auto;
    text-align: right;
    direction: rtl;
}

.no-sizes-message {
    padding: 10px;
    text-align: center;
    color: var(--text-color, #6c757d);
    font-style: italic;
    font-size: 13px;
}

.tamambaha-factor-container.dark-theme-active .no-sizes-message {
    color: var(--text-color, #adb5bd);
}

.autocomplete-suggestion {
    padding: 12px 18px;
    cursor: pointer;
    border-bottom: 1px solid var(--suggestions-border, #eee);
    color: var(--suggestions-text, #333);
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    text-align: right;
    font-size: 14px;
    line-height: 1.6;
}

.autocomplete-suggestion:last-child {
    border-bottom: none;
}

.autocomplete-suggestion:hover,
.autocomplete-suggestion.selected {
    background-color: var(--suggestions-hover-bg, #f0f0f0);
    color: var(--suggestions-text, #222);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.autocomplete-suggestion .highlight {
    font-weight: bold;
    color: #2575fc;
}

/* Ensure dark theme highlight is also updated or inherits correctly */
.tamambaha-factor-container.dark-theme-active .autocomplete-suggestion .highlight {
    color: #5a9aff;
}

/* کلاس جدید برای اطمینان از فونت صحیح در پاسخ‌های بات */
.tamambaha-factor-container .bot-message .message-content .bot-response {
    font-family: 'Peyda', Tahoma, Arial, sans-serif !important;
}

.tamambaha-factor-container .bot-message .message-content .bot-response * {
    font-family: 'Peyda', Tahoma, Arial, sans-serif !important;
}

/* استایل برای نشانگر "فکر کردن" */
.tamambaha-factor-container .typing-indicator {
    margin-bottom: 10px;
}

.tamambaha-factor-container .typing-indicator .message-content {
    display: flex;
    align-items: center;
    background-color: transparent !important; /* پس زمینه شفاف */
    box-shadow: none !important; /* حذف سایه */
    padding: 8px 12px !important; /* پدینگ کمتر */
}

.tamambaha-factor-container .typing-indicator .message-content p {
    margin: 0 0 10px 0;
    text-align: justify;
}

.tamambaha-factor-container .typing-indicator .message-content p:last-child {
    margin-bottom: 0;
}

/* انیمیشن برای نقطه‌های متفکرانه */
.tamambaha-factor-container .thinking-dots {
    display: inline-block;
}

.tamambaha-factor-container .thinking-dots .dot-1,
.tamambaha-factor-container .thinking-dots .dot-2,
.tamambaha-factor-container .thinking-dots .dot-3 {
    display: inline-block;
    opacity: 0;
    animation: dot-fade 1.4s infinite;
    font-weight: bold;
}

.tamambaha-factor-container .thinking-dots .dot-2 {
    animation-delay: 0.2s;
}

.tamambaha-factor-container .thinking-dots .dot-3 {
    animation-delay: 0.4s;
}

@keyframes dot-fade {
    0%, 60%, 100% {
        opacity: 0;
    }
    30% {
        opacity: 1;
    }
}

/* استایل justify برای پاراگراف‌های پیام‌های بات */
.tamambaha-factor-container .bot-message .message-content p {
    margin: 0 0 10px 0;
    text-align: justify;
}

.tamambaha-factor-container .bot-message .message-content p:last-child {
    margin-bottom: 0;
} 

/* استایل بخش پیش فاکتور */
.tamambaha-factor-container .pre-invoice-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    margin: 0 auto;
    padding: 10px 20px;
    max-height: calc(70vh - 50px);
    overflow-y: auto;
    box-sizing: border-box;
    transition: all 0.3s ease;
    opacity: 1;
}

.tamambaha-factor-container .pre-invoice-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    direction: rtl;
    font-family: 'Peyda', Tahoma, Arial, sans-serif;
    table-layout: fixed; /* به منظور ثابت کردن عرض ستون‌ها */
    border-top: none;
    border-right: none; /* حذف بوردر راست اضافی جدول */
}

.tamambaha-factor-container.dark-theme-active .pre-invoice-table {
    border-right: none; /* حذف بوردر راست اضافی جدول در حالت تاریک */
}

.tamambaha-factor-container .pre-invoice-table thead tr:first-child th {
    border-top: none;
}

/* تنظیم عرض ستون‌ها به صورت درصدی ثابت */
.tamambaha-factor-container .pre-invoice-table th,
.tamambaha-factor-container .pre-invoice-table td {
    padding: 10px;
    text-align: center;
    border-bottom: 1px solid var(--input-border);
    border-right: 1px solid var(--input-border);
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tamambaha-factor-container .pre-invoice-table th:last-child,
.tamambaha-factor-container .pre-invoice-table td:last-child {
    border-right: none;
}

.tamambaha-factor-container.dark-theme-active .pre-invoice-table th,
.tamambaha-factor-container.dark-theme-active .pre-invoice-table td {
    border-bottom: 1px solid var(--dark-border);
    border-right: 1px solid var(--dark-border);
}

.tamambaha-factor-container.dark-theme-active .pre-invoice-table th:last-child,
.tamambaha-factor-container.dark-theme-active .pre-invoice-table td:last-child {
    border-right: none;
}

.tamambaha-factor-container .pre-invoice-table th {
    font-weight: bold;
    background-color: var(--container-bg);
    color: var(--text-color);
    position: sticky;
    top: 0;
    z-index: 5;
}

.tamambaha-factor-container .pre-invoice-table tbody tr {
    transition: background-color 0.3s ease;
}

.tamambaha-factor-container .pre-invoice-table tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

.tamambaha-factor-container.dark-theme-active .pre-invoice-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

/* تنظیم عرض ستون برند */
.tamambaha-factor-container .pre-invoice-table th:nth-child(1),
.tamambaha-factor-container .pre-invoice-table td:nth-child(1) {
    width: 12%;
}

/* تنظیم عرض ستون نوع کالا */
.tamambaha-factor-container .pre-invoice-table th:nth-child(2),
.tamambaha-factor-container .pre-invoice-table td:nth-child(2) {
    width: 12%;
}

/* تنظیم عرض ستون نام کالا (بیشترین عرض) */
.tamambaha-factor-container .pre-invoice-table th:nth-child(3),
.tamambaha-factor-container .pre-invoice-table td:nth-child(3) {
    width: 25%;
}

/* تنظیم عرض ستون اندازه */
.tamambaha-factor-container .pre-invoice-table th:nth-child(4),
.tamambaha-factor-container .pre-invoice-table td:nth-child(4) {
    width: 10%;
}

/* تنظیم عرض ستون محاسبه قیمت */
.tamambaha-factor-container .pre-invoice-table th:nth-child(5),
.tamambaha-factor-container .pre-invoice-table td:nth-child(5) {
    width: 26%;
}

/* تنظیم عرض ستون تعداد */
.tamambaha-factor-container .pre-invoice-table th:nth-child(6),
.tamambaha-factor-container .pre-invoice-table td:nth-child(6) {
    width: 4%;
}

/* تنظیم عرض ستون قیمت */
.tamambaha-factor-container .pre-invoice-table th:nth-child(7),
.tamambaha-factor-container .pre-invoice-table td:nth-child(7) {
    width: 13%;
}

/* تنظیم عرض ستون تخفیف */
.tamambaha-factor-container .pre-invoice-table th:nth-child(8),
.tamambaha-factor-container .pre-invoice-table td:nth-child(8) {
    width: 4%;
}

/* تنظیم عرض ستون جمع */
.tamambaha-factor-container .pre-invoice-table th:nth-child(9),
.tamambaha-factor-container .pre-invoice-table td:nth-child(9) {
    width: 12%;
}

/* تنظیم عرض ستون بازنشانی */
.tamambaha-factor-container .pre-invoice-table th:nth-child(10),
.tamambaha-factor-container .pre-invoice-table td:nth-child(10) {
    width: 8%;
    min-width: 60px;
}

/* استایل header ستون بازنشانی */
.tamambaha-factor-container .pre-invoice-table th:nth-child(10) {
    color: #d32f2f;
    font-weight: 600;
    white-space: nowrap;
    padding: 10px 6px;
}

.tamambaha-factor-container.dark-theme-active .pre-invoice-table th:nth-child(10) {
    color: #ef5350;
}

.tamambaha-factor-container .pre-invoice-table th:nth-child(10) i {
    margin-left: 5px;
    font-size: 14px;
    vertical-align: middle;
}

/* نگهدارنده برای افزایش ویژگی انتخاب‌گر در قواعد بعدی */
.tamambaha-factor-container .pre-invoice-table th,
.tamambaha-factor-container .pre-invoice-table td { padding: 10px; }

/* پنهان کردن 4 ستون اول فقط در هدِر و ردیف‌های محصول */
.tamambaha-factor-container .pre-invoice-table thead th:nth-child(-n+4),
.tamambaha-factor-container .pre-invoice-table tbody tr.pre-invoice-row td:nth-child(-n+4) {
    display: none;
}

/* بازتوزیع عرض برای 5 ستون باقی‌مانده پس از حذف */
.tamambaha-factor-container .pre-invoice-table thead th:nth-child(5),
.tamambaha-factor-container .pre-invoice-table tbody td:nth-child(5) {
    /* Increased to absorb the width of the hidden "بها" (price) column */
    width: 60%;
}
.tamambaha-factor-container .pre-invoice-table thead th:nth-child(6),
.tamambaha-factor-container .pre-invoice-table tbody td:nth-child(6) {
    width: 9%; /* کاهش برای جبران افزایش ستون محاسبه قیمت */
}
.tamambaha-factor-container .pre-invoice-table thead th:nth-child(7),
.tamambaha-factor-container .pre-invoice-table tbody td:nth-child(7) {
    /* Hide the price column (بها) visually; its width is added to the features column */
    display: none;
}
.tamambaha-factor-container .pre-invoice-table thead th:nth-child(8),
.tamambaha-factor-container .pre-invoice-table tbody td:nth-child(8) {
    width: 9%; /* کاهش برای جبران افزایش ستون محاسبه قیمت */
}
.tamambaha-factor-container .pre-invoice-table thead th:nth-child(9),
.tamambaha-factor-container .pre-invoice-table tbody td:nth-child(9) {
    width: 22%; /* کاهش برای جبران افزایش ستون محاسبه قیمت */
}

/* Inline PEFP controls */
.tamambaha-factor-container .pre-invoice-table .pefp-inline {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
}
.tamambaha-factor-container .pre-invoice-table .pefp-inline-scroll {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    gap: 6px;
    width: 100%;
}
.tamambaha-factor-container .pre-invoice-table .pefp-inline-scroll.grabbing {
    cursor: grabbing;
}
.tamambaha-factor-container .pre-invoice-table .pefp-inline-scroll::-webkit-scrollbar { height: 0; }
.tamambaha-factor-container .pre-invoice-table .pefp-inline-scroll { scrollbar-width: none; }
.tamambaha-factor-container .pre-invoice-table .pefp-inline-field {
    min-width: 160px;
}
/* navigation buttons removed per UX: no styles needed */
.tamambaha-factor-container .pre-invoice-table .pefp-inline-field select.pefp-inline-select {
    width: 100%;
    padding: 4px; /* کاهش padding برای فشردگی */
    border: 1px solid var(--input-border);
    border-radius: 4px; /* کاهش border-radius */
    background-color: var(--input-bg);
    color: var(--input-text);
    font-size: 11px; /* کاهش اندازه فونت */
}
.tamambaha-factor-container .pre-invoice-table .pefp-inline-field .pefp-inline-label {
    display: block;
    font-size: 9px; /* کاهش اندازه فونت برچسب */
    color: var(--text-color);
    opacity: .8;
    margin-bottom: 1px; /* کاهش فاصله */
}

/* جلوگیری از همپوشانی محتوای ستون ویژگی‌ها روی ستون‌های بعدی */
.tamambaha-factor-container .pre-invoice-table tbody td { position: relative; }
.tamambaha-factor-container .pre-invoice-table tbody td:nth-child(5) { overflow: hidden; }
.tamambaha-factor-container .pre-invoice-table .pefp-inline { max-width: 100%; overflow: hidden; }
.tamambaha-factor-container .pre-invoice-table .pefp-inline-scroll { max-width: 100%; }

.tamambaha-factor-container .pre-invoice-table input {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    background-color: var(--input-bg);
    color: var(--input-text);
    font-family: 'Peyda', Tahoma, Arial, sans-serif;
    transition: border-color 0.3s ease, background-color 0.3s ease, color 0.3s ease;
    text-align: center;
    box-sizing: border-box;
}

/* Style for brand dropdown selects */
.tamambaha-factor-container .pre-invoice-table select.brand-input {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    background-color: var(--input-bg);
    color: var(--input-text);
    font-family: 'Peyda', Tahoma, Arial, sans-serif;
    transition: border-color 0.3s ease, background-color 0.3s ease, color 0.3s ease;
    text-align: center;
    direction: rtl;
    appearance: none; /* Remove default arrow */
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: left 8px center;
    background-size: 1em;
    padding-left: 30px; /* Make room for the custom arrow */
    cursor: pointer;
    box-sizing: border-box;
}

.tamambaha-factor-container .pre-invoice-table select.brand-input:focus {
    outline: none;
    border-color: var(--btn-bg);
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.05);
}

.tamambaha-factor-container.dark-theme-active .pre-invoice-table select.brand-input {
    background-color: var(--input-bg);
    color: var(--input-text);
    border-color: var(--input-border);
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
}

/* Make sure the select options have appropriate styling */
.tamambaha-factor-container .pre-invoice-table select.brand-input option {
    padding: 8px;
    background-color: var(--container-bg);
    color: var(--text-color);
    font-family: 'Peyda', Tahoma, Arial, sans-serif;
}

.tamambaha-factor-container .pre-invoice-table input:focus {
    outline: none;
    border-color: var(--btn-bg);
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.05);
}

.tamambaha-factor-container .product-input-container {
    position: relative;
}

.tamambaha-factor-container .product-name-input {
    width: 100%;
}

.tamambaha-factor-container .pre-invoice-table .price-input,
.tamambaha-factor-container .pre-invoice-table .total-cell {
    font-weight: bold;
    color: var(--text-color);
}

/* Styles for price input field */
.tamambaha-factor-container .pre-invoice-table .price-input {
    width: 100%;
    padding: 10px 15px;
    border: none;
    border-radius: 0;
    background-color: transparent;
    color: var(--text-color);
    font-family: inherit;
    font-size: inherit;
    text-align: center;
    direction: ltr; /* Left-to-right for numbers */
    box-sizing: border-box;
    transition: background-color 0.3s ease;
}

.tamambaha-factor-container .pre-invoice-table .price-input:focus {
    outline: none;
    background-color: rgba(0, 0, 0, 0.02);
}

.tamambaha-factor-container .pre-invoice-table .price-input:disabled {
    background-color: rgba(0, 0, 0, 0.05);
    color: #999;
    cursor: not-allowed;
}

/* Ensure the total is right-aligned and keeps a bold font weight */
.tamambaha-factor-container .pre-invoice-table .total-cell {
    text-align: center;
    font-weight: bold;
}

/* Fix row hover state to not interfere with price cell hover */
.tamambaha-factor-container .pre-invoice-table tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

/* اطمینان از نمایش مناسب عناصر فرم در ستون‌ها */
.tamambaha-factor-container .product-accordion {
    width: 100%;
    box-sizing: border-box;
}

/* Style for product accordion to fit within product column */
.tamambaha-factor-container .product-accordion-header {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    font-family: 'Peyda', Tahoma, Arial, sans-serif;
    font-size: 0.95rem;
    position: relative;
    user-select: none;
    padding: 8px 12px;
    background-color: var(--input-bg);
    color: var(--input-text);
    text-align: center;
    border-bottom: 1px solid var(--input-border);
}

.tamambaha-factor-container .product-accordion-header::after {
    content: "";
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 10px;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    transition: transform 0.3s ease;
    filter: brightness(0) invert(1);
}

.tamambaha-factor-container .product-accordion.active .product-accordion-header::after {
    transform: translateY(-50%) rotate(180deg);
}

.tamambaha-factor-container .product-accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background-color: var(--bg-light);
}

.tamambaha-factor-container .product-accordion.active .product-accordion-content {
    max-height: 300px;
    overflow-y: auto;
    border-top: 1px solid var(--border-color);
}

.tamambaha-factor-container .product-search {
    padding: 8px;
    position: sticky;
    top: 0;
    background-color: var(--bg-light);
    z-index: 1;
    border-bottom: 1px solid var(--border-color);
}

.tamambaha-factor-container .product-search-input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    background-color: var(--input-bg);
    color: var(--input-text);
    font-family: 'Peyda', Tahoma, Arial, sans-serif;
}

.tamambaha-factor-container .product-items-container {
    max-height: 220px;
    overflow-y: auto;
}

.tamambaha-factor-container .product-item {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.tamambaha-factor-container .product-item:hover {
    background-color: var(--hover-light);
}

.tamambaha-factor-container .product-item:last-child {
    border-bottom: none;
}

.tamambaha-factor-container .product-accordion-header.has-selection {
    color: var(--btn-bg);
    font-weight: bold;
}

/* Dark theme optimizations for pre-invoice container */
.tamambaha-factor-container.dark-theme-active .pre-invoice-container {
    background-color: var(--background-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.tamambaha-factor-container.dark-theme-active .pre-invoice-table th {
    background-color: var(--table-header-bg);
    color: var(--text-color);
    border-bottom: 1px solid var(--table-border);
    font-weight: 600;
}

.tamambaha-factor-container.dark-theme-active .pre-invoice-table td {
    border-bottom: 1px solid var(--table-border);
}

.tamambaha-factor-container.dark-theme-active .pre-invoice-table tbody tr:hover {
    background-color: var(--table-row-hover);
}

.tamambaha-factor-container.dark-theme-active .pre-invoice-table input {
    background-color: var(--dark-input-bg);
    color: var(--dark-text);
    border-color: var(--dark-border);
}

.tamambaha-factor-container.dark-theme-active .pre-invoice-table input:focus {
    border-color: var(--btn-bg);
    box-shadow: 0 0 0 2px rgba(58, 95, 173, 0.25);
}

.tamambaha-factor-container.dark-theme-active .pre-invoice-table select.brand-input {
    background-color: var(--dark-input-bg);
    color: var(--dark-text);
    border-color: var(--dark-border);
}

.tamambaha-factor-container.dark-theme-active .pre-invoice-table select.brand-input:focus {
    border-color: var(--btn-bg);
    box-shadow: 0 0 0 2px rgba(58, 95, 173, 0.25);
}

.tamambaha-factor-container.dark-theme-active .pre-invoice-table select.brand-input option {
    background-color: var(--dark-input-bg);
    color: var(--dark-text);
}

.tamambaha-factor-container.dark-theme-active .pre-invoice-table .price-input,
.tamambaha-factor-container.dark-theme-active .pre-invoice-table .total-cell {
    color: var(--text-color);
}

.tamambaha-factor-container.dark-theme-active .pre-invoice-table .price-input {
    background-color: transparent;
}

.tamambaha-factor-container.dark-theme-active .pre-invoice-table .price-input:focus {
    background-color: rgba(255, 255, 255, 0.1);
}

.tamambaha-factor-container.dark-theme-active .pre-invoice-table .price-input:disabled {
    background-color: rgba(255, 255, 255, 0.05);
}

.tamambaha-factor-container.dark-theme-active .row-send-btn {
    background-color: var(--btn-bg);
    color: var(--btn-color);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.tamambaha-factor-container.dark-theme-active .row-send-btn:hover {
    background-color: var(--btn-hover);
}

.tamambaha-factor-container.dark-theme-active .pre-invoice-table .autocomplete-container {
    background-color: var(--dark-input-bg);
    border-color: var(--dark-border);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.tamambaha-factor-container.dark-theme-active .pre-invoice-table .suggestion-item {
    color: var(--dark-text);
    border-bottom: 1px solid var(--dark-border-light);
}

.tamambaha-factor-container.dark-theme-active .pre-invoice-table .suggestion-item:hover,
.tamambaha-factor-container.dark-theme-active .pre-invoice-table .suggestion-item.selected {
    background-color: var(--dark-hover);
}

/* Enhanced styling for grand total row in dark mode */
.tamambaha-factor-container.dark-theme-active .grand-total-row {
    background-color: var(--cell-highlight);
    border-top: 2px solid var(--btn-bg);
}

.tamambaha-factor-container.dark-theme-active .grand-total-value {
    color: #ffffff;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Empty cell in grand total row */
.tamambaha-factor-container .grand-total-empty {
    background-color: inherit;
    border: none;
}

.tamambaha-factor-container.dark-theme-active .grand-total-empty {
    background-color: inherit;
}

/* Enhanced dark theme for product accordion */
.tamambaha-factor-container.dark-theme-active .product-accordion {
    border-color: var(--dark-border);
    background-color: var(--dark-input-bg);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.tamambaha-factor-container.dark-theme-active .product-accordion-header {
    background-color: var(--dark-input-bg);
    color: var(--dark-text);
    border-bottom: 1px solid var(--dark-border);
}

.tamambaha-factor-container.dark-theme-active .product-accordion-header.has-selection {
    color: #6b96e0;
    font-weight: 600;
}

.tamambaha-factor-container.dark-theme-active .product-accordion-content {
    background-color: var(--dark-bg-light);
    border-top: 1px solid var(--dark-border);
}

.tamambaha-factor-container.dark-theme-active .product-search {
    background-color: var(--dark-bg-light);
    border-color: var(--dark-border);
}

.tamambaha-factor-container.dark-theme-active .product-search-input {
    border-color: var(--dark-border);
    background-color: var(--dark-input-bg);
    color: var(--dark-text);
}

.tamambaha-factor-container.dark-theme-active .product-search-input:focus {
    border-color: var(--btn-bg);
    box-shadow: 0 0 0 2px rgba(58, 95, 173, 0.25);
}

.tamambaha-factor-container.dark-theme-active .product-item {
    border-color: var(--dark-border-light);
    color: var(--dark-text);
}

.tamambaha-factor-container.dark-theme-active .product-item:hover {
    background-color: var(--cell-highlight);
}

/* Enhanced scrollbar for dark theme */
.tamambaha-factor-container.dark-theme-active ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.tamambaha-factor-container.dark-theme-active ::-webkit-scrollbar-track {
    background-color: var(--dark-bg-light);
    border-radius: 4px;
}

.tamambaha-factor-container.dark-theme-active ::-webkit-scrollbar-thumb {
    background-color: var(--dark-border);
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

.tamambaha-factor-container.dark-theme-active ::-webkit-scrollbar-thumb:hover {
    background-color: var(--btn-bg);
}

/* Dark mode styles for popups and modals */
.tamambaha-factor-container.dark-theme-active .popup,
.tamambaha-factor-container.dark-theme-active .modal,
.tamambaha-factor-container.dark-theme-active .dialog,
.tamambaha-factor-container.dark-theme-active .overlay,
.tamambaha-factor-container.dark-theme-active .pre-invoice-info-popup {
    background-color: var(--container-bg) !important;
    color: var(--text-color) !important;
    border: 1px solid var(--dark-border) !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6) !important;
}

.tamambaha-factor-container.dark-theme-active .popup-header,
.tamambaha-factor-container.dark-theme-active .modal-header,
.tamambaha-factor-container.dark-theme-active .dialog-header {
    background-color: var(--dark-bg-light) !important;
    color: var(--text-color) !important;
    border-bottom: 1px solid var(--dark-border) !important;
}

.tamambaha-factor-container.dark-theme-active .popup-content,
.tamambaha-factor-container.dark-theme-active .modal-content,
.tamambaha-factor-container.dark-theme-active .dialog-content {
    background-color: var(--container-bg) !important;
    color: var(--text-color) !important;
}

.tamambaha-factor-container.dark-theme-active .popup-footer,
.tamambaha-factor-container.dark-theme-active .modal-footer,
.tamambaha-factor-container.dark-theme-active .dialog-footer {
    background-color: var(--dark-bg-light) !important;
    border-top: 1px solid var(--dark-border) !important;
}

/* Close buttons in dark mode */
.tamambaha-factor-container.dark-theme-active .popup-close,
.tamambaha-factor-container.dark-theme-active .modal-close,
.tamambaha-factor-container.dark-theme-active .close-btn {
    color: var(--text-color) !important;
    background-color: transparent !important;
}

.tamambaha-factor-container.dark-theme-active .popup-close:hover,
.tamambaha-factor-container.dark-theme-active .modal-close:hover,
.tamambaha-factor-container.dark-theme-active .close-btn:hover {
    background-color: var(--dark-hover) !important;
    color: #ffffff !important;
}

/* Backdrop/overlay in dark mode */
.tamambaha-factor-container.dark-theme-active .popup-backdrop,
.tamambaha-factor-container.dark-theme-active .modal-backdrop,
.tamambaha-factor-container.dark-theme-active .dialog-backdrop {
    background-color: rgba(0, 0, 0, 0.8) !important;
}

/* Form elements inside popups */
.tamambaha-factor-container.dark-theme-active .popup input,
.tamambaha-factor-container.dark-theme-active .modal input,
.tamambaha-factor-container.dark-theme-active .dialog input,
.tamambaha-factor-container.dark-theme-active .popup textarea,
.tamambaha-factor-container.dark-theme-active .modal textarea,
.tamambaha-factor-container.dark-theme-active .dialog textarea,
.tamambaha-factor-container.dark-theme-active .popup select,
.tamambaha-factor-container.dark-theme-active .modal select,
.tamambaha-factor-container.dark-theme-active .dialog select {
    background-color: var(--dark-input-bg) !important;
    color: var(--dark-text) !important;
    border: 1px solid var(--dark-border) !important;
}

.tamambaha-factor-container.dark-theme-active .popup input:focus,
.tamambaha-factor-container.dark-theme-active .modal input:focus,
.tamambaha-factor-container.dark-theme-active .dialog input:focus,
.tamambaha-factor-container.dark-theme-active .popup textarea:focus,
.tamambaha-factor-container.dark-theme-active .modal textarea:focus,
.tamambaha-factor-container.dark-theme-active .dialog textarea:focus,
.tamambaha-factor-container.dark-theme-active .popup select:focus,
.tamambaha-factor-container.dark-theme-active .modal select:focus,
.tamambaha-factor-container.dark-theme-active .dialog select:focus {
    border-color: var(--btn-bg) !important;
    box-shadow: 0 0 0 2px rgba(58, 95, 173, 0.25) !important;
}

/* Buttons inside popups */
.tamambaha-factor-container.dark-theme-active .popup .btn,
.tamambaha-factor-container.dark-theme-active .modal .btn,
.tamambaha-factor-container.dark-theme-active .dialog .btn,
.tamambaha-factor-container.dark-theme-active .popup button,
.tamambaha-factor-container.dark-theme-active .modal button,
.tamambaha-factor-container.dark-theme-active .dialog button {
    background-color: var(--btn-bg) !important;
    color: var(--btn-color) !important;
    border: 1px solid var(--dark-border) !important;
}

.tamambaha-factor-container.dark-theme-active .popup .btn:hover,
.tamambaha-factor-container.dark-theme-active .modal .btn:hover,
.tamambaha-factor-container.dark-theme-active .dialog .btn:hover,
.tamambaha-factor-container.dark-theme-active .popup button:hover,
.tamambaha-factor-container.dark-theme-active .modal button:hover,
.tamambaha-factor-container.dark-theme-active .dialog button:hover {
    background-color: var(--btn-hover) !important;
    border-color: var(--btn-hover) !important;
}

/* Secondary buttons */
.tamambaha-factor-container.dark-theme-active .popup .btn-secondary,
.tamambaha-factor-container.dark-theme-active .modal .btn-secondary,
.tamambaha-factor-container.dark-theme-active .dialog .btn-secondary {
    background-color: var(--dark-bg-light) !important;
    color: var(--text-color) !important;
    border: 1px solid var(--dark-border) !important;
}

.tamambaha-factor-container.dark-theme-active .popup .btn-secondary:hover,
.tamambaha-factor-container.dark-theme-active .modal .btn-secondary:hover,
.tamambaha-factor-container.dark-theme-active .dialog .btn-secondary:hover {
    background-color: var(--dark-hover) !important;
}

/* Text elements inside popups */
.tamambaha-factor-container.dark-theme-active .popup p,
.tamambaha-factor-container.dark-theme-active .modal p,
.tamambaha-factor-container.dark-theme-active .dialog p,
.tamambaha-factor-container.dark-theme-active .popup h1,
.tamambaha-factor-container.dark-theme-active .modal h1,
.tamambaha-factor-container.dark-theme-active .dialog h1,
.tamambaha-factor-container.dark-theme-active .popup h2,
.tamambaha-factor-container.dark-theme-active .modal h2,
.tamambaha-factor-container.dark-theme-active .dialog h2,
.tamambaha-factor-container.dark-theme-active .popup h3,
.tamambaha-factor-container.dark-theme-active .modal h3,
.tamambaha-factor-container.dark-theme-active .dialog h3,
.tamambaha-factor-container.dark-theme-active .popup label,
.tamambaha-factor-container.dark-theme-active .modal label,
.tamambaha-factor-container.dark-theme-active .dialog label,
.tamambaha-factor-container.dark-theme-active .popup span,
.tamambaha-factor-container.dark-theme-active .modal span,
.tamambaha-factor-container.dark-theme-active .dialog span {
    color: var(--text-color) !important;
}

/* 🎨 استایل اختصاصی و مدرن برای پاپ‌آپ اطلاعات پیش فاکتور */
/* این استایل کاملاً مستقل است و با هیچ بخش دیگری از سایت تداخل ندارد */

/* Overlay با افکت blur زیبا و gradient خاص */
.invoice-dialog-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: linear-gradient(135deg, 
        rgba(15, 23, 42, 0.95), 
        rgba(30, 41, 59, 0.9), 
        rgba(51, 65, 85, 0.85)) !important;
    backdrop-filter: blur(15px) saturate(150%) !important;
    -webkit-backdrop-filter: blur(15px) saturate(150%) !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    z-index: 10000 !important;
    animation: tmb-fadeInOverlay 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
    font-family: 'Peyda', Tahoma, Arial, sans-serif !important;
}

/* پاپ‌آپ اصلی با طراحی گلاس مورفیزم */
.invoice-dialog-content {
    background: linear-gradient(145deg, 
        rgba(30, 41, 59, 0.95), 
        rgba(51, 65, 85, 0.9)) !important;
    border: 1px solid rgba(148, 163, 184, 0.3) !important;
    border-radius: 24px !important;
    padding: 36px !important;
    width: 90% !important;
    max-width: 520px !important;
    max-height: 85vh !important;
    overflow-y: auto !important;
    box-shadow: 
        0 32px 64px -12px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(255, 255, 255, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.12),
        0 8px 32px rgba(59, 130, 246, 0.15) !important;
    position: relative !important;
    animation: tmb-slideInScale 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    direction: rtl !important;
    color: #f1f5f9 !important;
    font-family: 'Peyda', Tahoma, Arial, sans-serif !important;
}

/* دسکتاپ: تمام‌عرض کردن دیالوگ اطلاعات پیش فاکتور */
@media (min-width: 1024px) {
    .invoice-dialog-content {
        width: 100% !important;
        max-width: none !important;
    }
}

/* عنوان پاپ‌آپ با گرادیانت خاص */
.invoice-dialog-content h3 {
    color: transparent !important;
    font-size: 26px !important;
    font-weight: 800 !important;
    margin: 0 0 28px 0 !important;
    text-align: center !important;
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 50%, #06b6d4 100%) !important;
    background-clip: text !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    position: relative !important;
    text-shadow: 0 2px 8px rgba(59, 130, 246, 0.3) !important;
}

.invoice-dialog-content h3::after {
    content: '' !important;
    position: absolute !important;
    bottom: -12px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 80px !important;
    height: 4px !important;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6) !important;
    border-radius: 2px !important;
    animation: tmb-shimmer 2s ease-in-out infinite alternate !important;
}

/* ردیف‌های فرم */
.invoice-form-row {
    margin-bottom: 24px !important;
    position: relative !important;
}

/* برچسب‌ها با استایل مدرن */
.invoice-form-row label {
    color: #cbd5e1 !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    margin-bottom: 10px !important;
    display: block !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4) !important;
    position: relative !important;
}

/* فیلدهای ورودی با گلاس مورفیزم */
.invoice-form-row input,
.invoice-form-row textarea {
    width: 100% !important;
    padding: 16px 20px !important;
    background: rgba(30, 41, 59, 0.8) !important;
    border: 1px solid rgba(148, 163, 184, 0.4) !important;
    border-radius: 16px !important;
    color: #f1f5f9 !important;
    font-size: 16px !important;
    font-family: 'Peyda', Tahoma, Arial, sans-serif !important;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
    box-sizing: border-box !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
}

.invoice-form-row input:focus,
.invoice-form-row textarea:focus {
    outline: none !important;
    border-color: #3b82f6 !important;
    background: rgba(30, 41, 59, 0.95) !important;
    box-shadow: 
        0 0 0 4px rgba(59, 130, 246, 0.15),
        0 8px 24px rgba(59, 130, 246, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
    transform: translateY(-2px) scale(1.02) !important;
}

.invoice-form-row input::placeholder,
.invoice-form-row textarea::placeholder {
    color: rgba(148, 163, 184, 0.7) !important;
    font-family: 'Peyda', Tahoma, Arial, sans-serif !important;
}

/* کانتینر دکمه‌ها */
.invoice-dialog-buttons {
    display: flex !important;
    gap: 16px !important;
    margin-top: 36px !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
}

/* استایل دکمه‌ها با گرادیانت و انیمیشن */
.invoice-dialog-content button {
    flex: 1 !important;
    min-width: 140px !important;
    padding: 16px 28px !important;
    border: none !important;
    border-radius: 16px !important;
    font-size: 16px !important;
    font-weight: 700 !important;
    font-family: 'Peyda', Tahoma, Arial, sans-serif !important;
    cursor: pointer !important;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
    position: relative !important;
    overflow: hidden !important;
    text-transform: none !important;
}

/* دکمه چاپ با گرادیانت سبز */
.print-button {
    background: linear-gradient(135deg, #10b981 0%, #059669 50%, #047857 100%) !important;
    color: white !important;
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.4) !important;
}

.print-button:hover {
    transform: translateY(-3px) scale(1.05) !important;
    box-shadow: 0 12px 32px rgba(16, 185, 129, 0.6) !important;
    background: linear-gradient(135deg, #059669 0%, #047857 50%, #065f46 100%) !important;
}

.print-button:active {
    transform: translateY(-1px) scale(1.02) !important;
}

/* دکمه دانلود با گرادیانت آبی */
.download-button {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 50%, #1d4ed8 100%) !important;
    color: white !important;
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.4) !important;
}

.download-button:hover {
    transform: translateY(-3px) scale(1.05) !important;
    box-shadow: 0 12px 32px rgba(59, 130, 246, 0.6) !important;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 50%, #1e40af 100%) !important;
}

.download-button:active {
    transform: translateY(-1px) scale(1.02) !important;
}

/* دکمه انصراف با گرادیانت خاکستری */
.cancel-button {
    background: linear-gradient(135deg, #64748b 0%, #475569 50%, #334155 100%) !important;
    color: white !important;
    box-shadow: 0 8px 24px rgba(100, 116, 139, 0.4) !important;
}

.cancel-button:hover {
    transform: translateY(-3px) scale(1.05) !important;
    box-shadow: 0 12px 32px rgba(100, 116, 139, 0.6) !important;
    background: linear-gradient(135deg, #475569 0%, #334155 50%, #1e293b 100%) !important;
}

.cancel-button:active {
    transform: translateY(-1px) scale(1.02) !important;
}

/* انیمیشن‌های زیبا */
@keyframes tmb-fadeInOverlay {
    from {
        opacity: 0;
        backdrop-filter: blur(0px);
        -webkit-backdrop-filter: blur(0px);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(15px);
        -webkit-backdrop-filter: blur(15px);
    }
}

@keyframes tmb-slideInScale {
    from {
        opacity: 0;
        transform: scale(0.85) translateY(30px) rotateX(15deg);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.02) translateY(-5px) rotateX(0deg);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0) rotateX(0deg);
    }
}

@keyframes tmb-shimmer {
    from {
        box-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
    }
    to {
        box-shadow: 0 0 30px rgba(139, 92, 246, 0.7);
    }
}

/* اسکرولبار سفارشی */
.invoice-dialog-content::-webkit-scrollbar {
    width: 8px;
}

.invoice-dialog-content::-webkit-scrollbar-track {
    background: rgba(51, 65, 85, 0.6);
    border-radius: 4px;
}

.invoice-dialog-content::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    border-radius: 4px;
    transition: background 0.3s ease;
}

.invoice-dialog-content::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #2563eb, #4f46e5);
}

/* ریسپانسیو برای موبایل */
@media (max-width: 768px) {
    .invoice-dialog-content {
        width: 95% !important;
        padding: 28px !important;
        margin: 16px !important;
        border-radius: 20px !important;
        max-height: 90vh !important;
    }
    
    .invoice-dialog-content h3 {
        font-size: 22px !important;
        margin-bottom: 24px !important;
    }
    
    .invoice-dialog-buttons {
        flex-direction: column !important;
        gap: 12px !important;
    }
    
    .invoice-dialog-content button {
        min-width: 100% !important;
        padding: 18px 24px !important;
    }
    
    .invoice-form-row input,
    .invoice-form-row textarea {
        padding: 14px 18px !important;
        font-size: 16px !important;
    }
}

@media (max-width: 480px) {
    .invoice-dialog-content {
        padding: 24px !important;
        border-radius: 16px !important;
    }
    
    .invoice-dialog-content h3 {
        font-size: 20px !important;
    }
}

/* =====================
   Light theme overrides
   ===================== */
/* Light overlay background */
.tmb-dialog-light.invoice-dialog-overlay {
    background: linear-gradient(135deg,
        rgba(255, 255, 255, 0.9),
        rgba(241, 245, 249, 0.9),
        rgba(226, 232, 240, 0.85)) !important;
    backdrop-filter: blur(10px) saturate(140%) !important;
    -webkit-backdrop-filter: blur(10px) saturate(140%) !important;
}

/* Light dialog container */
.tmb-dialog-light .invoice-dialog-content {
    background: #ffffff !important;
    color: #0f172a !important; /* slate-900 */
    border: 1px solid rgba(15, 23, 42, 0.08) !important;
    box-shadow:
        0 16px 40px -8px rgba(15, 23, 42, 0.15),
        0 0 0 1px rgba(15, 23, 42, 0.04) !important;
}

/* Light inputs */
.tmb-dialog-light .invoice-form-row label {
    color: #334155 !important; /* slate-700 */
    text-shadow: none !important;
}
.tmb-dialog-light .invoice-form-row input,
.tmb-dialog-light .invoice-form-row textarea {
    background: #ffffff !important;
    color: #0f172a !important;
    border: 1px solid #e2e8f0 !important; /* slate-200 */
}
.tmb-dialog-light .invoice-form-row input:focus,
.tmb-dialog-light .invoice-form-row textarea:focus {
    background: #ffffff !important;
    border-color: #3b82f6 !important; /* blue-500 */
    box-shadow:
        0 0 0 4px rgba(59, 130, 246, 0.15),
        0 6px 18px rgba(59, 130, 246, 0.15) !important;
}
.tmb-dialog-light .invoice-form-row input::placeholder,
.tmb-dialog-light .invoice-form-row textarea::placeholder {
    color: #94a3b8 !important; /* slate-400 */
}

/* Light scrollbars */
.tmb-dialog-light .invoice-dialog-content::-webkit-scrollbar-track {
    background: #f1f5f9 !important; /* slate-100 */
}
.tmb-dialog-light .invoice-dialog-content::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #94a3b8, #cbd5e1) !important; /* slate-400 -> slate-300 */
}
.tmb-dialog-light .invoice-dialog-content::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #7c8aa0, #b6c3d4) !important;
}

/* Enhanced loading animations for dark theme */
.tamambaha-factor-container.dark-theme-active .loading-dots {
    color: var(--btn-bg);
}

.tamambaha-factor-container.dark-theme-active .thinking-dots .dot-1,
.tamambaha-factor-container.dark-theme-active .thinking-dots .dot-2,
.tamambaha-factor-container.dark-theme-active .thinking-dots .dot-3 {
    background-color: var(--btn-bg);
}

/* استایل بخش پیش فاکتور در حالت تاریک */
.tamambaha-factor-container.dark-theme-active .pre-invoice-table th {
    color: #ffffff!important;
}

/* تغییر در بوردر سلول‌های جدول برای اصلاح خطوط عمودی */
.tamambaha-factor-container .pre-invoice-table th:first-child,
.tamambaha-factor-container .pre-invoice-table td:first-child {
    border-right: 1px solid var(--input-border);
}

.tamambaha-factor-container.dark-theme-active .pre-invoice-table th:first-child,
.tamambaha-factor-container.dark-theme-active .pre-invoice-table td:first-child {
    border-right: 1px solid var(--dark-border);
} 

/* Enhanced Mobile Responsiveness for Pre-Invoice */
@media screen and (max-width: 767px) {
    /* تنظیمات عمومی برای موبایل */
    .tamambaha-factor-container {
        font-size: 13px;
    }
    
    /* بهینه‌سازی هدر در موبایل */
    .tamambaha-factor-container .factor-header {
        padding: 8px 10px;
        height: auto;
        min-height: 46px;
    }

    /* بهینه‌سازی جدول پیش‌فاکتور در موبایل */
    .tamambaha-factor-container .pre-invoice-container {
        padding: 5px 8px;
        overflow-x: auto; /* امکان اسکرول افقی در صورت نیاز */
    }
    
    /* تغییر نمایش جدول در موبایل - ساختار کارت‌مانند */
    .tamambaha-factor-container .pre-invoice-table {
        display: block;
        width: 100%;
    }
    
    .tamambaha-factor-container .pre-invoice-table thead {
        display: none; /* پنهان کردن هدر جدول در موبایل */
    }
    
    .tamambaha-factor-container .pre-invoice-table tbody {
        display: block;
        width: 100%;
    }
    
    .tamambaha-factor-container .pre-invoice-table tr {
        display: block;
        width: 100%;
        margin-bottom: 12px;
        background-color: var(--container-bg);
        border-radius: 8px;
        box-shadow: 0 1px 4px rgba(0,0,0,0.1);
        padding: 8px;
        position: relative;
    }
    
    .tamambaha-factor-container.dark-theme-active .pre-invoice-table tr {
        background-color: var(--dark-bg-light);
        box-shadow: 0 1px 4px rgba(0,0,0,0.3);
    }
    
    .tamambaha-factor-container .pre-invoice-table td {
        display: flex;
        width: 100%;
        justify-content: space-between;
        align-items: center;
        padding: 6px 8px;
        text-align: right;
        border: none;
        border-bottom: 1px solid var(--input-border);
    }
    
    .tamambaha-factor-container.dark-theme-active .pre-invoice-table td {
        border-bottom: 1px solid var(--dark-border);
    }
    
    .tamambaha-factor-container .pre-invoice-table td:last-child {
        border-bottom: none;
    }
    
    /* اضافه کردن برچسب برای نمایش عنوان هر فیلد */
    .tamambaha-factor-container .pre-invoice-table td:before {
        content: attr(data-label);
        font-weight: bold;
        width: auto;
        min-width: 30%;
        max-width: 40%;
        margin-left: 10px;
        white-space: nowrap;
        overflow: visible;
        flex-shrink: 0;
    }
    
    /* تنظیم عرض ورودی‌ها در موبایل */
    .tamambaha-factor-container .pre-invoice-table input,
    .tamambaha-factor-container .pre-invoice-table select {
        width: 65%;
        padding: 6px 8px;
        font-size: 13px;
    }
    
    /* حذف استایل دکمه ارسال در موبایل */
    
    /* حالت خاص برای ردیف جمع کل */
    .tamambaha-factor-container .grand-total-row {
        background-color: var(--input-bg);
        padding: 10px;
        margin-top: 15px;
        border-radius: 8px;
    }
    
    .tamambaha-factor-container.dark-theme-active .grand-total-row {
        background-color: var(--cell-highlight);
    }
    
    .tamambaha-factor-container .grand-total-row td {
        justify-content: center;
        padding: 8px;
    }
    
    .tamambaha-factor-container .grand-total-label {
        font-size: 15px;
        font-weight: bold;
        text-align: center;
        padding: 0;
    }
    
    .tamambaha-factor-container .grand-total-value {
        font-size: 18px;
        text-align: center;
        font-weight: bold;
    }
    
    /* بهینه‌سازی آکاردئون محصولات در موبایل */
    .tamambaha-factor-container .product-accordion {
        margin-bottom: 0;
    }
    
    .tamambaha-factor-container .product-accordion-header {
        padding: 8px;
        font-size: 13px;
    }
    
    .tamambaha-factor-container .product-accordion-content {
        max-height: 200px;
    }
    
    .tamambaha-factor-container .product-item {
        padding: 8px;
        font-size: 13px;
    }
    
    /* بهبود خوانایی و کنتراست در موبایل */
    .tamambaha-factor-container.dark-theme-active .pre-invoice-table td:before {
        color: #ffffff;
    }
    
    /* استایل جدید برای نمایش جداگانه بخش محصول */
    .tamambaha-factor-container .product-section {
        display: block;
        width: 100%;
        margin-bottom: 5px;
    }
    
    /* استایل هاور زیباتر برای ردیف‌ها در موبایل */
    .tamambaha-factor-container .pre-invoice-table tr:active {
        transform: scale(0.98);
        transition: transform 0.2s ease;
    }
    
    /* دکمه اسکرول به بالا برای موبایل */
    .tamambaha-factor-container .scroll-to-top {
        position: fixed;
        bottom: 20px;
        right: 20px;
        width: 40px;
        height: 40px;
        background-color: var(--btn-bg);
        color: var(--btn-color);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 1010;
        box-shadow: 0 2px 5px rgba(0,0,0,0.2);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }
    
    .tamambaha-factor-container .scroll-to-top.visible {
        opacity: 1;
        visibility: visible;
    }
    
    .tamambaha-factor-container.dark-theme-active .scroll-to-top {
        background-color: var(--btn-bg);
        box-shadow: 0 2px 5px rgba(0,0,0,0.4);
    }
}

/* تنظیمات برای تبلت */
@media screen and (min-width: 768px) and (max-width: 1024px) {
    .tamambaha-factor-container .pre-invoice-table .pefp-inline {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 5px;
    }
    
    .tamambaha-factor-container .pre-invoice-table .pefp-inline-field select.pefp-inline-select {
        padding: 5px;
        font-size: 11px;
        min-height: 32px;
    }
    
    .tamambaha-factor-container .pre-invoice-table .pefp-inline-field .pefp-inline-label {
        font-size: 9px;
        margin-bottom: 2px;
    }
}

/* اصلاح حالت منظره فیلدهای عددی در موبایل */
@media screen and (max-width: 767px) {
    .tamambaha-factor-container .pre-invoice-table input[type="number"] {
        text-align: left;
        direction: ltr;
    }
}

/* اضافه کردن حالت نمایش افقی برای موبایل */
@media screen and (max-width: 767px) and (orientation: landscape) {
    .tamambaha-factor-container .factor-content-section.expanded {
        max-height: 85vh;
    }
    
    .tamambaha-factor-container .pre-invoice-container {
        max-height: calc(85vh - 50px);
    }
}

/* Touch-friendly and row selection styles for mobile */
@media screen and (max-width: 767px) {
    /* استایل برای هنگام انتخاب ردیف با دابل تپ */
    .tamambaha-factor-container .pre-invoice-table tr.row-selected {
        background-color: rgba(0, 0, 0, 0.05);
        transition: background-color 0.3s ease;
    }
    
    .tamambaha-factor-container.dark-theme-active .pre-invoice-table tr.row-selected {
        background-color: rgba(255, 255, 255, 0.1);
    }
    
    /* استایل برای آیتم‌های محصول هنگام لمس */
    .tamambaha-factor-container .product-item.touch-active {
        background-color: rgba(0, 0, 0, 0.05);
    }
    
    .tamambaha-factor-container.dark-theme-active .product-item.touch-active {
        background-color: rgba(255, 255, 255, 0.1);
    }
    
    /* افزایش فاصله بین ردیف‌ها برای لمس راحت‌تر */
    .tamambaha-factor-container .pre-invoice-table tr {
        margin-bottom: 15px;
    }
    
    /* افزایش سایز ناحیه قابل لمس برای دکمه‌ها */
    
    /* افزایش ارتفاع فیلدهای ورودی برای لمس راحت‌تر */
    .tamambaha-factor-container .pre-invoice-table input,
    .tamambaha-factor-container .pre-invoice-table select.brand-input {
        min-height: 38px;
    }
    
    /* اضافه کردن فضای کافی بین عناصر برای جلوگیری از لمس اشتباهی */
    .tamambaha-factor-container .product-accordion-header {
        padding: 10px 8px;
    }
    
    /* نمایش دکمه‌های اضافه و همزمان ویرایش برای موبایل */
    .tamambaha-factor-container .mobile-actions {
        display: flex;
        justify-content: space-around;
        margin-top: 10px;
        gap: 8px;
    }
    
    .tamambaha-factor-container .mobile-action-btn {
        padding: 8px 12px;
        background-color: var(--btn-bg);
        color: var(--btn-color);
        border: none;
        border-radius: 4px;
        font-family: 'Peyda', Tahoma, Arial, sans-serif;
        font-size: 13px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 5px;
        flex: 1;
    }
    
    .tamambaha-factor-container.dark-theme-active .mobile-action-btn {
        background-color: var(--dark-bg-light);
        border: 1px solid var(--dark-border);
    }
    
    /* بهبود استایل فوکوس فیلدها در موبایل */
    .tamambaha-factor-container .pre-invoice-table input:focus,
    .tamambaha-factor-container .pre-invoice-table select:focus {
        outline: none;
        border-color: var(--btn-bg);
        box-shadow: 0 0 0 2px rgba(58, 95, 173, 0.25);
    }
}

/* تنظیمات جدول پیش‌فاکتور با اسکرول افقی برای موبایل */
@media screen and (max-width: 767px) {
    /* اصلاحات استایل برای نمایش جدول با اسکرول افقی */
    .tamambaha-factor-container .pre-invoice-container {
        padding: 5px 8px;
        overflow: auto; /* امکان اسکرول به صورت افقی و عمودی */
        max-width: 100%;
        -webkit-overflow-scrolling: touch; /* اسکرول نرم برای iOS */
    }
    
    /* حفظ ساختار جدول در حالت موبایل */
    .tamambaha-factor-container .pre-invoice-table {
        min-width: 850px; /* عرض حداقلی برای جدول - افزایش یافته برای 8 ستون */
        width: 100%;
        table-layout: fixed;
        display: table;
        border-collapse: separate;
        border-spacing: 0;
    }
    
    .tamambaha-factor-container .pre-invoice-table thead {
        display: table-header-group;
    }
    
    .tamambaha-factor-container .pre-invoice-table tbody {
        display: table-row-group;
    }
    
    .tamambaha-factor-container .pre-invoice-table tr {
        display: table-row;
        margin-bottom: 0;
        background-color: transparent;
        box-shadow: none;
        padding: 0;
        position: relative;
    }
    
    .tamambaha-factor-container .pre-invoice-table th,
    .tamambaha-factor-container .pre-invoice-table td {
        display: table-cell;
        width: auto;
        justify-content: center;
        align-items: center;
        padding: 8px 4px;
        text-align: center;
        border-bottom: 1px solid var(--input-border);
        border-right: 1px solid var(--input-border);
        white-space: nowrap;
    }
    
    .tamambaha-factor-container.dark-theme-active .pre-invoice-table th,
    .tamambaha-factor-container.dark-theme-active .pre-invoice-table td {
        border-bottom: 1px solid var(--dark-border);
        border-right: 1px solid var(--dark-border);
    }
    
    .tamambaha-factor-container .pre-invoice-table th:last-child,
    .tamambaha-factor-container .pre-invoice-table td:last-child {
        border-right: none;
    }
    
    /* حذف برچسب سلول‌ها */
    .tamambaha-factor-container .pre-invoice-table td:before {
        content: none;
    }
    
    /* تنظیم مجدد عرض ورودی‌ها در جدول */
    .tamambaha-factor-container .pre-invoice-table input,
    .tamambaha-factor-container .pre-invoice-table select {
        width: 100%;
        padding: 4px 6px;
        font-size: 12px;
        min-height: 30px;
    }
    
    /* تنظیم عرض ستون‌ها در حالت موبایل */
    .tamambaha-factor-container .pre-invoice-table th:nth-child(1),
    .tamambaha-factor-container .pre-invoice-table td:nth-child(1) {
        width: 12%;
        min-width: 80px;
    }
    
    .tamambaha-factor-container .pre-invoice-table th:nth-child(2),
    .tamambaha-factor-container .pre-invoice-table td:nth-child(2) {
        width: 12%;
        min-width: 80px;
    }
    
    .tamambaha-factor-container .pre-invoice-table th:nth-child(3),
    .tamambaha-factor-container .pre-invoice-table td:nth-child(3) {
        width: 25%;
        min-width: 160px;
    }
    
    .tamambaha-factor-container .pre-invoice-table th:nth-child(4),
    .tamambaha-factor-container .pre-invoice-table td:nth-child(4) {
        width: 10%;
        min-width: 70px;
    }
    
    .tamambaha-factor-container .pre-invoice-table th:nth-child(5),
    .tamambaha-factor-container .pre-invoice-table td:nth-child(5) {
        width: 21%; /* کاهش کمی برای جا دادن ستون بازنشانی */
        min-width: 65px;
        overflow: visible !important; /* اجازه به محتوا برای خروج از باکس در موبایل */
        position: relative !important;
        z-index: 10 !important; /* اولویت بالاتر از ستون‌های بعدی */
    }
    
    /* تنظیمات خاص محاسبه قیمت برای موبایل */
    .tamambaha-factor-container .pre-invoice-table .pefp-inline {
        /* حفظ حالت flex برای اسکرول افقی */
        display: flex !important;
        gap: 8px !important;
        position: relative !important;
        z-index: 10 !important; /* اطمینان از قرار گرفتن روی عناصر دیگر */
    }
    
    .tamambaha-factor-container .pre-invoice-table .pefp-inline-scroll {
        /* بهبود اسکرول افقی برای موبایل */
        padding: 8px 4px;
        gap: 10px !important;
        scroll-padding: 10px;
        /* نمایش اسکرول‌بار در موبایل برای راهنمایی کاربر */
        scrollbar-width: thin;
        scrollbar-color: rgba(0, 0, 0, 0.3) transparent;
        position: relative !important;
        z-index: 11 !important; /* یک سطح بالاتر از container */
    }
    
    .tamambaha-factor-container .pre-invoice-table .pefp-inline-scroll::-webkit-scrollbar {
        height: 6px !important;
        display: block !important;
    }
    
    .tamambaha-factor-container .pre-invoice-table .pefp-inline-scroll::-webkit-scrollbar-track {
        background: rgba(0, 0, 0, 0.05);
        border-radius: 10px;
    }
    
    .tamambaha-factor-container .pre-invoice-table .pefp-inline-scroll::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.3);
        border-radius: 10px;
    }
    
    .tamambaha-factor-container.dark-theme-active .pre-invoice-table .pefp-inline-scroll::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.1);
    }
    
    .tamambaha-factor-container.dark-theme-active .pre-invoice-table .pefp-inline-scroll::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.4);
    }
    
    .tamambaha-factor-container .pre-invoice-table .pefp-inline-field {
        /* افزایش اندازه برای لمس راحت‌تر */
        min-width: 180px !important;
        flex-shrink: 0;
        position: relative !important;
        z-index: 12 !important; /* بالاتر از همه */
    }
    
    .tamambaha-factor-container .pre-invoice-table .pefp-inline-field select.pefp-inline-select {
        padding: 10px 8px !important; /* افزایش padding برای لمس راحت‌تر */
        font-size: 13px !important; /* فونت بزرگتر و خواناتر */
        min-height: 44px !important; /* ارتفاع استاندارد دکمه‌های موبایل */
        border-width: 1.5px !important;
        border-radius: 6px !important;
        -webkit-appearance: none;
        appearance: none;
        background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
        background-repeat: no-repeat;
        background-position: left 8px center;
        background-size: 16px;
        padding-left: 30px;
        position: relative !important;
        z-index: 13 !important; /* بالاترین سطح برای کلیک مستقیم */
    }
    
    .tamambaha-factor-container .pre-invoice-table .pefp-inline-field .pefp-inline-label {
        font-size: 11px !important; /* فونت برچسب بزرگتر و خواناتر */
        margin-bottom: 4px !important;
        font-weight: 600;
        color: var(--text-color);
        opacity: 0.9;
    }
    
    /* اضافه کردن gradient برای نمایش قابلیت اسکرول */
    .tamambaha-factor-container .pre-invoice-table .pefp-inline::after {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        width: 30px;
        background: linear-gradient(to left, transparent, rgba(255, 255, 255, 0.8));
        pointer-events: none;
        z-index: 14 !important; /* بالاتر از select فیلدها اما پایین‌تر از دکمه بازنشانی */
        transition: opacity 0.3s ease;
        max-width: calc(100% - 50px); /* جلوگیری از تداخل با ستون بازنشانی */
    }
    
    .tamambaha-factor-container.dark-theme-active .pre-invoice-table .pefp-inline::after {
        background: linear-gradient(to left, transparent, rgba(30, 30, 30, 0.8));
    }
    
    /* اضافه کردن نشانگر اسکرول سمت چپ */
    .tamambaha-factor-container .pre-invoice-table .pefp-inline::before {
        content: '◀';
        position: absolute;
        top: 50%;
        left: 5px;
        transform: translateY(-50%);
        font-size: 12px;
        color: var(--text-color);
        opacity: 0.5;
        pointer-events: none;
        z-index: 15 !important; /* بالاتر از gradient */
        animation: scrollHint 2s ease-in-out infinite;
    }
    
    @keyframes scrollHint {
        0%, 100% { 
            left: 5px;
            opacity: 0.5;
        }
        50% { 
            left: 10px;
            opacity: 0.8;
        }
    }
    
    /* حذف نشانگر بعد از اولین اسکرول */
    .tamambaha-factor-container .pre-invoice-table .pefp-inline.scrolled::before {
        display: none;
    }
    
    .tamambaha-factor-container .pre-invoice-table th:nth-child(6),
    .tamambaha-factor-container .pre-invoice-table td:nth-child(6) {
        width: 7%;
        min-width: 85px;
        position: relative !important;
        z-index: 1 !important; /* پایین‌تر از ستون ویژگی‌ها */
    }
    
    /* اطمینان از عدم تداخل input فیلدها با ویژگی‌های کالا */
    .tamambaha-factor-container .pre-invoice-table td:nth-child(6) input,
    .tamambaha-factor-container .pre-invoice-table td:nth-child(7) input,
    .tamambaha-factor-container .pre-invoice-table td:nth-child(8) input {
        position: relative !important;
        z-index: 2 !important; /* بالاتر از td اما پایین‌تر از ویژگی‌ها */
    }
    
    .tamambaha-factor-container .pre-invoice-table th:nth-child(7),
    .tamambaha-factor-container .pre-invoice-table td:nth-child(7) {
        width: 7%;
        min-width: 50px;
        position: relative !important;
        z-index: 1 !important; /* پایین‌تر از ستون ویژگی‌ها */
    }
    
    .tamambaha-factor-container .pre-invoice-table th:nth-child(8),
    .tamambaha-factor-container .pre-invoice-table td:nth-child(8) {
        width: 7%;
        min-width: 75px;
        position: relative !important;
        z-index: 1 !important; /* پایین‌تر از ستون ویژگی‌ها */
    }
    
    /* تنظیمات برای ستون جمع */
    .tamambaha-factor-container .pre-invoice-table th:nth-child(9),
    .tamambaha-factor-container .pre-invoice-table td:nth-child(9) {
        width: 7%;
        min-width: 70px;
        position: relative !important;
        z-index: 1 !important; /* پایین‌تر از ستون ویژگی‌ها */
    }
    
    /* تنظیمات برای ستون بازنشانی - بالاتر از همه */
    .tamambaha-factor-container .pre-invoice-table th:nth-child(10),
    .tamambaha-factor-container .pre-invoice-table td:nth-child(10) {
        position: relative !important;
        z-index: 20 !important; /* بالاتر از فیلدهای ویژگی‌ها */
        overflow: visible !important;
        width: 10% !important; /* افزایش عرض برای موبایل */
        min-width: 80px !important; /* افزایش حداقل عرض */
    }
    
    /* نمایش بهتر header ستون بازنشانی در موبایل */
    .tamambaha-factor-container .pre-invoice-table th:nth-child(10) {
        white-space: normal !important;
        line-height: 1.3;
        padding: 8px 4px !important;
    }
    
    .tamambaha-factor-container .pre-invoice-table th:nth-child(10) i {
        display: block;
        margin: 0 auto 3px auto;
        font-size: 16px;
    }
    
    /* اطمینان از کلیک‌پذیری دکمه بازنشانی */
    .tamambaha-factor-container .pre-invoice-table td:nth-child(10) button,
    .tamambaha-factor-container .pre-invoice-table td:nth-child(10) .row-reset-btn {
        position: relative !important;
        z-index: 21 !important;
        pointer-events: auto !important;
        touch-action: manipulation !important;
    }
    
    /* نمایش اسکرول‌بار افقی */
    .tamambaha-factor-container .pre-invoice-container::-webkit-scrollbar {
        height: 6px;
        width: 6px;
    }
}

/* تغییر رنگ فلش‌های رو به پایین در حالت شب */
.tamambaha-factor-container.dark-theme-active .product-accordion-header::after {
    filter: brightness(0) invert(1);
}

/* استایل برای دکمه ارسال */
.tamambaha-factor-container .row-send-btn {
    background-color: var(--btn-bg);
    color: var(--btn-color);
    border: none;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    display: none; /* پنهان کردن همه دکمه‌های ارسال به طور پیش‌فرض */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tamambaha-factor-container .row-send-btn.visible {
    display: flex; /* نمایش فقط دکمه با کلاس visible */
}

.tamambaha-factor-container .row-send-btn:hover {
    background-color: var(--btn-hover);
}

.tamambaha-factor-container.dark-theme-active .row-send-btn:hover {
    background-color: #ffffff; /* سفید برای هاور در حالت تاریک */
    color: #000000; /* تغییر رنگ متن به مشکی برای خوانایی بهتر روی پس‌زمینه سفید */
}

/* استایل برای حالت در حال بارگیری دکمه ارسال */
.tamambaha-factor-container .row-send-btn.loading {
    background-color: var(--btn-bg);
    color: var(--btn-color);
    animation: pulse 1.5s infinite;
    cursor: wait;
}

.tamambaha-factor-container.dark-theme-active .row-send-btn.loading {
    background-color: var(--btn-bg);
}

.tamambaha-factor-container .row-send-btn.loading:hover {
    background-color: var(--btn-bg);
    transform: none;
}

/* انیمیشن چرخش فلش‌های تکرار پس از اتمام بارگیری */
.tamambaha-factor-container .row-send-btn:not(.loading) .fa-arrows-rotate {
    transition: transform 0.3s ease;
}

.tamambaha-factor-container .row-send-btn:not(.loading):hover .fa-arrows-rotate {
    transform: rotate(180deg);
}

@keyframes pulse {
    0% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0.6;
    }
}

/* حذف دکمه اسکرول به بالا برای موبایل */
.tamambaha-factor-container .scroll-to-top {
    display: none !important; /* حذف کامل دکمه اسکرول به بالا */
}

.tamambaha-factor-container .scroll-to-top.visible {
    display: none !important;
}

.tamambaha-factor-container.dark-theme-active .scroll-to-top {
    display: none !important;
}

/* جلوگیری از تاثیر استایل‌های چت بات روی محتوای سایت */
.tamambaha-factor-container * {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    color: inherit !important;
}

/* دیگر استایل‌های چت بات نباید استایل‌های اصلی سایت را تحت تاثیر قرار دهند */
.tamambaha-factor-container .bot-message .message-content *:not(code):not(pre) {
    color: var(--message-bot-text) !important;
}

/* محدود کردن استایل‌های چت بات به داخل کانتینر - body styles removed to avoid overriding main site background */

/* مشخص کردن استایل‌های چت بات برای استفاده فقط داخل کانتینر */
.tamambaha-factor-container {
    font-family: 'Peyda', Tahoma, Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    direction: rtl;
    transition: background-color 0.3s ease, color 0.3s ease;
    /* Reset some body styles locally if needed, otherwise handled by scoping */
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    height: auto;
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 9999;
    pointer-events: none; /* اجازه کلیک روی سایت اصلی */
    width: 100%;
    font-size: 14px;
    opacity: 0; /* شروع با حالت مخفی */
    animation: fadeIn 0.3s ease 0.5s forwards; /* نمایش با تاخیر */
}

.tamambaha-factor-container .bot-message .message-content * {
    color: var(--message-bot-text) !important;
}

.tamambaha-factor-container .user-message .message-content * {
    color: var(--message-user-text) !important;
}

/* استایل‌های دیگر پلاگین */

/* استایل‌های جدید برای منوی کشویی انتخاب محصول در موبایل */
@media (max-width: 767px) {
    .desktop-only {
        display: none !important;
    }
    
    .product-select-dropdown {
        width: 100%;
        padding: 10px;
        border: 1px solid var(--input-border);
        border-radius: 4px;
        background-color: var(--input-bg);
        color: var(--text-color);
        font-family: inherit;
        font-size: 14px;
        direction: rtl;
        margin-bottom: 10px;
        margin-top: 5px;
        height: auto;
        appearance: auto;
        -webkit-appearance: auto;
        text-align: right;
    }
    
    .tamambaha-factor-container.dark-theme-active .product-select-dropdown {
        background-color: var(--dark-input-bg);
        color: var(--dark-text);
        border-color: var(--dark-border);
    }
    
    .product-select-dropdown option {
        padding: 10px;
        direction: rtl;
        text-align: right;
        background-color: var(--input-bg);
        color: var(--text-color);
    }
    
    .tamambaha-factor-container.dark-theme-active .product-select-dropdown option {
        background-color: var(--dark-input-bg);
        color: var(--dark-text);
    }
    
    .product-accordion-content {
        display: none !important;
    }
    
    /* اصلاح استایل برای کانتینر آکاردئون */
    .product-selection-container {
        position: relative;
    }
}

/* Professional Buttons Container */
.tamambaha-factor-container .buttons-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 25px 0;
    gap: 15px;
    flex-wrap: wrap;
}

/* Ensure white text for key action buttons in light mode as well */
.tamambaha-factor-container:not(.dark-theme-active) .add-product-btn,
.tamambaha-factor-container:not(.dark-theme-active) .add-product-btn span,
.tamambaha-factor-container:not(.dark-theme-active) .add-product-btn i,
.tamambaha-factor-container:not(.dark-theme-active) .add-product-btn.reset-all-btn,
.tamambaha-factor-container:not(.dark-theme-active) .add-product-btn.reset-all-btn span,
.tamambaha-factor-container:not(.dark-theme-active) .add-product-btn.reset-all-btn i,
.tamambaha-factor-container:not(.dark-theme-active) .print-invoice-button,
.tamambaha-factor-container:not(.dark-theme-active) .print-invoice-button span,
.tamambaha-factor-container:not(.dark-theme-active) .print-invoice-button i,
.tamambaha-factor-container:not(.dark-theme-active) .download-invoice-button,
.tamambaha-factor-container:not(.dark-theme-active) .download-invoice-button span,
.tamambaha-factor-container:not(.dark-theme-active) .download-invoice-button i,
.tamambaha-factor-container:not(.dark-theme-active) #open-chat-btn,
.tamambaha-factor-container:not(.dark-theme-active) #open-chat-btn span,
.tamambaha-factor-container:not(.dark-theme-active) #open-chat-btn i {
    color: #ffffff !important;
}

/* Professional Add Product Button */
.tamambaha-factor-container .add-product-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 28px;
    background: linear-gradient(135deg, #2196F3, #1976D2);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3), 0 2px 4px rgba(0, 0, 0, 0.1);
    font-family: 'Peyda', Tahoma, Arial, sans-serif;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
}

.tamambaha-factor-container .add-product-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.tamambaha-factor-container .add-product-btn:hover::before {
    left: 100%;
}

.tamambaha-factor-container .add-product-btn:hover {
    background: linear-gradient(135deg, #1976D2, #1565C0);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(33, 150, 243, 0.4), 0 4px 8px rgba(0, 0, 0, 0.15);
}

.tamambaha-factor-container .add-product-btn:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3), 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tamambaha-factor-container .add-product-btn i {
    font-size: 16px;
    transition: transform 0.3s ease;
}

.tamambaha-factor-container .add-product-btn:hover i {
    transform: rotate(90deg);
}

.tamambaha-factor-container .add-product-btn:disabled {
    background: linear-gradient(135deg, #9E9E9E, #757575);
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tamambaha-factor-container .add-product-btn:disabled::before {
    display: none;
}

/* Professional Print Button */
.tamambaha-factor-container .print-invoice-button {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 28px;
    background: linear-gradient(135deg, #4CAF50, #388E3C);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3), 0 2px 4px rgba(0, 0, 0, 0.1);
    font-family: 'Peyda', Tahoma, Arial, sans-serif;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
}

.tamambaha-factor-container .print-invoice-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.tamambaha-factor-container .print-invoice-button:hover::before {
    left: 100%;
}

.tamambaha-factor-container .print-invoice-button:hover {
    background: linear-gradient(135deg, #388E3C, #2E7D32);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4), 0 4px 8px rgba(0, 0, 0, 0.15);
}

.tamambaha-factor-container .print-invoice-button:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3), 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tamambaha-factor-container .print-invoice-button i {
    transition: transform 0.3s ease;
}

.tamambaha-factor-container .print-invoice-button:hover i {
    transform: scale(1.1);
}

/* Professional Download Button */
.tamambaha-factor-container .download-invoice-button {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 28px;
    background: linear-gradient(135deg, #FF9800, #F57C00);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.3), 0 2px 4px rgba(0, 0, 0, 0.1);
    font-family: 'Peyda', Tahoma, Arial, sans-serif;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
}

.tamambaha-factor-container .download-invoice-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.tamambaha-factor-container .download-invoice-button:hover::before {
    left: 100%;
}

.tamambaha-factor-container .download-invoice-button:hover {
    background: linear-gradient(135deg, #F57C00, #E65100);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(255, 152, 0, 0.4), 0 4px 8px rgba(0, 0, 0, 0.15);
}

.tamambaha-factor-container .download-invoice-button:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.3), 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tamambaha-factor-container .download-invoice-button i {
    transition: transform 0.3s ease;
}

.tamambaha-factor-container .download-invoice-button:hover i {
    transform: translateY(-2px);
}



/* Dark theme styling for add product button */
.tamambaha-factor-container.dark-theme-active .add-product-btn {
    background: linear-gradient(135deg, #1E88E5, #1565C0);
    box-shadow: 0 4px 12px rgba(30, 136, 229, 0.4), 0 2px 4px rgba(0, 0, 0, 0.2);
}

.tamambaha-factor-container.dark-theme-active .add-product-btn:hover {
    background: linear-gradient(135deg, #1565C0, #0D47A1);
    box-shadow: 0 6px 20px rgba(30, 136, 229, 0.5), 0 4px 8px rgba(0, 0, 0, 0.25);
}

.tamambaha-factor-container.dark-theme-active .add-product-btn:disabled {
    background: linear-gradient(135deg, #424242, #212121);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Dark theme styling for print button */
.tamambaha-factor-container.dark-theme-active .print-invoice-button {
    background: linear-gradient(135deg, #43A047, #2E7D32);
    box-shadow: 0 4px 12px rgba(67, 160, 71, 0.4), 0 2px 4px rgba(0, 0, 0, 0.2);
}

.tamambaha-factor-container.dark-theme-active .print-invoice-button:hover {
    background: linear-gradient(135deg, #2E7D32, #1B5E20);
    box-shadow: 0 6px 20px rgba(67, 160, 71, 0.5), 0 4px 8px rgba(0, 0, 0, 0.25);
}

/* Dark theme styling for download button */
.tamambaha-factor-container.dark-theme-active .download-invoice-button {
    background: linear-gradient(135deg, #FB8C00, #E65100);
    box-shadow: 0 4px 12px rgba(251, 140, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.2);
}

.tamambaha-factor-container.dark-theme-active .download-invoice-button:hover {
    background: linear-gradient(135deg, #E65100, #BF360C);
    box-shadow: 0 6px 20px rgba(251, 140, 0, 0.5), 0 4px 8px rgba(0, 0, 0, 0.25);
}



/* Mobile responsive styling for buttons */
@media (max-width: 767px) {
    .tamambaha-factor-container .buttons-container {
        flex-direction: column;
        margin: 30px 0;
        padding: 0 20px;
        gap: 20px;
    }
    
    .tamambaha-factor-container .add-product-btn,
    .tamambaha-factor-container .print-invoice-button,
    .tamambaha-factor-container .download-invoice-button {
        width: 100%;
        max-width: 280px;
        padding: 16px 24px;
        font-size: 16px;
        border-radius: 10px;
    }
    
    .tamambaha-factor-container .add-product-btn i,
    .tamambaha-factor-container .print-invoice-button i,
    .tamambaha-factor-container .download-invoice-button i {
        font-size: 18px;
    }
}

/* ================= Compatibility: prevent footer conflicts ================= */
/* Some themes use the class `fa` for non-FontAwesome text spans (e.g., footer). 
   Because this plugin loads FontAwesome, that text could inherit the icon font. 
   The following rules ensure footer texts remain unaffected. */
.site-footer .fa,
.site-footer-section .fa,
.site-footer-primary-section-4 .fa,
.footer-widget-area .fa,
footer .fa {
    font: inherit !important;
    font-family: inherit !important;
    font-weight: inherit !important;
    line-height: inherit !important;
}

/* Keep FontAwesome inside the plugin container working as expected */
.tamambaha-factor-container .fa,
.tamambaha-factor-container .fas,
.tamambaha-factor-container .far,
.tamambaha-factor-container .fab {
    font-family: "Font Awesome 6 Free", "Font Awesome 6 Brands", sans-serif;
}

/* Reset Row Button - Small red button in table cells */
.tamambaha-factor-container .reset-row-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	background: linear-gradient(135deg, #E53935, #C62828);
	color: white;
	border: none;
	border-radius: 8px;
	font-size: 14px;
	cursor: pointer;
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	box-shadow: 0 2px 6px rgba(229, 57, 53, 0.3);
	font-family: 'Peyda', Tahoma, Arial, sans-serif;
}

.tamambaha-factor-container .reset-row-btn:hover {
	background: linear-gradient(135deg, #C62828, #B71C1C);
	transform: scale(1.05);
	box-shadow: 0 4px 12px rgba(229, 57, 53, 0.4);
}

.tamambaha-factor-container .reset-row-btn:active {
	transform: scale(0.95);
	box-shadow: 0 2px 6px rgba(229, 57, 53, 0.3);
}

.tamambaha-factor-container .reset-row-btn i {
	transition: transform 0.3s ease;
}

.tamambaha-factor-container .reset-row-btn:hover i {
	transform: rotate(90deg);
}

/* Dark theme variant for reset row button */
.tamambaha-factor-container.dark-theme-active .reset-row-btn {
	background: linear-gradient(135deg, #D32F2F, #B71C1C);
	box-shadow: 0 2px 6px rgba(211, 47, 47, 0.4);
}

.tamambaha-factor-container.dark-theme-active .reset-row-btn:hover {
	background: linear-gradient(135deg, #B71C1C, #8E0000);
	box-shadow: 0 4px 12px rgba(211, 47, 47, 0.5);
}

/* Modifier: Reset All button uses same base layout as add-product-btn with danger color */
.tamambaha-factor-container .add-product-btn.reset-all-btn {
	background: linear-gradient(135deg, #E53935, #C62828);
	box-shadow: 0 4px 12px rgba(229, 57, 53, 0.3), 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tamambaha-factor-container .add-product-btn.reset-all-btn:hover {
	background: linear-gradient(135deg, #C62828, #B71C1C);
	transform: translateY(-3px);
	box-shadow: 0 6px 20px rgba(229, 57, 53, 0.4), 0 4px 8px rgba(0, 0, 0, 0.15);
}

.tamambaha-factor-container .add-product-btn.reset-all-btn:active {
	transform: translateY(-1px);
	box-shadow: 0 4px 12px rgba(229, 57, 53, 0.3), 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tamambaha-factor-container .add-product-btn.reset-all-btn i {
	font-size: 16px;
	transition: transform 0.3s ease;
}

.tamambaha-factor-container .add-product-btn.reset-all-btn:hover i {
	transform: rotate(-90deg);
}

/* Dark theme variant */
.tamambaha-factor-container.dark-theme-active .add-product-btn.reset-all-btn {
	background: linear-gradient(135deg, #D32F2F, #B71C1C);
	box-shadow: 0 4px 12px rgba(211, 47, 47, 0.4), 0 2px 4px rgba(0, 0, 0, 0.2);
}

.tamambaha-factor-container.dark-theme-active .add-product-btn.reset-all-btn:hover {
	background: linear-gradient(135deg, #B71C1C, #8E0000);
	box-shadow: 0 6px 20px rgba(211, 47, 47, 0.5), 0 4px 8px rgba(0, 0, 0, 0.25);
}

/* Mobile sizing inherits from add-product-btn responsive rule */

/* Mobile: add data-label for reset column when table becomes stacked */
@media (max-width: 767px) {
	/* مخفی کردن data-label برای ستون بازنشانی */
	.tamambaha-factor-container .pre-invoice-table td.reset-row-cell:before,
	.tamambaha-factor-container .pre-invoice-table td:nth-child(10):before {
		display: none !important;
	}

	/* Ensure reset cell layouts well on mobile stacked rows */
	.tamambaha-factor-container .pre-invoice-table td.reset-row-cell {
		justify-content: flex-end;
	}
	
	/* اطمینان از z-index و کلیک‌پذیری دکمه بازنشانی در موبایل */
	.tamambaha-factor-container .pre-invoice-table td:nth-child(10) button,
	.tamambaha-factor-container .pre-invoice-table td:nth-child(10) .row-reset-btn,
	.tamambaha-factor-container .pre-invoice-table .reset-row-cell button {
		position: relative !important;
		z-index: 25 !important;
		pointer-events: auto !important;
		touch-action: manipulation !important;
		-webkit-tap-highlight-color: rgba(255, 0, 0, 0.2);
	}
}

/* Notification System Animations */
@keyframes slideInRight {
	from {
		transform: translateX(100%);
		opacity: 0;
	}
	to {
		transform: translateX(0);
		opacity: 1;
	}
}

@keyframes slideOutRight {
	from {
		transform: translateX(0);
		opacity: 1;
	}
	to {
		transform: translateX(100%);
		opacity: 0;
	}
}

/* Notification styling */
.tamambaha-notification {
	font-size: 14px;
	font-weight: 500;
	direction: rtl;
	text-align: right;
}

.tamambaha-notification-success {
	background: linear-gradient(135deg, #4CAF50, #388E3C) !important;
}

.tamambaha-notification-error {
	background: linear-gradient(135deg, #F44336, #D32F2F) !important;
}

.tamambaha-notification-info {
	background: linear-gradient(135deg, #2196F3, #1976D2) !important;
}

