/**
 * Componente Chat IA - Sistema SIDASP
 * Dropdown de assistente IA integrado na navbar
 * @version 1.0.0
 * @date 2025-11-14
 */

/* ========== CHAT IA WRAPPER ========== */
/* Botão do Chat - Integrado com a navbar */
.ia-chat-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  outline: none;
  position: relative;
}

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

.ia-chat-btn.active {
  background: rgba(255, 255, 255, 0.15);
}

/* Ícone SVG do Chat */
.ia-chat-icon {
  flex-shrink: 0;
}

/* Animação da seta quando ativo */
.ia-chat-btn.active .ia-arrow {
  transform: rotate(180deg);
}

/* Responsivo - ocultar label em telas pequenas */
@media (max-width: 768px) {
  .ia-label {
    display: none;
  }
}

/* ========== DROPDOWN DO CHAT ========== */
.ia-chat-dropdown {
  position: fixed;
  top: 60px;
  right: 20px;
  width: 400px;
  height: 560px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.2);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  animation: slideDown 0.2s ease-out;
}

.ia-chat-dropdown.active {
  display: flex;
}

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

/* Header do Chat */
.ia-chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.ia-chat-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ia-chat-title {
  font-size: 15px;
  font-weight: 600;
}

.ia-chat-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  opacity: 0.9;
}

.status-dot {
  width: 6px;
  height: 6px;
  background: #2ecc71;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.ia-chat-close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.2s;
}

.ia-chat-close:hover {
  background: rgba(255,255,255,0.15);
}

/* Área de Mensagens */
.ia-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f8f9fa;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ia-chat-messages::-webkit-scrollbar {
  width: 6px;
}

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

.ia-chat-messages::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: 3px;
}

/* Mensagem */
.msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 85%;
}

.msg-ia {
  align-self: flex-start;
}

.msg-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #e9ecef;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.msg-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  word-wrap: break-word;
}

.msg-ia .msg-bubble {
  background: #fff;
  color: #333;
  border: 1px solid #e9ecef;
  border-bottom-left-radius: 4px;
}

.msg-user .msg-bubble {
  background: #3498db;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg-bubble ul {
  margin: 8px 0 0 18px;
  padding: 0;
}

.msg-bubble li {
  margin: 4px 0;
}

.msg-time {
  font-size: 10px;
  color: #95a5a6;
  padding: 0 4px;
}

.msg-user .msg-time {
  text-align: right;
}

/* Input */
.ia-chat-input {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  background: #fff;
  border-top: 1px solid #e9ecef;
}

#iaChatInput {
  flex: 1;
  border: 1px solid #dfe4ea;
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 13px;
  font-family: inherit;
  resize: none;
  outline: none;
  transition: border 0.2s;
  max-height: 100px;
  line-height: 1.4;
}

#iaChatInput:focus {
  border-color: #3498db;
}

.ia-chat-send {
  width: 40px;
  height: 40px;
  border: none;
  background: #3498db;
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.ia-chat-send:hover {
  background: #2980b9;
  transform: scale(1.05);
}

.ia-chat-send:active {
  transform: scale(0.95);
}

/* ========== TYPING INDICATOR ========== */
.typing-dots {
  display: flex;
  gap: 4px;
  padding: 8px 0;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  background: #95a5a6;
  border-radius: 50%;
  animation: typingAnimation 1.4s infinite;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

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

/* ========== RESPONSIVO ========== */
@media (max-width: 768px) {
  .ia-chat-dropdown {
    width: 100vw;
    height: 100vh;
    top: 0;
    right: 0;
    left: 0;
    border-radius: 0;
  }

  .ia-label {
    display: none;
  }

  .ia-chat-btn {
    padding: 0.5rem;
  }
}

/* ========== DARK MODE ========== */
body.dark .ia-chat-dropdown {
  background: #1e293b;
}

body.dark .ia-chat-messages {
  background: #0f172a;
}

body.dark .msg-ia .msg-bubble {
  background: #334155;
  color: #e2e8f0;
  border-color: #475569;
}

body.dark .ia-chat-input {
  background: #1e293b;
  border-top-color: #334155;
}

body.dark #iaChatInput {
  background: #334155;
  color: #e2e8f0;
  border-color: #475569;
}
