/* WhatsApp Multi-User Styles */
:root {
  --whatsapp-green: #25d366;
  --whatsapp-dark: #075e54;
  --whatsapp-light: #dcf8c6;
  --whatsapp-gray: #f0f0f0;
}

/* Layout Principal */
#app {
  height: 100vh !important;
  width: 100vw !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
}

.container-fluid {
  flex: 1 !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  padding: 0 !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
}

.row {
  flex: 1 !important;
  margin: 0 !important;
  overflow: hidden !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
}

.col-md-4,
.col-lg-3 {
  height: 100% !important;
  max-height: 100vh !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  flex: 0 0 auto !important;
}

.col-md-8,
.col-lg-9 {
  height: 100% !important;
  max-height: 100vh !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  flex: 1 !important;
}

/* Regras globais para html e body - apenas quando há #app (página principal) */
html:has(#app) {
  height: 100%;
  width: 100%;
  overflow: hidden;
  margin: 0;
  padding: 0;
}

body:has(#app) {
  background-color: #f8f9fa;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  height: 100vh !important;
  width: 100vw !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  overflow: hidden !important;
  margin: 0 !important;
  padding: 0 !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
}

.conversation-card-body {
  gap: 4px;
}

.conversation-label-row {
  margin-top: 4px;
  gap: 6px;
}

.conversation-label-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.conversation-label-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  color: #fff;
  background: #25d366;
  line-height: 1.2;
}

.conversation-label-placeholder {
  font-size: 11px;
  color: #99a1a7;
}

.conversation-label-flow {
  background-color: #6c757d !important;
  color: #ffffff !important;
  cursor: help;
  margin-left: 4px;
}

.conversation-meta .badge {
  min-width: 18px;
}

.label-filter-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.label-filter-item:hover {
  background-color: #f0f2f5;
}

.label-filter-item.selected {
  background-color: #e7f8ef;
  color: #1f845a;
}

.label-filter-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #1b1f23;
}

.label-filter-swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  display: inline-block;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.label-filter-check {
  opacity: 0;
  transition: opacity 0.2s ease;
  font-size: 12px;
}

.label-filter-item.selected .label-filter-check {
  opacity: 1;
}

/* Header */
.navbar-brand {
  font-weight: bold;
}

