/* ============================================================
   Поддержка — панель чата (ui/support.js, docs/SUPPORT-DESIGN.md §5).

   Панель, а не модалка: модалка затемняет консоль и забирает клики, а вопрос
   в поддержку задают посреди живого турнира — часы и столы под панелью должны
   оставаться рабочими. Поэтому на десктопе она стоит у правого края без
   подложки, а на телефоне, где места на два слоя нет, — во весь экран выше
   нижнего дока (тот же слой, что лист «Ещё»).

   Лента — общие классы `.sc-*` (#shared/lib/support-chat.js), вид — консольный.
   ============================================================ */

/* Кнопка в подвале меню и строка в «Ещё»: `display:flex` у .navlink сильнее
   атрибута hidden; точка — «пришёл ответ». */
.nav-help { margin-top: 8px; }
.nav-help[hidden] { display: none; }
.cs-dot { display: none; position: absolute; top: 8px; right: 10px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--amber); box-shadow: 0 0 0 2px #14102a; }
.has-new > .cs-dot { display: block; }
.ns-row { position: relative; }
.ns-row .cs-dot { position: static; flex: none; }

.cs-panel {
  position: fixed; z-index: 400; inset: 0;
  display: flex; flex-direction: column;
  /* Стекло — поверх НЕПРОЗРАЧНОЙ подложки: --lg-strong полупрозрачен, и без
     неё сквозь чат читались карточки дашборда (проверено на 400px). */
  background: linear-gradient(var(--lg-strong), var(--lg-strong)), var(--bg);
  animation: csin .22s var(--ease-glass);
}
.cs-panel[hidden] { display: none; }
@keyframes csin { from { transform: translateY(12px); opacity: 0; } }

.cs-top { flex: none; display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--lg-brd); }
.cs-badge { flex: none; width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  font-size: 19px; color: var(--teal); background: rgba(45, 226, 197, .1); border: 1px solid rgba(45, 226, 197, .28); }
.cs-ttl { flex: 1; min-width: 0; }
.cs-ttl b { display: block; font-size: 15.5px; font-weight: 800; }
.cs-ttl small { display: block; margin-top: 2px; font-size: 12px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-x { flex: none; width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; cursor: pointer;
  font-size: 18px; color: var(--muted); background: rgba(255, 255, 255, .05); border: 1px solid var(--lg-brd); }
.cs-x:hover { color: var(--text); }

.cs-feed { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 16px; display: flex; flex-direction: column; gap: 10px; }

.cs-form { flex: none; display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--lg-brd); }
.cs-form textarea { flex: 1; min-width: 0; resize: none; max-height: 120px; overflow-y: hidden; padding: 10px 13px;
  border-radius: 13px; border: 1px solid var(--lg-brd); background: rgba(0, 0, 0, .25);
  color: var(--text); font: inherit; font-size: 14.5px; line-height: 1.4; outline: none; }
