:root {
  --bg-0: #080c14;
  --bg-1: #0d1117;
  --bg-2: #161b27;
  --bg-3: #1e2433;
  --bg-card: #1a2035;
  --border: rgba(255,255,255,0.07);
  --border-hover: rgba(255,255,255,0.15);
  --text-primary: #e8eaf0;
  --text-secondary: #8892a4;
  --text-muted: #4a5568;
  --accent-blue: #4f8ef7;
  --accent-blue-dim: rgba(79,142,247,0.15);
  --accent-purple: #9b59f7;
  --accent-purple-dim: rgba(155,89,247,0.15);
  --accent-green: #10d9a8;
  --accent-green-dim: rgba(16,217,168,0.12);
  --accent-yellow: #f7c948;
  --accent-yellow-dim: rgba(247,201,72,0.12);
  --accent-red: #f74f4f;
  --sidebar-w: 240px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-0);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-logo {
  padding: 20px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 800; color: #fff;
  box-shadow: 0 0 20px rgba(79,142,247,0.4);
}

.logo-title { font-size: 15px; font-weight: 700; color: var(--text-primary); display: block; }
.logo-sub { font-size: 11px; color: var(--text-muted); display: block; }

.sidebar-nav { flex: 1; padding: 8px; display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-secondary); background: transparent;
  border: none; cursor: pointer; font-size: 13.5px;
  font-family: inherit; transition: all 0.2s; text-align: left;
  position: relative;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: var(--bg-2); color: var(--text-primary); }
.nav-item.active {
  background: var(--accent-blue-dim);
  color: var(--accent-blue);
}
.nav-item.active::before {
  content: '';
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 60%; background: var(--accent-blue);
  border-radius: 0 2px 2px 0;
}
.nav-badge {
  margin-left: auto;
  background: var(--accent-blue);
  color: #fff; font-size: 11px; font-weight: 600;
  padding: 2px 7px; border-radius: 20px; min-width: 20px; text-align: center;
}

.sidebar-footer {
  padding: 16px; border-top: 1px solid var(--border);
}

.status-indicator {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-secondary);
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-muted); transition: background 0.3s;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.05);
}
.status-dot.connected { background: var(--accent-green); box-shadow: 0 0 8px var(--accent-green); }
.status-dot.error { background: var(--accent-red); }

/* ===== MAIN ===== */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ===== TOPBAR ===== */
.topbar {
  height: 60px; padding: 0 24px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(12px);
}

.topbar-left { display: flex; align-items: center; gap: 12px; }
.menu-toggle {
  display: none; background: none; border: none;
  color: var(--text-secondary); font-size: 20px; cursor: pointer;
  padding: 4px 8px;
}
.page-title { font-size: 18px; font-weight: 700; color: var(--text-primary); }

.topbar-right { display: flex; align-items: center; gap: 16px; }

.control-group {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  background: var(--bg-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.control-label { font-size: 12px; color: var(--text-secondary); white-space: nowrap; }

/* TOGGLE SWITCH */
.toggle { position: relative; display: inline-block; width: 38px; height: 22px; cursor: pointer; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--bg-3);
  border-radius: 22px;
  transition: .3s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px; border-radius: 50%;
  left: 3px; bottom: 3px;
  background: var(--text-muted);
  transition: .3s;
}
.toggle input:checked + .toggle-slider { background: var(--accent-green); }
.toggle input:checked + .toggle-slider::before {
  transform: translateX(16px);
  background: #fff;
}

/* ===== PAGES ===== */
.pages { flex: 1; padding: 24px; }
.page { display: none; animation: fadeIn 0.3s ease; }
.page.active { display: block; }

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

/* ===== STATS GRID ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px; margin-bottom: 24px;
}

.stat-card {
  border-radius: var(--radius);
  padding: 20px;
  display: flex; align-items: center; gap: 16px;
  position: relative; overflow: hidden;
  border: 1px solid var(--border);
  transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card::after {
  content: ''; position: absolute;
  top: -20px; right: -20px;
  width: 80px; height: 80px;
  border-radius: 50%;
  opacity: 0.1;
}
.gradient-blue { background: linear-gradient(135deg, var(--bg-card), #0d1f3c); }
.gradient-blue .stat-icon svg { color: var(--accent-blue); }
.gradient-blue::after { background: var(--accent-blue); }
.gradient-yellow { background: linear-gradient(135deg, var(--bg-card), #1f1a0d); }
.gradient-yellow .stat-icon svg { color: var(--accent-yellow); }
.gradient-purple { background: linear-gradient(135deg, var(--bg-card), #1a0d2e); }
.gradient-purple .stat-icon svg { color: var(--accent-purple); }
.gradient-green { background: linear-gradient(135deg, var(--bg-card), #0d1f1a); }
.gradient-green .stat-icon svg { color: var(--accent-green); }

.stat-icon svg { width: 28px; height: 28px; }
.stat-value { font-size: 32px; font-weight: 800; display: block; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 4px; display: block; }

/* ===== DASHBOARD GRID ===== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 20px;
}

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.2s;
}
.card:hover { border-color: var(--border-hover); }

.card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.card-header h2 { font-size: 15px; font-weight: 600; color: var(--text-primary); }

/* ===== BUTTONS ===== */
.btn {
  padding: 8px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-3);
  color: var(--text-primary); cursor: pointer; font-size: 13px;
  font-family: inherit; font-weight: 500;
  transition: all 0.2s; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: var(--bg-2); border-color: var(--border-hover); }
