/* Внутренний чат использует тот же визуальный каркас, что и «Сообщения».
 * Здесь остаются только специфичные для него элементы и функции. */

#view-staff-chat .staff-chat-sidebar__title-row {
  display: block;
}
#view-staff-chat .chat-sidebar__header {
  position: relative;
}
#view-staff-chat #staff-chat-new-btn {
  position: absolute;
  top: var(--sp-4);
  right: var(--sp-4);
  width: 40px;
  min-width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
}
#view-staff-chat #staff-chat-search {
  box-sizing: border-box;
  height: 40px;
  min-height: 40px;
  padding-top: 0;
  padding-bottom: 0;
  line-height: 40px;
}
#view-staff-chat .chat-convo-list__empty {
  padding: var(--sp-4);
}
#view-staff-chat .staff-chat-msg__content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}
#view-staff-chat .chat-msg--out .staff-chat-msg__content { align-items: flex-end; }
#view-staff-chat .chat-msg__author { margin: 0 0 3px var(--sp-2); }
#view-staff-chat .chat-msg__text {
  margin: 0;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
}
#view-staff-chat .chat-msg__actions {
  position: static;
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  width: 100%;
  height: 0;
  margin-top: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: height var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease);
}
#view-staff-chat .chat-msg:hover .chat-msg__actions,
#view-staff-chat .chat-msg:focus-within .chat-msg__actions {
  height: 26px;
  margin-top: 1px;
  opacity: 1;
  pointer-events: auto;
}
#view-staff-chat .staff-chat-msg__action {
  width: 26px;
  min-width: 26px;
  height: 26px;
  min-height: 26px;
  padding: 0;
  border: 0 !important;
  border-radius: 0;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--muted);
}
#view-staff-chat .staff-chat-msg__action:hover,
#view-staff-chat .staff-chat-msg__action:focus-visible {
  border: 0 !important;
  background: transparent !important;
  color: var(--text);
}
#view-staff-chat .staff-chat-msg__action:last-child:hover { color: var(--red); }
#view-staff-chat .chat-msg__ticks--double svg + svg { margin-left: -6px; }
#view-staff-chat .staff-chat-read-receipt {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
#view-staff-chat .chat-msg__media-frame .chat-msg__time {
  pointer-events: auto;
}
#view-staff-chat .chat-msg--deleted .chat-msg__bubble { opacity: 0.7; }
#view-staff-chat .staff-chat-msg--highlight .chat-msg__bubble,
#view-staff-chat .staff-chat-msg--highlight .chat-msg__media-frame,
#view-staff-chat .staff-chat-msg--highlight .chat-msg__media-footer {
  animation: staff-chat-message-highlight 1.35s ease-out;
}
@keyframes staff-chat-message-highlight {
  0%, 35% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--blue) 42%, transparent); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
#view-staff-chat .chat-msg__gif { max-width: 240px; border-radius: 10px; }
#view-staff-chat .staff-chat-pin {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}
#view-staff-chat .staff-chat-header__avatar,
#view-staff-chat .staff-chat-header__identity {
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
}
#view-staff-chat .staff-chat-header__avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--r-full);
}
#view-staff-chat .staff-chat-header__avatar.has-avatar { cursor: zoom-in; }
#view-staff-chat .staff-chat-header__identity { cursor: pointer; }
#view-staff-chat .staff-chat-header__identity:hover #staff-chat-active-title {
  text-decoration: underline;
}
#view-staff-chat #staff-chat-settings-btn {
  width: 40px;
  min-width: 40px;
  height: 40px;
  min-height: 40px;
}

.staff-chat-context-menu {
  position: fixed;
  z-index: 2600;
}

.staff-chat-readers-popover {
  position: fixed;
  z-index: 2650;
  min-width: 210px;
  max-width: min(300px, calc(100vw - 16px));
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg-raised);
  box-shadow: var(--shadow-lg, 0 8px 24px rgba(0, 0, 0, 0.18));
}
.staff-chat-readers-popover__title {
  padding: 4px 6px 8px;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
}
.staff-chat-readers-popover__row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 40px;
  padding: 4px 6px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
}
.staff-chat-readers-popover__row:hover { background: var(--bg-soft); }
.staff-chat-readers-popover__arrow {
  flex: 0 0 auto;
  margin-left: auto;
  color: var(--muted);
}

