#cm-app {
    display: flex;
    height: 80vh;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    font-family: system-ui, sans-serif;
    background: #fff;
	position: relative;
}

#cm-users {
    width: 260px;
    border-right: 1px solid #eee;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.cm-user {
    padding: 14px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cm-user.active {
    background: #e5f0ff;
    font-weight: bold;
}

#cm-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
}

#cm-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: #f4f6fb;
}

.cm-msg {
    margin-bottom: 10px;
    max-width: 70%;
    display: flex;
    align-items: center;
}

.cm-msg.me {
    margin-left: auto;
    text-align: right;
}

/* پیام‌های معمولی (دریافتی) */
.cm-msg .bubble {
    display: inline-block;
    padding: 10px 14px;
    border-radius: 16px;
    background: #ffffff;
}

/* پیام‌های ارسالی خود کاربر */
.cm-msg.me .bubble {
    background: #3b82f6;
    color: #fff;
}

/* =========================
   قسمت کادر ورود و ویرایش متن
========================= */
#cm-input {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    padding: 5px 7px;
    min-height: 50px;
    max-height: 150px;
    overflow-y: auto;
    border-top: 1px solid #ddd;
    background: #fff;
    position: relative;
    z-index: 5;
}

#cm-input textarea {
    flex: 1;
    padding: 12px;
    border: none;
    resize: none;
    outline: none;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    max-height: 130px;
    overflow-y: auto;
    background: transparent;
}

/* اسکرول بار برای textarea */
#cm-input textarea::-webkit-scrollbar {
    width: 6px;
}

#cm-input textarea::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

#cm-input textarea::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 10px;
}

#cm-input textarea::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* دکمه‌های کنار textarea */
#cm-input button {
    padding: 7px 10px;
    height: 50px;
    border: none;
    border-radius: 8px;
    background: #3b82f6;
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
}

#cm-attach {
    height: 50px;
    background: transparent;
    color: #333;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    padding: 7px 7px;
}

/* همه دکمه‌های attach-btn */
.attach-btn {
    width: 50px !important;    /* افزایش عرض */
    height: 50px !important;   /* افزایش ارتفاع */
	padding: 0 !important;           /* حذف padding پیش‌فرض */
    display: flex !important;         /* فعال کردن flexbox */
    align-items: center !important;   /* وسط‌چین عمودی */
    justify-content: center !important; /* وسط‌چین افقی */
}

.attach-btn img {
    width: 24px !important;    /* افزایش سایز آیکون */
    height: 24px !important;
	display: block;            /* جلوگیری از فضای اضافی */
    margin: 0;                 /* حذف حاشیه */
}

.cm-image {
    max-width: 220px;
    border-radius: 8px;
}

.cm-file {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 7px;
    border-radius: 8px;
    text-decoration: none;
    color: #333;
}

/* برای پیام‌های خودمون */
.cm-msg.me .cm-file {
    color: #fff;
    border-color: #1d4ed8;
}

.cm-status {
    font-size: 12px;
    opacity: .6;
    margin-top: 4px;
}

/* =========================
   لودینگ
========================= */
.cm-progress {
    width: 100%;
    height: 6px;
    background: #ddd;
    border-radius: 4px;
    margin-top: 6px;
    overflow: hidden;
}

.cm-bar {
    height: 100%;
    width: 0%;
    background: #3b82f6;
    transition: width 0.2s ease;
}

.cm-msg.uploading .bubble {
    background: #e5e7eb;
    color: #333;
}

/* =========================
   کنسل
========================= */
.cm-cancel {
    background: transparent;
    border: none;
    cursor: pointer;
    margin-left: 8px;
    padding: 0;
}

.cm-cancel img {
    display: block;
    opacity: 0.7;
}

.cm-cancel:hover img {
    opacity: 1;
}

/* =========================
   انتخاب و حذف
========================= */
#cm-toolbar {
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
    background: #fafafa;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    min-height: 50px;
}

/* دکمه برگشت به راست چسبیده */
#cm-back-to-users {
    margin-left: auto;
}

