/* ============================================
   AI Wezos — Widget Flutuante de Chat
   ============================================ */

/* -- Variáveis de Design -- */
:root {
  --aiwezos-primary: #1a73e8;
  --aiwezos-primary-dark: #1557b0;
  --aiwezos-primary-light: #e8f0fe;
  --aiwezos-bg: #ffffff;
  --aiwezos-bg-dark: #1e1e2e;
  --aiwezos-text: #202124;
  --aiwezos-text-light: #5f6368;
  --aiwezos-border: #e0e0e0;
  --aiwezos-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  --aiwezos-radius: 16px;
  --aiwezos-msg-user: linear-gradient(135deg, #1a73e8, #4285f4);
  --aiwezos-msg-ai: #f8f9fa;
  --aiwezos-success: #34a853;
  --aiwezos-error: #ea4335;
  --aiwezos-warning: #fbbc04;
}

/* -- Botão Flutuante -- */
#aiwezos-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: var(--aiwezos-msg-user);
  color: white;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(26, 115, 232, 0.4);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#aiwezos-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 24px rgba(26, 115, 232, 0.5);
}

#aiwezos-toggle svg {
  width: 28px;
  height: 28px;
}

#aiwezos-toggle.active {
  background: #5f6368;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

/* Pulse animation */
#aiwezos-toggle::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--aiwezos-primary);
  animation: aiwezos-pulse 2s infinite;
}

#aiwezos-toggle.active::after {
  display: none;
}

@keyframes aiwezos-pulse {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* -- Painel de Chat -- */
#aiwezos-panel {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 420px;
  max-height: 600px;
  background: var(--aiwezos-bg);
  border-radius: var(--aiwezos-radius);
  box-shadow: var(--aiwezos-shadow);
  z-index: 99998;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: bottom right;
}

#aiwezos-panel.aiwezos-hidden {
  opacity: 0;
  transform: scale(0.8) translateY(20px);
  pointer-events: none;
}

/* -- Header -- */
#aiwezos-header {
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.aiwezos-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.aiwezos-header-icon {
  font-size: 28px;
}

#aiwezos-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.aiwezos-status {
  font-size: 11px;
  opacity: 0.8;
  display: flex;
  align-items: center;
  gap: 4px;
}

.aiwezos-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--aiwezos-success);
  display: inline-block;
}

#aiwezos-minimize {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
  padding: 4px;
}

#aiwezos-minimize:hover {
  opacity: 1;
}

/* -- Área de Mensagens -- */
#aiwezos-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 420px;
  min-height: 300px;
  background: #fafbfc;
}

/* Scrollbar customizada */
#aiwezos-messages::-webkit-scrollbar {
  width: 4px;
}

#aiwezos-messages::-webkit-scrollbar-track {
  background: transparent;
}

#aiwezos-messages::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
}

/* -- Mensagens -- */
.aiwezos-msg {
  display: flex;
  max-width: 90%;
  animation: aiwezos-fadeIn 0.3s ease-out;
}

@keyframes aiwezos-fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.aiwezos-msg-user {
  align-self: flex-end;
}

.aiwezos-msg-ai {
  align-self: flex-start;
}

.aiwezos-msg-content {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.aiwezos-msg-user .aiwezos-msg-content {
  background: var(--aiwezos-msg-user);
  color: white;
  border-bottom-right-radius: 4px;
}

.aiwezos-msg-ai .aiwezos-msg-content {
  background: white;
  color: var(--aiwezos-text);
  border: 1px solid var(--aiwezos-border);
  border-bottom-left-radius: 4px;
}

.aiwezos-msg-content p {
  margin: 0 0 8px 0;
}

.aiwezos-msg-content p:last-child {
  margin-bottom: 0;
}

/* Tabelas nas respostas */
.aiwezos-msg-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 12px;
}

.aiwezos-msg-content table th,
.aiwezos-msg-content table td {
  padding: 6px 8px;
  border: 1px solid var(--aiwezos-border);
  text-align: left;
}

.aiwezos-msg-content table th {
  background: #f1f3f4;
  font-weight: 600;
}

/* Código/SQL nas respostas */
.aiwezos-msg-content code {
  background: #f1f3f4;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-family: 'Courier New', monospace;
}

.aiwezos-msg-content pre {
  background: #1e1e2e;
  color: #cdd6f4;
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 12px;
  margin: 8px 0;
}

/* Negrito e listas */
.aiwezos-msg-content strong {
  font-weight: 600;
}

.aiwezos-msg-content ul,
.aiwezos-msg-content ol {
  margin: 4px 0;
  padding-left: 20px;
}

/* -- SQL Toggle -- */
.aiwezos-sql-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding: 4px 10px;
  font-size: 11px;
  color: var(--aiwezos-text-light);
  background: #f1f3f4;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.aiwezos-sql-toggle:hover {
  background: #e0e0e0;
}

.aiwezos-sql-content {
  display: none;
  margin-top: 8px;
}

.aiwezos-sql-content.show {
  display: block;
}

/* -- Sugestões -- */
.aiwezos-examples-title {
  font-size: 12px;
  color: var(--aiwezos-text-light);
  margin-top: 8px !important;
}

.aiwezos-suggestions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.aiwezos-suggestion {
  padding: 8px 12px;
  font-size: 12px;
  background: var(--aiwezos-primary-light);
  color: var(--aiwezos-primary);
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}

.aiwezos-suggestion:hover {
  background: white;
  border-color: var(--aiwezos-primary);
}

/* -- Loading -- */
.aiwezos-loading {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
}

.aiwezos-loading-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--aiwezos-primary);
  animation: aiwezos-bounce 1.4s infinite ease-in-out both;
}

.aiwezos-loading-dot:nth-child(1) { animation-delay: -0.32s; }
.aiwezos-loading-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes aiwezos-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* -- Input Area -- */
#aiwezos-input-area {
  padding: 12px 16px;
  border-top: 1px solid var(--aiwezos-border);
  background: white;
}

#aiwezos-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

#aiwezos-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--aiwezos-border);
  border-radius: 24px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  background: #f8f9fa;
}

#aiwezos-input:focus {
  border-color: var(--aiwezos-primary);
  background: white;
}

#aiwezos-input::placeholder {
  color: #aaa;
}

#aiwezos-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--aiwezos-msg-user);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

#aiwezos-send:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(26, 115, 232, 0.3);
}

#aiwezos-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* -- Responsivo -- */
@media (max-width: 480px) {
  #aiwezos-panel {
    width: calc(100vw - 16px);
    right: 8px;
    bottom: 80px;
    max-height: calc(100vh - 100px);
  }
  
  #aiwezos-toggle {
    right: 16px;
    bottom: 16px;
    width: 52px;
    height: 52px;
  }
}