.staff-chat-editor { width: min(440px, calc(100vw - 32px)); }
dialog.modal.staff-chat-editor::backdrop { background: rgba(0, 0, 0, 0.55); }
.staff-chat-editor .input,
.staff-chat-editor .modal__footer .btn,
.staff-chat-editor #staff-chat-editor-avatar-btn {
  height: 40px;
  min-height: 40px;
}
.staff-chat-editor__close {
  width: 40px;
  min-width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: var(--r-md);
}
.staff-chat-editor__avatar-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  width: 100%;
  margin-bottom: var(--sp-4);
}
.staff-chat-editor__avatar {
  width: 72px;
  height: 72px;
  flex: 0 0 72px;
  font-size: 24px;
}
.staff-chat-editor__avatar-button {
  width: 72px;
  height: 72px;
  padding: 0;
  border: 0;
  border-radius: var(--r-full);
  background: transparent;
  cursor: pointer;
}
.staff-chat-editor__avatar-button:hover .staff-chat-editor__avatar,
.staff-chat-editor__avatar-button:focus-visible .staff-chat-editor__avatar {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* Attachments */
#view-staff-chat .staff-chat-attachment {
  display: flex; flex-direction: column; gap: 4px;
  padding: var(--sp-2, 8px);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
#view-staff-chat .staff-chat-attachment.chat-attachment--scanning { outline: 1px dashed #d4a04e; }
#view-staff-chat .staff-chat-attachment.chat-attachment--infected { outline: 1px solid #d94444; background: rgba(217,68,68,0.10); }
#view-staff-chat .chat-attachment__thumb { max-width: 240px; max-height: 240px; border-radius: 8px; }
#view-staff-chat .chat-attachment__file { display: flex; gap: var(--sp-2, 8px); align-items: center; }
#view-staff-chat .chat-attachment__icon { font-size: 20px; }
#view-staff-chat .staff-chat-attachment__download {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--blue);
  font: inherit;
  cursor: pointer;
}
#view-staff-chat .staff-chat-attachment__download:hover { text-decoration: underline; }
#view-staff-chat .staff-chat-attachment__download:disabled { opacity: 0.55; cursor: wait; }

/* Voice bubble */
#view-staff-chat .chat-voice {
  display: flex; align-items: center; gap: var(--sp-2, 8px);
  min-width: min(260px, 68vw);
}
#view-staff-chat .chat-voice audio {
  display: block;
  width: min(260px, 62vw);
  min-width: 220px;
  height: 36px;
}
#view-staff-chat .chat-voice .chat-msg__time {
  flex: 0 0 auto;
  margin-left: auto;
}

/* Все действия располагаются в той же строке ввода, что и в «Сообщениях». */
#view-staff-chat .staff-chat-composer {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: end;
}
#view-staff-chat .staff-chat-composer > .chat-attachments {
  grid-column: 1 / -1;
  width: 100%;
  padding: 0 0 var(--sp-2);
}
#view-staff-chat .chat-composer__toolbar {
  display: flex;
  gap: var(--sp-2);
}
#view-staff-chat .chat-composer__row {
  display: contents;
}
#view-staff-chat .chat-composer__toolbar .btn,
#view-staff-chat .chat-composer__row > .btn {
  width: 40px;
  min-width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
}
#view-staff-chat .staff-chat-composer .chat-input {
  height: 40px;
  min-height: 40px;
  padding-top: 9px;
  padding-bottom: 9px;
}
#view-staff-chat .chat-typing { padding: 0 var(--sp-3, 12px); }
#view-staff-chat .chat-reply-strip {
  grid-column: 1 / -1;
  padding: 4px var(--sp-2, 8px);
  border-left: 3px solid var(--blue);
  background: var(--bg-raised);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-2, 8px);
}

/* Popovers */
.staff-chat-popover {
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: var(--sp-2, 8px);
  min-width: 240px;
  max-width: 480px;
  padding: var(--sp-2, 8px);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg, 0 8px 24px rgba(0,0,0,0.24));
  z-index: 5;
  display: flex; flex-direction: column; gap: var(--sp-2, 8px);
}
.staff-chat-popover[hidden] { display: none; }
#staff-chat-attach-popover {
  flex-direction: row;
}
.staff-chat-popover__tile {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: var(--sp-3, 12px);
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 13px;
}
.staff-chat-popover__hint { font-size: 11px; }

