/* CSS Design System - Dashboard Leads Multi-Origens NOVA */

:root {
  --bg-color: #0b0f19;
  --panel-bg: rgba(23, 31, 48, 0.75);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --primary: #3b82f6;
  --primary-hover: #2563eb;

  --amber: #f59e0b;
  --amber-glow: rgba(245, 158, 11, 0.15);

  --emerald: #10b981;
  --emerald-glow: rgba(16, 185, 129, 0.15);

  --sky: #38bdf8;
  --sky-glow: rgba(56, 189, 248, 0.15);

  --rose: #f43f5e;
  --rose-glow: rgba(244, 63, 94, 0.15);

  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-color);
  background-image:
    radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.08) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.05) 0px, transparent 50%);
  color: var(--text-main);
  font-family: var(--font-family);
  line-height: 1.5;
  min-height: 100vh;
  padding: 24px;
}

.app-container {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Login Screen */
.login-container {
  min-height: 85vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 420px;
  padding: 36px 32px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.login-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.brand-logo.large {
  width: 64px;
  height: 64px;
  font-size: 32px;
  border-radius: 18px;
}

.login-header h2 {
  font-size: 22px;
  font-weight: 700;
}

.login-header p {
  font-size: 13px;
  color: var(--text-muted);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.form-group input, .select-input {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text-main);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

.form-group input:focus, .select-input:focus {
  border-color: var(--primary);
}

.btn-block {
  width: 100%;
  justify-content: center;
  padding: 12px;
  font-size: 15px;
  margin-top: 6px;
}

.login-footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  border-top: 1px solid var(--panel-border);
  padding-top: 16px;
}

.login-footer code {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  color: #7dd3fc;
}

/* Header & Main Navigation */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  padding: 16px 24px;
  border-radius: var(--radius-lg);
  gap: 20px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
}

.brand-logo-wrapper.large {
  padding: 12px 20px;
  border-radius: var(--radius-lg);
  margin-bottom: 8px;
}

.brand-logo-img {
  height: 32px;
  width: auto;
  object-fit: contain;
}

.brand-logo-img.large {
  height: 48px;
}

.brand-info h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.sub-title {
  font-size: 12px;
  color: var(--text-muted);
}

.user-badge-header {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--panel-border);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-main);
  font-weight: 500;
}

.badge-role {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-admin {
  background: rgba(245, 158, 11, 0.2);
  color: var(--amber);
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.badge-analista {
  background: rgba(56, 189, 248, 0.2);
  color: var(--sky);
  border: 1px solid rgba(56, 189, 248, 0.4);
}

.badge-vendedor {
  background: rgba(16, 185, 129, 0.2);
  color: var(--emerald);
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.nav-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  font-family: inherit;
}

.nav-tab:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.nav-tab.active {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.3);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.4);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: 1px solid var(--panel-border);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.btn-outline:hover {
  background: rgba(59, 130, 246, 0.1);
}

.btn-danger-outline {
  background: transparent;
  color: var(--rose);
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.btn-danger-outline:hover {
  background: var(--rose-glow);
}

.btn-warning {
  background: var(--amber);
  color: #000;
  font-weight: 600;
}

.btn-warning:hover {
  background: #d97706;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-xs {
  padding: 4px 10px;
  font-size: 12px;
}

/* View Panels */
.view-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Stats Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.stat-icon.total { background: rgba(99, 102, 241, 0.15); color: #818cf8; }
.stat-icon.pending { background: var(--amber-glow); color: var(--amber); }
.stat-icon.sent { background: var(--emerald-glow); color: var(--emerald); }
.stat-icon.filtered { background: var(--sky-glow); color: var(--sky); }
.stat-icon.error { background: var(--rose-glow); color: var(--rose); }
.stat-icon.latency { background: rgba(129, 140, 248, 0.2); color: #a5b4fc; }

.text-indigo { color: #a5b4fc; }

.stat-label { font-size: 12px; color: var(--text-muted); }
.stat-value { font-size: 24px; font-weight: 700; line-height: 1.1; margin-top: 2px; }

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 260px;
}

.search-box i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 18px;
}

.search-box input {
  width: 100%;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 10px 14px 10px 42px;
  color: var(--text-main);
  font-size: 14px;
  outline: none;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.filter-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.3);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--panel-border);
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn.active {
  background: var(--primary);
  color: #fff;
}

/* Table */
.table-container {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  overflow-x: auto;
}

.leads-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.leads-table th {
  background: rgba(255, 255, 255, 0.03);
  padding: 12px 16px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--panel-border);
}

.leads-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--panel-border);
}

.leads-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
}

