/* ============================================
   kodassauro.css - Chatbot Kodda
   PAINEL MAIOR E BEM POSICIONADO
   ============================================ */

.kodassauro {
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 9999;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

/* ===== BALÃO DE SAUDAÇÃO INICIAL ===== */
.kodassauro-greeting-bubble {
  position: absolute;
  bottom: 85px; /* Mais próximo do botão */
  right: 0;
  width: 320px;
  background: #FFFFFF;
  border-radius: 20px 20px 4px 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  margin-bottom: 10px;
  border: 1px solid rgba(255, 138, 0, 0.1);
  animation: slideIn 0.3s ease-out;
  z-index: 10000;
}

/* Quando o painel abrir, esconder o balão */
.kodassauro.is-chat-open .kodassauro-greeting-bubble {
  display: none !important;
}

/* Classe utilitária para conteúdo acessível somente para leitores de tela */
.kodassauro-sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.greeting-header {
  display: flex;
  justify-content: flex-end;
  padding: 10px 10px 0 0;
}

.greeting-close-btn {
  background: transparent;
  border: none;
  color: #999;
  font-size: 1.2rem;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
  background: rgba(0, 0, 0, 0.05);
}

.greeting-close-btn:hover {
  background: #FF8A00;
  color: white;
  transform: scale(1.1);
}

.greeting-content {
  display: flex;
  padding: 0 20px 20px 20px;
  gap: 12px;
}

.greeting-emoji {
  font-size: 2.5rem;
  line-height: 1;
}

.greeting-text-wrapper {
  flex: 1;
}

.greeting-message {
  font-size: 1rem;
  line-height: 1.5;
  color: #333;
  margin: 0 0 4px 0;
}

.greeting-message strong {
  color: #FF8A00;
  font-weight: 700;
}

.greeting-brand {
  font-size: 0.75rem;
  color: #FF8A00;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.greeting-arrow {
  position: absolute;
  bottom: -8px;
  right: 30px;
  width: 16px;
  height: 16px;
  background: #FFFFFF;
  transform: rotate(45deg);
  border-right: 1px solid rgba(255, 138, 0, 0.1);
  border-bottom: 1px solid rgba(255, 138, 0, 0.1);
}

/* ===== BOTÃO TOGGLE ===== */
.kodassauro-toggle {
  position: relative;
  display: flex;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: #FF8A00;
  border: 3px solid white;
  box-shadow: 0 5px 20px rgba(255, 138, 0, 0.3);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  margin-left: auto;
}

.kodassauro-toggle:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 25px rgba(255, 138, 0, 0.4);
}

.kodassauro-icon-img {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  object-fit: cover;
}

.kodassauro-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #FF4444;
  color: white;
  font-size: 0.75rem;
  font-weight: bold;
  min-width: 22px;
  height: 22px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  border: 2px solid white;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* ===== GARANTIR QUE O PAINEL FIQUE SOBRE O CONTEÚDO ===== */
.kodassauro-panel {
  position: fixed ;
  bottom: 14px; 
  right: 10px; /* Alinhado à direita, mas com um pequeno espaço para não encostar na borda */
  width: 380px; /* Tamanho original */
  height: 580px; /* Um pouco menor que 600 para não ficar muito alto */
  max-height: calc(100vh - 20px);
  background: #F5F7FB;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(255, 138, 0, 0.1);
  animation: slideUp 0.3s ease-out;
  z-index: 10001;
}

@supports (height: 100dvh) {
  .kodassauro-panel {
    max-height: calc(100dvh - 20px);
  }
}

/* Header */
.kodassauro-header {
  background: linear-gradient(135deg, #0A1A2F 0%, #152B44 100%);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.kodassauro-avatar-img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid #FF8A00;
  background: white;
  padding: 2px;
}

.kodassauro-headings {
  flex: 1;
}

.kodassauro-title {
  color: white;
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
}

.kodassauro-subtitle {
  color: #FF8A00;
  font-size: 0.8rem;
  margin: 2px 0 0 0;
  opacity: 0.9;
  font-weight: 500;
  letter-spacing: 0.3px;
}

.kodassauro-header-actions {
  display: flex;
  gap: 8px;
}

.kodassauro-header-actions button {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.kodassauro-header-actions button:hover {
  background: #FF8A00;
  transform: scale(1.05);
}

.kodassauro-header-actions button i {
  font-size: 1.2rem;
}

/* Ícones sociais próximos ao avatar/identidade do chat */
.chat-social-icons {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 10px;
  padding: 0 16px 10px;
  background: #F5F7FB;
}

.chat-social-icons a {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #1e293b;
  color: #94a3b8;
  text-decoration: none;
  transition: all 0.2s ease;
}

.chat-social-icons a i {
  font-size: 1rem;
  line-height: 1;
}

.chat-social-icons a:hover {
  transform: translateY(-2px);
}

.chat-social-icons a:nth-child(1):hover {
  color: #E1306C; /* Instagram */
}

.chat-social-icons a:nth-child(2):hover {
  color: #0A66C2; /* LinkedIn */
}

.chat-social-icons a:nth-child(3):hover {
  color: #25D366; /* WhatsApp */
}

/* Social Bar */
.kodassauro-social-bar {
  padding: 12px;
  background: #FFFFFF;
  border-bottom: 1px solid #E9ECEF;
  display: flex;
  justify-content: center;
  gap: 8px;
}

.kodassauro-social-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #F8F9FA;
  color: #0A1A2F;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: all 0.2s ease;
  border: 1px solid #E9ECEF;
  text-decoration: none;
}

.kodassauro-social-btn:hover {
  background: #FF8A00;
  color: white;
  transform: translateY(-2px);
  border-color: #FF8A00;
}

/* ===== MENSAGENS ===== */
.kodassauro-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background: #F5F7FB;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Mensagem do Bot */
.message-bot {
  display: flex;
  gap: 10px;
  max-width: 85%;
  align-self: flex-start;
}

.message-bot-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: white;
  border: 1px solid #FF8A00;
  flex-shrink: 0;
}

