/* ═══════════════════════════════════════════
   MESSAGES.CSS — пузыри, reply, реакции, выделение
   ═══════════════════════════════════════════ */

.message-wrap {
  display: flex;
  flex-direction: column;
  max-width: 75%;
  position: relative;
}

.message-wrap.out {
  align-self: flex-end;
  align-items: flex-end;
}

.message-wrap.in {
  align-self: flex-start;
  align-items: flex-start;
}

.message-wrap, .message {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.select-checkbox {
  position: absolute;
  left: -30px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: var(--sidebar);
  transition: all 0.2s;
}

.select-checkbox.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.message {
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
  position: relative;
  width: fit-content;
  max-width: 100%;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.out {
  background: var(--out);
  border-bottom-right-radius: 4px;
  color: var(--text);
}

.message.in {
  background: var(--in);
  border-bottom-left-radius: 4px;
  color: var(--text);
}

.message .time {
  font-size: 11px;
  color: var(--muted);
  margin-left: 8px;
  float: right;
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.message .time svg {
  color: var(--muted);
}

.message .time svg.read {
  color: var(--accent);
}

.message img {
  max-width: 100%;
  max-height: 320px;
  border-radius: 8px;
  display: block;
  margin-bottom: 4px;
  cursor: pointer;
  object-fit: contain;
}

.message video {
  width: 250px;
  max-width: 100%;
  height: 250px;
  border-radius: 8px;
  display: block;
  margin-bottom: 4px;
  cursor: pointer;
  object-fit: cover;
}

.message .caption {
  display: block;
}

.message-photo,
.message-video {
  padding: 4px;
}

.message-photo .time,
.message-video .time {
  position: absolute;
  bottom: 8px;
  right: 12px;
  background: rgba(0, 0, 0, 0.5);
  padding: 2px 6px;
  border-radius: 8px;
  margin: 0;
  color: #fff;
}

.message-sticker {
  background: transparent !important;
  padding: 0 !important;
  border-radius: 0 !important;
  margin: 8px 0 !important;
  border-left: none !important;
  max-width: 100%;
  overflow: hidden;
}

.message-sticker img {
  width: 150px;
  height: 150px;
  object-fit: contain;
  margin: 0;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
}

.message-sticker .time {
  position: absolute;
  bottom: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.5);
  padding: 2px 6px;
  border-radius: 8px;
  margin: 0;
  color: #fff;
}

.message-sticker .reactions-container {
  margin-top: 8px;
  padding-top: 8px;
  border-top: none;
}

.message-author-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  cursor: pointer;
  width: fit-content;
  flex-wrap: wrap;
}

.message-author-wrap:hover .message-author {
  text-decoration: underline;
}

.message-author-mini {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #5288c1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  overflow: hidden;
}

.message-author-mini img,
.message-author-mini video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  margin: 0;
  border-radius: 0;
}

.message-author {
  font-size: 12px;
  font-weight: 600;
  margin: 0;
}

.message-edited {
  font-size: 11px;
  color: var(--muted);
  margin-left: 4px;
  float: left;
  margin-top: 4px;
}

.forwarded-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 4px;
  display: block;
  cursor: pointer;
}

/* ═══ REPLY ═══ */
.reply-block {
  background: var(--reply-bg);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  padding: 4px 8px;
  margin-bottom: 6px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0.9;
  transition: opacity 0.2s;
  width: 100%;
}

.reply-block:hover {
  opacity: 1;
}

.reply-block .reply-author {
  font-weight: 600;
  color: var(--accent);
  font-size: 12px;
}

.reply-block .reply-text {
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.reply-preview-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--sidebar);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.reply-preview-content {
  flex: 1;
  border-left: 3px solid var(--accent);
  padding-left: 10px;
  overflow: hidden;
}

.reply-preview-author {
  font-weight: 600;
  color: var(--accent);
  font-size: 13px;
}

.reply-preview-text {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ═══ REACTIONS ═══ */
.reactions-container {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

[data-theme="light"] .reactions-container {
  border-top-color: rgba(0, 0, 0, 0.1);
}

.reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.2);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.1s;
}

.reaction-chip:hover {
  transform: scale(1.05);
  background: rgba(0, 0, 0, 0.3);
}

.reaction-chip.mine {
  border-color: var(--accent);
  background: rgba(100, 181, 239, 0.2);
}