/* ============================================================================
   Техподдержка — офф-канвас панель чата с устройством (админка).
   Токены и примитивы (.btn, .badge, .backdrop) берутся из style.css.
   ========================================================================== */

/* ── Панель ──────────────────────────────────────────────────────────── */
.drawer {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 50;
  width: min(440px, 100vw);
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform 0.24s ease-out;
}
.drawer.is-open { transform: translateX(0); }

.drawer__head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 14px 13px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--card-2);
  flex: none;
}
.drawer__id { flex: 1; min-width: 0; }
.drawer__title {
  display: flex;
  align-items: baseline;
  gap: 9px;
  flex-wrap: wrap;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--fg);
  min-width: 0;
}
.drawer__sub {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--fg-muted);
  word-break: break-all;
}

/* ── Лента сообщений ─────────────────────────────────────────────────── */
.chat {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.chat__feed {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 18px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat__empty { margin: auto; padding: 30px 10px; text-align: center; color: var(--fg-subtle); font-size: 14px; }

/* разделитель даты */
.chat__day {
  align-self: center;
  margin: 6px 0 2px;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--card-2);
  border: 1px solid var(--border);
  color: var(--fg-muted);
  font-size: 12px;
  font-weight: 500;
}

.msg { max-width: 86%; display: flex; flex-direction: column; gap: 6px; }
.msg--in { align-self: flex-start; }
.msg--out { align-self: flex-end; align-items: flex-end; }

.msg__bubble {
  padding: 9px 13px;
  border-radius: var(--radius-md);
  background: var(--card-2);
  border: 1px solid var(--border);
  color: var(--fg);
  font-size: 14.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg--out .msg__bubble {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}
.msg__time { font-size: 11.5px; color: var(--fg-subtle); padding: 0 3px; }

/* картинки во вложениях */
.msg__shots { display: grid; gap: 4px; max-width: 100%; }
.msg__shots--one { grid-template-columns: minmax(0, 240px); }
.msg__shots--many { grid-template-columns: repeat(3, minmax(0, 80px)); }
.msg__shot {
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--card-2);
  cursor: zoom-in;
  line-height: 0;
}
.msg__shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.msg__shots--one .msg__shot img { max-height: 240px; }
.msg__shots--many .msg__shot { aspect-ratio: 1; }
.msg__shots--many .msg__shot img { aspect-ratio: 1; }

/* не-картинки — строкой-ссылкой */
.msg__file {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-2);
  color: var(--fg);
  font-size: 13.5px;
  text-decoration: none;
  min-width: 0;
}
.msg__file:hover { text-decoration: none; border-color: var(--border-strong); background: var(--card); }
.msg__file .icon { color: var(--fg-muted); }
.msg__file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg__file-size { color: var(--fg-muted); font-size: 12px; white-space: nowrap; }

/* ── Оверлей перетаскивания файлов ───────────────────────────────────── */
.chat__drop {
  position: absolute;
  inset: 8px;
  z-index: 5;
  display: grid;
  place-items: center;
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  background: var(--accent-soft);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.chat__drop[hidden] { display: none; }
.chat__drop > * { pointer-events: none; }
.chat__drop-text { color: var(--accent-ink); font-size: 14px; font-weight: 600; text-align: center; padding: 0 20px; }

/* ── Композер ────────────────────────────────────────────────────────── */
.composer {
  flex: none;
  border-top: 1px solid var(--border);
  background: var(--card-2);
  padding: 10px 12px 12px;
}
.composer__files {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 9px;
}
.composer__files[hidden] { display: none; }
.att {
  position: relative;
  width: 96px;
  height: 96px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--card);
  flex: none;
}
.att img { width: 100%; height: 100%; object-fit: cover; display: block; }
.att__doc {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  color: var(--fg-muted);
  font-size: 11px;
  line-height: 1.25;
  text-align: center;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.att__x {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  padding: 0;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 999px;
  background: rgba(10, 12, 16, 0.62);
  color: #fff;
  cursor: pointer;
}
.att__x:hover { background: rgba(10, 12, 16, 0.82); }
.att__x .icon { width: 13px; height: 13px; }

/* Ошибка отправки — строкой над полем ввода, без модалок */
.composer__err {
  margin-bottom: 8px;
  padding: 7px 11px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  border: 1px solid var(--danger-border);
  color: var(--danger);
  font-size: 13px;
  line-height: 1.4;
}
.composer__err[hidden] { display: none; }

.composer__row { display: flex; align-items: flex-end; gap: 7px; }
.composer__input {
  flex: 1;
  min-width: 0;
  resize: none;
  max-height: 120px;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--card);
  color: var(--fg);
  font: inherit;
  font-size: 14.5px;
  line-height: 1.4;
}
.composer__input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.composer__row .btn--icon { height: 38px; width: 38px; }

/* ── Лайтбокс ────────────────────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 4vh 4vw;
  background: rgba(6, 8, 12, 0.9);
  cursor: zoom-out;
  animation: fadeIn 0.14s ease-out;
}
.lightbox img {
  max-width: 92vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
}
.lightbox__close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
}
.lightbox__close:hover { background: rgba(255, 255, 255, 0.2); }

@media (max-width: 520px) {
  .drawer { width: 100vw; border-left: none; }
  .msg { max-width: 92%; }
}
