/* ==========================================================================
   Chat Widget Styles (Floating Drawer, Channels, Threads & File Previews)
   ========================================================================== */

:root {
  --chat-primary: #0d6efd;
  --chat-primary-hover: #0b5ed7;
  --chat-bg: #ffffff;
  --chat-header-bg: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
  --chat-bubble-self: #0d6efd;
  --chat-bubble-self-text: #ffffff;
  --chat-bubble-other: #f1f3f5;
  --chat-bubble-other-text: #212529;
  --chat-border: #e9ecef;
  --chat-text-muted: #6c757d;
  --chat-radius: 16px;
  --chat-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

/* Floating Launcher Button */
.chat-launcher-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
  color: #fff;
  border: none;
  box-shadow: 0 4px 15px rgba(30, 60, 114, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  z-index: 9999;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

html[dir="rtl"] .chat-launcher-btn {
  right: auto;
  left: 24px;
}

.chat-launcher-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(30, 60, 114, 0.5);
  color: #fff;
}

.chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background-color: #dc3545;
  color: #fff;
  border-radius: 10px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 700;
  border: 2px solid #fff;
  display: none;
}

html[dir="rtl"] .chat-badge {
  right: auto;
  left: -4px;
}

/* Main Chat Drawer Container */
.chat-widget-container {
  position: fixed;
  bottom: 95px;
  right: 24px;
  width: 400px;
  height: 600px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 120px);
  background: var(--chat-bg);
  border-radius: var(--chat-radius);
  box-shadow: var(--chat-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9998;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: all 0.25s ease-in-out;
  border: 1px solid rgba(0, 0, 0, 0.08);
  font-family: inherit;
}

html[dir="rtl"] .chat-widget-container {
  right: auto;
  left: 24px;
}

.chat-widget-container.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Chat Header */
.chat-widget-header {
  background: var(--chat-header-bg);
  color: #ffffff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-widget-header h5 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-header-actions .btn-chat-icon {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 15px;
  transition: all 0.2s;
}

.chat-header-actions .btn-chat-icon:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* Navigation Tabs */
.chat-nav-tabs {
  display: flex;
  background: #f8f9fa;
  border-bottom: 1px solid var(--chat-border);
  padding: 4px 8px;
  gap: 4px;
}

.chat-nav-tab {
  flex: 1;
  text-align: center;
  padding: 8px 4px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--chat-text-muted);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.chat-nav-tab i {
  font-size: 15px;
}

.chat-nav-tab:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--chat-primary);
}

