/* ============================================================
   Sistema de design — Trilhas & Módulos
   Paleta inspirada em diagrama unifilar / sinalização elétrica:
   fundo grafite, condutor âmbar, dados em teal.
   ============================================================ */

@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap");

:root {
  --bg: #14171a;
  --surface: #1b1f23;
  --surface-raised: #21262c;
  --border: #2c3138;
  --border-strong: #3a4047;
  --text: #ece9e2;
  --text-muted: #9aa1a8;
  --text-faint: #6b7178;
  --amber: #f0a824;
  --amber-soft: rgba(240, 168, 36, 0.14);
  --teal: #3fb6a6;
  --teal-soft: rgba(63, 182, 166, 0.14);
  --danger: #e2604a;
  --danger-soft: rgba(226, 96, 74, 0.14);
  --sucesso: #5fb56a;
  --sucesso-soft: rgba(95, 181, 106, 0.14);
  --radius-sm: 4px;
  --radius: 8px;
  --font-display: "Space Grotesk", sans-serif;
  --font-body: "IBM Plex Sans", sans-serif;
  --font-mono: "IBM Plex Mono", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.01em;
}

a {
  color: var(--teal);
  text-decoration: none;
}

button {
  font-family: var(--font-body);
}

:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

/* Garante que qualquer elemento marcado como hidden pelo JS
   fique realmente escondido, mesmo que outra classe (como
   .btn ou .linha-campos) declare seu próprio "display". */
[hidden] {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.topbar__brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.topbar__brand h1 {
  font-size: 18px;
}

.topbar__brand span {
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 12px;
}

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

.topbar__user span {
  font-family: var(--font-mono);
}

/* ---------- layout com navegação lateral ---------- */

.layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  min-height: calc(100vh - 65px);
}

.nav-rail {
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: 20px 12px;
}

.nav-rail a {
  display: block;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 4px;
}

.nav-rail a:hover {
  background: var(--surface-raised);
  color: var(--text);
}

.nav-rail a.ativo {
  background: var(--amber-soft);
  color: var(--amber);
  font-weight: 500;
}

.conteudo {
  padding: 28px 32px;
  max-width: 920px;
}

@media (max-width: 720px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .nav-rail {
    display: flex;
    border-right: none;
    border-bottom: 1px solid var(--border);
    gap: 4px;
    padding: 10px 16px;
  }
  .conteudo {
    padding: 20px;
  }
}

/* ---------- painéis / cartões ---------- */

.painel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.painel__titulo {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-bottom: 14px;
}

/* ---------- campos de formulário ---------- */

.campo {
  margin-bottom: 14px;
}

.campo label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.input,
.select,
textarea.input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: 14px;
  font-family: var(--font-body);
}

.input--mono {
  font-family: var(--font-mono);
}

.input:focus,
.select:focus {
  border-color: var(--amber);
}

.linha-campos {
  display: flex;
  gap: 12px;
}

.linha-campos .campo {
  flex: 1;
}

/* ---------- botões ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface-raised);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.btn:hover {
  border-color: var(--text-faint);
}

.btn--primary {
  background: var(--amber);
  border-color: var(--amber);
  color: #1a1305;
}

.btn--primary:hover {
  background: #f5b54a;
  border-color: #f5b54a;
}

.btn--ghost {
  background: transparent;
}

.btn--danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

.btn--danger:hover {
  background: var(--danger-soft);
}

.btn--sm {
  padding: 4px 9px;
  font-size: 12px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- mensagens de estado ---------- */

.mensagem {
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}

.mensagem--erro {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid var(--danger);
}

.mensagem--sucesso {
  background: var(--sucesso-soft);
  color: var(--sucesso);
  border: 1px solid var(--sucesso);
}

.estado-vazio {
  color: var(--text-faint);
  font-size: 14px;
  padding: 24px 0;
  text-align: center;
}

/* ---------- badge de carga horária ---------- */

.badge-ch {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  font-family: var(--font-mono);
  color: var(--teal);
  background: var(--teal-soft);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  font-size: 13px;
  white-space: nowrap;
}

