/* UPJET Live Chat v23 */
:root {
  --lc-bg: #0f172a;
  --lc-card: rgba(15, 23, 42, .94);
  --lc-card-2: rgba(30, 41, 59, .72);
  --lc-border: rgba(148, 163, 184, .18);
  --lc-text: #e5e7eb;
  --lc-muted: #94a3b8;
  --lc-accent: #22c55e;
  --lc-accent-2: #38bdf8;
  --lc-danger: #ef4444;
  --lc-warning: #f59e0b;
}
[data-bs-theme="light"], [data-theme="light"] {
  --lc-bg: #e5e7eb;
  --lc-card: rgba(241, 245, 249, .98);
  --lc-card-2: rgba(226, 232, 240, .9);
  --lc-border: rgba(51, 65, 85, .14);
  --lc-text: #111827;
  --lc-muted: #475569;
}
.upjet-live-chat { position: fixed; left: 22px; bottom: 22px; z-index: 9998; font-family: Vazirmatn, Tahoma, sans-serif; direction: rtl; }
.lc-fab { position: relative; display: inline-flex; align-items: center; gap: 9px; min-width: 132px; height: 52px; border: 0; border-radius: 999px; color: #fff; background: linear-gradient(135deg, #16a34a, #0284c7); box-shadow: 0 18px 45px rgba(2,132,199,.34); padding: 0 18px; font-weight: 800; cursor: pointer; }
.lc-fab i { font-size: 1.25rem; }
.lc-pulse { position: absolute; width: 12px; height: 12px; background: #22c55e; border: 2px solid #fff; border-radius: 50%; right: 12px; top: 8px; box-shadow: 0 0 0 0 rgba(34,197,94,.65); animation: lcPulse 1.6s infinite; }
@keyframes lcPulse { 70% { box-shadow: 0 0 0 12px rgba(34,197,94,0); } 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); } }
.lc-window { position: absolute; left: 0; bottom: 68px; width: min(380px, calc(100vw - 26px)); height: min(620px, calc(100vh - 110px)); display: none; flex-direction: column; overflow: hidden; border: 1px solid var(--lc-border); border-radius: 28px; background: var(--lc-card); color: var(--lc-text); box-shadow: 0 28px 90px rgba(0,0,0,.42); backdrop-filter: blur(18px); }
.lc-window.open { display: flex; }
.lc-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 18px; background: linear-gradient(135deg, rgba(34,197,94,.18), rgba(56,189,248,.14)); border-bottom: 1px solid var(--lc-border); }
.lc-head strong { display: block; font-size: .98rem; }
.lc-head span { display: block; color: var(--lc-muted); font-size: .78rem; margin-top: 3px; }
.lc-head button { width: 34px; height: 34px; border-radius: 12px; border: 1px solid var(--lc-border); color: var(--lc-text); background: rgba(255,255,255,.06); }
.lc-identity { padding: 12px 14px; border-bottom: 1px solid var(--lc-border); background: rgba(15,23,42,.18); }
.lc-identity p { margin: 0 0 8px; color: var(--lc-muted); font-size: .82rem; }
.lc-identity input { width: 100%; margin-top: 7px; border: 1px solid var(--lc-border); border-radius: 14px; padding: 10px 12px; outline: none; background: var(--lc-card-2); color: var(--lc-text); }
.lc-quick { display: flex; gap: 7px; overflow-x: auto; padding: 10px 12px 8px; border-bottom: 1px solid var(--lc-border); scrollbar-width: thin; }
.lc-quick button { flex: 0 0 auto; border: 1px solid rgba(56,189,248,.23); border-radius: 999px; padding: 7px 11px; background: rgba(56,189,248,.10); color: var(--lc-text); font-size: .78rem; white-space: nowrap; }
.lc-messages { flex: 1; overflow-y: auto; padding: 16px 14px; background: radial-gradient(circle at top right, rgba(34,197,94,.08), transparent 38%), radial-gradient(circle at bottom left, rgba(56,189,248,.08), transparent 42%); }
.lc-msg { display: flex; margin-bottom: 10px; }
.lc-msg > div { max-width: 86%; border-radius: 18px; padding: 10px 13px; line-height: 1.75; font-size: .88rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.lc-msg.customer { justify-content: flex-start; }
.lc-msg.customer > div { background: linear-gradient(135deg, #16a34a, #0284c7); color: #fff; border-bottom-right-radius: 6px; }
.lc-msg.admin, .lc-msg.bot, .lc-msg.system { justify-content: flex-end; }
.lc-msg.admin > div { background: rgba(56,189,248,.14); border: 1px solid rgba(56,189,248,.22); color: var(--lc-text); border-bottom-left-radius: 6px; }
.lc-msg.bot > div { background: rgba(34,197,94,.13); border: 1px solid rgba(34,197,94,.2); color: var(--lc-text); border-bottom-left-radius: 6px; }
.lc-msg.system > div { background: rgba(148,163,184,.12); color: var(--lc-muted); font-size: .78rem; margin-inline: auto; }
.lc-form { display: flex; gap: 8px; align-items: center; padding: 12px; border-top: 1px solid var(--lc-border); background: rgba(15,23,42,.22); }
.lc-form input { flex: 1; border: 1px solid var(--lc-border); border-radius: 16px; padding: 12px 13px; outline: none; background: var(--lc-card-2); color: var(--lc-text); }
.lc-form button { width: 46px; height: 46px; border: 0; border-radius: 16px; background: linear-gradient(135deg, #16a34a, #0284c7); color: #fff; }
@media (max-width: 576px) { .upjet-live-chat { left: 13px; bottom: 13px; } .lc-window { left: -1px; bottom: 62px; width: calc(100vw - 24px); height: min(610px, calc(100vh - 88px)); border-radius: 24px; } .lc-fab strong { display: none; } .lc-fab { min-width: 58px; width: 58px; padding: 0; justify-content: center; } }

/* Admin live chat */
.live-chat-admin { --admin-gap: 18px; }
.chat-hero { background: linear-gradient(135deg, rgba(34,197,94,.12), rgba(56,189,248,.10)), var(--lc-card) !important; border: 1px solid var(--lc-border) !important; border-radius: 28px !important; color: var(--lc-text); }
.chat-kicker { display: inline-flex; align-items: center; gap: 7px; color: #86efac; font-weight: 800; margin-bottom: 8px; }
.chat-admin-grid { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: var(--admin-gap); min-height: 640px; }
.chat-admin-list, .chat-admin-panel { background: var(--lc-card) !important; border: 1px solid var(--lc-border) !important; border-radius: 28px !important; color: var(--lc-text); overflow: hidden; }
.chat-list-head, .chat-panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--lc-border); background: rgba(255,255,255,.025); }
.chat-list-head strong { display: block; }
.chat-list-head span, .chat-panel-head span { display: block; color: var(--lc-muted); font-size: .82rem; margin-top: 3px; }
.btn-icon { width: 38px; height: 38px; display: inline-grid; place-items: center; border: 1px solid var(--lc-border); border-radius: 14px; background: rgba(255,255,255,.05); color: var(--lc-text); }
.chat-list-body { overflow-y: auto; max-height: 610px; padding: 10px; }
.chat-item { width: 100%; border: 1px solid transparent; border-radius: 18px; background: transparent; color: var(--lc-text); text-align: right; padding: 12px; margin-bottom: 8px; cursor: pointer; transition: border-color .15s ease, background .15s ease; }
.chat-item:hover, .chat-item.active { background: rgba(56,189,248,.08); border-color: rgba(56,189,248,.2); }
.chat-item-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.chat-item-name { font-weight: 800; }
.chat-unread { min-width: 24px; height: 24px; display: inline-grid; place-items: center; border-radius: 999px; background: #22c55e; color: #052e16; font-weight: 900; font-size: .75rem; }
.chat-item-msg { color: var(--lc-muted); font-size: .82rem; margin-top: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-status { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 9px; font-size: .72rem; margin-top: 8px; background: rgba(148,163,184,.12); color: var(--lc-muted); }
.chat-status.waiting_admin { background: rgba(245,158,11,.14); color: #fde68a; }
.chat-status.answered { background: rgba(34,197,94,.13); color: #bbf7d0; }
.chat-status.closed { background: rgba(239,68,68,.13); color: #fecaca; }
.chat-admin-messages { height: 510px; overflow-y: auto; padding: 20px; background: radial-gradient(circle at top left, rgba(56,189,248,.08), transparent 34%), radial-gradient(circle at bottom right, rgba(34,197,94,.08), transparent 36%); }
.chat-bubble { display: flex; margin-bottom: 12px; }
.chat-bubble > div { max-width: 76%; border-radius: 20px; padding: 11px 14px; line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-bubble .meta { display: block; color: var(--lc-muted); font-size: .72rem; margin-top: 6px; }
.chat-bubble.customer { justify-content: flex-start; }
.chat-bubble.customer > div { background: rgba(34,197,94,.14); border: 1px solid rgba(34,197,94,.22); border-bottom-right-radius: 6px; }
.chat-bubble.admin { justify-content: flex-end; }
.chat-bubble.admin > div { background: linear-gradient(135deg, rgba(2,132,199,.96), rgba(22,163,74,.88)); color: #fff; border-bottom-left-radius: 6px; }
.chat-bubble.bot, .chat-bubble.system { justify-content: center; }
.chat-bubble.bot > div { background: rgba(56,189,248,.13); border: 1px solid rgba(56,189,248,.20); }
.chat-bubble.system > div { background: rgba(148,163,184,.12); color: var(--lc-muted); font-size: .82rem; text-align: center; }
.chat-admin-form { display: flex; gap: 10px; padding: 14px; border-top: 1px solid var(--lc-border); background: rgba(255,255,255,.025); }
.chat-admin-form textarea { flex: 1; resize: none; min-height: 52px; border: 1px solid var(--lc-border); background: var(--lc-card-2); color: var(--lc-text); border-radius: 18px; padding: 12px 14px; outline: none; }
.chat-admin-form button { border: 0; border-radius: 18px; min-width: 110px; background: linear-gradient(135deg, #16a34a, #0284c7); color: #fff; font-weight: 800; }
.chat-empty-state, .chat-empty-mini { color: var(--lc-muted); text-align: center; padding: 36px 18px; }
.chat-empty-state i { display: block; font-size: 4rem; margin-bottom: 12px; opacity: .42; }
@media (max-width: 992px) { .chat-admin-grid { grid-template-columns: 1fr; } .chat-list-body { max-height: 320px; } .chat-admin-messages { height: 440px; } }

/* v25: نقش کاربر/نماینده در لیست چت مدیریت */
.chat-role-tag {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin-top: 8px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 800;
  border: 1px solid rgba(148,163,184,.22);
  color: #cbd5e1;
  background: rgba(15,23,42,.38);
}
.chat-role-tag.rep {
  color: #fef3c7;
  background: rgba(245,158,11,.15);
  border-color: rgba(245,158,11,.28);
}
.chat-role-tag.user {
  color: #bfdbfe;
  background: rgba(59,130,246,.14);
  border-color: rgba(59,130,246,.26);
}

/* v29: پاسخگوی هوشمند پیشرفته و هماهنگی پنل مدیریت */
.chat-intent-tag {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin-top: 8px;
  margin-inline-start: 6px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 800;
  color: #bbf7d0;
  background: rgba(34,197,94,.12);
  border: 1px solid rgba(34,197,94,.24);
}
.chat-ai-insight {
  border-bottom: 1px solid var(--lc-border);
  background: linear-gradient(135deg, rgba(14,165,233,.10), rgba(34,197,94,.08));
  padding: 12px 16px;
  color: var(--lc-text);
}
.chat-ai-insight .ai-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.chat-ai-insight .ai-title i { color: #7dd3fc; }
.chat-ai-insight .ai-title strong { font-weight: 900; }
.ai-priority {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 900;
  background: rgba(148,163,184,.12);
  color: #cbd5e1;
}
.ai-priority.high { background: rgba(245,158,11,.16); color: #fde68a; }
.ai-priority.urgent { background: rgba(239,68,68,.16); color: #fecaca; }
.ai-meta { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 8px; }
.ai-meta span {
  border: 1px solid rgba(148,163,184,.16);
  background: rgba(15,23,42,.20);
  color: var(--lc-muted);
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
}
.ai-suggestion {
  border: 1px solid rgba(56,189,248,.18);
  background: rgba(56,189,248,.07);
  border-radius: 16px;
  padding: 10px 12px;
}
.ai-suggestion b { display: block; margin-bottom: 5px; color: #bae6fd; }
.ai-suggestion p { margin: 0 0 8px; line-height: 1.8; color: var(--lc-text); white-space: pre-wrap; }
.ai-suggestion .btn { border-radius: 999px; font-weight: 800; }
@media (max-width: 576px) {
  .chat-ai-insight { padding: 10px 12px; }
  .ai-meta span { font-size: 11px; }
}
