/* Chat WhatsApp Overlay */
.chat-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
}

.chat-container {
  background: white;
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
  height: 600px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

/* Header */
.chat-header {
  background: #075e54;
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-client-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-avatar {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-client-details h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.chat-phone {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  opacity: 0.8;
  margin-top: 2px;
}

.chat-close-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
}

.chat-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Messages Area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #e5ddd5;
  background-image: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23d4d4d4' fill-opacity='0.1'%3E%3Cpath d='M20 20c0 11.046-8.954 20-20 20v-40c11.046 0 20 8.954 20 20z'/%3E%3C/g%3E%3C/svg%3E");
}

.chat-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #666;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e0e0e0;
  border-top: 3px solid #25d366;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 12px;
}

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

.chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #666;
  text-align: center;
}

.chat-empty svg {
  margin-bottom: 16px;
  opacity: 0.5;
}

.chat-empty p {
  margin: 0 0 8px 0;
  font-weight: 500;
}

.chat-empty span {
  font-size: 14px;
  opacity: 0.7;
}

/* Date Divider */
.chat-date-divider {
  text-align: center;
  margin: 16px 0;
  position: relative;
}

.chat-date-divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(0, 0, 0, 0.1);
}

.chat-date-divider::after {
  content: attr(data-date);
  background: rgba(255, 255, 255, 0.9);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  color: #666;
  position: relative;
  z-index: 1;
}

/* Messages */
.chat-message {
  margin-bottom: 8px;
  display: flex;
}

.chat-message.enviada {
  justify-content: flex-end;
}

.chat-message.recebida {
  justify-content: flex-start;
}

.message-content {
  max-width: 70%;
  padding: 8px 12px;
  border-radius: 8px;
  position: relative;
}

.chat-message.enviada .message-content {
  background: #dcf8c6;
  border-bottom-right-radius: 2px;
}

.chat-message.recebida .message-content {
  background: white;
  border-bottom-left-radius: 2px;
}

.message-content p {
  margin: 0 0 4px 0;
  word-wrap: break-word;
  line-height: 1.4;
}

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

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

.message-status {
  font-size: 12px;
  line-height: 1;
}

.message-status.enviando {
  color: #999;
}

.message-status.enviada {
  color: #4fc3f7;
}

.message-status.entregue {
  color: #4fc3f7;
}

.message-status.lida {
  color: #25d366;
}

/* Input Area */
.chat-input-area {
  background: white;
  padding: 16px;
  border-top: 1px solid #e0e0e0;
}

.chat-input-container {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #f5f5f5;
  border-radius: 24px;
  padding: 8px 12px;
}

.chat-input {
  flex: 1;
  border: none;
  background: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  max-height: 100px;
  min-height: 20px;
}

.chat-input::placeholder {
  color: #999;
}

.chat-send-btn {
  background: #25d366;
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
  background: #128c7e;
  transform: scale(1.05);
}

.chat-send-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
}

/* Responsive */
@media (max-width: 768px) {
  .chat-overlay {
    padding: 0;
  }
  
  .chat-container {
    height: 100vh;
    max-width: none;
    border-radius: 0;
  }
  
  .chat-header {
    padding: 12px 16px;
  }
  
  .chat-messages {
    padding: 12px;
  }
  
  .chat-input-area {
    padding: 12px;
  }
}

/* Scrollbar personalizada */
.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

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

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