.badge-ch small {
  color: var(--text-faint);
  font-family: var(--font-body);
}

/* ---------- trilha: trilho condutor com os módulos ---------- */

.trilho {
  position: relative;
  padding-left: 34px;
}

.trilho::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 12px;
  bottom: 12px;
  width: 2px;
  background: linear-gradient(
    to bottom,
    var(--amber) 0%,
    var(--border-strong) 100%
  );
}

.modulo-no {
  position: relative;
  margin-bottom: 14px;
}

.modulo-no::before {
  content: attr(data-ordem);
  position: absolute;
  left: -34px;
  top: 14px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--amber);
  color: var(--amber);
  font-family: var(--font-mono);
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modulo-no__cabecalho {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  cursor: pointer;
}

.modulo-no__cabecalho:hover {
  border-color: var(--border-strong);
}

.modulo-no__nome {
  font-size: 14px;
  font-weight: 500;
}

.modulo-no__pops {
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 4px 16px 10px 16px;
}

.pop-item {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  font-size: 13px;
}

.pop-item:first-child {
  border-top: none;
}

.pop-item__codigo {
  font-family: var(--font-mono);
  color: var(--text-faint);
  white-space: nowrap;
}

.trilha-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 18px;
}

.trilha-total h2 {
  font-size: 20px;
}

/* ---------- tabela de módulos ---------- */

.tabela {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.tabela th {
  text-align: left;
  color: var(--text-faint);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-strong);
}

.tabela td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
}

.tabela tr:hover td {
  background: var(--surface-raised);
}

.tabela tr {
  cursor: pointer;
}

/* ---------- lista de procedimentos no editor de módulo ---------- */

.lista-pops {
  list-style: none;
  margin: 0 0 14px 0;
  padding: 0;
}

.lista-pops li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.lista-pops li:last-child {
  border-bottom: none;
}

.lista-pops .codigo {
  font-family: var(--font-mono);
  color: var(--teal);
  font-size: 12px;
  white-space: nowrap;
}

.lista-pops .titulo {
  flex: 1;
  font-size: 13px;
}

/* ---------- página de login ---------- */

.tela-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.cartao-login {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}

.cartao-login__marca {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.cartao-login__trilho {
  width: 8px;
  height: 28px;
  border-radius: 2px;
  background: var(--amber);
}

.cartao-login h1 {
  font-size: 19px;
}

.cartao-login p {
  color: var(--text-faint);
  font-size: 13px;
  margin: 4px 0 24px 0;
}

.cartao-login .btn--primary {
  width: 100%;
  justify-content: center;
  padding: 10px;
  margin-top: 6px;
}

/* ---------- tabs do painel admin ---------- */

.tab-bar {
  display: flex;
  gap: 2px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  padding: 9px 18px;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}

.tab-btn:hover { color: var(--text); }

.tab-btn.ativo {
  color: var(--amber);
  border-bottom-color: var(--amber);
}

/* ---------- layout split (lista + detalhe) ---------- */

.admin-area {
  max-width: none;
  padding: 28px 32px;
}

.split {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  align-items: start;
}

.split__lista {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.split__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
}

.lista-nav {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: calc(100vh - 300px);
  overflow-y: auto;
}

.lista-nav li {
  padding: 9px 14px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  line-height: 1.3;
}

.lista-nav li:last-child { border-bottom: none; }
.lista-nav li:hover { background: var(--surface-raised); color: var(--text); }
.lista-nav li.ativo { background: var(--amber-soft); color: var(--amber); }

.lista-nav .sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  display: block;
  margin-top: 2px;
}

.split__detalhe {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  min-height: 420px;
}

.lista-busca {
  width: 100%;
  background: var(--bg);
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  font-size: 13px;
  font-family: var(--font-body);
}

.lista-busca:focus { outline: none; border-bottom-color: var(--amber); }

.tabela--proc td:first-child {
  font-family: var(--font-mono);
  color: var(--teal);
  font-size: 12px;
  white-space: nowrap;
  width: 160px;
}

@media (max-width: 720px) {
  .split { grid-template-columns: 1fr; }
  .admin-area { padding: 20px; }
}
