/* ========== استایل پیام‌ها ========== */
.msg-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.msg-row.me { flex-direction: row-reverse; }

.msg-row .mavatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,.07);
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  color: var(--muted);
  flex: 0 0 34px;
}
.msg-row .mavatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.msg {
  max-width: min(740px, 86%);
  padding: 10px 12px 25px 12px;
  border-radius: 18px;
  background: var(--bubble);
  border: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(0,0,0,.2);
  position: relative;
}
.msg.me { background: var(--bubbleMe); }

.msg .top {
  display: flex;
  gap: 10px;
  align-items: baseline;
  justify-content: space-between;
}
.msg .user { font-weight: 900; }
.msg .time {
  color: var(--muted);
  font-size: 12px;
  display: none; /* از time-bottom استفاده می‌شود */
}
.msg .body {
  white-space: pre-wrap;
  line-height: 1.65;
  margin-top: 4px;
  margin-bottom: 5px;
}
.msg .file {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
}
.msg .file .name { font-weight: 900; }
.msg .file .meta {
  color: var(--muted);
  font-size: 12px;
}
.msg .file img {
  max-width: 240px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.msg .time-bottom {
  position: absolute;
  bottom: 6px;
  left: 12px;
  color: var(--muted);
  font-size: 11px;
  opacity: 0.8;
}
.msg.me .time-bottom {
  left: auto;
  right: 12px;
}

/* حالت پیام خصوصی (DM) */
.msg-row.dm .mavatar { display: none !important; }
.msg-row.dm .msg .top { justify-content: flex-end; }
.msg-row.dm .msg .user { display: none; }
.msg-row.dm .msg { padding-bottom: 25px; }
.msg-row.dm.me .msg { margin-left: auto; margin-right: 0; }
.msg-row.dm:not(.me) .msg { margin-left: 0; margin-right: auto; }
.msg-row.dm { gap: 0; margin-bottom: 8px; }

/* ویس پیام */
.voice-message {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 15px;
  background: rgba(46,166,255,0.08);
  border-radius: 18px;
  border: 1px solid rgba(46,166,255,0.15);
  margin-top: 8px;
  position: relative;
  min-width: 200px;
  max-width: 300px;
}
.voice-message.voice-me { background: rgba(46,166,255,0.15); border-color: rgba(46,166,255,0.25); }
.voice-play-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
}
.voice-play-btn:hover {
  transform: scale(1.05);
  background: #1e90ff;
}
.voice-play-icon {
  color: white;
  font-size: 14px;
  margin-left: 2px;
}
.voice-waveform-display {
  flex: 1;
  height: 30px;
  background: rgba(255,255,255,0.05);
  border-radius: 15px;
  overflow: hidden;
  position: relative;
}
.voice-waveform-progress {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  background: rgba(46,166,255,0.2);
  transition: width 0.1s linear;
  z-index: 1;
}
.voice-waveform-display .voice-waveform-bars {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  padding: 0 8px;
}
.voice-waveform-display .voice-waveform-bar {
  background: var(--primary);
  opacity: 0.7;
  animation: none;
  height: 20px;
  margin: 0 1px;
}
.voice-duration {
  font-size: 12px;
  color: var(--muted);
  min-width: 40px;
  text-align: center;
  font-weight: 900;
}
.voice-play-btn.playing {
  background: linear-gradient(135deg, #ff6b6b, #ffa726);
  animation: pulse 1.5s infinite;
}