/* ===== صفحه گفتگو (پیشوند cx-) — بعد از ux-ui.css لود شود ===== */

.cx-chat { padding: 8px; display: flex; flex-direction: column; gap: 12px; }
.cx-chat * { text-align: inherit; }
.cx-chat .ux-hero { padding-bottom: 18px; }

/* چیپ‌های پروژه (مدیر/پشتیبان) */
.cx-groups { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; background: white; border-radius: 16px; padding: 8px 10px; border: 1px solid #eef0f4; box-shadow: 0 2px 12px rgba(17,24,39,.05); }
.cx-groups-lbl { color: #7a7f9a !important; font-size: .8rem; font-weight: 700; margin-left: 4px; }
.cx-chip { border: 1.5px solid #e2e8f0; background: white; color: #475569 !important; border-radius: 999px; padding: 5px 14px; font: inherit; font-size: .82rem; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: .15s; }
.cx-chip:hover { border-color: #93c5fd; background: #eff6ff; }
.cx-chip.on { background: linear-gradient(135deg, #1e3a8a, #3b82f6); border-color: transparent; color: white !important; box-shadow: 0 4px 12px rgba(59,130,246,.3); }
.cx-chip.on svg { fill: white !important; }

/* چیدمان دو ستونه */
.cx-wrap { display: grid; grid-template-columns: 310px minmax(0, 1fr); gap: 12px; height: calc(100vh - 250px); min-height: 460px; }
.cx-wrap.cx-has-groups { height: calc(100vh - 300px); }

/* ===== ستون افراد ===== */
.cx-side { background: white; border-radius: 18px; border: 1px solid #eef0f4; box-shadow: 0 2px 12px rgba(17,24,39,.06); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.cx-side-head { padding: 12px 12px 8px; display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid #f1f3f8; }
.cx-side-title { color: #1f2340 !important; font-weight: 800; font-size: .95rem; display: flex; align-items: center; gap: 6px; }
.cx-side-title .cx-n { background: #dbeafe; color: #1e3a8a !important; border-radius: 999px; padding: 0 8px; font-size: .72rem; }
.cx-types { display: flex; gap: 4px; background: #f1f5f9; border-radius: 12px; padding: 4px; }
.cx-type { flex: 1; border: 0; background: transparent; padding: 6px 4px; border-radius: 9px; font: inherit; font-weight: 700; font-size: .8rem; color: #64748b !important; cursor: pointer; text-align: center !important; }
.cx-type.on { background: white; color: #1d4ed8 !important; box-shadow: 0 2px 8px rgba(37,99,235,.15); }
.cx-search { display: flex; align-items: center; gap: 6px; background: #f8fafc; border: 1.5px solid #e2e8f0; border-radius: 12px; padding: 2px 10px; }
.cx-search:focus-within { border-color: #93c5fd; background: white; box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
.cx-search svg { fill: #94a3b8 !important; width: 18px; height: 18px; flex-shrink: 0; }
.cx-search input { border: 0 !important; outline: none; background: transparent; flex: 1; padding: 7px 0; min-width: 0; color: #1f2340 !important; font: inherit; font-size: .85rem; }

.cx-people { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; min-height: 0; }
.cx-people::-webkit-scrollbar, .cx-scroll::-webkit-scrollbar { width: 6px; }
.cx-people::-webkit-scrollbar-thumb, .cx-scroll::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 6px; }
.cx-person { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 14px; text-decoration: none !important; transition: .15s; margin-bottom: 2px; position: relative; }
.cx-person:hover { background: #f1f5f9; }
.cx-person.on { background: linear-gradient(135deg, #1e3a8a, #3b82f6); box-shadow: 0 6px 16px rgba(37,99,235,.28); }
.cx-av { width: 44px; height: 44px; border-radius: 50%; background: #e2e8f0 center/cover no-repeat; flex-shrink: 0; border: 2px solid white; box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.cx-person-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cx-person-user { color: #1f2340 !important; font-weight: 800; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cx-person-name { color: #7a7f9a !important; font-size: .76rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cx-person-pro { color: #2563eb !important; font-size: .7rem; font-weight: 700; }
.cx-person.on .cx-person-user, .cx-person.on .cx-person-name, .cx-person.on .cx-person-pro { color: white !important; }
.cx-badge { background: #ef4444; color: white !important; border-radius: 999px; min-width: 22px; height: 22px; padding: 0 6px; font-size: .72rem; font-weight: 800; display: grid; place-items: center; flex-shrink: 0; box-shadow: 0 2px 6px rgba(239,68,68,.35); }
.cx-person.on .cx-badge { background: white; color: #1d4ed8 !important; }
.cx-side-empty { color: #94a3b8 !important; text-align: center !important; padding: 30px 10px; font-size: .85rem; }

/* ===== ستون گفتگو ===== */
.cx-main { background: white; border-radius: 18px; border: 1px solid #eef0f4; box-shadow: 0 2px 12px rgba(17,24,39,.06); display: flex; flex-direction: column; min-height: 0; overflow: hidden; position: relative; }
.cx-chat.cx-full .cx-main { position: fixed; inset: 10px; z-index: 1300; height: auto; }
.cx-main-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid #f1f3f8; background: #fbfcfe; }
.cx-main-head .cx-av { width: 40px; height: 40px; }
.cx-main-who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cx-main-user { color: #1f2340 !important; font-weight: 800; font-size: .95rem; }
.cx-main-name { color: #7a7f9a !important; font-size: .76rem; }
.cx-icon-btn { border: 0; background: #f1f5f9; width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; cursor: pointer; transition: .15s; flex-shrink: 0; padding: 0; }
.cx-icon-btn:hover { background: #dbeafe; }
.cx-icon-btn svg { fill: #475569 !important; width: 20px; height: 20px; }
.cx-back { display: none !important; }

.cx-loading { position: absolute; top: 0; right: 0; left: 0; height: 3px; overflow: hidden; z-index: 5; }
.cx-loading::after { content: ""; position: absolute; top: 0; bottom: 0; width: 35%; background: linear-gradient(90deg, transparent, #3b82f6, transparent); animation: cxLoad 1s linear infinite; }
@keyframes cxLoad { from { right: -35%; } to { right: 100%; } }

.cx-scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-anchor: none; padding: 10px 16px 16px; background: #f6f8fc; background-image: radial-gradient(rgba(59,130,246,.07) 1px, transparent 1px); background-size: 18px 18px; }
.cx-more { text-align: center !important; color: #94a3b8 !important; font-size: .75rem; padding: 6px; }

.cx-date { display: flex; justify-content: center; margin: 14px 0 8px; position: sticky; top: 0; z-index: 2; }
.cx-date span { background: rgba(30,58,138,.85); color: white !important; font-size: .72rem; font-weight: 700; padding: 3px 12px; border-radius: 999px; box-shadow: 0 2px 6px rgba(0,0,0,.12); }

.cx-row { display: flex; align-items: flex-end; gap: 8px; margin-top: 3px; position: relative; }
.cx-row.cx-first { margin-top: 12px; }
.cx-row.cx-mine { flex-direction: row; }        /* راست (RTL) */
.cx-row.cx-their { flex-direction: row-reverse; } /* چپ */
.cx-row .cx-av { width: 34px; height: 34px; border-width: 2px; }
.cx-av-gap { width: 34px; flex-shrink: 0; }

.cx-bubble { max-width: min(72%, 560px); padding: 8px 12px 5px; border-radius: 16px; position: relative; box-shadow: 0 1px 2px rgba(15,23,42,.08); word-wrap: break-word; overflow-wrap: anywhere; }
.cx-mine .cx-bubble { background: linear-gradient(135deg, #2563eb, #3b82f6); border-top-right-radius: 6px; }
.cx-their .cx-bubble { background: white; border: 1px solid #e5e7eb; border-top-left-radius: 6px; }
.cx-bubble.cx-media { padding: 5px; }
.cx-text { font-size: .9rem; line-height: 1.75; }
.cx-mine .cx-text, .cx-mine .cx-text * { color: white !important; }
.cx-their .cx-text, .cx-their .cx-text * { color: #1f2937 !important; }
.cx-text img.showEmj { width: 1.3em; vertical-align: middle; }
.cx-text img.showEmjB { width: 3em; }

.cx-meta { display: flex; align-items: center; gap: 4px; justify-content: flex-end; margin-top: 2px; font-size: .68rem; direction: ltr; }
.cx-mine .cx-meta, .cx-mine .cx-meta span { color: rgba(255,255,255,.8) !important; }
.cx-their .cx-meta, .cx-their .cx-meta span { color: #94a3b8 !important; }
.cx-meta svg { width: 14px; height: 14px; }
.cx-mine .cx-meta svg { fill: rgba(255,255,255,.85) !important; }
.cx-their .cx-meta svg { fill: #94a3b8 !important; }
.cx-media .cx-meta { padding: 0 6px 2px; }

.cx-img { display: block; max-width: 100%; width: 280px; max-height: 320px; object-fit: cover; border-radius: 12px; cursor: zoom-in; background: #e2e8f0; }
.cx-file { display: flex; align-items: center; gap: 8px; text-decoration: none !important; padding: 6px 8px; border-radius: 12px; min-width: 180px; }
.cx-mine .cx-file { background: rgba(255,255,255,.16); }
.cx-their .cx-file { background: #f1f5f9; }
.cx-file-ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.cx-mine .cx-file-ico { background: rgba(255,255,255,.25); }
.cx-their .cx-file-ico { background: #dbeafe; }
.cx-file-ico svg { width: 20px; height: 20px; }
.cx-mine .cx-file-ico svg { fill: white !important; }
.cx-their .cx-file-ico svg { fill: #1d4ed8 !important; }
.cx-file-name { font-size: .8rem; font-weight: 700; direction: ltr; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.cx-mine .cx-file-name { color: white !important; }
.cx-their .cx-file-name { color: #1f2937 !important; }
.cx-kala { display: inline-block; background: #0ea5e9; color: white !important; border-radius: 10px; padding: 6px 12px; font-size: .82rem; font-weight: 700; text-decoration: none !important; line-height: 1.6; }

.cx-reply-in { display: block; border-right: 3px solid; padding: 3px 8px; border-radius: 8px; margin-bottom: 4px; font-size: .78rem; max-height: 3.2em; overflow: hidden; text-decoration: none !important; }
.cx-mine .cx-reply-in { background: rgba(255,255,255,.16); border-color: white; }
.cx-mine .cx-reply-in, .cx-mine .cx-reply-in * { color: rgba(255,255,255,.92) !important; }
.cx-their .cx-reply-in { background: #eff6ff; border-color: #3b82f6; }
.cx-their .cx-reply-in, .cx-their .cx-reply-in * { color: #334155 !important; }
.cx-reply-in img { width: 2.4em; height: 2.4em; object-fit: cover; border-radius: 6px; vertical-align: middle; }
.cx-reply-in svg { width: 18px; height: 18px; vertical-align: middle; fill: currentColor; }

/* منوی هر پیام */
.cx-dots { border: 0; background: transparent; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; opacity: 0; transition: .15s; flex-shrink: 0; padding: 0; align-self: center; }
.cx-row:hover .cx-dots, .cx-dots.on { opacity: 1; }
.cx-dots:hover { background: rgba(148,163,184,.2); }
.cx-dots svg { fill: #94a3b8 !important; width: 18px; height: 18px; }
.cx-menu { position: absolute; bottom: calc(100% - 6px); z-index: 20; background: white; border-radius: 12px; box-shadow: 0 10px 30px rgba(15,23,42,.18); border: 1px solid #eef0f4; padding: 4px; min-width: 130px; animation: cxPop .15s ease both; }
.cx-mine .cx-menu { right: 42px; }
.cx-their .cx-menu { left: 42px; }
.cx-menu button { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: transparent; padding: 7px 10px; border-radius: 8px; font: inherit; font-size: .82rem; color: #334155 !important; cursor: pointer; }
.cx-menu button:hover { background: #f1f5f9; }
.cx-menu button svg { width: 18px; height: 18px; fill: #64748b !important; }
.cx-menu button.cx-danger { color: #dc2626 !important; }
.cx-menu button.cx-danger svg { fill: #dc2626 !important; }
.cx-menu-back { position: fixed; inset: 0; z-index: 15; }
@keyframes cxPop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* حالت خالی */
.cx-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: #94a3b8 !important; padding: 20px; text-align: center !important; }
.cx-empty-ico { width: 84px; height: 84px; border-radius: 26px; background: linear-gradient(135deg, #dbeafe, #ede9fe); display: grid; place-items: center; transform: rotate(-8deg); }
.cx-empty-ico svg { width: 42px; height: 42px; fill: #3b82f6 !important; }
.cx-empty b { color: #1f2340 !important; font-size: 1rem; }
.cx-empty span { color: #7a7f9a !important; font-size: .84rem; }

/* باکس ارسال */
.cx-replybar { display: flex; align-items: center; gap: 8px; margin: 0 12px; padding: 6px 10px; border-radius: 12px 12px 0 0; border-right: 3px solid #3b82f6; background: #eff6ff; }
.cx-replybar.cx-edit { border-color: #f59e0b; background: #fffbeb; }
.cx-replybar-txt { flex: 1; min-width: 0; font-size: .8rem; max-height: 2.6em; overflow: hidden; }
.cx-replybar-txt, .cx-replybar-txt * { color: #334155 !important; }
.cx-replybar-lbl { font-weight: 800; font-size: .74rem; color: #1d4ed8 !important; display: block; }
.cx-replybar.cx-edit .cx-replybar-lbl { color: #b45309 !important; }
.cx-replybar img { max-width: 2em; }
.cx-replybar svg { width: 18px; height: 18px; }

.cx-send { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid #f1f3f8; background: white; position: relative; }
.cx-send textarea { flex: 1; min-width: 0; resize: none; border: 1.5px solid #e2e8f0 !important; border-radius: 14px; padding: 9px 14px; font: inherit; font-size: .9rem; line-height: 1.6; color: #1f2340 !important; background: #f8fafc; outline: none; min-height: 44px; max-height: 120px; height: 44px; }
.cx-send textarea:focus { border-color: #93c5fd !important; background: white; box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
.cx-send-btn { border: 0; width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; cursor: pointer; flex-shrink: 0; background: linear-gradient(135deg, #1e3a8a, #3b82f6); box-shadow: 0 4px 12px rgba(37,99,235,.3); transition: .15s; padding: 0; }
.cx-send-btn:hover { transform: translateY(-1px); }
.cx-send-btn svg { fill: white !important; width: 22px; height: 22px; }
.cx-send-btn.cx-reply { background: linear-gradient(135deg, #0f766e, #14b8a6); }
.cx-send-btn.cx-edit { background: linear-gradient(135deg, #c2410c, #fb923c); }
.cx-send .cx-icon-btn { width: 44px; height: 44px; border-radius: 14px; }
.cx-send .MicrophoneBTN { position: static !important; box-shadow: none !important; background: #f1f5f9 !important; width: 44px !important; height: 44px !important; border-radius: 14px !important; min-width: 0 !important; }
.cx-send .recording-indicator { position: absolute; top: -26px; right: 14px; background: #fee2e2; color: #b91c1c !important; border-radius: 999px; padding: 2px 10px; font-size: .74rem; }

/* مودال عکس */
.cx-modal { position: fixed; inset: 0; z-index: 1400; background: rgba(15,23,42,.82); display: flex; align-items: center; justify-content: center; padding: 20px; animation: cxPop .2s ease both; }
.cx-modal img { max-width: 100%; max-height: 90vh; border-radius: 14px; box-shadow: 0 20px 50px rgba(0,0,0,.4); }
.cx-modal-x { position: absolute; top: 16px; left: 16px; width: 42px; height: 42px; border-radius: 50%; border: 0; background: rgba(255,255,255,.15); cursor: pointer; display: grid; place-items: center; }
.cx-modal-x svg { fill: white !important; }

/* موبایل */
@media (max-width: 800px) {
    .cx-wrap, .cx-wrap.cx-has-groups { grid-template-columns: 1fr; height: auto; }
    .cx-side { max-height: 260px; }
    .cx-main { height: 72vh; min-height: 420px; }
    .cx-bubble { max-width: 84%; }
    .cx-dots { opacity: 1; }
    .cx-chat.cx-show-chat .cx-side { display: none; }
    .cx-chat.cx-show-chat .cx-back { display: grid !important; }
}