.btn-primary {
  background: var(--accent-blue); border-color: transparent;
  color: #fff; box-shadow: 0 0 20px rgba(79,142,247,0.25);
}
.btn-primary:hover { background: #3d7de0; box-shadow: 0 0 30px rgba(79,142,247,0.4); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-danger { background: rgba(247,79,79,0.15); border-color: var(--accent-red); color: var(--accent-red); }
.btn-full { width: 100%; justify-content: center; }
.btn-green { background: var(--accent-green-dim); border-color: var(--accent-green); color: var(--accent-green); }

/* ===== TABLE ===== */
.table-container { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
  padding: 12px 16px; text-align: left;
  background: var(--bg-2); color: var(--text-secondary);
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-2); }

/* STATUS BADGES */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.badge-pending { background: var(--accent-yellow-dim); color: var(--accent-yellow); }
.badge-approved { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.badge-contacted { background: var(--accent-blue-dim); color: var(--accent-blue); }
.badge-responded { background: var(--accent-purple-dim); color: var(--accent-purple); }
.badge-interested { background: var(--accent-green-dim); color: var(--accent-green); }
.badge-rejected { background: rgba(247,79,79,0.12); color: var(--accent-red); }
.badge-unknown { background: var(--bg-3); color: var(--text-muted); }

/* ===== FORMS ===== */
.input, .select, .textarea {
  width: 100%; padding: 10px 14px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-family: inherit; font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px var(--accent-blue-dim);
}
.select { cursor: pointer; }
.textarea { resize: vertical; }
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; margin-bottom: 6px;
  font-size: 12px; font-weight: 600;
  color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em;
}
.form-actions { margin-top: 24px; display: flex; gap: 12px; justify-content: flex-end; }

/* ===== SCANNER ===== */
.scanner-grid { display: grid; grid-template-columns: 1fr 1.5fr; gap: 20px; }

