/* ============================================================
   CHAT — Chat header, message bubbles, typing indicator,
   input bar, audio, file attachments, image messages
   ============================================================ */

/* ----- Chat Header (screen-chat) ----- */
.chat-header {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  justify-content: flex-start;
  gap: 8px;
}

.chat-header .avatar-wrap { width: 36px; height: 36px; }

.user-meta { flex: 1; margin-left: 10px; }
.user-meta h3 { font-size: 14px; color: var(--white); }
.online-status { font-size: 11px; opacity: 0.8; }

.chat-header-actions { display: flex; gap: 8px; }

/* ----- Chat Body ----- */
.chat-body {
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.encrypted-notice {
  background: var(--notice-bg);
  border: 1px solid var(--notice-border);
  border-radius: 10px;
  padding: 10px 15px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 11px;
  color: var(--amber-800);
}

.date-divider {
  text-align: center;
  font-size: 11px;
  background: var(--border-color);
  color: var(--text-muted);
  padding: 4px 12px;
  border-radius: 12px;
  align-self: center;
}

/* ----- Message Bubbles ----- */
.message-bubble { display: flex; flex-direction: column; max-width: 80%; }

.message-sent { align-self: flex-end; align-items: flex-end; }
.message-sent .bubble-content {
  background: var(--sent-bubble);
  color: var(--text-dark);
  border-radius: 16px 16px 2px 16px;
  padding: 12px 14px;
  font-size: 13px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.message-received { align-self: flex-start; flex-direction: row; gap: 8px; }

.avatar-small {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 4px;
  overflow: hidden;
}
.avatar-small i { width: 14px; height: 14px; }

.avatar-small-img {
  width: 28px;
  height: 28px;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
  flex-shrink: 0;
  margin-top: 4px;
  display: block;
}

.message-received .bubble-content {
  background: var(--card-bg);
  color: var(--text-dark);
  border-radius: 16px 16px 16px 2px;
  padding: 12px 14px;
  font-size: 13px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.bubble-content ul { margin-top: 8px; padding-left: 18px; }
.bubble-content li { margin-bottom: 4px; }

.message-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Error bubble */
.error-bubble {
  background: var(--red-100) !important;
  color: var(--red-800) !important;
}

/* ----- Typing Indicator ----- */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 14px;
  background: var(--card-bg);
  border-radius: 16px 16px 16px 2px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  max-width: 80px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: var(--gray-400);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ----- Chat Input Bar ----- */
.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  background: var(--card-bg);
  border-top: 1px solid var(--border-color);
}

.chat-input-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.chat-input-wrapper input {
  width: 100%;
  border: 1px solid var(--border-color);
  background: var(--gray-50);
  padding: 10px 36px 10px 14px;
  border-radius: 20px;
  font-size: 16px;
  outline: none;
}

.inside-input { position: absolute; right: 8px; }

#chat-input-field::placeholder {
  transition: color 0.3s;
}

/* ----- Audio Message ----- */
.audio-message {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
}

.audio-message audio {
  height: 36px;
  max-width: 200px;
}

.audio-message .audio-duration {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ----- File Attachment in Message ----- */
.file-attachment {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}

.file-attachment-preview {
  width: 60px;
  height: 60px;
  border-radius: 10px;
  object-fit: cover;
  object-position: center;
  flex-shrink: 0;
}

.file-attachment-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.file-attachment-name {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-attachment-size {
  font-size: 10px;
  color: var(--text-muted);
}

.file-attachment-download {
  font-size: 11px;
  color: var(--primary);
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

/* ----- Image Message ----- */
.message-image {
  max-width: 220px;
  border-radius: 12px;
  cursor: pointer;
  display: block;
}
