/* =========================================================
   Ravisign - casca do painel
   Consome os tokens --d2-* do design system (d2.css).
   ========================================================= */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--d2-bg);
  color: var(--d2-text);
  font-family: var(--d2-font-sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
[hidden] { display: none !important; }

:root {
  --rs-sombra-1: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 1px rgba(15, 23, 42, .03);
  --rs-sombra-2: 0 8px 24px rgba(15, 23, 42, .09), 0 2px 6px rgba(15, 23, 42, .05);
  --rs-brand-tinta: rgba(16, 185, 129, .11);
  --rs-brand-borda: rgba(16, 185, 129, .28);
  --d2-brand: #047857;
  --d2-brand-dim: #065f46;
  --d2-bg: #f3f6f8;
  --d2-bg-subtle: #f7f9fa;
  --d2-bg-hover: #edf2f5;
  --d2-border: #e1e7ec;
  --d2-text: #172b3a;
  --d2-text-muted: #526574;
  --d2-text-faint: #657583;
}
html[data-theme="dark"] {
  --rs-sombra-1: 0 1px 2px rgba(0, 0, 0, .4);
  --rs-sombra-2: 0 12px 28px rgba(0, 0, 0, .5);
  --rs-brand-tinta: rgba(16, 185, 129, .14);
  --rs-brand-borda: rgba(16, 185, 129, .35);
  --d2-brand: #34d399;
  --d2-brand-dim: #10b981;
  --d2-text-faint: #94a3b8;
  color-scheme: dark;
}
html:not([data-theme="dark"]) { color-scheme: light; }
:where(a, button, input, select, textarea):focus-visible { outline: 3px solid var(--d2-brand); outline-offset: 3px; }

/* ---------------- Estrutura ---------------- */
.app { display: flex; min-height: 100vh; }
.lateral {
  position: fixed;
  inset: 0 auto 0 0;
  width: 240px;
  display: flex;
  flex-direction: column;
  background: var(--d2-bg-elevated);
  border-right: 1px solid var(--d2-border);
  z-index: 100;
}
.principal {
  flex: 1;
  min-width: 0;
  margin-left: 240px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topo {
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 26px;
  background: color-mix(in srgb, var(--d2-bg-elevated) 86%, transparent);
  backdrop-filter: blur(10px) saturate(1.4);
  border-bottom: 1px solid var(--d2-border);
}
.topo-textos { min-width: 0; }
.topo-titulo { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: -.035em; }
.topo-subtitulo { margin-top: 4px; font-size: 13px; color: var(--d2-text-muted); }
.topo-acoes { display: flex; align-items: center; gap: 8px; }

/* Sem teto de largura: em monitor grande a tela inteira trabalha. Textos de
   leitura têm os próprios limites (.formulario-maximo). */
.conteudo { flex: 1; padding: 24px 26px; width: 100%; margin-left: auto; margin-right: auto; }

.rodape-creditos { padding: 6px 26px 14px; text-align: center; font-size: 11px; letter-spacing: .03em; color: var(--d2-text-muted); opacity: .65; }

/* ---------------- Marca ---------------- */
.lateral-marca { position: relative; display: flex; align-items: center; gap: 11px; padding: 18px 18px 16px; min-height: 76px; }
.marca-icone {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, .35);
  flex: none;
}
.marca-icone svg { width: 18px; height: 18px; }
.marca-icone.grande { width: 54px; height: 54px; border-radius: 15px; }
.marca-icone.grande svg { width: 28px; height: 28px; }
.marca-nome { font-size: 18px; font-weight: 400; letter-spacing: -.01em; }
.marca-nome b { font-weight: 750; color: var(--d2-brand); }
.menu-alternar { margin-left: auto; }

/* ---------------- Navegação ---------------- */
.lateral-nav { flex: 1; padding: 4px 12px 12px; overflow-y: auto; }
.nav-secao { margin: 25px 10px 10px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; color: var(--d2-text-faint); }
.nav-secao:first-child { margin-top: 4px; }
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 43px;
  padding: 9px 12px;
  margin-bottom: 5px;
  border-radius: 9px;
  color: var(--d2-text-muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background .13s, color .13s;
}
.nav-item svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav-item:hover { background: var(--d2-bg-hover); color: var(--d2-text); }
.nav-item.ativo { background: var(--rs-brand-tinta); color: var(--d2-brand); font-weight: 600; box-shadow: inset 0 0 0 1px var(--rs-brand-borda); }
.nav-item.ativo svg { opacity: 1; }
.nav-item.ativo::before { content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--d2-brand); }

