/* NALQIVO ERP — employee chat (Discuss page + header slide-in panel). Logical
   properties only, so RTL and LTR share one stylesheet. */

/* ---------- shared bits ---------- */
.dx-icon-btn { width: 32px; height: 32px; border-radius: 9px; border: 0; background: transparent; color: var(--muted);
  display: inline-grid; place-items: center; cursor: pointer; flex: 0 0 auto; text-decoration: none; }
.dx-icon-btn:hover { background: var(--surface-3); color: var(--brand); }
.dx-search { position: relative; display: flex; align-items: center; }
.dx-search > svg { position: absolute; inset-inline-start: 11px; color: var(--muted); pointer-events: none; }
.dx-search .input { padding-inline-start: 34px; width: 100%; }
.dx-empty-sm { padding: 18px 12px; color: var(--muted); font-size: 13px; text-align: center; }
.dx-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; color: var(--muted);
  padding: 40px 18px; margin: auto; max-width: 340px; font-size: 13px; }
.dx-empty b { color: var(--ink); font-size: 14.5px; }
.dx-empty-icon { width: 46px; height: 46px; border-radius: 14px; background: var(--brand-50); color: var(--brand); display: grid; place-items: center; margin-bottom: 4px; }
.dx-empty-icon.big { width: 60px; height: 60px; border-radius: 18px; }
.dx-unread { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--brand); color: #fff;
  font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; flex: 0 0 auto; }
.dx-unread.soft { background: var(--brand-50); color: var(--brand); min-width: 18px; height: 18px; font-size: 10.5px; }
.dx-tag { font-size: 10.5px; padding: 1px 7px; border-radius: 99px; background: var(--brand-50); color: var(--brand); font-weight: 600; }
.dx-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; font-size: 12.5px; color: var(--ink-2); font-weight: 600; }

/* ---------- conversation rows ---------- */
.dx-conv { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: transparent;
  border-radius: 10px; cursor: pointer; text-align: start; color: inherit; font: inherit; }
