@import url("./tokens.css");

/* ---------- reset e superfícies do navegador (craft-floor: seleção, cursor, rolagem, foco) ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100dvh; background: var(--fundo); color: var(--texto); font: 400 var(--t-14)/1.55 var(--fonte); font-synthesis: none; -webkit-font-smoothing: antialiased; }
::selection { background: var(--acento-fundo); color: var(--texto); }
input, textarea { caret-color: var(--acento-forte); }
* { scrollbar-width: thin; scrollbar-color: var(--n-600) transparent; }
:focus-visible { outline: none; box-shadow: var(--anel-foco); border-radius: var(--raio-interno); }
a { color: var(--acento-texto); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.02em; text-wrap: balance; }
h1, h2 { font-family: var(--fonte-titulo); }
h1 { font-size: var(--t-24); font-weight: 600; letter-spacing: -0.035em; }
h2 { font-size: var(--t-16); }
h3 { font-size: var(--t-14); }
p { text-wrap: pretty; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--fonte-mono); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.pular { position: absolute; left: var(--esp-3); top: -60px; z-index: 50; background: var(--acento); color: var(--sobre-acento); padding: var(--esp-2) var(--esp-3); border-radius: var(--raio-controle); font-weight: 600; text-decoration: none; }
.pular:focus { top: var(--esp-3); }
svg.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- botões: mesma linguagem do botão avião (ui/botao-aviao.css) ----------
   Face escura em degradê, borda fina; no hover/foco uma luz lima percorre a borda. Sem markup extra: vale para todo .btn.
   Movimento só com o ponteiro em cima; modo calmo e "reduzir movimento" deixam a borda parada. */