/* بقیه دکمه‌ها در چپ */
#cm-select-mode,
#cm-delete-selected,
#cm-forward-selected,
#cm-select-all {
    margin-right: 4px;
}

#cm-toolbar button {
    margin-right: 8px;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid #ddd;
    background: #fff;
    cursor: pointer;
}

.cm-select-box {
    display: none;
    margin-right: 6px;
}

.cm-msg.select-mode .cm-select-box {
    display: inline-block;
}

/* =========================
   نسخه موبایل بازگشت لیست کاربران
========================= */
@media (max-width: 768px) {
    #cm-toolbar {
        justify-content: flex-start;
    }
    
    #cm-back-to-users {
        margin-left: 0;
        order: 2;
    }
    
    #cm-select-mode {
        order: 1;
    }
}

/* =========================
   ویرایش
========================= */
.cm-edit-btn {
    margin-right: 6px;
    font-size: 12px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: #666;
}

.cm-edit-btn:hover {
    color: #000;
}

/* =========================
   Time
========================= */
.cm-time {
    font-size: 11px;
}

.cm-day-separator {
    text-align: center;
    margin: 18px 0;
    font-size: 13px;
    color: #666;
    opacity: 0.8;
    white-space: nowrap;
}

/* =========================
   Read Receipt (تیک‌ها)
========================= */


/* =========================
   Bubble Footer (زمان و تیک داخل پیام)
========================= */
.bubble-wrapper {
    position: relative;
    display: inline-block;
    max-width: 100%;
}

.bubble {
    position: relative;
    padding: 10px 14px;
    padding-bottom: 22px;  /* جا برای زمان و تیک */
    border-radius: 16px;
    background: #e0e0e0;
    word-wrap: break-word;
}

.cm-msg.me .bubble {
    background: #3b82f6;
    color: #fff;
}

.bubble-footer {
    position: absolute;
    bottom: 4px;
    right: 10px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    opacity: 0.8;
}

/* برای پیام‌های دیگران */
.cm-msg:not(.me) .bubble-footer {
    left: auto;
    right: 10px;
}

/* تنظیمات تیک‌ها */
.cm-msg.me .cm-time,
.cm-msg.me .cm-read {
    color: rgba(255, 255, 255, 0.9);
}

.cm-msg.me .cm-read.read {
    color: #a3e4ff;   /* آبی روشن برای دو تیک */
}

/* حذف استایل‌های اضافی */
.cm-time, .cm-read {
    background: none;
    border: none;
    margin: 0;
    padding: 0;
}


/* =========================
   Logout
========================= */
.cm-logout {
    margin-top: auto;
    padding: 12px;
    text-align: center;
    border-top: 1px solid #eee;
    background: #fafafa;
}

.cm-logout a {
    display: block;
    padding: 8px 12px;
    border-radius: 8px;
    background: #ef4444;
    color: #fff;
    text-decoration: none;
    font-size: 14px;
}

.cm-logout a:hover {
    background: #dc2626;
}

/* =========================
   Profile Page حساب کاربری
========================= */
.cm-profile {
    margin-top: auto;
    padding: 12px;
    text-align: center;
    border-top: 1px solid #eee;
    background: #fafafa;
}

.cm-profile a {
    display: block;
    padding: 8px 12px;
    border-radius: 8px;
    background: #3b82f6;
    color: #fff;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s ease;
}

.cm-profile a:hover {
    background: #2563eb;
}

#cm-profile-page {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #fff;
}

#cm-profile-header {
    padding: 15px;
    border-bottom: 1px solid #eee;
    background: #fafafa;
    display: flex;
    align-items: center;
    gap: 15px;
}

#cm-profile-back {
    background: transparent;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 8px 15px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
}

#cm-profile-back:hover {
    background: #e5e7eb;
}

#cm-profile-header h3 {
    margin: 0;
    font-size: 18px;
    color: #333;
}

#cm-profile-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.cm-profile-info {
    background: #f9fafb;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    border: 1px solid #e5e7eb;
}