.chat-nav-tab.active {
  background: #ffffff;
  color: var(--chat-primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

/* Views & Content */
.chat-widget-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.chat-view {
  display: none;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.chat-view.active {
  display: flex;
}

/* Search bar */
.chat-search-box {
  padding: 10px 14px;
  border-bottom: 1px solid var(--chat-border);
}

.chat-search-box input {
  width: 100%;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  border: 1px solid var(--chat-border);
  outline: none;
  background: #f8f9fa;
}

.chat-search-box input:focus {
  border-color: var(--chat-primary);
  background: #fff;
}

/* Item Lists (Users & Groups) */
.chat-item-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 0;
}

.chat-list-item {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid #f1f3f5;
  cursor: pointer;
  transition: background 0.15s;
  gap: 12px;
}

.chat-list-item:hover {
  background: #f8f9fa;
}

.chat-item-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #e9ecef;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #495057;
  font-size: 15px;
  flex-shrink: 0;
  position: relative;
}

.chat-item-avatar.group-avatar {
  background: #e0e7ff;
  color: #4338ca;
}

.chat-item-info {
  flex: 1;
  min-width: 0;
}

.chat-item-title {
  font-weight: 600;
  font-size: 13.5px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #212529;
}

.chat-item-sub {
  font-size: 11.5px;
  color: var(--chat-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Active Conversation View */
.chat-conversation-view {
  display: none;
  flex-direction: column;
  height: 100%;
  background: #ffffff;
}

.chat-conversation-view.active {
  display: flex;
}

.chat-conv-header {
  padding: 10px 14px;
  background: #f8f9fa;
  border-bottom: 1px solid var(--chat-border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-conv-back {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #495057;
  padding: 2px 6px;
  border-radius: 4px;
}

.chat-conv-back:hover {
  background: #e9ecef;
}

.chat-conv-title {
  flex: 1;
  min-width: 0;
}

.chat-conv-title h6 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-conv-title span {
  font-size: 11px;
  color: var(--chat-text-muted);
}

/* Message Stream */
.chat-messages-stream {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fdfdfd;
}

.chat-message-row {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  position: relative;
}

.chat-message-row.self {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-message-row.other {
  align-self: flex-start;
  align-items: flex-start;
}

.chat-message-sender {
  font-size: 11px;
  font-weight: 600;
  color: #6c757d;
  margin-bottom: 2px;
  padding: 0 4px;
}

.chat-bubble {
  padding: 9px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.45;
  word-break: break-word;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.chat-message-row.self .chat-bubble {
  background: var(--chat-bubble-self);
  color: var(--chat-bubble-self-text);
  border-bottom-right-radius: 3px;
}

.chat-message-row.self .chat-bubble .text-muted {
  color: rgba(255, 255, 255, 0.85) !important;
}

html[dir="rtl"] .chat-message-row.self .chat-bubble {
  border-bottom-right-radius: 14px;
  border-bottom-left-radius: 3px;
}

.chat-message-row.other .chat-bubble {
  background: var(--chat-bubble-other);
  color: var(--chat-bubble-other-text);
  border-bottom-left-radius: 3px;
}

html[dir="rtl"] .chat-message-row.other .chat-bubble {
  border-bottom-left-radius: 14px;
  border-bottom-right-radius: 3px;
}

.chat-message-time {
  font-size: 10px;
  color: #8c98a4;
  margin-top: 3px;
  padding: 0 4px;
}

.chat-message-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 3px;
  padding: 0 4px;
  font-size: 10.5px;
  color: #8c98a4;
}

.chat-read-status {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  line-height: 1;
}

.chat-read-status.sent {
  color: #adb5bd;
}

.chat-read-status.read {
  color: #0d6efd;
  font-weight: bold;
}

/* Online status dot */
.chat-avatar-wrapper {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 40px;
}

.online-status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #fff;
  background-color: #adb5bd;
}

.online-status-dot.online {
  background-color: #28a745;
  box-shadow: 0 0 6px #28a745;
}

html[dir="rtl"] .online-status-dot {
  right: auto;
  left: 0;
}

/* File & Image Attachments in Bubble */
.chat-image-attachment {
  max-width: 220px;
  max-height: 200px;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 4px;
  transition: transform 0.2s;
  display: block;
}

.chat-image-attachment:hover {
  transform: scale(1.02);
}

.chat-file-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.05);
  padding: 8px 12px;
  border-radius: 8px;
  margin-top: 4px;
  text-decoration: none;
  color: inherit;
  font-size: 12.5px;
}

.chat-message-row.self .chat-file-card {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.chat-file-card i {
  font-size: 22px;
}

.chat-file-meta {
  flex: 1;
  min-width: 0;
}

.chat-file-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-file-size {
  font-size: 10.5px;
  opacity: 0.8;
}

/* Attachment Pending Preview Bar */
.chat-attachment-preview {
  padding: 8px 14px;
  background: #eef2ff;
  border-top: 1px solid #dbeafe;
  display: none;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}

.chat-attachment-preview.active {
  display: flex;
}

/* Composer Bar */
.chat-composer {
  padding: 10px 12px;
  border-top: 1px solid var(--chat-border);
  background: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-composer textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--chat-border);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 13px;
  outline: none;
  height: 38px;
  max-height: 80px;
  line-height: 1.4;
  background: #f8f9fa;
  font-family: inherit;
}

.chat-composer textarea:focus {
  border-color: var(--chat-primary);
  background: #fff;
}

.chat-composer-btn {
  background: transparent;
  border: none;
  color: var(--chat-primary);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.2s;
}

.chat-composer-btn:hover {
  background: #eef2ff;
}

.chat-composer-btn.send-btn {
  background: var(--chat-primary);
  color: #fff;
}

.chat-composer-btn.send-btn:hover {
  background: var(--chat-primary-hover);
}

/* Modal for Group Creation */
.chat-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 16px;
}

.chat-modal-backdrop.active {
  display: flex;
}

.chat-modal-box {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-height: 90%;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.chat-modal-header {
  padding: 12px 16px;
  background: #f8f9fa;
  border-bottom: 1px solid var(--chat-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-modal-body {
  padding: 14px 16px;
  overflow-y: auto;
  flex: 1;
}

.chat-modal-footer {
  padding: 10px 16px;
  background: #f8f9fa;
  border-top: 1px solid var(--chat-border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ==========================================================================
   WebRTC Video & Voice Call Overlay & Controls
   ========================================================================== */
.webrtc-call-overlay {
  position: fixed;
  top: 30px;
  right: 30px;
  width: 460px;
  height: 520px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 60px);
  background: #111827;
  border-radius: 18px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 10001;
  border: 1px solid rgba(255, 255, 255, 0.15);
  animation: callOverlayIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

html[dir="rtl"] .webrtc-call-overlay {
  right: auto;
  left: 30px;
}

.webrtc-call-overlay.active {
  display: flex;
}

@keyframes callOverlayIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.webrtc-call-header {
  padding: 12px 18px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 2;
}

.pulse-dot {
  animation: pulseDot 1.5s infinite;
}

@keyframes pulseDot {
  0% { opacity: 1; }
  50% { opacity: 0.4; }
  100% { opacity: 1; }
}

.webrtc-video-stage {
  flex: 1;
  position: relative;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.webrtc-remote-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #1f2937;
}

.webrtc-local-video {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 120px;
  height: 90px;
  border-radius: 10px;
  border: 2px solid #fff;
  object-fit: cover;
  background: #374151;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 5;
  transform: scaleX(-1); /* Mirror local video */
}

html[dir="rtl"] .webrtc-local-video {
  right: auto;
  left: 16px;
}

.webrtc-call-controls {
  padding: 14px 20px;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 2;
}

.btn-call-action {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-call-action:hover {
  background: rgba(255, 255, 255, 0.35);
  transform: scale(1.08);
}

.btn-call-action.btn-hangup {
  background: #dc3545;
}

.btn-call-action.btn-hangup:hover {
  background: #bb2d3b;
}

/* Avatar SVG Container Utilities */
.chat-item-avatar svg {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: block;
}

/* ==========================================================================
   New Enhancements: Badges, Voice Notes, Task Cards, Reactions, Lightbox
   ========================================================================== */

/* Tab Badges */
.chat-tab-badge {
  position: absolute;
  top: 4px;
  right: 6px;
  background-color: #dc3545;
  color: #fff;
  border-radius: 8px;
  padding: 1px 5px;
  font-size: 10px;
  font-weight: bold;
}
html[dir="rtl"] .chat-tab-badge {
  right: auto;
  left: 6px;
}

/* In-Conversation Search Bar */
.chat-conv-search-bar {
  padding: 8px 12px;
  background: #f8f9fa;
  border-bottom: 1px solid var(--chat-border);
  animation: slideDown 0.2s ease-out;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Pinned Announcement Banner */
.chat-pinned-banner {
  display: flex;
  align-items: center;
  padding: 7px 12px;
  background: #fff8e1;
  border-bottom: 1px solid #ffe082;
  font-size: 12px;
  color: #795548;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}
.chat-pinned-banner:hover {
  background: #ffecb3;
}

/* Voice Recording Bar */
.chat-voice-recording-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #fff5f5;
  border-top: 1px solid #fed7d7;
}
.recording-pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e53e3e;
  animation: pulseDot 1s infinite;
}
.voice-wave-animation {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 16px;
}
.voice-wave-animation span {
  width: 3px;
  height: 100%;
  background: #e53e3e;
  border-radius: 2px;
  animation: soundWave 1.2s infinite ease-in-out;
}
.voice-wave-animation span:nth-child(2) { animation-delay: 0.2s; }
.voice-wave-animation span:nth-child(3) { animation-delay: 0.4s; }
.voice-wave-animation span:nth-child(4) { animation-delay: 0.6s; }
.voice-wave-animation span:nth-child(5) { animation-delay: 0.8s; }
@keyframes soundWave {
  0%, 100% { height: 4px; }
  50% { height: 16px; }
}

/* Audio Player in Chat Bubble */
.chat-audio-bubble {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  min-width: 220px;
}
.chat-audio-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.25);
  color: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.15s;
}
.chat-message-row.other .chat-audio-btn {
  background: #e2e8f0;
  color: #2b6cb0;
}
.chat-audio-btn:hover {
  transform: scale(1.1);
}
.chat-audio-progress-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.chat-audio-slider {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
.chat-message-row.other .chat-audio-slider {
  background: #cbd5e0;
}
.chat-audio-time {
  font-size: 11px;
  opacity: 0.85;
}

/* Task Card in Message Bubble */
.chat-task-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 4px;
  color: #2d3748;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  max-width: 280px;
}
.chat-task-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-weight: bold;
  font-size: 13px;
  color: #2b6cb0;
}
.chat-task-card-body {
  font-size: 12px;
  color: #4a5568;
  margin-bottom: 8px;
}
.chat-task-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: #718096;
}

/* Message Hover Actions & Reaction Bar */
.chat-message-row {
  position: relative;
}
.chat-message-actions-bar {
  position: absolute;
  top: -12px;
  display: none;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  padding: 2px 6px;
  gap: 4px;
  z-index: 10;
}
.chat-message-row.self .chat-message-actions-bar {
  left: 12px;
}
.chat-message-row.other .chat-message-actions-bar {
  right: 12px;
}
.chat-message-row:hover .chat-message-actions-bar {
  display: flex;
}
.btn-reaction-emoji {
  background: none;
  border: none;
  font-size: 14px;
  cursor: pointer;
  padding: 2px;
  transition: transform 0.15s;
}
.btn-reaction-emoji:hover {
  transform: scale(1.3);
}

/* Reaction Badges Container below Bubble */
.chat-reactions-container {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 3px;
}
.reaction-pill {
  background: #edf2f7;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 1px 6px;
  font-size: 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  transition: background 0.15s;
}
.reaction-pill:hover {
  background: #e2e8f0;
}
.reaction-pill.reacted {
  background: #ebf8ff;
  border-color: #bee3f8;
  color: #2b6cb0;
  font-weight: bold;
}

/* Image Lightbox */
.chat-lightbox-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100000;
  animation: fadeIn 0.2s ease-in;
}
.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.lightbox-content img {
  max-width: 90vw;
  max-height: 80vh;
  border-radius: 8px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  object-fit: contain;
}
.lightbox-actions {
  margin-top: 12px;
  display: flex;
  gap: 12px;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ==========================================================================
   Reply / Quote Styling
   ========================================================================== */
.chat-reply-preview {
  display: none;
  background: #f1f5f9;
  border-right: 4px solid #3b82f6;
  padding: 6px 12px;
  border-radius: 6px 6px 0 0;
  margin: 0;
  align-items: center;
  justify-content: space-between;
  animation: slideUp 0.15s ease-out;
  border-bottom: 1px solid #e2e8f0;
}
.chat-reply-preview.active {
  display: flex !important;
}
.chat-reply-info {
  flex: 1;
  min-width: 0;
}
.chat-reply-sender {
  font-size: 11px;
  font-weight: 700;
  color: #2563eb;
  margin-bottom: 1px;
}
.chat-reply-snippet {
  font-size: 12px;
  color: #475569;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-quote-box {
  background: rgba(0, 0, 0, 0.05);
  border-right: 3px solid #3b82f6;
  border-radius: 4px;
  padding: 4px 8px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.chat-message-row.self .chat-quote-box {
  background: rgba(255, 255, 255, 0.2);
  border-right-color: #ffffff;
}
.chat-quote-sender {
  font-size: 10.5px;
  font-weight: 700;
  margin-bottom: 2px;
  color: #1e40af;
}
.chat-message-row.self .chat-quote-sender {
  color: #ffffff;
}
.chat-quote-text {
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.85;
}

/* ==========================================================================
   Typing Indicators
   ========================================================================== */
.chat-typing-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 0 4px;
  animation: fadeIn 0.2s ease-in;
}
.chat-typing-bubble {
  background: #e2e8f0;
  border-radius: 14px;
  padding: 6px 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.chat-typing-bubble span {
  width: 6px;
  height: 6px;
  background: #64748b;
  border-radius: 50%;
  animation: typingBounce 1.2s infinite ease-in-out;
}
.chat-typing-bubble span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-bubble span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40% { transform: translateY(-5px); opacity: 1; }
}

.chat-typing-subtitle-active {
  color: #16a34a !important;
  font-weight: 600;
  animation: pulseOpacity 1.5s infinite ease-in-out;
}
@keyframes pulseOpacity {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* ==========================================================================
   Video Attachment Player & PDF Previews
   ========================================================================== */
.chat-video-attachment {
  max-width: 100%;
  width: 320px;
  max-height: 240px;
  border-radius: 8px;
  outline: none;
  background: #000;
}
.chat-pdf-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 12px;
  color: #1e293b;
  text-decoration: none;
  margin-top: 4px;
  transition: all 0.2s;
}
.chat-pdf-card:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #1e293b;
}
.chat-pdf-icon {
  font-size: 24px;
  color: #ef4444;
}

/* ==========================================================================
   Emoji Picker Popover
   ========================================================================== */
.chat-emoji-popover {
  position: absolute;
  bottom: 60px;
  left: 14px;
  width: 310px;
  max-width: calc(100vw - 32px);
  height: 280px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
  display: none;
  flex-direction: column;
  z-index: 1000;
  overflow: hidden;
  animation: slideUp 0.15s ease-out;
}
.chat-emoji-popover.active {
  display: flex !important;
}
.chat-emoji-header {
  display: flex;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  padding: 4px;
  gap: 4px;
}
.chat-emoji-category-btn {
  flex: 1;
  background: none;
  border: none;
  padding: 4px;
  font-size: 16px;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s;
}
.chat-emoji-category-btn.active, .chat-emoji-category-btn:hover {
  background: #e2e8f0;
}
.chat-emoji-grid {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  align-content: start;
}
.chat-emoji-item {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: transform 0.1s, background 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-emoji-item:hover {
  background: #f1f5f9;
  transform: scale(1.25);
}

/* ==========================================================================
   Load More Messages Button / Infinite Scroll
   ========================================================================== */
.chat-load-more-container {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}
.chat-load-more-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #475569;
  padding: 4px 14px;
  border-radius: 16px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.chat-load-more-btn:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #0f172a;
}

@keyframes slideUp {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}


