/**
 * WhatsApp Web Interface - CAPPES Admin Panel
 * Inspirado no WhatsApp Web com cores da marca CAPPES
 */

/* Container principal */
.whatsapp-container {
  display: flex;
  height: calc(100vh - 120px);
  background: #f0f0f0;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Coluna Esquerda - Lista de Conversas */
.conversations-sidebar {
  width: 380px;
  background: #fff;
  border-right: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
}

.conversations-header {
  padding: 15px;
  background: linear-gradient(135deg, #3d2817 0%, #5a3d28 100%);
  border-bottom: 1px solid rgba(212, 175, 55, 0.3);
}

.conversations-header input[type="search"] {
  width: 100%;
  padding: 10px 15px;
  border: none;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 14px;
  outline: none;
}

.conversations-header input[type="search"]::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

.conversations-list {
  flex: 1;
  overflow-y: auto;
  background: #fff;
}

/* Item de conversa */
.conversation-item {
  display: flex;
  align-items: center;
  padding: 12px 15px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.2s;
}

.conversation-item:hover {
  background: #f5f5f5;
}

.conversation-item.active {
  background: #ebebeb;
  border-left: 4px solid #D4AF37;
}

.conversation-item .avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, #D4AF37 0%, #c9a530 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: bold;
  margin-right: 12px;
  flex-shrink: 0;
}

.conversation-info {
  flex: 1;
  min-width: 0;
  margin-right: 8px;
}

.conversation-info h4 {
  margin: 0 0 4px 0;
  font-size: 16px;
  font-weight: 500;
  color: #3d2817;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-info .last-message {
  margin: 0;
  font-size: 13px;
  color: #667781;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.conversation-meta .time {
  font-size: 12px;
  color: #667781;
}

.conversation-meta .badge {
  background: #D4AF37;
  color: #fff;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: bold;
  min-width: 20px;
  text-align: center;
}

/* Coluna Direita - Chat Ativo */
.chat-window {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #e5ddd5;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: linear-gradient(135deg, #3d2817 0%, #5a3d28 100%);
  border-bottom: 1px solid rgba(212, 175, 55, 0.3);
  color: #fff;
}

.customer-info h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
}

.customer-info p {
  margin: 2px 0 0 0;
  font-size: 13px;
  opacity: 0.8;
}

.chat-actions button {
  background: rgba(212, 175, 55, 0.2);
  color: #fff;
  border: 1px solid rgba(212, 175, 55, 0.4);
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.chat-actions button:hover {
  background: rgba(212, 175, 55, 0.3);
  border-color: rgba(212, 175, 55, 0.6);
}

/* Área de mensagens */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="260" height="260"><defs><filter id="a"><feGaussianBlur stdDeviation="3"/></filter></defs><path fill="%23ffffff" fill-opacity=".05" d="M130 130L0 0v260h260V0z" filter="url(%23a)"/></svg>');
  background-size: 260px 260px;
}

/* Mensagens */
.message {
  display: flex;
  margin-bottom: 12px;
  animation: fadeIn 0.3s;
}

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

.message.received {
  justify-content: flex-start;
}

.message.sent {
  justify-content: flex-end;
}

.message-content {
  max-width: 65%;
  padding: 8px 12px;
  border-radius: 8px;
  position: relative;
  word-wrap: break-word;
}

.message.received .message-content {
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  border-bottom-left-radius: 0;
}

.message.sent .message-content {
  background: #dcf8c6;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  border-bottom-right-radius: 0;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
  margin-top: 4px;
  padding: 0 4px;
}

.message-meta .time {
  font-size: 11px;
  color: #667781;
}

.message-meta .status {
  font-size: 11px;
  color: #4fc3f7;
}

/* Input de mensagem */
.chat-input {
  background: #f0f0f0;
  padding: 12px 20px;
  border-top: 1px solid #e0e0e0;
}

.chat-input input[type="text"] {
  width: 100%;
  padding: 12px 15px;
  border: 1px solid #d0d0d0;
  border-radius: 24px;
  font-size: 14px;
  outline: none;
  transition: border 0.2s;
  margin-bottom: 8px;
}

.chat-input input[type="text"]:focus {
  border-color: #D4AF37;
}

.quick-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.quick-actions button {
  background: linear-gradient(135deg, #3d2817 0%, #5a3d28 100%);
  color: #fff;
  border: 1px solid #D4AF37;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.quick-actions button:hover {
  background: linear-gradient(135deg, #5a3d28 0%, #6b4a35 100%);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Estado vazio */
.empty-chat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #667781;
}

.empty-chat svg {
  width: 120px;
  height: 120px;
  margin-bottom: 20px;
  opacity: 0.3;
}

.empty-chat h3 {
  margin: 0 0 8px 0;
  font-size: 20px;
  font-weight: 400;
}

.empty-chat p {
  margin: 0;
  font-size: 14px;
}

/* Scrollbar personalizado */
.conversations-list::-webkit-scrollbar,
.messages-container::-webkit-scrollbar {
  width: 6px;
}

.conversations-list::-webkit-scrollbar-thumb,
.messages-container::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

.conversations-list::-webkit-scrollbar-thumb:hover,
.messages-container::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* Loading spinner */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(212, 175, 55, 0.3);
  border-radius: 50%;
  border-top-color: #D4AF37;
  animation: spin 0.8s linear infinite;
}

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

/* Responsive */
@media (max-width: 1024px) {
  .conversations-sidebar {
    width: 320px;
  }

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

@media (max-width: 768px) {
  .whatsapp-container {
    height: calc(100vh - 80px);
  }

  .conversations-sidebar {
    width: 100%;
    position: absolute;
    z-index: 10;
    display: none;
  }

  .conversations-sidebar.mobile-visible {
    display: flex;
  }

  .chat-window {
    width: 100%;
  }

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