.dx-conv:hover { background: var(--surface-3); }
.dx-conv.active { background: var(--brand-50); }
.dx-conv-icon { border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto; background: var(--surface-3); color: var(--ink-2); }
.dx-conv-icon.group { background: #eef2ff; color: #4f46e5; }
.dx-conv-icon.channel { background: var(--teal-soft, #e6f6f4); color: var(--teal, #0f766e); }
.dx-conv-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dx-conv-top, .dx-conv-bottom { display: flex; align-items: center; gap: 8px; min-width: 0; }
.dx-conv-name { flex: 1; min-width: 0; font-weight: 600; font-size: 13.5px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dx-conv-time { font-size: 11px; color: var(--muted); flex: 0 0 auto; }
.dx-conv-preview { flex: 1; min-width: 0; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dx-conv.has-unread .dx-conv-name { font-weight: 700; }
.dx-conv.has-unread .dx-conv-preview { color: var(--ink-2); }
.dx-conv.has-unread .dx-conv-time { color: var(--brand); font-weight: 600; }

/* ---------- full page ---------- */
.dx-page { display: grid; grid-template-columns: 320px 1fr; height: calc(100dvh - 120px); min-height: 420px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius, 14px); overflow: hidden; }
.dx-side { min-width: 0; display: flex; flex-direction: column; min-height: 0; border-inline-end: 1px solid var(--line); background: var(--surface); }
.dx-side-head { display: flex; align-items: center; gap: 8px; padding: 14px 14px 10px; }
.dx-title { font-size: 18px; margin: 0; flex: 1; }
.dx-side-actions { display: flex; align-items: center; gap: 4px; }
.dx-side > .dx-search { margin: 0 12px 8px; }
.dx-list { flex: 1; overflow-y: auto; padding: 4px 6px 10px; }
.dx-section + .dx-section { margin-top: 8px; }
.dx-section-title { font-size: 11.5px; font-weight: 700; color: var(--muted); padding: 8px 10px 4px; display: flex; align-items: center; gap: 6px; text-transform: uppercase; letter-spacing: .02em; }
.dx-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg-soft, #f8fafc); }
.dx-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface); }
.dx-head-text { flex: 1; min-width: 0; }
.dx-head-name { font-weight: 700; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dx-head-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dx-back { display: none; }
.dx-thread-host { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.dx-welcome { margin: auto; text-align: center; max-width: 420px; padding: 30px 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--muted); }
.dx-welcome h2 { margin: 6px 0 0; color: var(--ink); font-size: 18px; }
.dx-welcome p { margin: 0 0 8px; line-height: 1.7; font-size: 13.5px; }

/* ---------- thread ---------- */
.dx-thread { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.dx-msgs { flex: 1; overflow-y: auto; padding: 14px 16px 8px; display: flex; flex-direction: column; }
.dx-day { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 11.5px; margin: 12px 0 6px; }
.dx-day::before, .dx-day::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.dx-more { align-self: center; border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 4px 12px; font-size: 12px; cursor: pointer; color: var(--ink-2); margin-bottom: 6px; }
.dx-system { align-self: center; font-size: 11.5px; color: var(--muted); background: var(--surface-3); padding: 3px 10px; border-radius: 99px; margin: 6px 0; text-align: center; }
.dx-msg { position: relative; display: flex; gap: 10px; padding: 6px 8px; margin: 0 -8px; border-radius: 10px; }
.dx-msg.grouped { padding-top: 1px; }
.dx-msg:hover { background: var(--surface); }
.dx-msg-avatar { width: 32px; flex: 0 0 32px; }
.dx-msg-main { flex: 1; min-width: 0; }
.dx-msg-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 1px; }
.dx-msg-author { font-weight: 700; font-size: 13px; color: var(--ink); }
.dx-msg.mine .dx-msg-author { color: var(--brand); }
.dx-msg-time { font-size: 11px; color: var(--muted); }
.dx-msg-body { font-size: 13.5px; line-height: 1.65; color: var(--ink); white-space: normal; overflow-wrap: anywhere; }
.dx-msg-body.deleted { color: var(--muted); font-style: italic; }
.dx-edited { color: var(--muted); font-size: 11px; }
.dx-msg-actions { position: absolute; top: -10px; inset-inline-end: 8px; display: none; gap: 2px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 9px; padding: 2px; box-shadow: var(--shadow-sm); }
.dx-msg-actions .dx-icon-btn { width: 28px; height: 28px; }
@media (hover: hover) { .dx-msg:hover .dx-msg-actions { display: flex; } }
.dx-msg:focus-within .dx-msg-actions, .dx-msg.show-actions .dx-msg-actions { display: flex; }
.dx-reply-quote { font-size: 12px; color: var(--muted); border-inline-start: 3px solid var(--brand-200); padding: 2px 8px; margin: 2px 0 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dx-reply-quote b { color: var(--ink-2); }

/* ---------- record cards ---------- */
.dx-cards { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; max-width: 460px; }
.dx-card { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.dx-card-icon { width: 32px; height: 32px; border-radius: 9px; background: var(--brand-50); color: var(--brand); display: grid; place-items: center; flex: 0 0 auto; }
.dx-card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.dx-card-type { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.dx-card-status { color: var(--ink-2); }
.dx-card-status.s-active, .dx-card-status.s-paid, .dx-card-status.s-approved { color: var(--green); }
.dx-card-status.s-expired, .dx-card-status.s-cancelled { color: var(--red); }
.dx-card-title { font-size: 13px; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dx-card-open { font-size: 12.5px; font-weight: 600; color: var(--brand); text-decoration: none; padding: 5px 10px; border-radius: 8px; background: var(--brand-50); flex: 0 0 auto; }
.dx-card-open:hover { background: var(--brand-100); }
.dx-card.restricted, .dx-card.missing { background: var(--surface-2); border-style: dashed; }
.dx-card.restricted .dx-card-icon, .dx-card.missing .dx-card-icon { background: var(--surface-3); color: var(--muted); }
.dx-card.restricted .dx-card-title, .dx-card.missing .dx-card-title { color: var(--muted); font-weight: 500; white-space: normal; }

/* ---------- composer ---------- */
.dx-composer { border-top: 1px solid var(--line); background: var(--surface); padding: 8px 10px 10px; }
.dx-composer-row { display: flex; align-items: flex-end; gap: 6px; border: 1px solid var(--line-strong, var(--line)); border-radius: 12px; padding: 4px; background: var(--surface); }
.dx-composer-row:focus-within { border-color: var(--brand-300); box-shadow: 0 0 0 3px var(--brand-50); }
.dx-input { flex: 1; border: 0; outline: 0; resize: none; font: inherit; font-size: 13.5px; line-height: 1.5; padding: 6px 4px; min-height: 32px; max-height: 140px; background: transparent; color: var(--ink); }
.dx-send { width: 34px; height: 34px; border-radius: 9px; border: 0; background: var(--brand); color: #fff; display: grid; place-items: center; cursor: pointer; flex: 0 0 auto; }
.dx-send:disabled { opacity: .6; }
[dir="rtl"] .dx-send svg { transform: scaleX(-1); }
.dx-composer-ctx { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-2); background: var(--brand-50); border-radius: 9px; padding: 3px 4px 3px 10px; margin-bottom: 6px; }
.dx-composer-ctx[hidden] { display: none; }
.dx-composer-cards { display: flex; flex-direction: column; gap: 6px; }
.dx-composer-cards:not(:empty) { margin-bottom: 6px; }
.dx-warn { font-size: 12px; color: #92400e; background: var(--amber-soft, #fef3c7); border-radius: 9px; padding: 6px 10px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dx-warn[hidden] { display: none; }
.dx-readonly { padding: 12px; text-align: center; color: var(--muted); font-size: 12.5px; border-top: 1px solid var(--line); }

/* ---------- pickers ---------- */
.dx-user-list { display: flex; flex-direction: column; gap: 2px; max-height: 340px; overflow-y: auto; margin-top: 8px; }
.dx-user { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 10px; border: 0; background: transparent; cursor: pointer; font: inherit; color: inherit; text-align: start; }
.dx-user:hover, .dx-user.on { background: var(--brand-50); }
.dx-user.static { cursor: default; }
.dx-user.static:hover { background: transparent; }
.dx-user .grow { display: flex; flex-direction: column; font-size: 13.5px; font-weight: 600; }
.dx-user-sub { font-size: 11.5px; color: var(--muted); font-weight: 400; }
.dx-check { width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--line-strong, var(--line)); display: grid; place-items: center; color: #fff; }
.dx-user.on .dx-check { background: var(--brand); border-color: var(--brand); }
.dx-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.dx-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 10px; border-radius: 99px; background: var(--brand-50); color: var(--brand); font-size: 12px; font-weight: 600; }
.dx-chip button { border: 0; background: transparent; color: inherit; display: grid; place-items: center; cursor: pointer; padding: 2px; }
.dx-share-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dx-share-row .select { flex: 0 0 auto; min-width: 150px; }
.dx-share-row .grow { flex: 1 1 200px; }
.dx-results { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; max-height: 320px; overflow-y: auto; }
.dx-result { display: flex; align-items: center; gap: 10px; padding: 8px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; text-align: start; font: inherit; color: inherit; }
.dx-result:hover { background: var(--brand-50); }
.dx-result .grow { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.dx-result-code { font-weight: 700; }
.dx-result-label { color: var(--muted); }
.dx-current { margin-bottom: 12px; }
.dx-current-label { font-size: 11.5px; font-weight: 700; color: var(--muted); margin-bottom: 5px; }

/* ---------- header slide-in panel ---------- */
.dx-panel-wrap { position: fixed; inset: 0; z-index: 900; pointer-events: none; }
.dx-panel-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .18); opacity: 0; transition: opacity .18s ease; pointer-events: auto; }
.dx-panel { position: absolute; top: 0; bottom: 0; inset-inline-end: 0; width: min(400px, 100vw); background: var(--surface);
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; pointer-events: auto; transform: translateX(100%); transition: transform .2s ease; }
[dir="rtl"] .dx-panel { transform: translateX(-100%); }
.dx-panel-wrap.open .dx-panel { transform: none; }
.dx-panel-wrap.open .dx-panel-backdrop { opacity: 1; }
.dx-panel-head { display: flex; align-items: center; gap: 6px; padding: 10px 10px 10px 14px; border-bottom: 1px solid var(--line); }
.dx-panel-head [hidden] { display: none; }
.dx-panel-title { flex: 1; min-width: 0; font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.dx-panel-full { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--brand); text-decoration: none; padding: 5px 8px; border-radius: 8px; white-space: nowrap; }
.dx-panel-full:hover { background: var(--brand-50); }
.dx-panel-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.dx-panel-body > .dx-search { margin: 10px 12px 4px; }
.dx-panel-body .dx-list { padding: 4px 6px 10px; }
.dx-panel-body .dx-msgs { background: var(--bg-soft, #f8fafc); }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .topbar-actions .icon-btn[data-top="messages"] { display: grid; }
  .dx-page { grid-template-columns: minmax(0, 1fr); border-radius: 12px; }
  .dx-page .dx-main { display: none; }
  .dx-page.has-active .dx-side { display: none; }
  .dx-page.has-active .dx-main { display: flex; }
  .dx-back { display: inline-grid; }
  .dx-msgs { padding: 10px 10px 6px; }
  .dx-msg-actions { top: -14px; }
  .dx-panel-full span { display: none; }
}

/* ---------- S4: typing hint ---------- */
.dx-typing { height: 0; overflow: hidden; padding: 0 16px; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; transition: height .15s ease; }
.dx-typing.on { height: 22px; }
.dx-dots { display: inline-flex; gap: 3px; }
.dx-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--brand-300, #a5b4fc); animation: dx-blink 1.2s infinite ease-in-out; }
.dx-dots i:nth-child(2) { animation-delay: .2s; }
.dx-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes dx-blink { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }
@media (prefers-reduced-motion: reduce) { .dx-dots i { animation: none; } }

/* ---------- S5: employee directory tabs ---------- */
.dx-tabs { display: flex; gap: 4px; margin: 8px 12px 2px; padding: 3px; background: var(--bg-soft, #f1f5f9); border-radius: 10px; }
.dx-tab { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; background: transparent; padding: 7px 8px;
  border-radius: 8px; font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.dx-tab[aria-selected="true"] { background: var(--surface); color: var(--text, #0f172a); box-shadow: 0 1px 2px rgba(15, 23, 42, .08); }
.dx-tab-count { font-size: 11px; font-weight: 700; color: var(--muted); background: var(--line); border-radius: 99px; padding: 0 6px; }
.dx-tab-count:empty { display: none; }
.dx-av-wrap { position: relative; display: inline-flex; flex-shrink: 0; }
.dx-online { position: absolute; bottom: 0; inset-inline-end: 0; width: 10px; height: 10px; border-radius: 50%; background: #22c55e; border: 2px solid var(--surface); }
.dx-person .dx-person-go { color: var(--muted); opacity: 0; transition: opacity .12s; flex-shrink: 0; }
.dx-person:hover .dx-person-go, .dx-person:focus-visible .dx-person-go { opacity: 1; color: var(--brand); }
.dx-person:disabled { opacity: .6; }

/* ---------- S5: docked chat windows (every page) ---------- */
/* z-index: above page content and the mobile bottom nav (60), below modals (80 on phones / 250 desktop). */
.dx-dock { position: fixed; bottom: 0; inset-inline-end: 16px; z-index: 75; display: flex; flex-direction: row-reverse; align-items: flex-end; gap: 12px; pointer-events: none; }
.dx-dock.hidden { display: none; }
.dx-win { pointer-events: auto; width: 328px; height: 440px; max-height: calc(100vh - 90px); background: var(--surface); border: 1px solid var(--line);
  border-bottom: 0; border-radius: 12px 12px 0 0; box-shadow: 0 10px 30px rgba(15, 23, 42, .18); display: flex; flex-direction: column; overflow: hidden; }
.dx-win.min { height: auto; width: 230px; }
.dx-win-head { display: flex; align-items: center; gap: 8px; padding: 7px 8px 7px 10px; background: var(--surface); border-bottom: 1px solid var(--line); cursor: pointer; min-height: 44px; }
.dx-win.min .dx-win-head { border-bottom: 0; }
.dx-win.has-unread .dx-win-head { background: var(--brand-50, #eef2ff); }
.dx-win-name { flex: 1; min-width: 0; font-weight: 700; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dx-win-actions { display: inline-flex; gap: 0; }
.dx-win-actions .dx-icon-btn { width: 28px; height: 28px; }
.dx-win.min [data-expand] { display: none; }
.dx-win-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.dx-win.min .dx-win-body { display: none; }
.dx-win-body .dx-thread-host, .dx-win-body .dx-thread { flex: 1; min-height: 0; }
.dx-win-body .dx-msgs { background: var(--bg-soft, #f8fafc); }
.dx-dock-more { pointer-events: auto; position: relative; margin-bottom: 10px; }
.dx-more-btn { position: relative; width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-lg, 0 6px 20px rgba(0,0,0,.15));
  font: inherit; font-weight: 700; font-size: 14px; color: var(--text, #0f172a); cursor: pointer; }
.dx-more-btn .dx-unread { position: absolute; top: -4px; inset-inline-end: -4px; }
.dx-more-menu { position: absolute; bottom: 54px; inset-inline-end: 0; width: 240px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg, 0 6px 20px rgba(0,0,0,.15)); padding: 6px; }
.dx-more-menu[hidden] { display: none; }
.dx-more-row { display: flex; align-items: center; gap: 4px; }
.dx-more-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 0; background: transparent; border-radius: 8px; font: inherit; font-size: 13px; cursor: pointer; text-align: start; }
.dx-more-open:hover { background: var(--brand-50); }
.dx-more-open bdi { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
@media print { .dx-dock { display: none !important; } }

/* phones: an open window is full-screen; minimized ones are round bubbles above the bottom nav */
@media (max-width: 760px) {
  .dx-dock { inset-inline-end: 10px; bottom: calc(70px + env(safe-area-inset-bottom, 0px)); flex-direction: column-reverse; align-items: flex-end; gap: 8px; }
  .dx-win:not(.min) { position: fixed; inset: 0; width: auto; height: auto; max-height: none; border-radius: 0; border: 0; z-index: 76; }
  .dx-win:not(.min) .dx-win-head { padding-top: calc(7px + env(safe-area-inset-top, 0px)); }
  .dx-win.min { width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--line); overflow: visible; }
  .dx-win.min .dx-win-head { padding: 0; min-height: 0; width: 48px; height: 48px; justify-content: center; border-radius: 50%; position: relative; }
  .dx-win.min .dx-win-head > .avatar, .dx-win.min .dx-win-head > .dx-conv-icon { width: 40px !important; height: 40px !important; }
  .dx-win.min .dx-win-name, .dx-win.min .dx-win-actions { display: none; }
  .dx-win.min [data-win-unread] { position: absolute; top: -4px; inset-inline-end: -4px; }
  .dx-dock-more { margin: 0; }
  .dx-more-menu { bottom: 0; inset-inline-end: 54px; }
}
.dx-win [data-win-unread][hidden] { display: none; }