@property --giro { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
.btn { --face-a: #232a34; --face-b: #161a21; --luz: var(--lima-500);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--esp-2); min-height: 40px; padding: 0 var(--esp-4); border-radius: 12px;
  border: 1.5px solid transparent; color: var(--texto); font-weight: 500; font-size: var(--t-13); letter-spacing: -.005em; cursor: pointer; text-decoration: none; white-space: nowrap;
  background: linear-gradient(var(--face-a), var(--face-b)) padding-box, linear-gradient(to bottom, #ffffff26, #ffffff0a) border-box;
  box-shadow: 0 6px 14px #0000004d, 0 2px 4px #0000002e;
  transition: transform var(--dur-base) ease, box-shadow var(--dur-base) ease, color var(--dur-rapida), filter var(--dur-rapida); }
.btn:hover, .btn:focus-visible { transform: scale(1.02); box-shadow: 0 10px 22px #00000066, 0 2px 4px #0000002e;
  background: linear-gradient(var(--face-a), var(--face-b)) padding-box, conic-gradient(from var(--giro), #ffffff1f 0 62%, var(--luz) 84%, #ffffff1f 100%) border-box;
  animation: giro-borda 2.2s linear infinite; }
.btn:focus-visible { outline: 2px solid var(--luz); outline-offset: 3px; }
.btn:active { transform: scale(1); }
@keyframes giro-borda { to { --giro: 360deg; } }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; animation: none; box-shadow: none; }
.btn.primario { --face-a: #d4ff4a; --face-b: var(--lima-500); --luz: #ffffff; color: var(--sobre-acento); font-weight: 600;
  background: linear-gradient(var(--face-a), var(--face-b)) padding-box, linear-gradient(to bottom, #ffffff66, #ffffff1a) border-box; box-shadow: 0 6px 14px #00000059, inset 0 1px 0 #ffffff66; }
.btn.primario:hover, .btn.primario:focus-visible { filter: brightness(1.04);
  background: linear-gradient(var(--face-a), var(--face-b)) padding-box, conic-gradient(from var(--giro), #ffffff40 0 62%, #fff 84%, #ffffff40 100%) border-box; }
.btn.sucesso, .btn.ok { --face-a: #5fd39426; --face-b: #5fd3941a; --luz: var(--verde-400); color: var(--verde-400); font-weight: 600; }
.btn.sucesso:hover, .btn.ok:hover { color: var(--verde-400); }
.btn.fantasma { --face-a: transparent; --face-b: transparent; color: var(--texto-2); box-shadow: none;
  background: linear-gradient(transparent, transparent) padding-box, linear-gradient(transparent, transparent) border-box; }
.btn.fantasma:hover, .btn.fantasma:focus-visible { color: var(--texto); box-shadow: none; transform: none; animation: none;
  background: linear-gradient(#ffffff0f, #ffffff0f) padding-box, linear-gradient(#ffffff14, #ffffff14) border-box; }
.btn.perigo { --face-a: #f2766a1f; --face-b: #f2766a12; --luz: var(--vermelho-400); color: var(--perigo); }
.btn.perigo:hover { color: var(--perigo); }
.btn.icone { width: 40px; padding: 0; }
.btn[aria-busy="true"] { position: relative; color: transparent; }
.btn[aria-busy="true"]::after { content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--texto-3); border-top-color: var(--texto); animation: girar .7s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }
html[data-calmo="1"] .btn:hover, html[data-calmo="1"] .btn:focus-visible { animation: none; transform: none; }
@media (prefers-reduced-motion: reduce) { .btn { transition: none; } .btn:hover, .btn:focus-visible { animation: none; transform: none; } }

/* ---------- campos ---------- */
.campo { display: grid; gap: var(--esp-1); font-size: var(--t-13); color: var(--texto-2); font-weight: 500; }
input:not([type=checkbox]):not([type=file]), select, textarea { width: 100%; min-width: 0; min-height: 40px; padding: var(--esp-2) var(--esp-3); background: var(--superficie-2); border: 1px solid var(--linha); border-radius: var(--raio-controle); color: var(--texto); transition: border-color var(--dur-rapida); }
input:hover, select:hover, textarea:hover { border-color: var(--n-600); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ciano); box-shadow: 0 0 0 1px #00edff44, 0 0 24px #00edff18; }
input::placeholder, textarea::placeholder { color: var(--texto-3); }
input[type=checkbox] { accent-color: var(--acento); width: 16px; height: 16px; }

/* ---------- indicadores ---------- */
.ponto { width: 8px; height: 8px; border-radius: 50%; background: var(--texto-3); flex: none; }
.ponto.ok { background: var(--ok); } .ponto.alerta { background: var(--alerta); } .ponto.erro { background: var(--perigo); }
.ponto.vivo { background: var(--acento); animation: pulso 2s var(--curva-saida) infinite; }
@keyframes pulso { 0% { box-shadow: 0 0 0 0 #b7ff0073; } 100% { box-shadow: 0 0 0 7px #b7ff0000; } }
.estado-linha { display: inline-flex; align-items: center; gap: var(--esp-2); font-size: var(--t-13); color: var(--texto-2); white-space: nowrap; }

/* ---------- casca do app: barra lateral única para Painel, Sala 3D e Configurador ---------- */
.app { display: grid; grid-template-columns: 256px minmax(0, 1fr); min-height: 100dvh; }
.lateral { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; background: #000000ed; border-right: 1px solid var(--linha-viva); min-width: 0; }
.marca { display: flex; align-items: center; gap: var(--esp-3); padding: var(--esp-4) var(--esp-4) var(--esp-3); }
.marca svg { width: 30px; height: 30px; flex: none; }
.marca strong { display: block; font-family: var(--fonte-titulo); font-size: var(--t-16); font-weight: 700; letter-spacing: -0.02em; }
.marca small { display: flex; align-items: center; gap: 6px; color: var(--texto-3); font-size: var(--t-12); }
.navegacao { display: grid; gap: 2px; padding: var(--esp-2) var(--esp-2) var(--esp-3); border-bottom: 1px solid var(--linha-suave); }
.navegacao a { display: flex; align-items: center; gap: var(--esp-3); min-height: 44px; padding: 0 var(--esp-3); border-radius: var(--raio-controle); color: var(--texto-2); text-decoration: none; font-weight: 500; transition: background var(--dur-rapida), color var(--dur-rapida); }
.navegacao a:hover { background: #18181b; color: var(--texto); }
.navegacao a[aria-current="page"] { background: #00edff0b; color: var(--texto); box-shadow: inset 2px 0 0 var(--ciano); }
.navegacao a[aria-current="page"] svg { color: var(--ciano); filter: drop-shadow(0 0 5px #00edff60); }
.navegacao .contador { margin-left: auto; font-size: 11px; color: var(--texto-2); font-variant-numeric: tabular-nums; }
.navegacao .contador:not(:empty) { padding: 0 6px; border-radius: 4px; background: #2d2d32; }
.equipe { flex: 1; overflow-y: auto; padding: var(--esp-4) var(--esp-2) var(--esp-2); display: grid; align-content: start; gap: 2px; }
.equipe h2 { font-size: 10px; font-weight: 550; color: var(--texto-3); letter-spacing: 1.2px; text-transform: uppercase; padding: 0 var(--esp-3) var(--esp-2); }
.equipe h2:not(:first-child) { margin-top: var(--esp-4); }
.membro { display: flex; align-items: center; gap: var(--esp-3); min-height: 44px; padding: var(--esp-1) var(--esp-3); border-radius: var(--raio-controle); color: inherit; text-decoration: none; min-width: 0; }
.membro:hover { background: #18181b; }
.membro .avatar { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-weight: 600; font-size: var(--t-13); color: var(--n-950); flex: none; position: relative; }
.membro .avatar .ponto { position: absolute; right: -2px; bottom: -2px; width: 9px; height: 9px; border: 2px solid #000; box-sizing: content-box; }
.membro span:last-child { min-width: 0; }
.membro strong { display: block; font-weight: 500; font-size: var(--t-13); }
.membro small { display: block; color: var(--texto-3); font-size: var(--t-12); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rodape-lateral { display: flex; align-items: center; justify-content: space-between; gap: var(--esp-2); padding: var(--esp-3) var(--esp-4); border-top: 1px solid var(--linha-suave); font-size: var(--t-13); color: var(--texto-2); }
.rodape-lateral small { display: block; color: var(--texto-3); font-size: var(--t-12); }
.abrir-menu { display: none; }

.principal { min-width: 0; display: flex; flex-direction: column; }
/* o conteúdo fica por cima da rede neural do fundo */
.app { position: relative; z-index: 1; }
#neural { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.neural-controle { position: fixed; right: 22px; bottom: 16px; z-index: 24; }
.neural-controle button { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 14px; background: #000000f2; color: #d7e8ec; border: 1px solid #55747e; border-radius: 12px;
  font: 12px var(--fonte-mono); cursor: pointer; box-shadow: 0 0 18px #00edff0c; }
.neural-controle button:hover { border-color: var(--ciano); }
.neural-controle button:disabled { color: var(--texto-3); cursor: default; }
.neural-icone { font-size: 18px; line-height: 1; color: var(--texto-3); }
.neural-controle.viva .neural-icone { color: var(--ciano); text-shadow: 0 0 8px var(--ciano); }
[data-estado] { color: var(--texto-2); }
/* textos grandes sobre a rede: sombra preta para não perder leitura quando os impulsos passam */
.cabecalho h1, .foco h2 { text-shadow: 0 2px 12px #000, 0 0 24px #000; }
.cabecalho { display: flex; align-items: center; gap: var(--esp-4); padding: var(--esp-5) var(--esp-8) var(--esp-4); }
.cabecalho .titulo { flex: 1; min-width: 0; }
.cabecalho p { margin: 2px 0 0; color: var(--texto-3); font-size: var(--t-13); }
.cabecalho .acoes { display: flex; gap: var(--esp-2); flex-wrap: wrap; justify-content: flex-end; }

@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .lateral { position: fixed; inset: 0 auto 0 0; width: min(288px, 86vw); z-index: 40; transform: translateX(-102%); transition: transform var(--dur-base) var(--curva-saida); }
  .app.menu-aberto .lateral { transform: none; box-shadow: 0 0 0 100vmax rgb(0 0 0 / .7); }
  .abrir-menu { display: inline-flex; }
  .cabecalho { padding: var(--esp-4); flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}

/* modo calmo (ui/conforto.js): nada se mexe sozinho */
[data-calmo="1"] *, [data-calmo="1"] *::before, [data-calmo="1"] *::after {
  animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important;
}

/* celular: título em cima, ações numa linha só embaixo (rola de lado se faltar espaço) */
@media (max-width: 640px) {
  .cabecalho { align-items: flex-start; gap: var(--esp-2) var(--esp-3); padding: var(--esp-3) var(--esp-4); }
  .cabecalho .titulo { flex: 1 1 calc(100% - 56px); }
  .cabecalho h1 { font-size: var(--t-20); }
  .cabecalho .acoes { flex: 1 1 100%; flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; }
  .cabecalho .acoes .btn { min-height: 36px; padding: 0 var(--esp-3); font-size: var(--t-13); white-space: nowrap; flex: none; }
}

/* assinatura: a cor do agente marca o que é dele (faixa à esquerda), como na Sala 3D */
[data-agente] { --cor-ag: var(--linha); }
[data-agente="alva"] { --cor-ag: var(--ag-alva); } [data-agente="atlas"] { --cor-ag: var(--ag-atlas); }
[data-agente="nova"] { --cor-ag: var(--ag-nova); } [data-agente="maia"] { --cor-ag: var(--ag-maia); }
[data-agente="leo"] { --cor-ag: var(--ag-leo); } [data-agente="operador"] { --cor-ag: var(--acento); }

/* barra de navegação do celular */
.nav-inferior { display: none; }
@media (max-width: 640px) {
  .nav-inferior { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; display: grid; grid-template-columns: repeat(5, 1fr);
    background: #000000f5; backdrop-filter: blur(10px); border-top: 1px solid #00edff30;
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .nav-inferior a { position: relative; display: grid; justify-items: center; gap: 2px; padding: 6px 0 4px; color: var(--texto-3); text-decoration: none; font-size: 11px; font-weight: 500; border-radius: var(--raio-controle); }
  .nav-inferior a svg { width: 22px; height: 22px; }
  .nav-inferior a[aria-current="page"] { color: var(--ciano); background: #00edff10; }
  .nav-inferior a[aria-current="page"]::before { content: ""; position: absolute; top: 0; width: 22px; height: 2px; border-radius: 2px; background: var(--ciano); box-shadow: 0 0 8px var(--ciano); }
  .neural-controle { right: 12px; bottom: calc(78px + env(safe-area-inset-bottom)); }
  .neural-controle button { font-size: 11px; padding: 6px 10px; min-height: 36px; }
  .nav-inferior .selo-cont { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--acento); color: var(--sobre-acento); font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums; }
  body.com-nav-inferior { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  /* telas de altura fixa (Sala 3D, Configurador, Base) encolhem para a barra não cobrir nada */
  body.com-nav-inferior .sala, body.com-nav-inferior .conversa { height: calc(100dvh - 64px - env(safe-area-inset-bottom)); }
  body.com-nav-inferior .abrir-menu { display: none; }
}
/* telas com compositor no rodapé (Configurador): o controle da rede sobe para não cobrir o "enviar" */
body:has(.compositor) .neural-controle { bottom: 88px; }
@media (max-width: 640px) { body:has(.compositor) .neural-controle { display: none; } }

/* grupos da barra lateral (Workspace / Escritório), como o "WORKSPACE" do Órbita */
.nav-grupo { margin: var(--esp-3) 0 var(--esp-1); padding: 0 var(--esp-3); font-size: 10px; font-weight: 550; letter-spacing: 1.2px; text-transform: uppercase; color: var(--texto-3); }
.nav-grupo:first-child { margin-top: 0; }
.nav-mais { display: none; }
@media (max-width: 640px) {
  .nav-inferior .nav-mais { position: relative; display: grid; justify-items: center; gap: 2px; padding: 6px 0 4px; background: none; border: 0; color: var(--texto-3); font: 500 11px var(--fonte); cursor: pointer; border-radius: var(--raio-controle); }
  .nav-inferior .nav-mais svg { width: 22px; height: 22px; }
  .nav-inferior .nav-mais[aria-current="page"] { color: var(--ciano); background: #00edff10; }
}
/* menu aberto no celular/tablet: fundo sólido (texto de trás não pode vazar) e o controle da rede some */
@media (max-width: 960px) {
  .lateral { background: #000; }
  .app.menu-aberto ~ .neural-controle { display: none; }
}

/* faixa da demonstração pública (DEMO=1) */
.faixa-demo { position: relative; z-index: 26; padding: 6px 16px; text-align: center; font-size: 12px; color: #111900; background: var(--acento); box-shadow: 0 0 14px #b7ff0050; }
.faixa-demo a { color: #111900; font-weight: 600; }
