/* ========== CHAT WIDGET — AlumiCalc ========== */
/* Isolado com prefixo .ac-chat para não interferir com estilos existentes */

/* Botão flutuante — posição controlada pelo wrapper #ac-chat-btn-wrap */
.ac-chat-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #1565C0;
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(21,101,192,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  transition: transform .2s, box-shadow .2s;
}
.ac-chat-btn:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(21,101,192,.55); }
.ac-chat-btn .ac-chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #E53935;
  color: #fff;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  display: none;
}

/* Janela do chat */
.ac-chat-window {
  position: fixed;
  bottom: 90px;
  left: 220px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,.18);
  display: flex;
  flex-direction: column;
  z-index: 9991;
  overflow: hidden;
  animation: acChatSlideUp .25s ease;
}
@keyframes acChatSlideUp {
  from { opacity: 0; transform: translateY(20px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
.ac-chat-header {
  background: linear-gradient(135deg, #1565C0, #0D47A1);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.ac-chat-header img { width: 36px; height: 36px; border-radius: 50%; background: #fff; padding: 2px; }
.ac-chat-header .ac-chat-title { font-weight: 600; font-size: 15px; }
.ac-chat-header .ac-chat-subtitle { font-size: 11px; opacity: .85; }
.ac-chat-header .ac-chat-close {
  margin-left: auto;
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  opacity: .8;
  line-height: 1;
}
.ac-chat-header .ac-chat-close:hover { opacity: 1; }

/* Status online/offline */
.ac-chat-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #aaa;
  flex-shrink: 0;
}
.ac-chat-status-dot.online { background: #4CAF50; }

/* Formulário inicial */
.ac-chat-form {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}
.ac-chat-form h6 { font-size: 14px; color: #333; margin-bottom: 12px; }
.ac-chat-form .form-control, .ac-chat-form .form-select {
  font-size: 13px;
  margin-bottom: 8px;
}
.ac-chat-form .btn { font-size: 13px; width: 100%; }

/* Área de mensagens */
.ac-chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f5f7fa;
}
.ac-chat-msgs::-webkit-scrollbar { width: 4px; }
.ac-chat-msgs::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

/* Balões de mensagem */
.ac-msg {
  max-width: 80%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
}
.ac-msg.usuario {
  background: #1565C0;
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.ac-msg.operador {
  background: #fff;
  color: #333;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.ac-msg.sistema {
  background: #E3F2FD;
  color: #1565C0;
  align-self: center;
  font-size: 11px;
  border-radius: 8px;
  text-align: center;
  max-width: 90%;
}
.ac-msg-time {
  font-size: 10px;
  opacity: .6;
  margin-top: 3px;
  text-align: right;
}
.ac-msg.operador .ac-msg-time { text-align: left; }

/* Indicador digitando */
.ac-typing {
  align-self: flex-start;
  background: #fff;
  border-radius: 12px;
  padding: 8px 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  display: none;
}
.ac-typing span {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #aaa;
  border-radius: 50%;
  margin: 0 2px;
  animation: acTyping 1.2s infinite;
}
.ac-typing span:nth-child(2) { animation-delay: .2s; }
.ac-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes acTyping {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* Input de mensagem */
.ac-chat-input {
  padding: 10px 12px;
  border-top: 1px solid #eee;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
  background: #fff;
}
.ac-chat-input textarea {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 13px;
  resize: none;
  max-height: 80px;
  outline: none;
  font-family: inherit;
}
.ac-chat-input textarea:focus { border-color: #1565C0; }
.ac-chat-input .ac-btn-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #1565C0;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  transition: background .15s;
}
.ac-chat-input .ac-btn-send:hover { background: #0D47A1; }
.ac-chat-input .ac-btn-attach {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: none;
  border: 1px solid #ddd;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.ac-chat-input .ac-btn-attach:hover { background: #f5f5f5; }

/* Ações extras */
.ac-chat-actions {
  padding: 6px 12px;
  border-top: 1px solid #f0f0f0;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  background: #fafafa;
}
.ac-chat-actions button {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 12px;
  border: 1px solid #ddd;
  background: #fff;
  color: #555;
  cursor: pointer;
}
.ac-chat-actions button:hover { background: #E3F2FD; border-color: #1565C0; color: #1565C0; }

/* Imagem no chat */
.ac-msg img { max-width: 200px; border-radius: 8px; cursor: pointer; }

/* Toast */
.ac-toast {
  position: fixed;
  bottom: 90px;
  right: 24px;
  background: #333;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 9995;
  animation: acFadeIn .3s;
  max-width: 280px;
}
@keyframes acFadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Mobile — chat em tela cheia APENAS em dispositivos touch (celular/tablet) */
@media (max-width: 767px) {
  .ac-chat-btn { display: none !important; }
  #ac-modal-remoto { display: none !important; }
  /* Botões de anexo e microfone visíveis no mobile */
  .ac-chat-input .ac-btn-attach {
    display: flex !important;
  }
}

/* Tela cheia APENAS em dispositivos móveis reais (não desktop com janela pequena) */
@media (max-width: 767px) and (pointer: coarse) {
  /* Janela do chat ocupa a tela toda no celular */
  .ac-chat-window {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    z-index: 9999 !important;
  }
}