.font-mono { font-family: monospace; }
.bold { font-weight: 600; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-pendente { background: var(--amber-glow); color: var(--amber); border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-enviado { background: var(--emerald-glow); color: var(--emerald); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-enriquecimento { background: rgba(168, 85, 247, 0.2); color: #c084fc; border: 1px solid rgba(168, 85, 247, 0.4); box-shadow: 0 0 10px rgba(168, 85, 247, 0.15); }
.badge-excedido { background: rgba(249, 115, 22, 0.2); color: #fb923c; border: 1px solid rgba(249, 115, 22, 0.4); }
.badge-duplicado { background: rgba(148, 163, 184, 0.2); color: #94a3b8; border: 1px solid rgba(148, 163, 184, 0.4); }
.badge-filtrado { background: var(--sky-glow); color: var(--sky); border: 1px solid rgba(56, 189, 248, 0.3); }
.badge-erro { background: var(--rose-glow); color: var(--rose); border: 1px solid rgba(244, 63, 94, 0.3); }

.origin-tag {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.tenure-badge {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Pagination Footer */
.pagination-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 4px;
}

.pagination-info { font-size: 13px; color: var(--text-muted); }
.pagination-controls { display: flex; align-items: center; gap: 10px; }

/* Sources Section */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
}

.section-header h2 { font-size: 20px; font-weight: 700; }
.section-header p { font-size: 13px; color: var(--text-muted); }

.sources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 20px;
}

.source-card {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
}

.source-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.source-card-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.source-card-title h3 { font-size: 16px; font-weight: 700; }

.source-badge {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

.toggle-switch {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.toggle-switch input { display: none; }
.slider {
  width: 40px;
  height: 22px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  position: relative;
  transition: background 0.2s;
}

.slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
  transition: transform 0.2s;
}

.toggle-switch input:checked + .slider {
  background: var(--emerald);
}

.toggle-switch input:checked + .slider::before {
  transform: translateX(18px);
}

.source-info-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  background: rgba(0, 0, 0, 0.3);
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--panel-border);
}

.info-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.info-item label { color: var(--text-muted); font-size: 12px; }

.source-webhook-box {
  background: rgba(15, 23, 42, 0.8);
  border: 1px dashed rgba(59, 130, 246, 0.3);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.source-webhook-box code {
  font-family: monospace;
  font-size: 12px;
  color: #7dd3fc;
  word-break: break-all;
}

.source-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Analytics Section */
.analytics-toolbar {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.analytics-title h2 { font-size: 20px; font-weight: 700; }
.analytics-title p { font-size: 13px; color: var(--text-muted); }

.analytics-filters {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.analytics-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.kpi-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kpi-title { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.kpi-card h3 { font-size: 32px; font-weight: 700; line-height: 1; }
.kpi-sub { font-size: 12px; color: var(--text-dim); }

.analytics-panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 20px;
}

.analytics-box {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.analytics-box h3 {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #93c5fd;
}

.distribution-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dist-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dist-header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.bar-bg {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  border-radius: 4px;
  transition: width 0.4s ease;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: #131b2e;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 640px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

.modal-content.large-modal {
  max-width: 800px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--panel-border);
}

.modal-header h3 { font-size: 18px; font-weight: 600; }
.btn-close { background: transparent; border: none; color: var(--text-muted); font-size: 24px; cursor: pointer; }

.modal-body {
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.divider {
  border: none;
  border-top: 1px solid var(--panel-border);
  margin: 10px 0;
}

.mapping-section h4 {
  font-size: 15px;
  margin-bottom: 4px;
  color: #93c5fd;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.mapping-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-main);
}

.checkbox-label input {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.json-code {
  background: #090d16;
  border: 1px solid var(--panel-border);
  padding: 14px;
  border-radius: var(--radius-sm);
  font-family: monospace;
  font-size: 12px;
  color: #a5f3fc;
  overflow-x: auto;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--panel-border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.hidden { display: none !important; }
.text-amber { color: var(--amber); }
.text-emerald { color: var(--emerald); }
.text-sky { color: var(--sky); }
.text-rose { color: var(--rose); }

.spin {
  animation: spin 1s linear infinite;
  display: inline-block;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   TOAST NOTIFICATIONS (NOTIFICAÇÕES FLUTUANTES NO TOPO)
   ========================================================================== */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 9999999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
  max-width: 440px;
  width: calc(100% - 48px);
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.4;
  color: #ffffff;
  box-shadow: 0 12px 28px -4px rgba(0, 0, 0, 0.6), 0 6px 12px -4px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(16px);
  animation: toastSlideDown 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: opacity 0.3s ease, transform 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.toast i {
  font-size: 22px;
  flex-shrink: 0;
}

/* Erro: Vermelho Intenso Sobreposto */
.toast-error {
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.96), rgba(185, 28, 28, 0.98));
  border-color: rgba(248, 113, 113, 0.7);
  box-shadow: 0 10px 25px -4px rgba(220, 38, 38, 0.4);
}

/* Sucesso: Verde Intenso / Esmeralda */
.toast-success {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.96), rgba(5, 150, 105, 0.98));
  border-color: rgba(52, 211, 153, 0.7);
  box-shadow: 0 10px 25px -4px rgba(16, 185, 129, 0.4);
}

/* Aviso: Âmbar */
.toast-warning {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.96), rgba(217, 119, 6, 0.98));
  border-color: rgba(251, 191, 36, 0.7);
  box-shadow: 0 10px 25px -4px rgba(245, 158, 11, 0.4);
}

/* Info: Ciano */
.toast-info {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.96), rgba(2, 132, 199, 0.98));
  border-color: rgba(56, 189, 248, 0.7);
  box-shadow: 0 10px 25px -4px rgba(14, 165, 233, 0.4);
}

@keyframes toastSlideDown {
  from {
    opacity: 0;
    transform: translateY(-24px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
