/* Original AiOS · sistema de janelas (abas, janelas, barra de tarefas, alerta)
   Mesma linguagem do chat: janela = comanda, topo café com borda picotada e título em Anton. */
@font-face { font-family: "Anton"; src: url(/fontes/Anton-Regular.ttf) format("truetype"); font-display: swap; }
:root { --cafe: #2b231c; --cafe-2: #3a2f26; --creme: #f6efe2; --mostarda: #e0a43a; --titulo: "Anton", "Oswald", Impact, sans-serif; --barra: 52px; }
:root[data-tema="escuro"] { --cafe: #0d0b09; --cafe-2: #1f1a15; --creme: #efe4d0; }
.so-camada .i, .so-barra .i, .so-alerta .i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.so-camada button, .so-barra button, .so-abas button, .so-alerta button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.so-camada button:focus-visible, .so-barra button:focus-visible, .so-abas button:focus-visible, .so-alerta button:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; }

/* ---------- abas no topo ---------- */
.so-abas { display: flex; align-items: stretch; gap: 2px; height: 100%; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.so-abas button { position: relative; display: inline-flex; align-items: center; gap: 7px; padding: 0 14px; font-size: 14px !important; font-weight: 600;
  color: var(--texto-2) !important; white-space: nowrap; }
.so-abas button:hover { color: var(--texto) !important; }
.so-abas button.ligada { color: var(--texto) !important; }
.so-abas button.ligada::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: var(--acento); }
.so-abas em { font-style: normal; font-size: 11px; font-weight: 650; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; display: inline-grid; place-items: center;
  background: var(--hover); color: var(--texto-2); font-variant-numeric: tabular-nums; }
.so-abas button.ligada em { background: var(--selecao); color: var(--acento); }

/* ---------- desktop de cada aba ---------- */
/* o canvas (terminal, subagentes, mídias) é o fundo da aba Conversas */
body:not([data-aba="conversas"]) #palco, body:not([data-aba="conversas"]) #zoom-indicador { display: none !important; }
.so-vazio { position: fixed; left: var(--menu); right: 0; top: var(--topo); bottom: var(--barra); display: grid; place-content: center; text-align: center; color: var(--texto-2); pointer-events: none; padding: 20px; }
.so-vazio[hidden] { display: none; }
.so-vazio b { font: 400 26px/1.1 var(--titulo); letter-spacing: .01em; color: var(--texto-3); }
.so-vazio p { margin: 8px 0 0; font-size: 13.5px; max-width: 42ch; }

/* ---------- janela ---------- */
.so-camada { position: fixed; inset: 0; pointer-events: none; z-index: 15; } /* abaixo do topo (busca) e do menu */
.so-janela { position: fixed; pointer-events: auto; display: flex; flex-direction: column; border-radius: 10px; overflow: hidden; background: var(--card);
  border: 1px solid var(--linha); box-shadow: 0 4px 14px rgba(30, 20, 10, .1); animation: so-abrir .14s ease-out; }
.so-janela.em-foco { box-shadow: 0 18px 50px rgba(30, 20, 10, .22); }
.so-janela[hidden] { display: none; }
.so-janela.maxi { border-radius: 8px; }
.so-janela.movendo { user-select: none; }
.so-janela.movendo iframe, .so-janela.movendo canvas, .so-janela.movendo .xterm { pointer-events: none; }
@keyframes so-abrir { from { opacity: 0; transform: translateY(6px); } }

.so-topo { position: relative; display: flex; align-items: center; gap: 10px; padding: 9px 8px 13px 12px; background: var(--cafe); color: var(--creme);
  cursor: grab; flex: none; touch-action: none; user-select: none; z-index: 2; }
.so-topo::after { content: ""; position: absolute; left: 0; right: 0; bottom: -5px; height: 10px;
  background: radial-gradient(circle at 5px 10px, transparent 4px, var(--cafe) 4.5px) 0 0 / 10px 10px repeat-x; }
.so-janela:not(.em-foco) .so-topo { --cafe: var(--cafe-2); }
.so-janela.movendo .so-topo { cursor: grabbing; }
.so-ic { display: grid; place-items: center; color: color-mix(in srgb, var(--creme) 75%, transparent); flex: none; }
.so-ic:empty { display: none; }
.so-titulo { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.so-titulo b { font: 400 17px/1.1 var(--titulo); letter-spacing: .01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.so-titulo small { font-size: 11.5px; color: color-mix(in srgb, var(--creme) 62%, transparent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.so-botoes { display: flex; gap: 1px; flex: none; }
.so-botoes button { width: 28px; height: 28px; border-radius: 5px; display: grid; place-items: center; color: color-mix(in srgb, var(--creme) 70%, transparent) !important; }
.so-botoes button:hover { background: rgba(255,255,255,.1) !important; color: var(--creme) !important; }
.so-botoes button.fechar:hover { background: #d93a26 !important; color: #fff !important; }
.so-botoes .i { width: 15px; height: 15px; }
.so-corpo { position: relative; flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }

.so-borda { position: absolute; z-index: 3; }
.so-borda.n, .so-borda.s { left: 12px; right: 12px; height: 6px; cursor: ns-resize; }
.so-borda.e, .so-borda.w { top: 12px; bottom: 12px; width: 6px; cursor: ew-resize; }
.so-borda.n { top: 0; } .so-borda.s { bottom: 0; } .so-borda.e { right: 0; } .so-borda.w { left: 0; }
.so-borda.ne, .so-borda.nw, .so-borda.se, .so-borda.sw { width: 14px; height: 14px; }
.so-borda.ne { top: 0; right: 0; cursor: nesw-resize; } .so-borda.sw { bottom: 0; left: 0; cursor: nesw-resize; }
.so-borda.nw { top: 0; left: 0; cursor: nwse-resize; } .so-borda.se { bottom: 0; right: 0; cursor: nwse-resize; }
.so-janela.maxi .so-borda { display: none; }
/* guia do encaixe (metade esquerda, direita ou tela cheia) */
.so-guia { position: fixed; border-radius: 10px; background: color-mix(in srgb, var(--acento) 14%, transparent); border: 2px dashed var(--acento); pointer-events: none; z-index: 99999; }
.so-guia[hidden] { display: none; }

/* ---------- barra de tarefas ---------- */
.so-barra { position: fixed; left: var(--menu); right: 0; bottom: 0; height: var(--barra); z-index: 35; display: flex; align-items: center; gap: 8px;
  padding: 0 84px 0 10px; background: var(--card); border-top: 1px solid var(--linha); }
.so-tarefas { flex: 1; min-width: 0; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; height: 100%; align-items: center; }
.so-tarefa { position: relative; display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px 0 10px; border-radius: 6px; max-width: 220px; flex: none;
  font-size: 12.5px !important; font-weight: 550; color: var(--texto-2) !important; }
.so-tarefa:hover { background: var(--hover) !important; color: var(--texto) !important; }
.so-tarefa.ativa { background: var(--selecao) !important; color: var(--texto) !important; }
.so-tarefa.ativa::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: 2px; height: 2px; border-radius: 2px; background: var(--acento); }
.so-tarefa.minimizada { opacity: .65; }
.so-tarefa-ic { display: grid; place-items: center; color: var(--acento); }
.so-tarefa-ic .i { width: 15px; height: 15px; }
.so-tarefa-nome { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.so-badge { min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px; background: #d93a26; color: #fff; font-size: 10.5px; font-weight: 700; display: inline-grid; place-items: center; }
.so-organizar { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 11px; border-radius: 6px; font-size: 12.5px !important; color: var(--texto-2) !important; flex: none; }
.so-organizar:hover { background: var(--hover) !important; color: var(--texto) !important; }
.so-organizar[hidden] { display: none; }

/* ---------- alerta (tamanho fixo) ---------- */
.so-alerta-fundo { position: fixed; inset: 0; z-index: 100000; display: grid; place-items: center; background: rgba(20, 14, 8, .38); animation: so-fundo .12s ease-out; }
@keyframes so-fundo { from { opacity: 0; } }
.so-alerta { width: 380px; max-width: calc(100vw - 32px); background: var(--card); color: var(--texto); border-radius: 10px; overflow: hidden; box-shadow: 0 24px 60px rgba(20, 14, 8, .35);
  border-top: 6px solid var(--cafe); padding: 20px 20px 16px; font-family: var(--fonte); }
.so-alerta b { display: block; font: 400 21px/1.15 var(--titulo); letter-spacing: .01em; }
.so-alerta p { margin: 8px 0 0; font-size: 13.5px; line-height: 1.5; color: var(--texto-2); }
.so-alerta-botoes { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.so-alerta-botoes button { height: 34px; padding: 0 14px; border-radius: 6px; font-size: 13px !important; font-weight: 600; background: var(--hover) !important; }
.so-alerta-botoes button:hover { filter: brightness(.96); }
.so-alerta-botoes .principal { background: var(--cafe) !important; color: var(--creme) !important; }
.so-alerta-botoes .perigo { background: #c0321f !important; color: #fff !important; }

/* ---------- partes do painel que agora moram dentro de janelas ---------- */
/* árvore de arquivos */
.so-corpo > .painel-lateral { position: static; inset: auto; width: auto; height: 100%; border-radius: 0; transform: none !important; opacity: 1 !important; pointer-events: auto !important;
  box-shadow: none; border: 0; background: var(--card); -webkit-backdrop-filter: none; backdrop-filter: none; }
.so-corpo > .painel-lateral .painel-topo .painel-titulo { display: none; }
.so-corpo > .painel-lateral .painel-topo { padding: 10px 10px 4px; justify-content: flex-end; }
/* conteúdos e configurações (eram folhas que subiam de baixo) */
.so-corpo > .folha { position: static; inset: auto; display: flex; flex-direction: column; height: 100%; z-index: auto; }
.so-corpo > .folha[hidden] { display: none; }
.so-corpo > .folha .folha-fundo { display: none; }
.so-corpo > .folha .folha-corpo { width: auto; height: 100%; max-height: none; margin: 0; border-radius: 0; box-shadow: none; border: 0; animation: none; transform: none; flex: 1; }
.so-corpo > .folha .folha-topo > .icone-botao, .so-corpo > .folha .folha-acoes > .icone-botao[data-acao^="fechar"] { display: none; }
.so-corpo > .folha .folha-topo { padding: 16px 18px 8px; }
/* visor de fotos e vídeos */
.so-corpo > .visor { position: absolute; inset: 0; z-index: auto; background: #141210; }
.so-corpo > .visor .visor-fundo { display: none; }
.so-corpo > .visor .visor-acoes [data-acao="fechar-visor"] { display: none; }
.so-corpo > .visor .visor-topo { top: 10px; left: 14px; right: 14px; }
.so-corpo > .visor .visor-palco { inset: 56px 70px 14px; }
.so-corpo > .visor .visor-midia, .so-corpo > .visor .visor-doc { max-height: 100%; box-shadow: none; }
.so-corpo > .visor .visor-nav.ant { left: 12px; } .so-corpo > .visor .visor-nav.prox { right: 12px; }
/* grafo */
.so-corpo > .grafo { position: absolute; inset: 0; z-index: auto; animation: none; }
.so-corpo .grafo-legenda { position: absolute; top: 12px; }
.so-corpo .grafo-modo { position: absolute; top: 10px; right: 10px; }
/* notas e arquivos */
.so-arquivo { flex: 1; overflow: auto; }
.so-arquivo > .md { padding: 18px 22px 26px; max-width: 78ch; }
.so-arquivo > img, .so-arquivo > video { display: block; width: 100%; height: 100%; object-fit: contain; background: #141210; }

@media (max-width: 640px) {
  .so-janela, .so-janela.maxi { border-radius: 0; }
  .so-borda, .so-botoes [data-max] { display: none; }
  .so-barra { left: 0; padding-right: 70px; }
  .so-organizar span { display: none; }
  .so-vazio { left: 0; }
}

/* fora de uma janela, a árvore não aparece solta na tela */
#app > #arvore { display: none; }
/* no visor em janela, o nome já está no topo da janela */
.so-corpo > .visor .visor-titulo { visibility: hidden; }