.cm-profile-avatar img {
    border-radius: 50%;
    border: 3px solid #3b82f6;
}

.cm-profile-details p {
    margin: 8px 0;
    font-size: 14px;
    color: #4b5563;
}

.cm-profile-details strong {
    color: #1f2937;
    min-width: 80px;
    display: inline-block;
}

.cm-profile-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cm-profile-edit-btn,
.cm-profile-logout-btn {
    display: block;
    padding: 12px;
    border-radius: 10px;
    text-align: center;
    text-decoration: none;
    font-size: 16px;
    transition: all 0.2s ease;
}

.cm-profile-edit-btn {
    background: #3b82f6;
    color: white;
    border: 1px solid #2563eb;
}

.cm-profile-edit-btn:hover {
    background: #2563eb;
}

.cm-profile-logout-btn {
    background: #ef4444;
    color: white;
    border: 1px solid #dc2626;
}

.cm-profile-logout-btn:hover {
    background: #dc2626;
}

/* وقتی صفحه پروفایل فعاله، چت رو مخفی کن */
#cm-app.profile-active #cm-users {
    display: none;
}

#cm-app.profile-active #cm-chat {
    display: none;
}

#cm-app.profile-active #cm-profile-page {
    display: flex !important;
}

/* برای موبایل */
@media (max-width: 768px) {
    .cm-profile-info {
        flex-direction: column;
        text-align: center;
    }
    
    .cm-profile-details p {
        text-align: right;
    }
}

/* =========================
   Unread Counter
========================= */
.cm-unread-count {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 20px;
    background: #ef4444;
    color: #fff;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#cm-total-unread {
    margin: 10px 10px 5px 10px;
    padding: 8px 12px;
    background: #ef4444;
    color: white;
    border-radius: 20px;
    text-align: center;
    font-weight: bold;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
    animation: pulse 2s infinite;
}

#cm-total-unread span:first-child {
    margin-left: 5px;
}

#cm-total-count {
    background: white;
    color: #ef4444;
    padding: 2px 8px;
    border-radius: 50px;
    margin-right: 5px;
    font-size: 13px;
    font-weight: bold;
}

/* =========================
   Reply
========================= */
.cm-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* متای پیام (زمان و تیک) */
.cm-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 2px;
}

/* ریپلای همیشه بالای متن */
.cm-reply-ref {
    font-size: 12px;
    background: #eef2ff;
    padding: 6px 8px;
    border-right: 3px solid #6366f1;
    border-radius: 6px;
    margin-bottom: 4px;
    cursor: pointer;
    width: fit-content;
    max-width: 100%;
}

#cm-reply-preview {
    background: #f8fafc;
    padding: 8px 12px;
    border-top: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    direction: rtl;
}

.cm-reply-content {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    overflow: hidden;
}

.cm-reply-label {
    color: #3b82f6;
    font-weight: 600;
    font-size: 12px;
    background: #e0f2fe;
    padding: 2px 8px;
    border-radius: 12px;
    white-space: nowrap;
}

.cm-reply-text {
    color: #334155;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

#cm-cancel-reply {
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease;
}

#cm-cancel-reply:hover {
    background: #f1f5f9;
}

#cm-cancel-reply img {
    display: block;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

#cm-cancel-reply:hover img {
    opacity: 1;
}

.cm-highlight {
    animation: flashHighlight 1.5s ease;
}

@keyframes flashHighlight {
    0%   { background: #fff3cd; }
    100% { background: transparent; }
}

/* =========================
   Unread Messages Separator
========================= */
.cm-unread-separator {
    text-align: center;
    margin: 20px 0;
    position: relative;
}

.cm-unread-separator span {
    background: #ef4444;
    color: #fff;
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 20px;
    display: inline-block;
    z-index: 2;
    position: relative;
}

.cm-unread-separator::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: #ef4444;
    opacity: 0.3;
    z-index: 1;
}

/* هایلایت برای پیام‌های جدید */
.cm-msg.unread-highlight .bubble {
    animation: newMessageGlow 2s ease;
}

