/* =====================================================
   CHAT AJAX - Atendimento em tempo real
   ===================================================== */

/* BOTÃO FLUTUANTE DO CHAT */
.chat-float-btn {
  position: fixed;
  bottom: 100px;
  right: 25px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0f766e 0%, #0d5a54 100%);
  color: white;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  z-index: 99;
  transition: all 200ms ease;
}

.chat-float-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.chat-float-btn:active {
  transform: scale(0.95);
}

.chat-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ef4444;
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* MODAL DO CHAT */
.chat-modal {
  display: none;
  position: fixed;
  bottom: 80px;
  right: 25px;
  width: 360px;
  height: 500px;
  background: white;
  border-radius: 1rem;
  border: 1px solid #e5e7eb;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  z-index: 99;
  flex-direction: column;
  animation: slideUp 300ms ease-out;
}

.chat-modal.open {
  display: flex;
}

/* HEADER DO CHAT */
.chat-header {
  padding: 1rem;
  background: linear-gradient(135deg, #0f766e 0%, #0d5a54 100%);
  color: white;
  border-radius: 1rem 1rem 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.chat-close {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 1.5rem;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 150ms;
}

.chat-close:hover {
  opacity: 0.8;
}

/* ÁREA DE MENSAGENS */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: #fafbfb;
  -webkit-overflow-scrolling: touch;
}

.chat-message {
  display: flex;
  max-width: 80%;
  word-wrap: break-word;
  animation: fadeIn 200ms ease-out;
}

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

.chat-message.atendente {
  align-self: flex-start;
}

.chat-message-bubble {
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  font-size: 0.85rem;
  line-height: 1.4;
}

.chat-message.usuario .chat-message-bubble {
  background: linear-gradient(135deg, #0f766e 0%, #0d5a54 100%);
  color: white;
  border-radius: 1rem 0.25rem 0.75rem 0.75rem;
}

.chat-message.atendente .chat-message-bubble {
  background: #e5e7eb;
  color: #111827;
  border-radius: 0.25rem 1rem 0.75rem 0.75rem;
}

.chat-message-time {
  font-size: 0.7rem;
  opacity: 0.7;
  margin-top: 0.25rem;
  padding: 0 0.75rem;
}

.chat-empty {
  text-align: center;
  color: #6b7280;
  font-size: 0.85rem;
  padding: 1rem;
}

/* FORMULÁRIO */
.chat-form {
  padding: 1rem;
  border-top: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chat-input-group {
  display: flex;
  gap: 0.5rem;
}

.chat-form input[type="text"],
.chat-form textarea {
  padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  font-size: 0.85rem;
  background: white;
  resize: none;
  font-family: inherit;
}

.chat-form input[type="text"] {
  height: 36px;
}

.chat-form textarea {
  height: 60px;
}

.chat-form input:focus,
.chat-form textarea:focus {
  outline: none;
  border-color: #0f766e;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.1);
}

.chat-form .btn {
  margin: 0;
  font-size: 0.85rem;
}

.chat-msg-error {
  font-size: 0.75rem;
  color: #ef4444;
  margin: -0.25rem 0 0.5rem;
}

.chat-msg-success {
  font-size: 0.75rem;
  color: #10b981;
  margin: -0.25rem 0 0.5rem;
}

/* ESTADO: CARREGANDO */
.chat-loading {
  text-align: center;
  padding: 2rem 1rem;
  color: #6b7280;
}

.chat-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid #e5e7eb;
  border-top: 2px solid #0f766e;
  border-radius: 50%;
  animation: spin 600ms linear infinite;
}

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

/* RESPONSIVO */
@media (max-width: 480px) {
  .chat-modal {
    bottom: 80px;
    right: 10px;
    left: 10px;
    width: auto;
    max-width: calc(100% - 20px);
  }

  .chat-float-btn {
    right: 15px;
    bottom: 80px;
  }

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

@media (max-width: 430px) {
  .chat-modal {
    height: 400px;
  }

  .chat-form textarea {
    height: 50px;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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