/* ========================================
   RESET E VARIÁVEIS
   ======================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Cores Principais */
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --secondary: #8b5cf6;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;

  /* Cores de Fundo */
  --bg-main: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --bg-board: #f8fafc;
  --bg-column: #f1f5f9;
  --bg-card: #ffffff;
  --bg-modal: rgba(0, 0, 0, 0.6);

  /* Cores de Texto */
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-light: #94a3b8;

  /* Cores de Probabilidade */
  --prob-cold: #3b82f6;      /* Azul - Leads Frios */
  --prob-warm: #f59e0b;      /* Laranja - Leads Mornos */
  --prob-hot: #ef4444;       /* Vermelho - Leads Quentes */
  --prob-closing: #8b5cf6;   /* Roxo - Prontos para Fechar */
  --prob-success: #10b981;   /* Verde - Fechados */

  /* Sombras */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);

  /* Bordas */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Transições */
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   ESTILOS GLOBAIS
   ======================================== */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ========================================
   HEADER
   ======================================== */
.app-header {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  padding: 1.5rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 2rem;
}

.header-left {
  flex: 1;
}

.app-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.5rem;
}

.header-stats {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.stat {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.stat strong {
  color: var(--primary);
  font-weight: 700;
}

.header-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.btn-secondary {
  background: white;
  color: var(--primary);
  border: 2px solid var(--primary);
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition);
}

.btn-secondary:hover {
  background: var(--primary);
  color: white;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-add-card {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow);
}

.btn-add-card:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-add-card:active,
.btn-secondary:active {
  transform: translateY(0);
}

/* ========================================
   KANBAN BOARD
   ======================================== */
.kanban-board {
  display: flex;
  gap: 1.5rem;
  padding: 2rem;
  overflow-x: auto;
  min-height: calc(100vh - 120px);
  align-items: flex-start;
}

.kanban-board::-webkit-scrollbar {
  height: 12px;
}

.kanban-board::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

.kanban-board::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 10px;
}

.kanban-board::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

/* ========================================
   COLUNAS
   ======================================== */
.kanban-column {
  flex-shrink: 0;
  width: 340px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-lg);
  transition: var(--transition);
}

.kanban-column:hover {
  box-shadow: var(--shadow-xl);
}

.column-success {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.05) 0%, rgba(16, 185, 129, 0.1) 100%);
  border: 2px solid rgba(16, 185, 129, 0.2);
}

.column-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--bg-column);
}

.column-title {
  flex: 1;
}

.column-title h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.card-count {
  background: var(--bg-column);
  color: var(--text-secondary);
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
}

.cards-container {
  min-height: 100px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.cards-container.drag-over {
  background: var(--bg-column);
  border-radius: var(--radius);
  padding: 0.5rem;
  margin: -0.5rem;
}

/* ========================================
   BADGES DE PROBABILIDADE
   ======================================== */
.probability-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: inline-block;
}

.probability-badge.cold {
  background: rgba(59, 130, 246, 0.1);
  color: var(--prob-cold);
}

.probability-badge.warm {
  background: rgba(245, 158, 11, 0.1);
  color: var(--prob-warm);
}

.probability-badge.hot {
  background: rgba(239, 68, 68, 0.1);
  color: var(--prob-hot);
}

.probability-badge.closing {
  background: rgba(139, 92, 246, 0.1);
  color: var(--prob-closing);
}

.probability-badge.success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--prob-success);
}

/* ========================================
   CARDS DE LEADS
   ======================================== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1rem;
  cursor: grab;
  transition: var(--transition);
  box-shadow: var(--shadow);
  border: 2px solid transparent;
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--primary);
}

.card:active {
  cursor: grabbing;
}

.card.dragging {
  opacity: 0.5;
  transform: rotate(3deg);
  cursor: grabbing;
}

.lead-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.lead-product {
  display: inline-block;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.lead-probability {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.probability-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.probability-circle.cold {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2) 0%, rgba(59, 130, 246, 0.3) 100%);
  color: var(--prob-cold);
}

.probability-circle.warm {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2) 0%, rgba(245, 158, 11, 0.3) 100%);
  color: var(--prob-warm);
}

.probability-circle.hot {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.2) 0%, rgba(239, 68, 68, 0.3) 100%);
  color: var(--prob-hot);
}

.probability-circle.closing {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2) 0%, rgba(139, 92, 246, 0.3) 100%);
  color: var(--prob-closing);
}

.probability-label {
  flex: 1;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.lead-motivo {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  padding: 0.75rem;
  background: var(--bg-column);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
}

/* ========================================
   MODAL
   ======================================== */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-modal);
  backdrop-filter: blur(5px);
  animation: fadeIn 0.3s ease-out;
}

.modal.active {
  display: flex;
  justify-content: center;
  align-items: center;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.3s ease-out;
  position: relative;
}

.modal-import {
  max-width: 600px;
}