@keyframes newMessageGlow {
    0% { background-color: #fef3c7; }
    100% { background-color: inherit; }
}

/* =========================
   Forward Modal
========================= */
#cm-forward-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.cm-forward-box {
    background: #fff;
    width: 320px;
    max-height: 400px;
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.cm-forward-header {
    padding: 12px;
    font-weight: bold;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
}

.cm-forward-users {
    overflow-y: auto;
}

.cm-forward-user {
    padding: 12px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
}

.cm-forward-user:hover {
    background: #f3f4f6;
}

/* =========================
   Responsive Design برای موبایل
========================= */
@media (max-width: 768px) {
    
    #cm-app {
        height: 90vh;
        position: relative;
    }
    
    /* حالت عادی: فقط کاربران نمایش داده بشه */
    #cm-users {
        width: 100%;
        display: block;
    }
    
    #cm-chat {
        width: 100%;
        display: none;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: #fff;
        z-index: 10;
    }
    
    /* وقتی چت فعاله، کاربران رو مخفی کن */
    #cm-app.chat-active #cm-users {
        display: none;
    }
    
    #cm-app.chat-active #cm-chat {
        display: flex;
    }
    
    /* دکمه برگشت رو فقط در موبایل نشون بده */
    #cm-back-to-users {
        display: flex !important;
        align-items: center;
        gap: 8px;
        background: transparent !important;
        border: none !important;
        padding: 8px 12px !important;
        cursor: pointer;
        direction: ltr;
    }
    
    /* تنظیمات اینپوت */
    #cm-input {
        position: relative;
    }
    
    #cm-input textarea {
        padding-bottom: 50px;
        box-sizing: border-box;
    }

    .attach-btn { 
        display: inline-flex; 
    }

    .send-btn { 
        display: none;
        position: absolute;
        right: 7px;
        bottom: 7px;
        height: 36px;
        padding: 0 12px;
        border-radius: 8px;
    }
    
    .cm-user {
        padding: 14px;
    }
    
    /* کادر فوروارد */
    .cm-forward-box {
        width: 90%;
        max-width: 320px;
    }
}

/* ===== برای دسکتاپ، دکمه برگشت مخفی باشه ===== */
@media (min-width: 769px) {
    #cm-back-to-users {
        display: none !important;
    }
}
/* ========================================== */

/* حالت خیلی کوچیک (موبایل‌های کوچک) */
@media (max-width: 480px) {
    .cm-user {
        padding: 12px;
    }
    
    #cm-toolbar button {
        padding: 4px 8px;
        font-size: 13px;
    }
    
    .cm-msg {
        max-width: 85%;
    }
}

/* =========================
   Long Press & Select All
========================= */
/* هایلایت هنگام hover برای دسکتاپ */
.cm-msg {
    transition: background 0.2s ease;
}

/* استایل دکمه انتخاب همه */
#cm-select-all {
    background: #10b981 !important;
    color: #fff !important;
    border-color: #059669 !important;
}

#cm-select-all:hover {
    background: #059669 !important;
}

/* افکت لمس برای موبایل */
.cm-msg:active {
    background: rgba(0, 0, 0, 0.05);
    transition: background 0.1s ease;
}

/* راهنمای long press (اختیاری) */
.cm-msg .cm-longpress-hint {
    display: none;
    font-size: 10px;
    color: #666;
    margin-right: 5px;
}

@media (max-width: 768px) {
    .cm-msg .cm-longpress-hint {
        display: inline;
    }
}

/* =========================
   Voice Messages - Local
========================= */

#cm-voice-preview {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    padding: 15px 20px;
    border-radius: 50px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    z-index: 1000;
    border: 1px solid #ddd;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

.cm-voice-preview-box {
    display: flex;
    align-items: center;
    gap: 12px;
}

#cm-voice-timer {
    font-size: 20px;
    font-weight: bold;
    color: #333;
    min-width: 60px;
    text-align: center;
    font-family: monospace;
}

.voice-control img {
    width: 20px;
    height: 20px;
    display: block;
}

