/* --- Base Popup Wrapper (Overlay) --- */
#mcp-custom-popup-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    /* تغییر: به جای flex-end از flex-start استفاده می‌کنیم که در حالت RTL به معنای راست است */
    justify-content: flex-start; 
    align-items: center;
    z-index: 10000;
    
    /* تغییر: اضافه کردن padding برای ایجاد حالت شناور */
    padding: 20px; 
    
    visibility: hidden;
    opacity: 0;
    transition: visibility 0.3s ease, opacity 0.3s ease;
}

/* --- حالت نمایش پاپ‌آپ --- */
#mcp-custom-popup-wrapper.is-visible {
    visibility: visible;
    opacity: 1;
}

/* --- پنجره اصلی محتوای چت --- */
.mcp-content {
    background: white;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.2); /* سایه بهتر */
    width: 420px;
    max-width: 100%; /* برای اینکه در padding جا شود */
    
    /* تغییر: ارتفاع را محدود می‌کنیم تا شناور به نظر برسد */
    height: calc(100vh - 40px); /* ارتفاع کامل صفحه منهای padding بالا و پایین */
    max-height: 700px; /* یک حداکثر ارتفاع منطقی */

    display: flex;
    flex-direction: column;
    
    /* تغییر: گوشه‌های گرد */
    border-radius: 16px; 
    overflow: hidden; /* برای اینکه محتوای داخلی از گوشه‌های گرد بیرون نزند */
    
    /* تغییر: انیمیشن سُر خوردن از راست (در حالت RTL از چپ می‌آید) */
    transform: translateX(-100%); /* منفی برای حرکت از چپ به راست در RTL */
    transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* وقتی پاپ‌آپ نمایش داده می‌شود، پنجره چت به جای خود برمی‌گردد */
#mcp-custom-popup-wrapper.is-visible .mcp-content {
    transform: translateX(0);
}

/* --- استایل‌های داخلی پنجره چت --- */
.mcp-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    border-bottom: 1px solid #eee;
    background-color: #f7f7f7;
    flex-shrink: 0;
}
.mcp-header h3 { margin: 0; font-size: 16px; }
#mcp-close-btn { background: none; border: none; font-size: 24px; cursor: pointer; line-height: 1; padding: 0 5px; }

.mcp-messages-area {
    flex-grow: 1;
    overflow-y: auto;
    padding: 15px;
    background-color: #fff;
}
.mcp-message { margin-bottom: 10px; padding: 8px 12px; border-radius: 18px; max-width: 80%; word-wrap: break-word; line-height: 1.4; }
/* تغییر: رنگ‌ها کمی ملایم‌تر شدند */
.mcp-message.sent { background-color: #0078FF; color: white; margin-left: auto; border-bottom-right-radius: 4px; }
.mcp-message.received { background-color: #E5E5EA; color: #050505; margin-right: auto; border-bottom-left-radius: 4px; }
.mcp-message p { margin: 0; }

.mcp-send-area { border-top: 1px solid #eee; padding: 10px 15px; background-color: #f7f7f7; flex-shrink: 0; }
.mcp-send-area form { display: flex; align-items: center; }
.mcp-send-area textarea { flex-grow: 1; border: 1px solid #ccc; border-radius: 18px; padding: 8px 12px; resize: none; height: 38px; }
.mcp-send-area button { margin-right: 10px; border: none; background: #0078FF; color: white; border-radius: 5px; cursor: pointer; padding: 8px 15px; font-weight: bold; }

/* --- استایل‌های مخصوص موبایل (واکنش‌گرا) --- */
@media (max-width: 767px) {
    #mcp-custom-popup-wrapper {
        padding: 0; /* حذف پدینگ برای حالت تمام صفحه موبایل */
        align-items: flex-end;
        justify-content: center;
    }

    .mcp-content {
        width: 100%;
        height: 100%; /* تمام صفحه */
        max-width: 100%;
        max-height: 100%;
        border-radius: 0; /* حذف گوشه‌های گرد در موبایل */
        box-shadow: none;
        
        transform: translateY(100%); 
    }
    
    #mcp-custom-popup-wrapper.is-visible .mcp-content {
        transform: translateY(0);
    }
}



/* --- Styles for Custom Alert Modal --- */
#mcp-alert-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10001; /* بالاتر از مودال چت */
    
    visibility: hidden;
    opacity: 0;
    transition: visibility 0.2s ease, opacity 0.2s ease;
}

#mcp-alert-modal.is-visible {
    visibility: visible;
    opacity: 1;
}

.mcp-alert-content {
    background: #fff;
    padding: 25px 30px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    text-align: center;
    max-width: 90%;
    width: 350px;
    
    /* انیمیشن بزرگ شدن */
    transform: scale(0.9);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1); /* افکت فنری */
}
#mcp-alert-modal.is-visible .mcp-alert-content {
    transform: scale(1);
}

.mcp-alert-message {
    font-size: 16px;
    line-height: 1.6;
    color: #333;
    margin: 0 0 20px 0;
}

.mcp-alert-close-btn {
    background-color: #0078FF;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 25px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}

.mcp-alert-close-btn:hover {
    background-color: #0056b3;
}


/* --- Multi-View Chat Styles --- */
.mcp-view {
    display: none; /* در حالت عادی همه نماها مخفی هستند */
    width: 100%;
    height: 100%;
    flex-direction: column;
}
.mcp-view.is-active {
    display: flex; /* نمای فعال نمایش داده می‌شود */
}

/* Style for Conversation List */
.mcp-conversations-list {
    flex-grow: 1;
    overflow-y: auto;
}
.mcp-conversation-item {
    display: flex;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background-color 0.2s;
}
.mcp-conversation-item:hover {
    background-color: #f9f9f9;
}
.mcp-conversation-item .ad-title {
    font-weight: bold;
    color: #333;
    font-size: 15px;
}
.mcp-conversation-item .last-message {
    color: #777;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Header modifications for messages view */
.mcp-back-to-list-btn {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    margin-left: 10px; /* In RTL, use margin-left */
    padding: 0 5px;
    color: #555;
}
.mcp-chat-title {
    flex-grow: 1;
    text-align: right; /* Ensure title is on the right */
}



/* --- Unread Messages Badge Styles --- */
.mcp-open-conversations-list {
    position: relative; /* برای جای‌گذاری صحیح نشانگر */
    display: inline-block;
}

.mcp-unread-badge {
    position: absolute;
    top: -5px;
    right: -10px; /* In RTL, use right */
    background-color: #ff3b30; /* رنگ قرمز روشن */
    color: white;
    font-size: 11px;
    font-weight: bold;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    line-height: 1;
    border: 2px solid #fff; /* برای جدا شدن از پس‌زمینه */
}