/* WhatsApp Status */
.alert {
  border-radius: 10px;
  border: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.alert-success {
  background-color: var(--whatsapp-light);
  color: var(--whatsapp-dark);
}

.alert-warning {
  background-color: #fff3cd;
  color: #856404;
}

.alert-danger {
  background-color: #f8d7da;
  color: #721c24;
}

/* Cards */
.card {
  border: none !important;
  border-radius: 15px !important;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1) !important;
  height: 100% !important;
  max-height: 100vh !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

.card-header {
  background-color: white;
  border-bottom: 1px solid #e9ecef;
  border-radius: 15px 15px 0 0 !important;
  flex-shrink: 0 !important;
  z-index: 10 !important;
  position: relative !important;
}

.card-body {
  padding: 0 !important;
  flex: 1 !important;
  display: flex !important;
  flex-direction: column !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

/* Padding específico para cards de notas (não afeta o card principal da conversa) */
.card-body.note-card-body {
  padding: 1rem !important;
  display: block !important;
  flex-direction: column !important;
  overflow: visible !important;
  min-height: auto !important;
  height: auto !important;
  flex: none !important;
  position: relative !important;
}

/* Conversations List */
.list-group-item {
  border: none;
  border-bottom: 1px solid #f0f0f0;
  padding: 15px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.list-group-item:hover {
  background-color: #f8f9fa;
  transform: translateX(5px);
}

.list-group-item.active {
  background-color: var(--whatsapp-light);
  color: var(--whatsapp-dark);
  border-left: 4px solid var(--whatsapp-green);
}

.conversation-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

@keyframes conversationPulse {
  0% {
    box-shadow: 0 0 0 rgba(37, 211, 102, 0);
    transform: translateX(0);
  }
  50% {
    box-shadow: 0 0 12px rgba(37, 211, 102, 0.6);
    transform: translateX(2px);
  }
  100% {
    box-shadow: 0 0 0 rgba(37, 211, 102, 0);
    transform: translateX(0);
  }
}

.conversation-item.unread-pulse {
  border: 2px solid #28a745;
  background-color: #fff9c4;
  border-radius: 10px;
}

.list-group-item.unread-pulse {
  border: 2px solid #28a745;
  background-color: #fff9c4;
  border-radius: 10px;
}

.conversation-avatar {
  width: 50px;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background-color: var(--whatsapp-green);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  font-size: 18px;
  flex-shrink: 0;
}

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

.conversation-name {
  font-weight: 600;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-last-message {
  font-size: 0.9em;
  color: #6c757d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-time {
  font-size: 0.8em;
  color: #6c757d;
  white-space: nowrap;
}

.conversation-unread {
  background-color: var(--whatsapp-green);
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8em;
  font-weight: bold;
}

/* Messages Area - Barra de Rolagem Independente */
#messagesArea {
  background-color: #f0f0f0 !important;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23e0e0e0' fill-opacity='0.1'%3E%3Ccircle cx='30' cy='30' r='2'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E") !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  height: calc(100vh - 280px) !important;
  max-height: 100vh !important;
  min-height: 200px !important;
  padding: 20px !important;
  padding-bottom: 80px !important;
  flex: 1 !important;
  position: relative !important;
  border-radius: 8px !important;
  margin-bottom: 0 !important;
}

/* Padding extra quando uma conversa está aberta (input visível) */
#messagesArea.conversation-open {
  padding-bottom: 120px !important; /* Espaço extra para garantir que última mensagem fique visível */
}

/* Spacer no final das mensagens para garantir espaço acima do input */
#messagesSpacer {
  height: 80px;
  width: 100%;
  flex-shrink: 0;
}

/* Conversations List - Barra de Rolagem Independente */
#conversationsList {
  overflow-y: auto !important;
  overflow-x: hidden !important;
  height: calc(100vh - 180px) !important;
  max-height: calc(100vh - 180px) !important;
  min-height: 300px !important;
  padding: 10px !important;
  flex: 1 !important;
  position: relative !important;
  background-color: white !important;
  border-radius: 8px !important;
}

.message {
  margin-bottom: 15px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.message.sent {
  flex-direction: row-reverse;
}

.message-avatar {
  width: 35px;
  height: 35px;
  border-radius: 50%;
  background-color: var(--whatsapp-green);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  font-size: 14px;
  flex-shrink: 0;
}

.message-content {
  max-width: 70%;
  padding: 10px 15px;
  border-radius: 18px;
  position: relative;
  word-wrap: break-word;
}

.message-text {
  white-space: normal;
  margin: 0;
  padding: 0;
}
.message-text.text-only {
  white-space: pre-wrap;
}
.message-text.text-only:has(.audio-player) {
  white-space: normal;
}

.message.received .message-content {
  background-color: white;
  border-bottom-left-radius: 5px;
}

.message.sent .message-content {
  background-color: var(--whatsapp-light);
  border-bottom-right-radius: 5px;
}

.message-time {
  font-size: 0.75em;
  color: #6c757d;
  margin-top: 5px;
  text-align: right;
}

.message.sent .message-time {
  text-align: left;
}

.message-status {
  font-size: 0.7em;
  margin-left: 5px;
}

.message-status.sent {
  color: #6c757d;
}

.message-status.delivered {
  color: #6c757d;
}

.message-status.read {
  color: var(--whatsapp-green);
}

/* Message Input - Fixado na parte de baixo da área do chat */
#messageInput {
  background-color: white !important;
  border-radius: 0 0 15px 15px !important;
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  position: absolute !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  z-index: 1000 !important;
  border-top: 1px solid #e9ecef !important;
  padding: 15px !important;
  width: 100% !important;
  height: 80px !important;
  box-sizing: border-box !important;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1) !important;
  flex-shrink: 0 !important;
}