@keyframes slideUp {
  from {
    transform: translateY(50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.close-button {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  background: var(--bg-column);
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-secondary);
  z-index: 10;
}

.close-button:hover {
  background: var(--danger);
  color: white;
  transform: rotate(90deg);
}

.modal-header {
  padding: 2rem 2rem 1.5rem;
  border-bottom: 2px solid var(--bg-column);
}

.modal-title-section h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.modal-subtitle {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.product-tag {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 0.4rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
}

.probability-indicator {
  background: var(--bg-column);
  color: var(--primary);
  padding: 0.4rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 700;
}

.modal-body {
  padding: 2rem;
}

/* ========================================
   INFO CARDS (ANÁLISE DA IA)
   ======================================== */
.lead-info-grid {
  display: grid;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.info-card {
  background: var(--bg-column);
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  border-left: 4px solid var(--primary);
}

.info-card h4 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.ai-analysis {
  color: var(--text-secondary);
  line-height: 1.7;
  font-size: 0.95rem;
}

.probability-bar {
  width: 100%;
  height: 30px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 0.75rem;
  position: relative;
}

.probability-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--prob-cold) 0%, var(--prob-warm) 50%, var(--prob-hot) 75%, var(--prob-closing) 100%);
  border-radius: var(--radius);
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 0.75rem;
  color: white;
  font-weight: 700;
  font-size: 0.85rem;
}

.probability-text {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
}

/* ========================================
   MODAL DE IMPORTAÇÃO
   ======================================== */
.import-instructions {
  margin-bottom: 1.5rem;
}

.import-instructions h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.import-instructions p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.import-instructions pre {
  background: var(--bg-column);
  padding: 1rem;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 0.5rem 0;
  border-left: 3px solid var(--primary);
}

.import-instructions code {
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  color: var(--text-primary);
}

#json-input {
  width: 100%;
  padding: 1rem;
  border: 2px solid var(--bg-column);
  border-radius: var(--radius);
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  resize: vertical;
  min-height: 200px;
  transition: var(--transition);
  background: var(--bg-column);
  color: var(--text-primary);
}

#json-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.import-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

/* ========================================
   CHAT
   ======================================== */
.chat-section {
  background: var(--bg-column);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.chat-header {
  margin-bottom: 1.5rem;
}

.chat-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.social-integrations {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.social-btn {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: var(--shadow);
}

.social-btn:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.social-btn:active {
  transform: translateY(0);
}

.social-btn.whatsapp {
  background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
}

.social-btn.instagram {
  background: linear-gradient(135deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
}

.social-btn.telegram {
  background: linear-gradient(135deg, #2aabee 0%, #229ed9 100%);
}

.social-btn.messenger {
  background: linear-gradient(135deg, #00b2ff 0%, #006aff 100%);
}

.chat-messages {
  background: white;
  border-radius: var(--radius);
  padding: 1.5rem;
  min-height: 200px;
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}

.chat-messages::-webkit-scrollbar {
  width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
  background: var(--bg-column);
  border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--text-light);
  border-radius: 10px;
}

.chat-message {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  animation: messageIn 0.3s ease-out;
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-message.system {
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary);
  text-align: center;
}

.chat-message.user {
  background: var(--primary);
  color: white;
  margin-left: auto;
  max-width: 80%;
}

.chat-message.received {
  background: var(--bg-column);
  color: var(--text-primary);
  max-width: 80%;
}

.chat-message p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.5;
}

.chat-input-container {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

#chat-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 2px solid transparent;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
  min-height: 44px;
  max-height: 120px;
  transition: var(--transition);
  background: white;
  color: var(--text-primary);
}

#chat-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

#chat-input::placeholder {
  color: var(--text-light);
}

.btn-send {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  box-shadow: var(--shadow);
}

.btn-send:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-send:active {
  transform: translateY(0);
}

.btn-send svg {
  width: 18px;
  height: 18px;
}

/* ========================================
   RESPONSIVIDADE
   ======================================== */
@media (max-width: 968px) {
  .app-header {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .header-actions {
    justify-content: stretch;
  }

  .header-actions button {
    flex: 1;
  }
}

@media (max-width: 768px) {
  .app-header {
    padding: 1rem;
  }

  .app-header h1 {
    font-size: 1.5rem;
  }

  .header-stats {
    flex-direction: column;
    gap: 0.5rem;
  }

  .kanban-board {
    padding: 1rem;
  }

  .kanban-column {
    width: 280px;
  }

  .modal-content {
    width: 95%;
    max-height: 95vh;
  }

  .modal-header,
  .modal-body {
    padding: 1.5rem;
  }

  .chat-input-container {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-send {
    justify-content: center;
  }

  .import-actions {
    flex-direction: column;
  }
}

/* ========================================
   ANIMAÇÕES EXTRAS
   ======================================== */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.loading {
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes slideInRight {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(400px);
    opacity: 0;
  }
}
