:root {
  /* Paleta de Cores Modernas (Slate & Indigo) */
  --primary: #4f46e5;       /* Indigo 600 */
  --primary-hover: #4338ca; /* Indigo 700 */
  --secondary: #64748b;     /* Slate 500 */
  --success: #10b981;       /* Emerald 500 */
  --info: #0ea5e9;          /* Sky 500 */
  --warning: #f59e0b;       /* Amber 500 */
  --danger: #ef4444;        /* Red 500 */
  
  --bg-body: #f3f4f6;       /* Gray 100 */
  --bg-sidebar: #111827;    /* Gray 900 */
  --bg-card: #ffffff;
  
  --text-main: #1f2937;     /* Gray 800 */
  --text-muted: #6b7280;    /* Gray 500 */
  --border-color: #e5e7eb;  /* Gray 200 */

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  font-size: 0.9rem;
  overflow-x: hidden;
}

/* === Layout & Wrapper === */
.wrapper {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  padding-bottom: 4rem;
}

/* === Sidebar Premium === */
.sidebar {
  width: 260px;
  background-color: var(--bg-sidebar);
  color: #e5e7eb;
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
  z-index: 1000;
  box-shadow: 4px 0 24px rgba(0,0,0,0.1);
}

.sidebar-brand {
  height: 70px;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: white;
  text-decoration: none;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sidebar-brand i {
  color: var(--primary); /* Logo accent */
  font-size: 1.5rem;
  margin-right: 0.75rem;
}

.sidebar-nav {
  list-style: none;
  padding: 1rem 0.75rem;
  margin: 0;
  flex: 1;
  overflow-y: auto;
}

.sidebar-nav li {
  margin-bottom: 0.25rem;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  color: #9ca3af;
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
}

.sidebar-nav .nav-link:hover {
  background-color: rgba(255,255,255,0.05);
  color: white;
  transform: translateX(4px);
}

.sidebar-nav .nav-link.active {
  background: linear-gradient(90deg, var(--primary) 0%, #6366f1 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.sidebar-nav .nav-link i {
  margin-right: 0.75rem;
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
}

.sidebar-footer {
  padding: 1rem;
  font-size: 0.75rem;
  color: #6b7280;
  text-align: center;
  border-top: 1px solid rgba(255,255,255,0.05);
}

/* === Topbar === */
.topbar {
  height: 70px;
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  box-shadow: var(--shadow-sm);
}

.topbar-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

/* === Cards & Stats === */
.page-section { display: none; opacity: 0; transition: opacity 0.2s ease-in-out; }
.page-section.active { display: block; opacity: 1; }

.panel-card, .card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  transition: transform 0.2s, box-shadow 0.2s;
}

.card-header {
  background-color: transparent;
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 1.5rem;
  font-weight: 600;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.2rem;
  margin-bottom: 0.75rem;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 0.25rem;
}

.stat-trend {
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
}
.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }
.stat-trend.neutral { color: var(--text-muted); }