/* Telegram-like chat information drawer. */
#view-staff-chat #staff-chat-window { position: relative; }
.staff-chat-info {
  position: absolute;
  inset: 0 0 0 auto;
  z-index: 20;
  display: flex;
  flex-direction: column;
  width: min(380px, 100%);
  background: var(--bg);
  border-left: 1px solid var(--line);
  box-shadow: -12px 0 32px rgba(15, 23, 42, 0.12);
}
.staff-chat-info[hidden] { display: none; }
.staff-chat-info__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line);
}
.staff-chat-info__close {
  display: grid;
  place-items: center;
  width: 40px;
  min-width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: var(--r-md);
  line-height: 0;
}
.staff-chat-info__profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: var(--sp-5) var(--sp-4);
  border-bottom: 1px solid var(--line);
  text-align: center;
}
.staff-chat-info__avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  margin-bottom: var(--sp-2);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: var(--bg-raised);
  color: var(--text);
  font-size: 28px;
}
.staff-chat-info__avatar:not(:disabled) { cursor: zoom-in; }
.staff-chat-info__avatar .avatar__initials,
.staff-chat-info__avatar .avatar__img { grid-area: 1 / 1; }
.staff-chat-info__avatar .avatar__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.staff-chat-info__tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}
.staff-chat-info__tab {
  height: 40px;
  min-height: 40px;
  padding: 0 6px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.staff-chat-info__tab:hover { color: var(--text); }
.staff-chat-info__tab.is-active {
  border-bottom-color: var(--blue);
  color: var(--blue);
}
.staff-chat-info__content {
  flex: 1;
  min-height: 0;
  padding: var(--sp-3);
  overflow-y: auto;
}
.staff-chat-info__empty {
  margin: var(--sp-6) 0;
  text-align: center;
}
.staff-chat-info__member-list { display: flex; flex-direction: column; }
.staff-chat-info__member {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  min-height: 56px;
  padding: 8px;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.staff-chat-info__member:hover { background: var(--bg-raised); }
.staff-chat-info__member-text { display: flex; flex-direction: column; min-width: 0; }
.staff-chat-info__member-arrow {
  flex: 0 0 auto;
  margin-left: auto;
  color: var(--muted);
}
.staff-chat-info__media-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}
.staff-chat-info__media {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 6px;
  background: var(--bg-raised);
  cursor: zoom-in;
}
.staff-chat-info__media img,
.staff-chat-info__media video { width: 100%; height: 100%; object-fit: cover; }
.staff-chat-info__media-play {
  position: absolute;
  inset: 50% auto auto 50%;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--r-full);
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  transform: translate(-50%, -50%);
}
.staff-chat-info__link,
.staff-chat-info__voice {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
}
.staff-chat-info__link { color: var(--blue); text-decoration: none; overflow-wrap: anywhere; }
.staff-chat-info__link:hover { background: var(--bg-raised); }
.staff-chat-info__voice audio { width: 100%; height: 40px; }

.staff-chat-popover--qr {
  align-items: center;
  padding: var(--sp-4, 16px);
}
.staff-chat-popover--qr img {
  background: #fff;
  padding: 8px;
  border-radius: 8px;
}

/* Voice recording row */
.staff-chat-voice {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: var(--sp-2, 8px);
  padding: var(--sp-2, 8px);
  background: rgba(217,68,68,0.10);
  border: 1px solid #d94444;
  border-radius: 10px;
}
.staff-chat-voice__dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #d94444;
  animation: staff-chat-voice-pulse 1s infinite;
}
@keyframes staff-chat-voice-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
.staff-chat-voice__timer { font-variant-numeric: tabular-nums; }

/* Кнопка-шестерёнка в карточке установленного модуля */
.store-settings-btn {
  width: 32px; height: 32px;
  padding: 0;
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border, rgba(255,255,255,0.10));
  background: rgba(255,255,255,0.04);
}
.store-settings-btn:hover { background: rgba(255,255,255,0.10); }

/* Модалка настроек интеграции (staff-chat и т.п.) */
.modal.modal--staff-chat-settings[hidden] { display: none; }
.modal.modal--staff-chat-settings {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
.modal.modal--staff-chat-settings .modal__backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(2px);
}
.modal.modal--staff-chat-settings .modal__panel {
  position: relative;
  max-width: 560px;
  width: min(560px, calc(100vw - 32px));
  max-height: 80vh;
  background: var(--surface-elevated, #1a1c22);
  border: 1px solid var(--border, rgba(255,255,255,0.10));
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.modal.modal--staff-chat-settings .modal__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-3, 12px) var(--sp-4, 16px);
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.08));
}
.modal.modal--staff-chat-settings .modal__body {
  padding: var(--sp-4, 16px);
  overflow-y: auto;
}