/* ===== CONVERSATIONS ===== */
.conversations-layout {
  display: grid; grid-template-columns: 320px 1fr;
  gap: 16px; height: calc(100vh - 120px);
}
.conv-list {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column;
}
.conv-search { padding: 12px; border-bottom: 1px solid var(--border); }
.conv-search .input { padding: 8px 12px; font-size: 13px; }
#conv-items { flex: 1; overflow-y: auto; }
.conv-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background 0.15s;
  display: flex; flex-direction: column; gap: 4px;
}
.conv-item:hover { background: var(--bg-2); }
.conv-item.active { background: var(--accent-blue-dim); border-left: 3px solid var(--accent-blue); }
.conv-item-name { font-size: 14px; font-weight: 600; }
.conv-item-preview { font-size: 12px; color: var(--text-secondary); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.conv-item-time { font-size: 11px; color: var(--text-muted); }

.conv-chat {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); display: flex; flex-direction: column;
  overflow: hidden;
}
.conv-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--text-muted); gap: 12px;
}
.conv-empty svg { width: 48px; height: 48px; }
.conv-header {
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.conv-messages {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.msg {
  max-width: 75%; padding: 10px 14px;
  border-radius: 16px; font-size: 13.5px; line-height: 1.5;
  position: relative;
}
.msg-bot {
  background: var(--accent-blue-dim);
  border: 1px solid rgba(79,142,247,0.2);
  align-self: flex-start; border-bottom-left-radius: 4px;
}
.msg-user {
  background: var(--bg-2); border: 1px solid var(--border);
  align-self: flex-end; border-bottom-right-radius: 4px;
}
.msg-time { font-size: 10px; color: var(--text-muted); margin-top: 4px; display: block; }
.conv-input-area {
  padding: 14px 16px; border-top: 1px solid var(--border);
  display: flex; gap: 10px;
}
.conv-input-area .input { flex: 1; }

/* ===== KNOWLEDGE ===== */
.knowledge-item {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 20px;
  margin-bottom: 12px; transition: border-color 0.2s;
}
.knowledge-item:hover { border-color: var(--border-hover); }
.knowledge-question { font-size: 14px; font-weight: 600; margin-bottom: 8px; color: var(--text-primary); }
.knowledge-answer { font-size: 13px; color: var(--text-secondary); line-height: 1.6; }
.knowledge-meta {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border);
}
.knowledge-category {
  font-size: 11px; padding: 3px 10px; border-radius: 20px;
  background: var(--accent-purple-dim); color: var(--accent-purple); font-weight: 600;
}

/* ===== SETTINGS ===== */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.setting-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.setting-card.full-width { grid-column: 1 / -1; }
.setting-card h3 { font-size: 13px; font-weight: 600; color: var(--accent-blue); margin-bottom: 16px; text-transform: uppercase; letter-spacing: 0.05em; }

/* ===== MODAL ===== */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
  z-index: 200; align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 16px; width: 90%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header {
  padding: 18px 22px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none; border: none; color: var(--text-secondary);
  font-size: 22px; cursor: pointer; line-height: 1;
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; transition: background 0.2s;
}
.modal-close:hover { background: var(--bg-3); color: var(--text-primary); }
.modal-body { padding: 22px; }

/* ===== LEAD LIST ===== */
.lead-list { display: flex; flex-direction: column; gap: 10px; }
.lead-list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.lead-list-item:last-child { border-bottom: none; }
.lead-list-name { font-size: 14px; font-weight: 500; }
.lead-list-sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* ===== PAGE TOOLBAR ===== */
.page-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; gap: 12px;
}
.page-toolbar h2 { font-size: 16px; font-weight: 700; }

.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 12px; flex: 1;
  max-width: 400px;
}
.search-box svg { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }
.search-box input {
  background: none; border: none; outline: none;
  color: var(--text-primary); font-size: 14px; font-family: inherit; width: 100%;
}
.select-filter {
  padding: 9px 12px; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-family: inherit; font-size: 13px; outline: none; cursor: pointer;
}

/* ===== INFO BOX ===== */
.info-box {
  background: var(--accent-blue-dim); border: 1px solid rgba(79,142,247,0.25);
  border-radius: var(--radius-sm); padding: 12px 16px;
  font-size: 13px; color: var(--text-secondary); margin-bottom: 20px; line-height: 1.6;
}

/* ===== JOB LIST ===== */
.job-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.job-item:last-child { border-bottom: none; }
.job-icon { font-size: 22px; }
.job-info { flex: 1; }
.job-title { font-size: 13px; font-weight: 600; }
.job-sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.job-stats { font-size: 11px; font-weight: 700; color: var(--accent-green); }

/* ===== TOAST ===== */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 500; display: flex; flex-direction: column; gap: 10px;
}
.toast {
  padding: 12px 18px; border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent-blue);
  background: var(--bg-card); color: var(--text-primary);
  font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow); min-width: 260px;
  animation: slideInRight 0.3s ease;
  display: flex; align-items: center; gap: 10px;
}
.toast-success { border-left-color: var(--accent-green); }
.toast-error { border-left-color: var(--accent-red); }
.toast-warning { border-left-color: var(--accent-yellow); }
@keyframes slideInRight { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== PAGINATION ===== */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 20px; }
.pagination button {
  padding: 6px 12px; border-radius: 6px;
  background: var(--bg-2); border: 1px solid var(--border);
  color: var(--text-secondary); cursor: pointer; font-size: 13px;
  transition: all 0.2s;
}
.pagination button:hover, .pagination button.active {
  background: var(--accent-blue-dim); color: var(--accent-blue);
  border-color: var(--accent-blue);
}

/* ===== LOADING ===== */
.loading {
  text-align: center; padding: 32px;
  color: var(--text-muted); font-size: 14px;
}
.loading::after {
  content: '';
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 8px; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== RESPONSIVE ===== */
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .scanner-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .menu-toggle { display: block; }
  .conversations-layout { grid-template-columns: 1fr; }
  .topbar-right { gap: 8px; }
  .control-label { display: none; }
}

/* ===== TELA DE LOGIN ===== */
.login-container {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg-0);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  gap: 24px;
  backdrop-filter: blur(10px);
}

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

.login-logo h2 {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
  margin-top: 8px;
}

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