.voice-control {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: #3b82f6;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;  /* مهم: padding رو صفر کنید */
}

.voice-control:hover {
    background: #2563eb;
    transform: scale(1.05);
}

.voice-control:active {
    transform: scale(0.95);
}

/* دکمه ویس */
#cm-voice {
    background: transparent !important;
    transition: all 0.2s ease;
	opacity: 1; /* اضافه شد */
	width: 55px !important;        /* سایز آیکن ویس */
    height: 55px !important;       /* سایز آیکن ویس */
}

#cm-voice:hover {
    transform: scale(1.1);
}

#cm-voice img {
    width: 45px !important;		/* سایز آیکن ویس */
    height: 45px !important;		/* سایز آیکن ویس */
    transition: filter 0.2s ease;
}

#cm-voice:hover img {
    transform: scale(1.1);
}

/* استایل وقتی دکمه فعاله (فشار داده شده) */
#cm-voice:active {
    transform: scale(0.95);
}

#cm-voice:active img {
    transform: scale(0.9);
}

/* پیام صوتی در چت */
.cm-voice-message {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    padding: 6px 6px 6px 6px;
    border-radius: 30px;
    border: 1px solid #e5e7eb;
    min-width: 90px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.cm-msg.me .cm-voice-message {
    background: #3b82f6;
    border-color: #2563eb;
}

.cm-play-voice-msg {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #3b82f6;
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.cm-msg.me .cm-play-voice-msg {
    background: #fff;
    color: #3b82f6;
}

.cm-play-voice-msg:hover {
    transform: scale(1.1);
}

.cm-voice-wave {
    flex: 1;
    height: 36px;
    background: linear-gradient(90deg, #f3f4f6 0%, #e5e7eb 100%);
    border-radius: 18px;
    position: relative;
    overflow: hidden;
}

.cm-msg.me .cm-voice-wave {
    background: linear-gradient(90deg, #2563eb 0%, #3b82f6 100%);
}

.cm-voice-duration {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: #4b5563;
    font-family: monospace;
    background: rgba(255,255,255,0.9);
    padding: 2px 6px;
    border-radius: 12px;
}

.cm-msg.me .cm-voice-duration {
    color: #fff;
    background: rgba(0,0,0,0.2);
}

/* حالت در حال پخش */
.cm-voice-wave.playing {
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
    animation: wave 1s infinite;
}

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

/* ریسپانسیو */
@media (max-width: 768px) {
    #cm-voice-preview {
        width: 90%;
        bottom: 80px;
    }
    
    .cm-voice-preview-box {
        justify-content: center;
    }
    
    .voice-control {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .cm-voice-message {
        min-width: 90px;
    }
}

/* مخفی کردن مدت زمان ویس */
.cm-voice-duration {
    display: none !important;
}

/* =========================
   دکمه برگشت به لیست کاربران (پیش‌فرض مخفی)
========================= */
#cm-back-to-users {
    display: none;  /* پیش‌فرض مخفی */
    align-items: center;
    gap: 8px;
    background: transparent !important;
    border: none !important;
    padding: 8px 12px !important;
    cursor: pointer;
    direction: ltr;
}

/* استایل اجزای دکمه برگشت (همیشه اعمال بشه) */
#cm-back-username {
    font-weight: 500;
    font-size: 14px;
    color: #333;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    background: #f0f0f0;
    padding: 4px 10px;
    border-radius: 16px;
    border: 1px solid #ddd;
}

#cm-back-icon {
    font-size: 44px;
	padding: 2px 3px 5px 3px;
    font-weight: bold;
    color: #3b82f6;
    line-height: 1;
    transition: transform 0.2s ease;
    display: inline-block;
}

#cm-back-to-users:hover #cm-back-icon {
    transform: translateX(-3px);
}

#cm-back-to-users:active #cm-back-icon {
    transform: translateX(-5px);
    color: #2563eb;
}



/* =========================
   Welcome Screen
========================= */
#cm-welcome-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    height: 100%;
    width: 100%;
}

