/* ==========================================================================
   ۱. مچ کردن فونت‌ها با قالب اصلی سایت
   ========================================================================== */
.crm-ticket-header-wrapper,
.crm-floating-panel,
.crm-floating-panel input,
.crm-floating-panel select,
.crm-floating-panel textarea,
.crm-floating-panel button {
    font-family: inherit !important;
}

/* ==========================================================================
   ۲. المان شورت‌کد در هدر (عیناً هماهنگ با باکس خوش‌آمدم‌گویی لایت)
   ========================================================================== */
.crm-ticket-header-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    padding: 0 14px; /* ایجاد فضا برای چیدمان متن و آیکون کنار هم */
    background: #f0f2f1; /* بک‌گراند لایت مشابه عکس خوش‌آمدگویی */
    border: 1px solid #d5deda; /* بوردر ظریف مشابه عکس */
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.crm-ticket-header-wrapper:hover {
    background: #e4e8e6;
}

.crm-notification-trigger {
    display: flex;
    align-items: center;
    gap: 8px; /* ایجاد فاصله مناسب بین آیکون و متن تیکت‌ها */
}

.crm-notification-trigger .crm-icon {
    width: 20px !important;
    height: 20px !important;
    color: #173624 !important; /* رنگ سبز سازمانی شما برای آیکون */
}

/* استایل متن «تیکت‌ها» کنار زنگوله */
.crm-trigger-text {
    font-size: 13px;
    font-weight: 500;
    color: #173624; /* هماهنگ با رنگ متن باکس خوش‌آمدم‌گویی */
}

/* نشانگر قرمز تعداد اعلان‌های خوانده‌نشده */
.crm-notif-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff3366;
    color: #fff;
    font-size: 10px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(255, 51, 102, 0.3);
    z-index: 10;
}

/* ==========================================================================
   ۳. بدنه اصلی پنل بازشونده (کاملاً دارک بر پایه رنگ #173624)
   ========================================================================== */
.crm-floating-panel {
    position: absolute;
    top: 55px;
    left: 0;
    width: 360px;
    max-height: 500px;
    background: #11281b; /* نسخه تاریک‌تر از رنگ پایه برای حفظ عمق و کنتراست */
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    overflow: hidden;
    direction: rtl;
    color: #e2eae6; /* متون روشن برای خوانایی در پوسته تاریک */
}

.crm-floating-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* هدرهای بخش داخلی پنل (لیست تیکت و چت‌باکس) */
.crm-chat-header, .crm-list-header {
    background: #173624 !important; /* رنگ پایه اصلی شما */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: #ffffff !important;
}

/* لودینگ و متون راهنما */
.crm-panel-loading {
    padding: 30px;
    text-align: center;
    color: #a3b8ad;
    font-size: 13px;
}

/* اسکرول‌بار اختصاصی تم تاریک */
.crm-floating-panel ::-webkit-scrollbar { width: 5px; }
.crm-floating-panel ::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 4px; }

/* دکمه‌های داخل پنل تاریک */
.crm-btn {
    background: #173624;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.crm-btn:hover {
    background: #204931;
    border-color: rgba(255, 255, 255, 0.25);
}

/* فیلدهای ورودی تم تاریک (فرم ارسال و پاسخ) */
.crm-floating-panel input[type="text"],
.crm-floating-panel select,
.crm-floating-panel textarea {
    width: 100%;
    background: #11281b !important; /* رنگ پس‌زمینه باکس منوی کشویی و فیلدها */
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: #ffffff !important;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    outline: none;
}

.crm-floating-panel input[type="text"]:focus,
.crm-floating-panel select:focus,
.crm-floating-panel textarea:focus {
    border-color: #173624 !important;
    box-shadow: 0 0 0 2px rgba(23, 54, 36, 0.5);
}

/* حل باگ رنگ شیری و ناخوانای گزینه‌های منوی کشویی */
.crm-floating-panel select option {
    background: #11281b !important; /* رنگ پس‌زمینه گزینه‌ها در حالت باز شده */
    color: #ffffff !important;
}

/* کارت‌های تیکت در لیست صندوق ورودی */
.crm-ticket-card {
    background: rgba(255, 255, 255, 0.03) !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    border-radius: 10px !important;
    padding: 12px;
    margin-bottom: 8px;
    transition: background 0.2s;
}

.crm-ticket-card:hover {
    background: rgba(255, 255, 255, 0.06) !important;
}

/* باکس چت تیکت */
.crm-chat-box {
    background: rgba(0, 0, 0, 0.15) !important;
}

/* حباب پیام‌های درون چت‌باکس */
.crm-chat-message-row .crm-chat-bubble {
    max-width: 85%;
    padding: 8px 12px;
    font-size: 12px;
    line-height: 1.6;
}

/* پیام‌های ارسال شده توسط خود کاربر (سبز سازمانی شما) */
.crm-chat-container .crm-chat-message-row:has(.crm-chat-sender-name:contains("شما")) .crm-chat-bubble,
.crm-chat-bubble[style*="background: #0073aa"] { 
    background: #173624 !important; 
    color: #ffffff !important;
}

/* پیام‌های دریافتی از طرف مقابل (دارک ملایم) */
.crm-chat-container .crm-chat-message-row:not(has(.crm-chat-sender-name:contains("شما"))) .crm-chat-bubble,
.crm-chat-bubble[style*="background: rgba(255,255,255,0.1)"] {
    background: rgba(255, 255, 255, 0.08) !important;
    color: #e2eae6 !important;
}

/* متمایز کردن کارت‌های دارای پیام جدید در لیست */
.crm-ticket-card.crm-ticket-unread {
    border-color: rgba(0, 230, 118, 0.3) !important; /* بوردر سبز ملایم */
    background: rgba(23, 54, 36, 0.15) !important; /* بک‌گراند متمایل به رنگ سازمانی */
}

/* نقطه چشمک‌زن یا ثابت سبز رنگ برای تیکت‌های جدید */
.crm-unread-dot {
    width: 8px;
    height: 8px;
    background-color: #00e676; /* سبز جیغ نئونی */
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 8px #00e676;
    animation: crmPulse 1.5s infinite;
}

@keyframes crmPulse {
    0% { transform: scale(0.9); opacity: 0.6; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.6; }
}