/**
 * Meu CORTEX — Cockpit Executivo
 * Direção Visual: CORTEX Obsidian Navy Deep (JD Tecnologia)
 */

:root {
  --bg-main: #070a12;
  --bg-sidebar: #090e1a;
  --bg-card: #0f172a;
  --bg-card-hover: #17223b;
  --bg-input: #0a0f1d;

  --border-color: #1e293b;
  --border-light: #334155;
  --border-focus: #2563eb;
  --border-glow: rgba(37, 99, 235, 0.35);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --text-bright: #ffffff;

  --accent-blue: #2563eb;
  --accent-blue-hover: #1d4ed8;
  --accent-blue-bg: rgba(37, 99, 235, 0.12);
  --accent-blue-light: #60a5fa;

  --accent-green: #10b981;
  --accent-green-bg: rgba(16, 185, 129, 0.12);

  --accent-red: #ef4444;
  --accent-red-bg: rgba(239, 68, 68, 0.12);

  --accent-purple: #8b5cf6;
  --accent-purple-bg: rgba(139, 92, 246, 0.14);

  --accent-amber: #f59e0b;
  --accent-amber-bg: rgba(245, 158, 11, 0.12);

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-pill: 9999px;

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  display: flex;
  height: 100vh;
  overflow: hidden;
}

#app {
  display: flex;
  width: 100vw;
  height: 100vh;
}

/* SIDEBAR DE PRODUTO */
.sidebar {
  width: 270px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding: 0 6px;
}
.brand-logo {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, #06b6d4, #2563eb);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 0 14px rgba(37, 99, 235, 0.35);
}
.brand-info h1 {
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.3px;
  line-height: 1.1;
}
.badge-plan {
  font-size: 9px;
  font-weight: 800;
  color: var(--accent-green);
  background: var(--accent-green-bg);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: inline-block;
  margin-top: 3px;
}

.tenant-selector {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
}
.tenant-icon { font-size: 18px; }
.tenant-meta { display: flex; flex-direction: column; overflow: hidden; }
.tenant-meta strong { font-size: 13px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tenant-meta small { font-size: 10px; color: var(--text-dim); }

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
  width: 100%;
}
.nav-item .icon { font-size: 16px; }
.nav-item:hover {
  background: var(--bg-card);
  color: var(--text-main);
}
.nav-item.active {
  background: var(--accent-blue-bg);
  border-color: rgba(37, 99, 235, 0.4);
  color: #93c5fd;
  box-shadow: 0 0 12px rgba(37, 99, 235, 0.2);
}

.sidebar-footer {
  padding: 14px 6px 0;
  border-top: 1px solid var(--border-color);
}
.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}
.version-label {
  font-size: 10px;
  color: var(--text-dim);
  display: block;
}

/* ÁREA PRINCIPAL */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-main);
}

.topbar {
  height: 64px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  flex-shrink: 0;
  background: rgba(9, 14, 26, 0.85);
  backdrop-filter: blur(12px);
}
.topbar-title h2 { font-size: 18px; font-weight: 700; color: #fff; letter-spacing: -0.4px; }
.topbar-title p { font-size: 11px; color: var(--text-dim); }
.topbar-actions { display: flex; align-items: center; gap: 14px; }

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 5px 12px 5px 6px;
  border-radius: var(--radius-pill);
}
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #8b5cf6);
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}
.user-details strong { font-size: 11px; font-weight: 600; color: #fff; display: block; }
.user-details small { font-size: 10px; color: var(--text-dim); display: block; }

.content-body {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
}

/* TAB PANE TRANSITIONS */
.tab-pane { display: none; }
.tab-pane.active { display: block; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
}
.btn-primary {
  background: var(--accent-blue);
  color: #fff;
  box-shadow: 0 0 10px rgba(37, 99, 235, 0.3);
}
.btn-primary:hover {
  background: var(--accent-blue-hover);
}
.btn-outline {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-muted);
}
.btn-outline:hover {
  background: var(--bg-card-hover);
  color: #fff;
}
.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-block { width: 100%; }

/* CARDS */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 20px;
}
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h3 { font-size: 14px; font-weight: 700; color: #fff; }
.card-body { padding: 18px; }
.card-body.p-0 { padding: 0; }

/* MÉTRICAS DASHBOARD */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
  margin-bottom: 22px;
}
.metric-card {
  margin-bottom: 0;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.metric-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}