.welcome-content {
    text-align: center;
    max-width: 400px;
    padding: 40px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.05);
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.welcome-title {
    font-size: 24px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 12px;
}

.welcome-text {
    font-size: 16px;
    color: #64748b;
    margin-bottom: 30px;
    line-height: 1.6;
}

.welcome-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: #f1f5f9;
    border-radius: 50px;
    color: #334155;
    font-size: 14px;
    border: 1px dashed #94a3b8;
}

.welcome-hint span {
    font-size: 20px;
    animation: slideLeft 1s infinite;
}

@keyframes slideLeft {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(-5px); }
}

/* وقتی چت فعاله، صفحه خوش‌آمدگویی مخفی بشه */
#cm-app.chat-active #cm-welcome-screen {
    display: none !important;
}

#cm-app.chat-active #cm-messages {
    display: block !important;
}

/* حالت عادی - پیش‌فرض */
#cm-toolbar,
#cm-input {
    display: flex;  /* یا block بسته به نوع */
}

/* وقتی کاربر انتخاب نشده */
#cm-messages.hidden,
#cm-toolbar.hidden,
#cm-input.hidden {
    display: none;
}
/* =========================
   Welcome Screen End
========================= */

/* =========================
   برای کاربران/گروه‌ها
========================= */
/* استایل یکسان برای کاربران و گروه‌ها */
.cm-user,
.cm-group-item {
    padding: 14px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s ease;
}

.cm-user:hover,
.cm-group-item:hover {
    background: #f5f5f5;
}

.cm-user.active,
.cm-group-item.active {
    background: #e5f0ff;
    font-weight: bold;
}

.cm-user-name,
.cm-group-name {
    font-size: 14px;
    font-weight: 500;
}

.cm-group-members {
    font-size: 12px;
    color: #666;
    background: #e5e7eb;
    padding: 2px 8px;
    border-radius: 12px;
    white-space: nowrap;
}

.cm-group-name img {
    margin-left: 5px;
    vertical-align: middle;
    width: 18px;
    height: 18px;
}

/* =========================
   نام فرستنده در گروه
========================= */
.cm-sender-name {
    font-size: 12px;
    font-weight: 600;
    color: #4b5563;
    margin-bottom: 2px;
    margin-right: 4px;
}

.cm-msg.me .cm-sender-name {
    display: none; /* برای پیام‌های خودمون نام رو نشون نده */
}

/* تنظیم موقعیت نام نسبت به پیام */
.cm-msg:not(.me) .cm-content {
    align-items: flex-start;
}

/* اگه پیام ریپلای داره، نام بالاتر از ریپلای باشه */
.cm-msg:not(.me) .cm-sender-name + .cm-reply-ref {
    margin-top: 2px;
}
/* =========================
   Tabs پایان برای کاربران/گروه‌ها
========================= */


/* =========================
   دکمه پیمایش به پایین
========================= */
#cm-scroll-down {
    position: fixed;
    bottom: 35%;
	left: 200px;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: #3b82f6;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;			/* وسط‌چین عمودی */
    justify-content: center;		/* وسط‌چین افقی */
    cursor: pointer;
    z-index: 1000;
    transition: all 0.2s ease;
}

#cm-scroll-down:hover {
    background: #2563eb;
    transform: scale(1.1);
}

#cm-scroll-down img {
    width: 24px;
    height: 24px;
    filter: brightness(0) invert(1);
}

#cm-scroll-down img,
#cm-scroll-down span {
    display: block;
    width: 24px;
    height: 24px;
    object-fit: contain;  /* برای حفظ تناسب تصویر */
}

/* برای موبایل */
@media (max-width: 768px) {
    #cm-scroll-down {
        bottom: 90px;
        left: 15px;
        width: 40px;
        height: 40px;
    }
    

	#cm-scroll-down img {
        width: 20px;
        height: 20px;
    }
}

/* =========================
   پایان دکمه پیمایش به پایین
========================= */

/* =========================
   Online Status
========================= */
.cm-user-name {
    display: flex;
    align-items: center;
    gap: 6px;
}