/* Forçar exibição do campo de input */
#messageInput.d-none {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* Estilização do formulário de envio */
#sendMessageForm {
  margin: 0 !important;
}

#messageText {
  border-radius: 25px !important;
  border: 1px solid #e9ecef !important;
  padding: 10px 15px !important;
  font-size: 14px !important;
}

#messageText:focus {
  border-color: var(--whatsapp-green) !important;
  box-shadow: 0 0 0 0.2rem rgba(37, 211, 102, 0.25) !important;
}

.btn-whatsapp {
  background-color: var(--whatsapp-green) !important;
  border-color: var(--whatsapp-green) !important;
  color: white !important;
  border-radius: 50% !important;
  width: 40px !important;
  height: 40px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.form-control:focus {
  border-color: var(--whatsapp-green);
  box-shadow: 0 0 0 0.2rem rgba(37, 211, 102, 0.25);
}

.btn-primary {
  background-color: var(--whatsapp-green);
  border-color: var(--whatsapp-green);
}

.btn-primary:hover {
  background-color: var(--whatsapp-dark);
  border-color: var(--whatsapp-dark);
}

/* Loading States */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid var(--whatsapp-green);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Responsive */
@media (max-width: 768px) {
  .col-md-4,
  .col-md-8 {
    margin-bottom: 20px;
  }

  .conversation-item {
    gap: 8px;
  }

  .conversation-avatar {
    width: 40px;
    aspect-ratio: 1 / 1;
    font-size: 16px;
  }

  .message-content {
    max-width: 85%;
  }
}

/* Animations */
.fade-in {
  animation: fadeIn 0.3s ease-in;
}

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

.slide-in {
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb {
  background: var(--whatsapp-green);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--whatsapp-dark);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1055;
}

.toast {
  min-width: 300px;
}

/* QR Code Display */
.qr-code-container {
  padding: 20px;
  background: white;
  border-radius: 10px;
  border: 2px solid #e9ecef;
}

.qr-code-text {
  font-family: "Courier New", monospace;
  font-size: 8px;
  line-height: 1;
  white-space: pre;
  background: white;
  padding: 10px;
  border-radius: 5px;
  border: 1px solid #ddd;
  max-width: 300px;
  margin: 0 auto;
}

/* Contact Avatar */
.contact-avatar .conversation-avatar {
  background: linear-gradient(
    135deg,
    var(--whatsapp-green),
    var(--whatsapp-dark)
  );
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Admin Panel */
.nav-tabs .nav-link {
  border: none;
  border-bottom: 2px solid transparent;
  color: #6c757d;
}

.nav-tabs .nav-link.active {
  border-bottom-color: var(--whatsapp-green);
  color: var(--whatsapp-green);
  background: none;
}

.nav-tabs .nav-link:hover {
  border-bottom-color: var(--whatsapp-green);
  color: var(--whatsapp-green);
}

/* Status Badges */
.badge {
  font-size: 0.75em;
}

/* WhatsApp Controls */
#whatsappControls {
  margin-top: -5px;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #6c757d;
}

.empty-state i {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* Loading States */
.loading-container {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid var(--whatsapp-green);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-right: 10px;
}

/* Message Status */
.message-status {
  font-size: 0.8em;
  margin-left: 5px;
}

.message-status.sent {
  color: #6c757d;
}

.message-status.delivered {
  color: #6c757d;
}

.message-status.read {
  color: var(--whatsapp-green);
}

/* Search Highlight */
.highlight {
  background-color: #fff3cd;
  padding: 2px 4px;
  border-radius: 3px;
}

/* Responsive Improvements */
@media (max-width: 768px) {
  .toast-container {
    top: 10px;
    right: 10px;
    left: 10px;
  }

  .toast {
    min-width: auto;
  }

  .qr-code-text {
    font-size: 6px;
    max-width: 250px;
  }

  #whatsappControls {
    float: none !important;
    margin-top: 10px;
    text-align: center;
  }

  #whatsappControls .btn {
    margin: 2px;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .qr-code-container {
    background: #2d3748;
    border-color: #4a5568;
  }

  .qr-code-text {
    background: #2d3748;
    border-color: #4a5568;
    color: #e2e8f0;
  }
}

/* Animation for new messages */
@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.fade-in {
  animation: messageSlideIn 0.3s ease-out;
}

/* Hover effects */
.list-group-item:hover {
  background-color: #f8f9fa;
  transform: translateX(2px);
  transition: all 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
  transition: all 0.2s ease;
}

/* Focus states */
.form-control:focus {
  border-color: var(--whatsapp-green);
  box-shadow: 0 0 0 0.2rem rgba(37, 211, 102, 0.25);
}

.btn:focus {
  box-shadow: 0 0 0 0.2rem rgba(37, 211, 102, 0.25);
}

/* Prevenir overflow horizontal e vertical */
* {
  box-sizing: border-box !important;
}

html:has(#app),
body:has(#app) {
  overflow: hidden !important;
  height: 100vh !important;
  width: 100vw !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
}

body:has(#app),
html:has(#app),
#app,
.container-fluid,
.row,
.col-md-4,
.col-lg-3,
.col-md-8,
.col-lg-9 {
  overflow-x: hidden !important;
  overflow-y: hidden !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
}

/* Forçar remoção de scroll geral - apenas quando há #app */
html:has(#app) {
  overflow: hidden !important;
  height: 100% !important;
  width: 100% !important;
}

body:has(#app) {
  overflow: hidden !important;
  height: 100vh !important;
  width: 100vw !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
}

/* Custom Scrollbars - Independentes */
/* Webkit browsers (Chrome, Safari, Edge) */

/* Barra de Rolagem dos Contatos */
#conversationsList::-webkit-scrollbar {
  width: 14px;
  background: transparent;
}

#conversationsList::-webkit-scrollbar-track {
  background: #f8f9fa;
  border-radius: 10px;
  border: 2px solid #e9ecef;
  margin: 5px;
}

#conversationsList::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #25d366 0%, #128c7e 100%);
  border-radius: 10px;
  border: 2px solid #f8f9fa;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#conversationsList::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #128c7e 0%, #075e54 100%);
  border: 2px solid #e9ecef;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

#conversationsList::-webkit-scrollbar-corner {
  background: #f8f9fa;
}

/* Barra de Rolagem das Mensagens */
#messagesArea::-webkit-scrollbar {
  width: 14px;
  background: transparent;
}