.pill {
  font-size: 9px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.pill-pj { background: var(--accent-purple-bg); color: #c4b5fd; }
.pill-pf { background: var(--accent-green-bg); color: #6ee7b7; }
.pill-accent { background: var(--accent-blue-bg); color: #93c5fd; }

.metric-values {
  display: flex;
  gap: 20px;
  margin-bottom: 14px;
}
.sub-metric small { display: block; font-size: 10px; color: var(--text-dim); }
.sub-metric strong { font-size: 18px; font-weight: 800; }
.text-green { color: var(--accent-green); }
.text-red { color: var(--accent-red); }

.metric-footer {
  border-top: 1px solid var(--border-color);
  padding-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}
.metric-footer strong { font-size: 15px; color: #fff; }

.productivity-stats {
  display: flex;
  justify-content: space-around;
  text-align: center;
  margin-top: 6px;
}
.stat-item .stat-number {
  font-size: 24px;
  font-weight: 800;
  color: #60a5fa;
  display: block;
  line-height: 1.1;
}
.stat-item small { font-size: 10px; color: var(--text-dim); }

/* DUAL GRID */
.dual-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 1024px) { .dual-grid { grid-template-columns: 1fr; } }

/* TASK LIST */
.task-list { list-style: none; }
.task-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
  font-size: 12px;
}
.task-item:last-child { border-bottom: none; }
.task-left { display: flex; align-items: center; gap: 10px; }
.task-checkbox { cursor: pointer; width: 15px; height: 15px; accent-color: var(--accent-blue); }
.task-meta { font-size: 10px; color: var(--text-dim); font-family: var(--font-mono); }

/* FEED DE NOTAS */
.notes-feed { display: flex; flex-direction: column; gap: 8px; }
.note-item {
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 12px;
}
.note-tags { display: flex; gap: 6px; margin-top: 6px; }
.tag-badge { font-size: 9px; background: var(--bg-card-hover); color: var(--text-muted); padding: 1px 6px; border-radius: var(--radius-xs); }

/* BOLETO CARD */
.boleto-card {
  border: 1px solid rgba(37, 99, 235, 0.35);
  background: linear-gradient(180deg, #131b2e 0%, #0f172a 100%);
}
.boleto-input-row { display: flex; gap: 10px; }
.input-mono { font-family: var(--font-mono); font-size: 12px; }
.boleto-result {
  margin-top: 14px;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  padding: 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}

/* DATA TABLE */
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; text-align: left; }
.data-table th { background: rgba(255, 255, 255, 0.02); padding: 10px 14px; color: var(--text-muted); font-weight: 600; border-bottom: 1px solid var(--border-color); }
.data-table td { padding: 10px 14px; border-bottom: 1px solid var(--border-color); }
.data-table tr:hover { background: var(--bg-card-hover); }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* MODULES GRID */
.modules-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; margin-top: 18px; }
.module-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.module-card-top { display: flex; gap: 12px; margin-bottom: 12px; }
.module-emoji { font-size: 26px; line-height: 1; }
.module-info h4 { font-size: 13px; font-weight: 700; color: #fff; margin-bottom: 4px; }
.module-info p { font-size: 11px; color: var(--text-dim); }
.module-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-color);
  padding-top: 10px;
}

/* SWITCH TOGGLE */
.switch { position: relative; display: inline-block; width: 38px; height: 20px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--border-light);
  transition: .25s;
  border-radius: 20px;
}
.slider:before {
  position: absolute; content: ""; height: 14px; width: 14px; left: 3px; bottom: 3px;
  background-color: white;
  transition: .25s;
  border-radius: 50%;
}
input:checked + .slider { background-color: var(--accent-green); }
input:checked + .slider:before { transform: translateX(18px); }

/* SUBNAV SEGUNDO CÉREBRO */
.subnav { display: flex; gap: 6px; margin-bottom: 18px; border-bottom: 1px solid var(--border-color); padding-bottom: 8px; }
.subnav-item {
  background: transparent; border: none; color: var(--text-dim); font-size: 12px; font-weight: 600;
  padding: 6px 12px; border-radius: var(--radius-sm); cursor: pointer; transition: all 0.15s;
}
.subnav-item.active { background: var(--bg-card); color: #fff; }
.subtab-pane { display: none; }
.subtab-pane.active { display: block; }
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 10px; }
.filters { display: flex; gap: 8px; }
.filters select { background: var(--bg-card); border: 1px solid var(--border-color); color: #fff; padding: 6px 10px; border-radius: var(--radius-sm); font-size: 11px; outline: none; }
.search-box { display: flex; gap: 6px; max-width: 360px; width: 100%; }

/* MODALS */
.modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(5px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal.active { display: flex; }
.modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 480px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.6);
  animation: modalScale 0.18s ease;
}
@keyframes modalScale { from { transform: scale(0.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.modal-header h4 { font-size: 15px; font-weight: 700; color: #fff; }
.modal-close { background: none; border: none; font-size: 18px; color: var(--text-dim); cursor: pointer; }
.modal-body { padding: 20px; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 10px; }

/* FORMS */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 11px; font-weight: 600; color: var(--text-dim); margin-bottom: 5px; }
.form-group input, .form-group select, .form-group textarea, .search-box input, .boleto-input-row input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: inherit;
  font-size: 12px;
  outline: none;
  transition: border 0.15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus, .boleto-input-row input:focus { border-color: var(--accent-blue); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.empty-state { padding: 20px; text-align: center; color: var(--text-dim); font-size: 12px; }
.mt-4 { margin-top: 20px; }