.cm-online-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #22c55e;  /* سبز */
    box-shadow: 0 0 0 2px #fff;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}
/* =========================
   Online Status End
========================= */

/* =========================
   Search Bar
========================= */
#cm-search-bar {
    background: #f8fafc;
    padding: 8px 12px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 10px;
    direction: rtl;
}

#cm-search-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

#cm-search-input:focus {
    border-color: #3b82f6;
}

.cm-search-controls {
    display: flex;
    align-items: center;
    gap: 5px;
    background: white;
    padding: 3px;
    border-radius: 20px;
    border: 1px solid #cbd5e1;
}

#cm-search-results {
    padding: 0 10px;
    font-size: 13px;
    color: #64748b;
    min-width: 70px;
    text-align: center;
}

#cm-search-prev,
#cm-search-next,
#cm-search-close {
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

#cm-search-prev:hover,
#cm-search-next:hover {
    background: #e2e8f0;
}

#cm-search-close:hover {
    background: #fee2e2;
    color: #ef4444;
}

/* هایلایت کردن متن پیدا شده */
.cm-search-highlight {
    background-color: #fef9c3;
    border-radius: 4px;
    padding: 2px 0;
    animation: pulse-highlight 1s ease;
}

.cm-search-highlight.active {
    background-color: #fcd34d;
    box-shadow: 0 0 0 2px #fbbf24;
}

@keyframes pulse-highlight {
    0% { background-color: #fef9c3; }
    50% { background-color: #fcd34d; }
    100% { background-color: #fef9c3; }
}

/* =========================
   Icon Buttons
========================= */
.icon-btn {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    width: 36px;
    height: 36px;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 6px !important;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: rgba(0,0,0,0.05) !important;
}

.icon-btn img {
    width: 18px;
    height: 18px;
    display: block;
}
/* =========================
   Search Bar End
========================= */

/* =========================
   Search Bar - Responsive
========================= */
@media (max-width: 768px) {
    #cm-search-bar {
        flex-wrap: wrap;
        padding: 8px;
        gap: 8px;
    }
    
    #cm-search-input {
        width: 100%;
        font-size: 16px; /* جلوگیری از زوم خودکار در iOS */
        padding: 10px 12px;
    }
    
    .cm-search-controls {
        width: 100%;
        justify-content: space-between;
        background: transparent;
        border: none;
        padding: 0;
    }
    
    #cm-search-results {
        background: #f1f5f9;
        border-radius: 20px;
        padding: 6px 15px;
        font-size: 14px;
        flex: 1;
        text-align: center;
    }
    
    #cm-search-prev,
    #cm-search-next,
    #cm-search-close {
        width: 44px;  /* بزرگتر برای لمس آسون‌تر */
        height: 44px;
        background: white;
        border: 1px solid #e2e8f0;
        box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    }
    
    #cm-search-prev:active,
    #cm-search-next:active,
    #cm-search-close:active {
        background: #e2e8f0;
        transform: scale(0.95);
    }
    
    /* دکمه جستجو در نوار ابزار */
    #cm-search-btn {
        width: 44px;
        height: 44px;
    }
    
    #cm-search-btn img {
        width: 22px;
        height: 22px;
    }
}

/* برای موبایل‌های خیلی کوچک */
@media (max-width: 480px) {
    .cm-search-controls {
        gap: 5px;
    }
    
    #cm-search-results {
        font-size: 13px;
        padding: 6px 10px;
    }
    
    #cm-search-prev,
    #cm-search-next,
    #cm-search-close {
        width: 40px;
        height: 40px;
    }
}
/* =========================
   Search Bar - Responsive End
========================= */

/* =========================
   لینک‌های داخل چت
========================= */
.cm-link {
    color: #3b82f6;
    text-decoration: none;
    border-bottom: 1px dashed #3b82f6;
    word-break: break-all;
}

.cm-link:hover {
    color: #2563eb;
    border-bottom: 1px solid #2563eb;
}

/* لینک در پیام‌های خودمون */
.cm-msg.me .cm-link {
    color: #fff;
    border-bottom: 1px dashed rgba(255,255,255,0.5);
}

