/* =====================================================
   Nomos New — Design System (Dark Theme)
   ===================================================== */

/* ── Variáveis ───────────────────────────────────────── */
:root {
  --bg:           #0d1117;
  --bg-sidebar:   #161b27;
  --bg-card:      #1c2333;
  --bg-card-2:    #1a2036;
  --bg-input:     #161b27;
  --border:       rgba(255,255,255,.07);
  --border-soft:  rgba(255,255,255,.04);
  --border-focus: #3b82f6;
  --text:         #cbd5e1;
  --text-muted:   #64748b;
  --text-head:    #f1f5f9;
  --primary:      #3b82f6;
  --primary-d:    #2563eb;
  --primary-glow: rgba(59,130,246,.25);
  --success:      #10b981;
  --warning:      #f59e0b;
  --danger:       #ef4444;
  --info:         #06b6d4;
  --purple:       #8b5cf6;
  --sidebar-w:    220px;
  --header-h:     56px;
  --radius:       8px;
  --radius-sm:    5px;
}

/* ── Reset ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

/* ── Scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.2); }

/* =====================================================
   Layout principal
   ===================================================== */
.layout { display: flex; flex-direction: column; min-height: 100vh; }

/* ── Header ──────────────────────────────────────────── */
.header {
  background: var(--bg-sidebar);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: var(--header-h);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 var(--border);
}

.header-brand .brand-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .3px;
  color: var(--text-head);
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-user { display: flex; align-items: center; gap: 12px; }
.header-user .user-name { font-size: 13px; color: var(--text); }

/* ── Body wrapper ────────────────────────────────────── */
.body-wrapper { display: flex; flex: 1; }

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-sidebar);
  padding: 12px 0 24px;
  min-height: calc(100vh - var(--header-h));
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.nav-list { list-style: none; margin: 0; padding: 0 8px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: background .15s, color .15s;
  margin-bottom: 2px;
  position: relative;
}

.nav-link::before {
  content: '';
  width: 3px;
  height: 18px;
  border-radius: 2px;
  background: transparent;
  transition: background .15s;
  flex-shrink: 0;
}

.nav-link:hover {
  background: rgba(255,255,255,.05);
  color: var(--text-head);
}

.nav-link:hover::before,
.nav-link.active::before {
  background: var(--primary);
}

.nav-link.active {
  background: rgba(59,130,246,.12);
  color: var(--primary);
}

/* ── Main content ────────────────────────────────────── */
.main-content {
  flex: 1;
  padding: 28px;
  overflow-y: auto;
  min-width: 0;
}

/* =====================================================
   Login
   ===================================================== */
.login-body {
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 20% 30%, rgba(59,130,246,.12) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 70%, rgba(139,92,246,.10) 0%, transparent 60%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-container { width: 100%; max-width: 400px; padding: 16px; }

.login-card {
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 24px 64px rgba(0,0,0,.5);
  overflow: hidden;
}

.login-header {
  background: linear-gradient(135deg, #1a2a4a 0%, #1e2a50 100%);
  padding: 32px 28px 24px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.login-title {
  margin: 0;
  font-size: 26px;
  color: #fff;
  font-weight: 700;
  letter-spacing: -.3px;
}

.login-subtitle { margin: 6px 0 0; color: var(--text-muted); font-size: 13px; }

.login-form { padding: 28px; }

/* =====================================================
   Formulários
   ===================================================== */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
}

.form-control {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--bg-input);
  color: var(--text-head);
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}

.form-control::placeholder { color: var(--text-muted); }

.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

select.form-control { cursor: pointer; }

textarea.form-control { resize: vertical; min-height: 80px; }

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
}

