/* chat-history-list.css — فهرستِ مکالمات (chat-history-list.js)، گوشی و کامپیوتر، همهٔ ربات‌ها.
*
 * رنگ‌ها: پنجرهٔ مکالماتِ کامپیوتر در هر دو تم یک کارتِ تیرهٔ ثابت است
 * (chat-desktop-shell.css «Forever 2026-08-20»)، پس این‌جا هم رنگِ ثابتِ روشن-روی-تیره
 * دارد. کشوی گوشی تم را دنبال می‌کند، پس متغیرهای تم.
 * کوتاه‌کردنِ عنوان با پهنا (ellipsis) است، نه با شمارشِ حرف.
 */

#chatList[data-nbh]  {
  --nbh-ink: var(--text, #e8eef6);
  /* Own secondary ink, not --text-secondary: measured 4.1:1 for 11.5px times in the
     phone drawer, under the 4.5 floor for small text. */
  --nbh-soft: #a9b4c3;
  --nbh-hover: rgba(148, 168, 200, 0.10);
  --nbh-active: var(--tg-accent-soft, rgba(52, 211, 153, 0.14));
  --nbh-accent: var(--tg-accent, #34d399);
  --nbh-line: rgba(148, 168, 200, 0.16);
  --nbh-danger: #f87171;
  gap: 2px !important;
}
html[data-theme="light"] body.mobile-chat #chatList[data-nbh],
html[data-theme="light"] body.mobile-chat #searchResults {
  --nbh-soft: #4b5563;
  --nbh-hover: rgba(15, 23, 42, 0.05);
  --nbh-line: rgba(15, 23, 42, 0.10);
  --nbh-danger: #dc2626;
}
body.desktop-chat .sidebar #chatList[data-nbh],
body.desktop-chat .sidebar #searchResults  {
  --nbh-ink: #f3f6fa;
  --nbh-soft: rgba(243, 246, 250, 0.62);
  --nbh-hover: rgba(255, 255, 255, 0.07);
  --nbh-active: rgba(16, 185, 129, 0.16);
  --nbh-accent: #34d399;
  --nbh-line: rgba(255, 255, 255, 0.10);
  --nbh-danger: #f87171;
}
body.mobile-chat #searchResults { --nbh-ink: var(--text, #e8eef6); --nbh-soft: #a9b4c3; --nbh-hover: rgba(148, 168, 200, 0.10); --nbh-accent: var(--tg-accent, #34d399); }

#sidebar .nbh-group { display: flex; flex-direction: column; gap: 1px; }
#sidebar .nbh-group + .nbh-group { margin-top: 10px; }
#sidebar .nbh-head {
  padding: 6px 10px 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--nbh-soft);
}

#sidebar .nbh-row { border-radius: 10px; }
#sidebar .nbh-row.is-open { background: var(--nbh-hover); }
#sidebar .nbh-line { display: flex; align-items: center; gap: 2px; min-width: 0; }
#sidebar .nbh-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--nbh-ink);
  font: inherit;
  text-align: right;
  direction: rtl;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#sidebar .nbh-main:hover { background: var(--nbh-hover); }
#sidebar .nbh-row.is-active .nbh-main { background: var(--nbh-active); }
#sidebar .nbh-row.is-active .nbh-title { font-weight: 700; }
#sidebar .nbh-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 14px;
  line-height: 1.9;
}
#sidebar .nbh-time {
  flex: 0 0 auto;
  font-size: 11.5px;
  color: var(--nbh-soft);
  white-space: nowrap;
}
#sidebar .nbh-pin { flex: 0 0 auto; display: inline-flex; color: var(--nbh-accent); }
#sidebar .nbh-pin svg { width: 14px; height: 14px; }

#sidebar .nbh-more {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--nbh-soft);
  cursor: pointer;
}
#sidebar .nbh-more svg { width: 18px; height: 18px; }
#sidebar .nbh-more:hover,
#sidebar .nbh-more[aria-expanded="true"] { background: var(--nbh-hover); color: var(--nbh-ink); }
/* A mouse sees «⋯» on the row it points at (and on the open one); a finger always sees it. */
@media (hover: hover) and (pointer: fine) {
#sidebar .nbh-row:not(:hover):not(.is-open):not(:focus-within) .nbh-more { opacity: 0; }
}

#sidebar .nbh-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 8px 10px;
}
#sidebar .nbh-actions button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--nbh-line);
  border-radius: 999px;
  background: transparent;
  color: var(--nbh-ink);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
#sidebar .nbh-actions button:hover { background: var(--nbh-hover); }
#sidebar .nbh-actions button svg { width: 15px; height: 15px; }
#sidebar .nbh-actions button.is-danger { color: var(--nbh-danger); }
#sidebar .nbh-stamp { flex-basis: 100%; font-size: 11.5px; color: var(--nbh-soft); padding: 2px 4px 0; }

#sidebar .nbh-input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 40px;
  margin: 1px 0;
  padding: 0 10px;
  border: 1px solid var(--nbh-accent);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.18);
  color: var(--nbh-ink);
  font: inherit;
  font-size: 14px;
  direction: rtl;
  outline: none;
}

#sidebar .nbh-empty { margin: 14px 10px; font-size: 13.5px; line-height: 1.9; color: var(--nbh-soft); text-align: center; }
#sidebar .nbh-older {
  margin: 10px 8px 4px;
  min-height: 40px;
  border: 1px dashed var(--nbh-line);
  border-radius: 10px;
  background: transparent;
  color: var(--nbh-soft);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

#sidebar .nbh-note {
  margin: 2px 4px 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--nbh-line);
  background: var(--nbh-hover);
  color: var(--nbh-ink);
  font-size: 12.5px;
  line-height: 1.85;
}
#sidebar .nbh-note p { margin: 0 0 6px; }
#sidebar .nbh-note-acts { display: flex; gap: 6px; }
#sidebar .nbh-note-acts button {
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--nbh-line);
  background: transparent;
  color: var(--nbh-ink);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}
#sidebar .nbh-note-acts [data-nbh-signin] { background: var(--nbh-accent); border-color: transparent; color: #04120c; font-weight: 700; }

/* search */
#sidebar #searchResults .nbh-head { padding-top: 2px; }
#sidebar .nbh-hit {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--nbh-ink);
  font: inherit;
  text-align: right;
  direction: rtl;
  cursor: pointer;
  box-sizing: border-box;
}
#sidebar .nbh-hit:hover { background: var(--nbh-hover); }
#sidebar .nbh-hit-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
#sidebar .nbh-hit-text {
  font-size: 12.5px;
  line-height: 1.8;
  color: var(--nbh-soft);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
#sidebar #searchResults mark, #chatList mark  {
  background: rgba(250, 204, 21, 0.28);
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}

/* a message opened from a search result */
.message.nbh-flash  { animation: nbh-flash 1.8s ease-out; }
@keyframes nbh-flash {
0%, 30%  { box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.45); border-radius: 14px; }
100%  { box-shadow: 0 0 0 0 rgba(250, 204, 21, 0); }
}
@media (prefers-reduced-motion: reduce) { .message.nbh-flash { animation: none; } }

.nbh-undo[hidden] { display: none !important; }

/* While a search is typed, the results replace the list. Older sheets force
   `#chatList{display:flex!important}` on the phone, so an inline style cannot hide it. */
body #sidebar #chatList[data-nbh][data-searching] { display: none !important; }