#messagesArea::-webkit-scrollbar-track {
  background: #f0f0f0;
  border-radius: 10px;
  border: 2px solid #e0e0e0;
  margin: 5px;
}

#messagesArea::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #25d366 0%, #128c7e 100%);
  border-radius: 10px;
  border: 2px solid #f0f0f0;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#messagesArea::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #128c7e 0%, #075e54 100%);
  border: 2px solid #e0e0e0;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

#messagesArea::-webkit-scrollbar-corner {
  background: #f0f0f0;
}

/* Firefox - Barras de Rolagem Independentes */
#conversationsList {
  scrollbar-width: thin;
  scrollbar-color: var(--whatsapp-green) #f8f9fa;
}

#messagesArea {
  scrollbar-width: thin;
  scrollbar-color: var(--whatsapp-green) #f0f0f0;
}

/* Smooth scrolling independente */
#conversationsList,
#messagesArea {
  scroll-behavior: smooth;
}

/* Garantir independência das áreas */
#conversationsList {
  isolation: isolate;
  contain: layout style;
}

#messagesArea {
  isolation: isolate;
  contain: layout style;
}

/* Barras de rolagem sempre visíveis */
#conversationsList::-webkit-scrollbar {
  width: 14px !important;
}

#messagesArea::-webkit-scrollbar {
  width: 14px !important;
}

/* Indicadores visuais de scroll */
#conversationsList::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 14px;
  height: 100%;
  background: linear-gradient(
    180deg,
    rgba(37, 211, 102, 0.1) 0%,
    transparent 50%,
    rgba(37, 211, 102, 0.1) 100%
  );
  pointer-events: none;
  border-radius: 0 8px 8px 0;
}

