/* ═══════════════════════════════════════════════
   DESKTOP MESSENGER — полный CSS
   ═══════════════════════════════════════════════ */

/* Оверлей (модалка по центру) */
#h1-messenger-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 3000;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

#h1-messenger-overlay.open {
  display: flex;
}

/* Окно мессенджера */
.h1-msg-window {
  width: 95%;
  max-width: 1200px;
  height: 85vh;
  max-height: 800px;
  background: var(--bg-surface);
  border-radius: 16px;
  display: flex;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border-color);
}

/* ═══ ЛЕВАЯ КОЛОНКА ═══ */
.h1-msg-sidebar {
  width: 340px;
  min-width: 340px;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  background: var(--bg-base);
}

.h1-msg-sidebar__head {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 8px;
}

.h1-msg-sidebar__title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
}

.h1-msg-sidebar__search {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}

.h1-msg-sidebar__search input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s;
}

.h1-msg-sidebar__search input:focus {
  border-color: var(--accent);
}

/* Вкладки */
.h1-msg-sidebar__tabs {
  display: flex;
  gap: 4px;
  padding: 8px 16px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border-color);
}

.h1-msg-sidebar__tabs::-webkit-scrollbar {
  display: none;
}

.h1-msg-tab {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s;
}

.h1-msg-tab:hover {
  background: rgba(255, 255, 255, 0.05);
}

.h1-msg-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Список чатов */
.h1-msg-chat-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.h1-msg-chat {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid transparent;
  transition: background 0.15s;
}

.h1-msg-chat:hover {
  background: rgba(255, 255, 255, 0.03);
}

.h1-msg-chat.active {
  background: rgba(124, 92, 255, 0.12);
  border-left: 3px solid var(--accent);
}

.h1-msg-chat__avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-elevated);
}

.h1-msg-chat__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.h1-msg-chat__top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.h1-msg-chat__top span:first-child {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.h1-msg-chat__preview {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ═══ ПРАВАЯ КОЛОНКА ═══ */
.h1-msg-chatarea {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-base);
  min-width: 0;
}

.h1-msg-chatarea__head {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-surface);
}

.h1-msg-chatarea__head .h1-msg-chat__avatar {
  width: 40px;
  height: 40px;
}

.h1-msg-chatarea__title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
}

.h1-msg-chatarea__status {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Превью вложений */
.h1-msg-pending {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 20px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
}

/* Сообщения */
.h1-msg-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.h1-msg-msg {
  display: flex;
  gap: 8px;
  max-width: 70%;
  align-self: flex-start;
}

.h1-msg-msg--mine {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.h1-msg-msg__body {
  background: var(--bg-elevated);
  border-radius: 16px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
  color: var(--text-primary);
}

.h1-msg-msg--mine .h1-msg-msg__body {
  background: var(--accent);
  color: #fff;
}

/* Форма ввода */
.h1-msg-form {
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--bg-surface);
}

.h1-msg-form button {
  flex-shrink: 0;
  transition: color 0.15s;
}

.h1-msg-form button:hover {
  color: var(--accent) !important;
}

.h1-msg-input {
  flex: 1;
  padding: 10px 16px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.h1-msg-input:focus {
  border-color: var(--accent);
}

/* ═══ ПРЕВЬЮ ВЛОЖЕНИЙ (PDA-стили) ═══ */
.pda-msgr-pending-item {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
}

.pda-msgr-pending-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pda-msgr-pending-item--audio,
.pda-msgr-pending-item--file {
  width: auto;
  min-width: 80px;
  padding: 0 12px;
  gap: 6px;
  font-size: 12px;
  color: var(--text-primary);
  background: rgba(124, 92, 255, 0.15);
}

.pda-msgr-pending-item--audio i { color: var(--accent); font-size: 16px; }
.pda-msgr-pending-item--file i { color: var(--text-secondary); font-size: 16px; }

.pda-msgr-pending-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.pda-msgr-pending-remove:hover {
  background: #ff4d6d;
}

/* ═══ АУДИО ПЛЕЕР ═══ */
.pda-voice {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  min-width: 200px;
  max-width: 100%;
}

.h1-msg-msg--mine .pda-voice {
  background: rgba(255, 255, 255, 0.2);
}

.pda-voice__play {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s;
}

.pda-voice__play:active {
  transform: scale(0.95);
}

.h1-msg-msg--mine .pda-voice__play {
  background: #fff;
  color: var(--accent);
}

.pda-voice__wave {
  flex: 1;
  height: 24px;
  position: relative;
  display: flex;
  align-items: center;
  cursor: pointer;
  background-image: repeating-linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.3) 0px,
    rgba(255, 255, 255, 0.3) 2px,
    transparent 2px,
    transparent 5px
  );
  background-size: 100% 12px;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.7;
}

.pda-voice__progress {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  background-image: repeating-linear-gradient(
    90deg,
    var(--accent) 0px,
    var(--accent) 2px,
    transparent 2px,
    transparent 5px
  );
  background-size: 100% 12px;
  background-position: center;
  background-repeat: no-repeat;
  border-radius: 999px;
  transition: width 0.1s linear;
}

.h1-msg-msg--mine .pda-voice__wave {
  background-image: repeating-linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.5) 0px,
    rgba(255, 255, 255, 0.5) 2px,
    transparent 2px,
    transparent 5px
  );
}

.h1-msg-msg--mine .pda-voice__progress {
  background-image: repeating-linear-gradient(
    90deg,
    #fff 0px,
    #fff 2px,
    transparent 2px,
    transparent 5px
  );
}

.pda-voice__time {
  font-size: 11px;
  color: var(--text-secondary);
  min-width: 32px;
  text-align: right;
  flex-shrink: 0;
}

.h1-msg-msg--mine .pda-voice__time {
  color: rgba(255, 255, 255, 0.9);
}

/* ═══ Светлая тема (если нужно) ═══ */
[data-bs-theme="light"] .h1-msg-window {
  background: #fff;
}

[data-bs-theme="light"] .h1-msg-sidebar {
  background: #f5f5f7;
}

[data-bs-theme="light"] .h1-msg-chatarea {
  background: #fff;
}

[data-bs-theme="light"] .h1-msg-msg__body {
  background: #f0f0f3;
}

[data-bs-theme="light"] .h1-msg-msg--mine .h1-msg-msg__body {
  background: var(--accent);
  color: #fff;
}
.h1-msg-msg:hover .h1-msg-actions {
  display: flex !important;
}
.h1-msg-actions {
  position: absolute;
  top: -10px;
  z-index: 10;
  display: none;
  gap: 4px;
  background: var(--bg-surface);
  padding: 4px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  transition: opacity 0.15s;
}

/* Для чужих сообщений — кнопки справа, для своих — слева */
.h1-msg-msg--mine .h1-msg-actions {
  left: -80px;
}
.h1-msg-msg:not(.h1-msg-msg--mine) .h1-msg-actions {
  right: -80px;
}

/* Скролл для вкладок */
.h1-msg-sidebar__tabs {
  overflow-x: auto;
  scrollbar-width: thin;
}
.h1-msg-sidebar__tabs::-webkit-scrollbar {
  height: 4px;
}
.h1-msg-sidebar__tabs::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

/* Кнопки действий */
.h1-msg-actions {
  transition: opacity 0.15s;
}
.h1-msg-msg:hover .h1-msg-actions {
  display: flex !important;
}

/* Выделение сообщения */
.h1-msg-msg.selected .h1-msg-msg__body {
  background: rgba(124, 92, 255, 0.2) !important;
}