.cm-msg.me .cm-link:hover {
    color: #fff;
    border-bottom: 1px solid #fff;
}
/* =========================
   لینک‌های داخل چت پایان
========================= */



/* =========================
   Message Buttons Container
========================= */
.cm-message-buttons {
    display: flex;
    gap: 5px;
    margin-top: 5px;
    justify-content: flex-end;
    opacity: 0;  /* در حالت عادی مخفی */
    transition: opacity 0.2s ease;
}

/* فقط در حالت انتخاب نمایش بده */
.cm-msg.select-mode .cm-message-buttons {
    opacity: 1;
}

.cm-copy-btn,
.cm-reply-btn,
.cm-edit-btn,
.cm-download-btn {
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 15px;
    padding: 3px 10px;
    font-size: 12px;
    cursor: pointer;
    color: #333;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.cm-download-btn img {
    width: 14px;
    height: 14px;
    display: block;
}

.cm-copy-btn:hover,
.cm-reply-btn:hover,
.cm-edit-btn:hover,
.cm-download-btn:hover {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.cm-download-btn:hover img {
    filter: brightness(0) invert(1);
}

/* برای موبایل */
@media (max-width: 768px) {
    .cm-message-buttons {
        /*opacity: 1;  /* در موبایل همیشه قابل مشاهده */
        margin-top: 8px;
    }
    
    .cm-copy-btn,
    .cm-reply-btn,
    .cm-edit-btn,
    .cm-download-btn {
        padding: 5px 12px;
        font-size: 14px;
    }
    
	.cm-download-btn img {
    width: 16px;
    height: 16px;
    display: block;
	}

}
/* =========================
   Message Buttons Container End
========================= */

/* =========================
   Group Unread Count
========================= */
.cm-group-unread-count {
    background: #ef4444;
    color: white;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: bold;
    min-width: 20px;
    text-align: center;
    animation: pulse 2s infinite;
}

.cm-group-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cm-group-item > div {
    display: flex;
    align-items: center;
    gap: 8px;
}
/* =========================
   Group Unread Count End
========================= */

/* =========================
   Password Change Form
========================= */
.cm-password-change {
    background: #f9fafb;
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0;
    border: 1px solid #e5e7eb;
}

.cm-password-change h4 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #1f2937;
    font-size: 16px;
}

.cm-form-group {
    margin-bottom: 15px;
}

.cm-form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    color: #4b5563;
    font-weight: 500;
}

.cm-form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.cm-form-group input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59,130,246,0.1);
}

#cm-change-password-btn {
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    width: 100%;
    transition: background 0.2s;
}

#cm-change-password-btn:hover {
    background: #2563eb;
}

#cm-password-loading {
    text-align: center;
    padding: 12px;
    color: #6b7280;
    font-size: 14px;
}

#cm-password-message {
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 13px;
}

/* برای موبایل */
@media (max-width: 768px) {
    .cm-password-change {
        padding: 15px;
    }
    
    .cm-form-group input {
        padding: 12px;
        font-size: 16px; /* جلوگیری از زوم در iOS */
    }
}
/* =========================
   Password Change Form End
========================= */

/* فقط برای موبایل - شمارنده پیام‌های جدید */
@media (max-width: 768px) {
    .cm-unread-count,
    .cm-group-unread-count {
        min-width: 22px;
        height: 22px;
        padding: 0 6px;
        border-radius: 20px;
        background: #ef4444;
        color: #fff !important;
        font-size: 12px;
        font-weight: bold;
        align-items: center;
        justify-content: center;
        margin-right: 8px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    }
    
    /* اگه عدد صفر یا خالی باشه، مخفی بشه */
    .cm-unread-count:empty,
    .cm-group-unread-count:empty {
        display: none !important;
    }
    
    /* اگه عدد صفر باشه، مخفی بشه */
    .cm-unread-count[data-count="0"],
    .cm-group-unread-count[data-count="0"] {
        display: none !important;
    }
}