/* ---------------- Rodapé da lateral ---------------- */
.lateral-rodape { border-top: 1px solid var(--d2-border); padding: 13px 14px; }
.usuario-bloco { display: flex; align-items: center; gap: 10px; margin-bottom: 11px; }
a.usuario-bloco { text-decoration: none; color: inherit; border-radius: 9px; padding: 6px; margin: -6px -6px 5px; transition: background .12s; }
a.usuario-bloco:hover { background: var(--d2-bg-hover); }
.usuario-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff; font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center; flex: none;
}
.usuario-info { min-width: 0; }
.usuario-nome { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.usuario-perfil { font-size: 11px; color: var(--d2-text-faint); }
.usuario-acoes { display: flex; align-items: center; gap: 6px; }
.botao-icone {
  display: inline-flex; align-items: center; justify-content: center;
  width: 31px; height: 31px; min-width: 36px; min-height: 36px; padding: 0;
  border: 1px solid transparent; border-radius: 7px;
  background: transparent; color: var(--d2-text-muted);
  cursor: pointer; text-decoration: none;
  transition: background .13s, color .13s;
}
.botao-icone:hover { background: var(--d2-bg-hover); color: var(--d2-text); border-color: var(--d2-border); }
.botao-icone svg { width: 17px; height: 17px; }
html[data-theme="dark"] .icone-lua { display: none; }
html:not([data-theme="dark"]) .icone-sol { display: none; }
.icone-expandir { display: none; }

/* ---------------- Menu recolhido ---------------- */
html.menu-recolhido .lateral { width: 64px; }
html.menu-recolhido .principal { margin-left: 64px; }
html.menu-recolhido .lateral-marca { flex-direction: column; gap: 8px; justify-content: center; padding: 16px 8px 14px; }
html.menu-recolhido .menu-alternar { margin-left: 0; }
html.menu-recolhido .marca-nome,
html.menu-recolhido .nav-secao,
html.menu-recolhido .nav-item span,
html.menu-recolhido .usuario-info { display: none; }
html.menu-recolhido .lateral-nav { padding: 10px 8px 12px; }
html.menu-recolhido .nav-item { justify-content: center; padding: 11px 0; margin-bottom: 4px; }
html.menu-recolhido .nav-item.ativo::before { left: -8px; }
html.menu-recolhido .usuario-bloco { justify-content: center; margin-bottom: 8px; }
html.menu-recolhido .usuario-acoes { flex-direction: column; gap: 4px; align-items: center; }
html.menu-recolhido .icone-recolher { display: none; }
html.menu-recolhido .icone-expandir { display: inline; }

/* Cartão de dica da barra lateral: nome em cima, o que a tela faz embaixo.
   Elemento único no body, reposicionado pelo JS a cada hover. */
.rs-dica {
  position: fixed; z-index: 1300; max-width: 270px; padding: 9px 12px;
  background: #111827; color: #f1f5f9; border: 1px solid #334155; border-radius: 9px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
  opacity: 0; transform: translateX(-4px); pointer-events: none;
  transition: opacity .1s ease, transform .1s ease;
}
.rs-dica.on { opacity: 1; transform: none; }
.rs-dica b { display: block; font-size: 12.5px; font-weight: 600; }
.rs-dica span { display: block; font-size: 11.5px; line-height: 1.45; color: #94a3b8; margin-top: 3px; }
.rs-dica::before {
  content: ''; position: absolute; left: -5px; top: 50%; width: 8px; height: 8px;
  background: #111827; border-left: 1px solid #334155; border-bottom: 1px solid #334155;
  transform: translateY(-50%) rotate(45deg);
}
@media (pointer: coarse) { .rs-dica { display: none; } }

/* ---------------- Cartões e tabelas ---------------- */
.cartao { background: var(--d2-bg-elevated); border: 1px solid var(--d2-border); border-radius: 16px; box-shadow: 0 3px 14px rgba(15, 23, 42, .035); overflow: hidden; }
.cartao-recheio { padding: 20px; }
.cartao-recheio + .cartao-recheio, .cartao + .cartao { margin-top: 14px; }
.cartao-titulo { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.cartao-titulo h2 { margin: 0; font-size: 15px; font-weight: 650; }
.cartao-titulo .descricao { font-size: 12.5px; color: var(--d2-text-muted); margin-top: 2px; line-height: 1.45; }
.cartao-titulo-icone { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 11px; background: var(--rs-brand-tinta); color: var(--d2-brand); flex: none; }
.cartao-titulo-icone svg { width: 20px; height: 20px; }
.cartao-acoes { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.formulario-maximo { max-width: 640px; margin: 0 auto; }
.formulario-maximo.largo { max-width: 980px; }
.tabela { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tabela th {
  text-align: left; padding: 11px 16px; font-size: 11px; font-weight: 650;
  text-transform: uppercase; letter-spacing: .06em; color: var(--d2-text-muted);
  background: var(--d2-bg-subtle); border-bottom: 1px solid var(--d2-border);
}
.tabela td { padding: 12px 16px; border-bottom: 1px solid var(--d2-border); }
.tabela tbody tr:last-child td { border-bottom: none; }
.tabela tbody tr:hover td { background: var(--d2-bg-hover); }
.tabela-vazia { text-align: center; color: var(--d2-text-faint); padding: 34px 16px !important; }
.coluna-acoes { text-align: right; white-space: nowrap; }
.texto-mono { font-family: var(--d2-font-mono); font-size: 12px; }
.btn-mini { padding: 4px 11px; font-size: 12px; border-radius: 7px; }
.d2-btn { min-height: 36px; }
.d2-btn-primary { background: #047857; color: #fff; }
.d2-btn-primary:hover { background: #065f46; color: #fff; box-shadow: 0 3px 12px rgba(16, 185, 129, .42); }

/* ---------------- Verificação em duas etapas ---------------- */
.codigo-2fa { font-family: var(--d2-font-mono); font-size: 18px; letter-spacing: .35em; text-align: center; }
.segredo-2fa { text-align: center; font-size: 12px; color: var(--d2-text-muted); margin: 12px 0 4px; word-break: break-all; }

/* ---------------- Medidor de força de senha (js/senha.js) ---------------- */
.senha-forca { margin-top: 8px; }
.senha-forca-barra { display: flex; gap: 4px; }
.senha-forca-barra i { height: 4px; flex: 1; border-radius: 2px; background: var(--d2-border); transition: background .25s; }
.senha-forca[data-nivel="1"] .senha-forca-barra i:nth-child(1) { background: var(--d2-st-4); }
.senha-forca[data-nivel="2"] .senha-forca-barra i:nth-child(-n+2) { background: var(--d2-st-3); }
.senha-forca[data-nivel="3"] .senha-forca-barra i:nth-child(-n+3) { background: var(--d2-st-6); }
.senha-forca[data-nivel="4"] .senha-forca-barra i { background: var(--d2-st-6); }
.senha-forca-info { display: flex; justify-content: space-between; gap: 10px; margin-top: 5px; font-size: 12px; }
.senha-forca-rotulo { font-weight: 600; color: var(--d2-text-muted); }
.senha-forca[data-nivel="0"] .senha-forca-rotulo, .senha-forca[data-nivel="1"] .senha-forca-rotulo { color: var(--d2-st-4); }
.senha-forca[data-nivel="2"] .senha-forca-rotulo { color: var(--d2-st-3); }
.senha-forca[data-nivel="3"] .senha-forca-rotulo, .senha-forca[data-nivel="4"] .senha-forca-rotulo { color: #1d9e57; }
.senha-forca-dica { color: var(--d2-text-faint); text-align: right; }

/* ---------------- Responsivo ---------------- */
@media (max-width: 900px) {
  .lateral { width: 62px; }
  .principal { margin-left: 62px; }
  .lateral-marca { flex-direction: column; gap: 8px; justify-content: center; padding: 15px 8px; }
  .menu-alternar { margin-left: 0; }
  .marca-nome, .nav-item span, .nav-secao, .usuario-info { display: none; }
  .lateral-nav { padding: 8px 7px; }
  .nav-item { justify-content: center; padding: 11px 0; }
  .nav-item.ativo::before { left: -7px; }
  .usuario-bloco { justify-content: center; margin-bottom: 8px; }
  .usuario-acoes { flex-direction: column; }
  .conteudo, .topo { padding-left: 16px; padding-right: 16px; }
}
@media (max-width: 600px) {
  .topo { flex-wrap: wrap; align-items: flex-start; }
  .topo-textos { flex: 1 1 160px; }
  .topo-acoes { flex-wrap: wrap; max-width: 100%; }
  .topo-titulo { overflow-wrap: anywhere; }
}