.message-bot-content {
  background: #FFFFFF;
  padding: 12px 16px;
  border-radius: 18px 18px 18px 4px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  max-width: 100%;
  word-wrap: break-word; /* Quebrar palavras longas */
}

.message-bot-content p {
  margin: 0;
  color: #333;
  font-size: 0.95rem;
  line-height: 1.5;
}

.message-bot-content p strong {
  color: #FF8A00;
  font-weight: 700;
}

/* Mensagem do Cliente */
.message-user {
  display: flex;
  justify-content: flex-end;
  max-width: 85%;
  align-self: flex-end;
}

/* ===== MENSAGEM DO CLIENTE ===== */
.message-user-content {
  background: linear-gradient(135deg, #FF8A00 0%, #FF9F2E 100%);
  color: white;
  padding: 12px 16px;
  border-radius: 18px 18px 4px 18px;
  box-shadow: 0 2px 5px rgba(255, 138, 0, 0.2);
  max-width: 100%;
  word-wrap: break-word;
}

.message-user-content p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.5;
}

/* Timestamp */
.message-time {
  font-size: 0.7rem;
  color: #999;
  margin-top: 4px;
  display: block;
}

.message-user .message-time {
  color: rgba(255, 255, 255, 0.7);
  text-align: right;
}

/* Opções rápidas */
.kodassauro-quick {
  padding: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-top: 1px solid #E9ECEF;
  background: #FFFFFF;
}

/* ===== OPÇÕES RÁPIDAS ===== */
.quick-option {
  padding: 10px 18px;
  border-radius: 30px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
  flex: 1 0 auto;
  max-width: calc(50% - 4px);
  text-align: center;
  white-space: nowrap; /* Evitar quebra de texto */
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-chat-primary {
  background-color: #2563eb;
  border: none;
  color: #fff;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.btn-chat-primary:hover {
  background-color: #1d4ed8;
  transform: translateY(-2px);
}

.btn-chat-secondary {
  background: #1e293b;
  color: #cbd5f5;
  border: 1px solid #334155;
  border-radius: 999px;
}

.btn-chat-secondary:hover {
  background: #334155;
  color: #e2e8f0;
  transform: translateY(-2px);
  box-shadow: 0 5px 10px rgba(15, 23, 42, 0.28);
}

/* Composer */
.kodassauro-composer {
  padding: 16px;
  background: #FFFFFF;
  border-top: 1px solid #E9ECEF;
  display: flex;
  gap: 10px;
}

/* ===== COMPOSER ===== */
.kodassauro-input {
  flex: 1;
  padding: 12px 18px;
  border: 1px solid #E9ECEF;
  border-radius: 30px;
  font-size: 0.95rem;
  outline: none;
  transition: all 0.2s ease;
  background: #F8F9FA;
  width: 100%;
}

.kodassauro-input:focus {
  border-color: #FF8A00;
  background: #FFFFFF;
  box-shadow: 0 0 0 3px rgba(255, 138, 0, 0.1);
}

.kodassauro-send {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #FF8A00;
  border: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 5px 10px rgba(255, 138, 0, 0.2);
}

.kodassauro-send:hover {
  background: #e67e00;
  transform: scale(1.05);
  box-shadow: 0 8px 15px rgba(255, 138, 0, 0.3);
}

.kodassauro-send i {
  font-size: 1.2rem;
}

/* Animações */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes typingPulse {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.6; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ===== ANIMAÇÃO DE DIGITAÇÃO (OPCIONAL) ===== */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: #FFFFFF;
  border-radius: 18px 18px 18px 4px;
  width: fit-content;
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: #999;
  border-radius: 50%;
  animation: typingPulse 1.4s infinite;
}


.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

/* ===== AJUSTES MOBILE (garante topo do chat visível) ===== */
@media (max-width: 768px) {
  .kodassauro {
    right: 10px;
    bottom: max(8px, env(safe-area-inset-bottom));
  }

  .kodassauro-panel {
    left: 10px;
    right: 10px;
    width: auto;
    bottom: max(8px, env(safe-area-inset-bottom));
    height: min(
      580px,
      calc(100vh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom))
    );
    max-height: calc(100vh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    border-radius: 20px;
  }

  .kodassauro-greeting-bubble {
    width: min(320px, calc(100vw - 20px));
    right: 0;
  }

  .kodassauro-composer {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
}

@supports (height: 100dvh) {
  @media (max-width: 768px) {
    .kodassauro-panel {
      height: min(
        580px,
        calc(100dvh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom))
      );
      max-height: calc(100dvh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    }
  }
}