/* =====================================================
   Botões
   ===================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all .15s;
  line-height: 1.4;
  letter-spacing: .1px;
  font-family: inherit;
}

.btn:active { transform: scale(.98); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(59,130,246,.35);
}
.btn-primary:hover { background: var(--primary-d); box-shadow: 0 4px 16px rgba(59,130,246,.45); }

.btn-secondary {
  background: rgba(255,255,255,.08);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: rgba(255,255,255,.13); color: var(--text-head); }

.btn-danger {
  background: rgba(239,68,68,.15);
  color: #fca5a5;
  border: 1px solid rgba(239,68,68,.25);
}
.btn-danger:hover { background: rgba(239,68,68,.25); color: #fff; }

.btn-success {
  background: rgba(16,185,129,.15);
  color: #6ee7b7;
  border: 1px solid rgba(16,185,129,.25);
}
.btn-success:hover { background: rgba(16,185,129,.25); color: #fff; }

.btn-sm { padding: 5px 11px; font-size: 11px; }
.btn-block { display: flex; width: 100%; text-align: center; justify-content: center; }

/* =====================================================
   Badges / perfis
   ===================================================== */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.badge-admin        { background: rgba(59,130,246,.2);  color: #93c5fd; border: 1px solid rgba(59,130,246,.3); }
.badge-operador     { background: rgba(16,185,129,.2);  color: #6ee7b7; border: 1px solid rgba(16,185,129,.3); }
.badge-cliente      { background: rgba(6,182,212,.2);   color: #67e8f9; border: 1px solid rgba(6,182,212,.3); }
.badge-auditor      { background: rgba(245,158,11,.2);  color: #fcd34d; border: 1px solid rgba(245,158,11,.3); }
.badge-suporte      { background: rgba(139,92,246,.2);  color: #c4b5fd; border: 1px solid rgba(139,92,246,.3); }
.badge-visualizador { background: rgba(100,116,139,.2); color: #cbd5e1; border: 1px solid rgba(100,116,139,.3); }

/* =====================================================
   Flash messages
   ===================================================== */
.flash {
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 13px;
  font-weight: 500;
}

.flash-success {
  background: rgba(16,185,129,.15);
  color: #6ee7b7;
  border: 1px solid rgba(16,185,129,.2);
}
.flash-error {
  background: rgba(239,68,68,.15);
  color: #fca5a5;
  border: 1px solid rgba(239,68,68,.2);
}

/* =====================================================
   Cards (dashboard)
   ===================================================== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 8px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .2s, box-shadow .2s;
}

.card:hover {
  border-color: rgba(59,130,246,.25);
  box-shadow: 0 4px 20px rgba(0,0,0,.3);
}

.card-header {
  background: rgba(59,130,246,.08);
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.card-body { padding: 16px; }

.card-stat {
  font-size: 34px;
  font-weight: 700;
  color: var(--text-head);
  margin: 0 0 4px;
  letter-spacing: -1px;
}

.card-label { font-size: 12px; color: var(--text-muted); margin: 0; }

/* =====================================================
   Tabelas
   ===================================================== */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
}

table { width: 100%; border-collapse: collapse; }

thead th {
  background: rgba(255,255,255,.04);
  color: var(--text-muted);
  padding: 11px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr { border-bottom: 1px solid var(--border-soft); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,.03); }

td {
  padding: 11px 14px;
  font-size: 13px;
  color: var(--text);
  vertical-align: middle;
}

td strong { color: var(--text-head); }
td code {
  font-size: 12px;
  background: rgba(255,255,255,.07);
  padding: 2px 7px;
  border-radius: 4px;
  color: #93c5fd;
  font-family: 'Consolas', monospace;
}

/* =====================================================
   Page header
   ===================================================== */
.btn-voltar {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: 10px;
  transition: color .15s;
}
.btn-voltar:hover { color: var(--primary); }

.page-header { margin-bottom: 28px; }

.page-header h2 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-head);
  letter-spacing: -.3px;
}

.text-muted { color: var(--text-muted); font-size: 13px; margin: 0; }

/* =====================================================
   Form cards (dentro do main-content)
   ===================================================== */
.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 560px;
  transition: border-color .2s;
}

.form-card h3 {
  color: var(--text-head) !important;
}

.form-actions { display: flex; gap: 10px; margin-top: 24px; flex-wrap: wrap; }

.filter-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }

td.actions { white-space: nowrap; display: flex; gap: 5px; align-items: center; }

/* =====================================================
   Error page
   ===================================================== */
.error-page { text-align: center; padding: 80px 24px; }
.error-page h2 { font-size: 28px; color: var(--text-head); margin-bottom: 12px; font-weight: 700; }
.error-page p { color: var(--text-muted); margin-bottom: 28px; }

/* =====================================================
   Modal
   ===================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  box-shadow: 0 24px 64px rgba(0,0,0,.6);
  overflow: hidden;
}

.modal-header {
  background: rgba(255,255,255,.04);
  border-bottom: 1px solid var(--border);
  color: var(--text-head);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 { margin: 0; font-size: 15px; font-weight: 600; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color .15s, background .15s;
}

.modal-close:hover { color: var(--text-head); background: rgba(255,255,255,.08); }

.modal-box form { padding: 24px; }

/* =====================================================
   Árvore organizacional
   ===================================================== */
.org-tree-list { list-style: none; margin: 0; padding: 0 0 0 28px; }
.org-tree-list:first-child { padding-left: 0; }
.org-tree-list::before { content: none; }

.org-tree-item { margin: 6px 0; position: relative; }

.org-node {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  transition: border-color .15s, background .15s;
}

.org-node:hover { background: var(--bg-card-2, #1a2036); border-color: rgba(59,130,246,.4); }

.org-node-info { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.org-node-type { font-size: 12px; color: var(--primary); min-width: 60px; font-weight: 600; }
.org-node-name { font-size: 13px; color: var(--text-head); font-weight: 500; }
.org-node-code {
  font-size: 11px;
  background: rgba(255,255,255,.06);
  color: var(--text-muted);
  padding: 2px 7px;
  border-radius: 4px;
  font-family: monospace;
}

.org-depth-badge {
  font-size: 10px;
  color: #fff;
  padding: 2px 7px;
  border-radius: 99px;
  font-weight: 700;
}

.org-node-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.empty-state { color: var(--text-muted); font-size: 14px; padding: 32px 0; text-align: center; }

/* =====================================================
   Inline styles override — harmonia dark
   ===================================================== */

/* Labels dentro de inline styles */
label { color: var(--text-muted) !important; }

/* Selects */
select { color: var(--text-head); background: var(--bg-input); }
select option { background: var(--bg-card); color: var(--text-head); font-family: 'Courier New', monospace; }

/* Inputs color */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="color"],
textarea,
select {
  color: var(--text-head);
  background-color: var(--bg-input) !important;
}

/* Variavel blocks e faixa blocks nos forms de matriz */
.variavel-block,
[style*="border:1px solid #e0e0e0"],
[style*="border: 1px solid #e0e0e0"] {
  background: var(--bg-card) !important;
  border-color: var(--border) !important;
}

/* Inline background branco → card dark */
[style*="background:#fff"],
[style*="background: #fff"],
[style*="background:#fafafa"],
[style*="background: #fafafa"],
[style*="background-color:#fff"],
[style*="background-color: #fff"] {
  background: var(--bg-card) !important;
}

/* Inline background f4f6f9 → escuro */
[style*="background:#f4f6f9"],
[style*="background: #f4f6f9"] {
  background: rgba(255,255,255,.04) !important;
}

/* Textos escuros nos inline styles */
[style*="color:#888"],
[style*="color: #888"],
[style*="color:#555"],
[style*="color: #555"],
[style*="color:#666"],
[style*="color: #666"] {
  color: var(--text-muted) !important;
}

[style*="color:#333"],
[style*="color: #333"] {
  color: var(--text) !important;
}

/* Borders inline */
[style*="border:1px solid #d0d7e3"],
[style*="border: 1px solid #d0d7e3"] {
  border-color: rgba(255,255,255,.1) !important;
}

/* Headings de seção nos forms (ex: form-card h3) */
[style*="color:#1F3864"] {
  color: var(--text-head) !important;
}

/* Código inline (small, muted) */
small { color: var(--text-muted) !important; }

/* Table header cor na matriz form */
th[style*="background:#1F3864"],
th[style*="background: #1F3864"] {
  background: var(--primary) !important;
  color: #fff !important;
}

/* =====================================================
   Animações / helpers
   ===================================================== */
.fade-in { animation: fadeIn .2s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* =====================================================
   Responsivo
   ===================================================== */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { padding: 16px; }
  .cards-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .cards-grid { grid-template-columns: 1fr; }
}