/* === Tables === */
.table-responsive {
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.table-panel {
  width: 100%;
  margin-bottom: 0;
  background-color: var(--bg-card);
}

.table-panel th {
  background-color: #f9fafb;
  color: #4b5563;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

.table-panel td {
  padding: 0.85rem 1.25rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.875rem;
}

.table-panel tbody tr:last-child td { border-bottom: none; }
.table-panel tbody tr:hover { background-color: #f9fafb; }

/* === Badges & Buttons === */
.badge {
  padding: 0.35em 0.65em;
  font-weight: 600;
  border-radius: 6px;
  font-size: 0.75rem;
}
/* === Admin Specific Polishing === */
code {
  background: #1e293b;
  color: #38bdf8;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85em;
}

.badge-ativo {
  background-color: #ecfdf5;
  color: #059669;
  border: 1px solid #10b981;
}

.badge-inativo {
  background-color: #fff1f2;
  color: #dc2626;
  border: 1px solid #f87171;
}

/* Status de envio */
.badge-enviado { background: #ecfdf5; color: #059669; border: 1px solid #10b981; }
.badge-dry_run { background: #fefce8; color: #a16207; border: 1px solid #facc15; }
.badge-erro { background: #fef2f2; color: #dc2626; border: 1px solid #f87171; }
.badge-falha_entrega { background: #fff7ed; color: #c2410c; border: 1px solid #fb923c; }
.badge-falha_sessao { background: #fdf4ff; color: #9333ea; border: 1px solid #c084fc; }
.badge-falha_numero { background: #fef2f2; color: #be123c; border: 1px solid #fb7185; }
.badge-bloqueado_bot_ativo { background: #f0f9ff; color: #0369a1; border: 1px solid #38bdf8; }
.badge-expirado { background: #f5f5f4; color: #78716c; border: 1px solid #a8a29e; }

/* Configuração de Automações em Grid */
#configCards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

.config-card {
  border: 1px solid var(--border-color);
  background: white;
  border-radius: var(--radius-md);
  padding: 1.25rem;
  transition: all 0.2s;
}

.config-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.config-card .form-check-input:checked {
  background-color: var(--success);
  border-color: var(--success);
}

/* Unified Config Accordions */
#page-config-unified .accordion-button {
  font-size: 0.9rem;
  padding: 0.6rem 1rem;
}
#page-config-unified .accordion-button:not(.collapsed) {
  background: #f0f0ff;
  color: var(--primary);
}
#page-config-unified .accordion-body {
  padding: 1rem;
}
#page-config-unified .accordion-item {
  border-color: var(--border-color);
}
#page-config-unified .form-label {
  font-size: 0.78rem;
  font-weight: 500;
  margin-bottom: 0.15rem;
}
#page-config-unified textarea.form-control-sm {
  font-size: 0.82rem;
}

/* Modal Polishing */
.modal-lg { max-width: 900px; }
.modal-header {
  background: #f9fafb;
  border-bottom: 1px solid var(--border-color);
}
.modal-title { font-weight: 700; color: var(--bg-sidebar); }

/* Variable Hints */
.variable-hints {
  background: #f1f5f9;
  padding: 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.5rem;
  border-left: 4px solid var(--info);
}


.btn-primary {
  background-color: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2);
}
.btn-primary:hover {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-action {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  border-radius: 6px;
}

/* === Inputs === */
.form-control, .form-select {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* === Empty States === */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}
.empty-state i {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 1rem;
  color: #d1d5db;
}

/* === Modals === */
.modal-content {
  border-radius: var(--radius-lg);
  border: none;
  box-shadow: var(--shadow-lg);
}
.modal-header { border-bottom: 1px solid var(--border-color); }
.modal-footer { border-top: 1px solid var(--border-color); }

/* === Scrollbars === */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* === Mobile Toggle === */
.btn-sidebar-toggle {
  background: none; border: none; font-size: 1.5rem; color: var(--text-main);
  display: none;
}

@media (max-width: 992px) {
  .sidebar {
    position: fixed; left: -260px; height: 100vh;
  }
  .sidebar.show { left: 0; }
  .btn-sidebar-toggle { display: block; }
  .sidebar-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 900;
    display: none; backdrop-filter: blur(2px);
  }
  .sidebar-overlay.show { display: block; }
}

/* === Analise IA Cards === */
.card-analise { border-left: 4px solid var(--primary); }
.analise-bi { border-left-color: var(--success); }
.analise-tech { border-left-color: var(--danger); }

/* === Agent Organogram === */
.org-agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}
.org-agent-card {
  background: var(--bg-card, #fff);
  border: 2px solid var(--border-color, #e2e5ed);
  border-radius: 12px;
  padding: 1.25rem;
  cursor: pointer;
  transition: all 0.2s;
}
.org-agent-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(79,70,229,0.15);
  transform: translateY(-2px);
}
.org-inactive { opacity: 0.5; }
.org-agent-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-size: 1rem;
}
.org-agent-name { font-weight: 700; }
.org-agent-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: #6b7185;
  margin-bottom: 0.75rem;
}
.org-agent-stats {
  display: flex;
  gap: 1.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color, #e2e5ed);
}
.org-stat-value { font-size: 1.25rem; font-weight: 700; }
.org-stat-label { font-size: 0.7rem; color: #6b7185; text-transform: uppercase; }

/* Flowchart */
.org-flow-container { max-width: 600px; margin: 0 auto; }
.org-flow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 1rem 0;
}
.org-step {
  background: #fff;
  border: 2px solid #e2e5ed;
  border-radius: 10px;
  padding: 1rem 1.5rem;
  min-width: 320px;
  max-width: 500px;
  width: 100%;
}
.org-step-start { border-color: var(--primary); border-width: 3px; }
.org-step-final { border-color: var(--success, #10b981); border-width: 3px; }
.org-step-inactive { opacity: 0.4; }
.org-step-header { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.25rem; }
.org-step-slug { font-weight: 700; font-family: monospace; font-size: 0.9rem; }
.org-step-name { font-size: 0.85rem; color: #6b7185; margin-bottom: 0.5rem; }
.org-step-tools { margin-bottom: 0.5rem; }
.org-step-tools .badge { font-size: 0.7rem; }
.org-step-transitions { font-size: 0.8rem; }
.org-trans { padding: 0.15rem 0; }
.org-trans-fallback { color: #f59e0b; }
.org-trans-tool { color: #10b981; }
.org-trans-match { color: var(--primary); }
.org-arrow { font-size: 1.25rem; color: #6b7185; padding: 0.25rem 0; text-align: center; }