#messagesArea::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 14px;
  height: 100%;
  background: linear-gradient(
    180deg,
    rgba(37, 211, 102, 0.1) 0%,
    transparent 50%,
    rgba(37, 211, 102, 0.1) 100%
  );
  pointer-events: none;
  border-radius: 0 8px 8px 0;
}

/* Scrollbar for conversation items */
.conversation-item {
  scroll-margin: 10px;
}

/* Auto-scroll to bottom for messages */
#messagesArea {
  scroll-snap-type: y proximity;
}

.message:last-child {
  scroll-snap-align: end;
}

/* Video player styles */
.video-player {
  background: #000;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: transform 0.2s ease;
  width: 100%;
  height: auto;
}

.video-player:hover {
  transform: scale(1.02);
}

.video-player::-webkit-media-controls {
  background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.7));
}

.video-player::-webkit-media-controls-panel {
  background: rgba(0, 0, 0, 0.5);
}

.video-player::-webkit-media-controls-play-button {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
}

.video-player::-webkit-media-controls-timeline {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 5px;
}

.video-player::-webkit-media-controls-current-time-display,
.video-player::-webkit-media-controls-time-remaining-display {
  color: white;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

/* Media message container */
.media-message {
  margin: 4px 0;
  border-radius: 8px;
  overflow: hidden;
}

.media-message img,
.media-message video {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Document item styles */
.document-item {
  border: 1px solid #dee2e6;
  border-radius: 8px;
  background: #f8f9fa;
  transition: all 0.2s ease;
  cursor: pointer;
}

.document-item:hover {
  background: #e9ecef;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.document-item .file-icon {
  flex-shrink: 0;
}

.document-item .fw-bold {
  font-size: 0.9rem;
  line-height: 1.2;
}

.document-item .text-muted {
  font-size: 0.75rem;
}

.document-item .fa-download {
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.document-item:hover .fa-download {
  opacity: 1;
}

/* Audio Player - Estilo WhatsApp Simples */
.audio-message {
  display: inline-block;
  max-width: 320px;
  width: 100%;
}

.audio-player-whatsapp {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: white;
  border-radius: 8px;
  min-width: 240px;
  user-select: none;
}

.message.sent .audio-player-whatsapp {
  background: #dcf8c6;
}

/* Botão Play/Pause */
.audio-player-whatsapp .btn-circle {
  width: 45px;
  height: 45px;
  min-width: 45px;
  border-radius: 50%;
  background: none;
  border: none;
  color: #8696a0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: all 0.2s;
}

.audio-player-whatsapp .btn-circle:hover {
  color: #25d366;
}

.audio-player-whatsapp .btn-circle i {
  font-size: 30px;
}

/* Timeline Container */
.audio-player-whatsapp .flex-grow-1 {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0;
}

/* Linha de Progresso */
.audio-waveform {
  height: 6px;
  position: relative;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 3px;
  overflow: hidden;
}

.message.sent .audio-waveform {
  background: rgba(0, 0, 0, 0.1);
}

.progress-overlay {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0%;
  background: #25d366;
  transition: width 0.1s linear;
  pointer-events: none;
}

/* Ocultar waveform-bars (não será usado) */
.waveform-bars {
  display: none;
}

/* Tempo e Velocidade */
.audio-time {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: #667781;
}

.audio-time small {
  font-size: 11px;
  font-weight: 400;
}

.speed-button {
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 600;
  color: #667781;
  background: rgba(0, 0, 0, 0.06);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 30px;
}

.speed-button:hover {
  background: rgba(0, 0, 0, 0.12);
}

/* Avatar */
.audio-avatar {
  width: 36px;
  height: 36px;
  min-width: 36px;
}

.audio-avatar .rounded-circle {
  width: 36px;
  height: 36px;
  font-size: 14px;
  font-weight: 600;
  color: white;
  background: #8696a0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

/* Responsivo */
@media (max-width: 768px) {
  .audio-message {
    max-width: 280px;
  }
}

/* ===================== */
/* Vídeo nas mensagens   */
/* ===================== */
.message .video-message {
  width: 100%;
  max-width: 360px;
}
.message .video-message .chat-video {
  width: 100%;
  height: auto;
  aspect-ratio: 16/9;
  max-height: 280px;
  background: #000;
  border-radius: 8px;
  display: block;
  object-fit: contain;
}
.message .video-message .video-actions {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.message .video-message .video-actions .btn {
  padding: 2px 8px;
  font-size: 12px;
  line-height: 1.2;
}
.message .video-message .caption {
  margin-top: 6px;
  font-size: 12px;
  color: #6c757d;
}

/* ===================== */
/* Player estilo referência (.audio-player) */
/* ===================== */
.audio-player {
  --player-color-featured: #00e5c0;
  --player-color-background: #262d31;
  --player-color-text: #c5c6c8;
  --player-percent-played: 0;
  --player-current-time: "00:00";
  --player-current-date-time: "00:00";

  background: var(--player-color-background);
  display: inline-flex;
  width: 100%;
  border-radius: 0.4rem;
  padding: 0.5rem 1rem 0.5rem 0.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
  user-select: none;
  font-family: Arial, sans-serif;
  gap: 20px;
}

.audio-player + .audio-player {
  margin-top: 1rem;
}

.audio-player .player {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.audio-player .player .btn-play {
  display: flex;
  align-items: center;
  outline: none;
  appearance: none;
  cursor: pointer;
  background: none;
  height: 50px;
  width: 50px;
  border: 0;
  padding: 0 0.8rem 0 0.4rem;
}

.audio-player .player .btn-play:disabled {
  cursor: default;
}

.audio-player .player .btn-play .material-icons {
  color: var(--player-color-text);
  font-size: 38px;
  opacity: 0.8;
}

.audio-player .player .btn-play .material-icons:not(.icon-play),
.audio-player.playing .player .btn-play .material-icons:not(.icon-pause),
.audio-player.loading .player .btn-play .material-icons:not(.icon-loop) {
  display: none;
}

.audio-player.playing .player .btn-play .icon-pause {
  display: inline-block;
}

@keyframes audioPlayerLoad {
  to {
    transform: rotate(360deg);
  }
}

.audio-player.loading .player .btn-play {
  pointer-events: none;
}

.audio-player.loading .player .btn-play .material-icons {
  animation: audioPlayerLoad 1s linear infinite;
}

.audio-player.loading .player .btn-play .icon-loop {
  display: inline-block;
}

.audio-player .player .timeline {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  padding-bottom: 0;
  gap: 8px;
}

.audio-player .player .timeline .line {
  --line-height: 0.24rem;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  position: relative;
  height: 0.24rem;
  margin-top: 4px;
}

.audio-player .player .timeline .line::before {
  content: "";
  width: var(--player-percent-played);
  position: absolute;
  background: var(--player-color-featured);
  height: var(--line-height);
  border-radius: calc(var(--line-height) / 2);
}

.audio-player .player .timeline .line input[type="range"] {
  flex: 1;
  all: unset;
  appearance: none;
  background-color: initial !important;
  border: none;
  outline: none;
  width: 100%;
  position: relative;
}

.audio-player
  .player
  .timeline
  .line
  input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  background: var(--player-color-featured);
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 50%;
  margin-top: calc(var(--line-height) * -1.4);
}
.audio-player .player .timeline .line input[type="range"]::-moz-range-thumb {
  appearance: none;
  border: 0;
  background: var(--player-color-featured);
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 50%;
  margin-top: calc(var(--line-height) * -1.4);
}
.audio-player .player .timeline .line input[type="range"]::-ms-thumb {
  appearance: none;
  background: var(--player-color-featured);
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 50%;
  margin-top: calc(var(--line-height) * -1.4);
}

.audio-player
  .player
  .timeline
  .line
  input[type="range"]::-webkit-slider-runnable-track {
  background: rgba(255, 255, 255, 0.2);
  height: var(--line-height);
  border-radius: calc(var(--line-height) / 2);
}
.audio-player .player .timeline .line input[type="range"]::-moz-range-track {
  background: rgba(255, 255, 255, 0.2);
  height: var(--line-height);
  border-radius: calc(var(--line-height) / 2);
}
.audio-player .player .timeline .line input[type="range"]::-ms-track {
  background: rgba(255, 255, 255, 0.2);
  height: var(--line-height);
  border-radius: calc(var(--line-height) / 2);
}

.audio-player .player .timeline .data {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--player-color-text);
  position: relative;
  width: 100%;
  margin-top: 4px;
  padding-top: 2px;
}

.audio-player .player .timeline .data .current-time {
  font-variant-numeric: tabular-nums;
  min-width: 40px;
}

.audio-player .player .timeline .data .current-time::before {
  display: none; /* Remover conteúdo CSS variable duplicado */
}

.audio-player .player .timeline .data .time {
  display: flex;
  align-items: center;
  font-variant-numeric: tabular-nums;
  min-width: 40px;
  justify-content: flex-end;
}

.audio-player .player .timeline .data .time::before {
  display: none; /* Remover conteúdo CSS variable duplicado */
}

.audio-player .player .timeline .data .time .material-icons {
  font-size: 1rem;
  margin-left: 0.4rem;
  color: var(--player-color-featured);
}

.audio-player .player .btn-speed {
  display: flex;
  align-items: center;
  justify-content: center;
  outline: none;
  appearance: none;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  padding: 4px 10px;
  min-width: 40px;
  height: 28px;
  transition: all 0.2s ease;
}

.audio-player .player .btn-speed:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--player-color-featured);
}

.audio-player .player .btn-speed .speed-text {
  color: var(--player-color-text);
  font-size: 0.75rem;
  font-weight: 500;
  user-select: none;
}

.audio-player .player .btn-speed:hover .speed-text {
  color: var(--player-color-featured);
}

.audio-player .user {
  position: relative;
  width: 15px;
  height: 40px;
}

.audio-player .user img {
  width: 35px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.01);
}

.audio-player .user .material-icons {
  position: absolute;
  left: 0;
  bottom: 0;
  color: var(--player-color-featured);
  transform: translateX(-50%);
  font-size: 1.6rem;
  text-shadow: -1px -1px 0 var(--player-color-background),
    1px -1px 0 var(--player-color-background),
    -1px 1px 0 var(--player-color-background),
    1px 1px 0 var(--player-color-background);
}

/* Editar nome do contato - ícone na lista */
.conversation-edit-btn {
  margin-left: 6px;
  padding: 0 4px;
  border: none;
  background: transparent;
  color: #667781;
  opacity: 0.7;
  display: inline-flex;
  align-items: center;
}
.conversation-edit-btn:hover {
  opacity: 1;
  color: #25d366;
}
.conversation-item:hover .conversation-edit-btn {
  opacity: 1;
}

/* Áudio enviado (mine) */
.audio-player.mine {
  --player-color-background: #056162;
}

/* ======= Chat Video Message (isolado) ======= */
.video-message {
  max-width: 320px;
  width: 100%;
  margin: 2px 0;
}

.message.sent .video-message,
.message.received .video-message {
  display: block;
}

.video-message .chat-video {
  display: block;
  width: 100%;
  height: auto;
  max-height: 240px;
  background: #000;
  border-radius: 8px;
  object-fit: cover;
}

@media (max-width: 768px) {
  .video-message {
    max-width: 260px;
  }
  .video-message .chat-video {
    max-height: 200px;
  }
}

.video-message .video-actions {
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.video-message .video-actions .btn {
  padding: 2px 8px;
  font-size: 12px;
  line-height: 1.2;
}

.video-message .caption {
  margin-top: 6px;
  font-size: 0.85rem;
  color: #667781;
  white-space: pre-wrap;
  word-break: break-word;
}