.cs-form textarea:focus { border-color: rgba(45, 226, 197, .5); }
.cs-send { flex: none; width: 42px; height: 42px; border-radius: 13px; border: 0; cursor: pointer;
  display: grid; place-items: center; font-size: 19px; color: #04241c; background: var(--teal); }
.cs-send:disabled { background: rgba(255, 255, 255, .08); color: var(--dim); cursor: default; }
/* Снимки грузятся — пульс, а не просто погасшая кнопка. */
.cs-send.busy { animation: csbusy 1s ease-in-out infinite; }
@keyframes csbusy { 50% { opacity: .45; } }
.cs-att { flex: none; width: 42px; height: 42px; border-radius: 13px; cursor: pointer;
  display: grid; place-items: center; font-size: 20px; color: var(--muted);
  background: rgba(255, 255, 255, .05); border: 1px solid var(--lg-brd); }
.cs-att:hover { color: var(--text); border-color: rgba(45, 226, 197, .5); }

/* Очередь снимков над полем ввода. */
.cs-tray { flex: none; display: flex; gap: 8px; padding: 10px 12px 0; border-top: 1px solid var(--lg-brd); }
.cs-tray[hidden] { display: none; }
.cs-tray + .cs-form { border-top: 0; }
.cs-tray .sc-att { position: relative; width: 60px; height: 60px; border-radius: 11px; overflow: hidden;
  border: 1px solid var(--lg-brd); background: rgba(0, 0, 0, .25); }
.cs-tray .sc-att img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cs-tray .sc-att-x { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; border: 0;
  cursor: pointer; display: grid; place-items: center; font-size: 12px; color: #fff; background: rgba(0, 0, 0, .65); }

/* Файл над панелью — подсветка, куда отпустить. */
.cs-panel.sc-drop { box-shadow: inset 0 0 0 2px var(--teal), var(--shadow-pop); }

/* Снимки в ленте: превью, по нажатию — полный размер во вкладке. */
.cs-feed .sc-files { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.cs-feed .sc-b.only-files { padding: 6px; }
.cs-feed .sc-b.only-files .sc-files { margin: 0; }
.cs-feed .sc-file { display: block; border-radius: 9px; overflow: hidden; line-height: 0; }
.cs-feed .sc-file img { max-width: 200px; max-height: 200px; display: block; object-fit: cover; }
/* Картинка базы знаний в ответе помощника — на своём месте в тексте и крупнее снимка. */
.cs-feed .sc-pic { margin: 8px 0; width: max-content; max-width: 100%; }
.cs-feed .sc-pic img { max-width: 100%; max-height: 340px; object-fit: contain; }

/* ---- лента ---- */
.cs-feed .sc-m { display: flex; flex-direction: column; max-width: 86%; gap: 3px; }
.cs-feed .sc-m.user { align-self: flex-end; align-items: flex-end; }
.cs-feed .sc-m.agent, .cs-feed .sc-m.operator { align-self: flex-start; }
.cs-feed .sc-who { font-size: 11px; font-weight: 700; color: var(--muted); padding: 0 4px; }
.cs-feed .sc-m.operator .sc-who { color: var(--amber); }
.cs-feed .sc-b { padding: 9px 12px; border-radius: 14px; font-size: 14px; line-height: 1.45;
  white-space: pre-wrap; overflow-wrap: anywhere; }
.cs-feed .sc-b a { color: var(--teal); text-decoration: underline; }
.cs-feed .sc-m.user .sc-b { background: linear-gradient(120deg, rgba(45, 226, 197, .24), rgba(63, 140, 255, .18));
  border: 1px solid rgba(45, 226, 197, .3); border-bottom-right-radius: 5px; }
.cs-feed .sc-m.agent .sc-b { background: rgba(255, 255, 255, .05); border: 1px solid var(--lg-brd); border-bottom-left-radius: 5px; }
.cs-feed .sc-m.operator .sc-b { background: rgba(255, 159, 10, .08); border: 1px solid rgba(255, 159, 10, .3); border-bottom-left-radius: 5px; }
.cs-feed .sc-time { font-size: 10.5px; color: var(--dim); padding: 0 4px; font-family: var(--num); }
.cs-feed .sc-sys { align-self: center; max-width: 92%; text-align: center; font-size: 12px; color: var(--muted);
  padding: 5px 11px; border-radius: 10px; background: rgba(255, 255, 255, .04); }
.cs-feed .sc-div { display: flex; align-items: center; gap: 10px; margin: 4px 0; color: var(--dim); font-size: 11px; }
.cs-feed .sc-div::before, .cs-feed .sc-div::after { content: ''; flex: 1; height: 1px; background: var(--lg-brd); }
.cs-feed .sc-typing .sc-b { display: flex; gap: 5px; padding: 13px 15px; }
.cs-feed .sc-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: csdot 1.2s infinite ease-in-out; }
.cs-feed .sc-typing i:nth-child(2) { animation-delay: .15s; }
.cs-feed .sc-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes csdot { 0%, 80%, 100% { opacity: .25; transform: none; } 40% { opacity: 1; transform: translateY(-3px); } }
.cs-feed .sc-empty { margin: auto 0 0; display: flex; flex-direction: column; gap: 12px; }
.cs-feed .sc-empty-tx { font-size: 13px; line-height: 1.55; color: var(--muted); }
.cs-feed .sc-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.cs-feed .sc-chip { padding: 8px 12px; border-radius: 999px; cursor: pointer; font: inherit; font-size: 12.5px;
  color: var(--text); background: rgba(255, 255, 255, .04); border: 1px solid var(--lg-brd); }
.cs-feed .sc-chip:hover { border-color: rgba(45, 226, 197, .5); }

@media (min-width: 768px) {
  /* Панель у правого края, без подложки: консоль под ней остаётся рабочей. */
  .cs-panel {
    inset: auto 16px 16px auto; width: 400px; height: min(640px, calc(100dvh - 32px));
    border-radius: 20px; border: 1px solid var(--lg-brd); box-shadow: var(--shadow-pop);
  }
}
