/* Sprint 97: adaptação a telas. Mantém o desenho aprovado e só ajusta escala e altura.
   1) Telas grandes e TV: amplia o painel de forma uniforme (a 3840 px ele se comporta como em 1920 px, com letras maiores).
      Só o painel (.root): login e primeiro acesso já se ajustam sozinhos pela altura da tela.
   2) Notebook: o primeiro bloco do painel deixa de ocupar mais da metade da altura da tela. */

:root { --z: 1; }
@media (min-width: 2300px) { :root { --z: 1.25; } }
@media (min-width: 3000px) { :root { --z: 1.5; } }
@media (min-width: 3600px) { :root { --z: 2; } }

@media (min-width: 2300px) {
  .root { zoom: var(--z); }
  /* "100vh" dentro de uma área ampliada ficaria Z vezes maior que a tela: divide por Z para fechar certo */
  .root, body:has(.n3-dashboard) .root { min-height: calc(100vh / var(--z)); }
  .sidebar, body:has(.n3-dashboard) .sidebar { height: calc(100vh / var(--z)) !important; min-height: calc(100vh / var(--z)) !important; max-height: calc(100vh / var(--z)); }
}

/* 2) Notebook (largura até 1600 px e altura até 900 px): o logotipo do hero (que define a altura do bloco) fica menor,
      e o hero deixa de ocupar mais da metade da tela. Tudo continua lá: logotipo, título, botões, cartões e mapa. */
@media (min-width: 1051px) and (max-width: 1600px) and (max-height: 900px) {
  body[data-theme] .n3-hero-brand { width: min(100%, 165px); margin-bottom: 6px; }
  body[data-theme] .n3-hero-content h1 { margin-bottom: 4px !important; }
  body[data-theme] .n3-hero-content p { margin-bottom: 8px !important; }
}
/* Telas bem baixas (até 800 px, como 1366x768 e 1280x720): o botão secundário sai, os botões deixam de empilhar. O Atlas segue no menu. */
@media (min-width: 1051px) and (max-width: 1600px) and (max-height: 800px) {
  body[data-theme] .n3-hero-actions .n3-secondary { display: none; }
}

/* Notebook: o rodapé do mapa tem três blocos em ~175 px; sem os ícones o texto cabe inteiro. */
@media (min-width: 1051px) and (max-width: 1500px) {
  body[data-theme] .n3-global-stats > div > span { display: none; }
}

/* Telas grandes: as páginas que medem altura em "vh" (SQL Studio, Atlas, Database Manager, ORQION Studio) também
   precisam dividir pela escala, senão ficam Z vezes mais altas que a tela. Mesmos seletores, mesma conta, dividida por Z. */
@media (min-width: 2300px) {
  .s13-page-host { min-height: calc(100vh / var(--z) - 76px); }
  .s13-center { grid-template-rows: minmax(380px, calc(47vh / var(--z))) minmax(300px, 1fr); }
  .s13-workspace.is-fullscreen .s13-center { grid-template-rows: minmax(380px, calc(54vh / var(--z))) 1fr; }
  .atlas-root .atlas-layout { height: min(calc(88vh / var(--z)), 880px); }
  .atlas-premium .atlas-sql-pane.expanded { max-height: calc(78vh / var(--z)); }
  .atlas-premium.atlas-map-expanded .atlas-layout { height: calc(100vh / var(--z) - 190px); }
  .s06-root.s06-v2 { min-height: calc(100vh / var(--z) - 68px); }
  #s06-page.s06-v3 { min-height: calc(100vh / var(--z) - 72px); }
  #s06-page.s06-v5 .s06-v5-workspace { height: clamp(610px, calc(68vh / var(--z)), 840px); }
  #s07-root.s07-focus-mode .s07-center { min-height: calc(100vh / var(--z) - 190px); }
  #s07-root.s07-focus-mode .s07-canvas { min-height: calc(100vh / var(--z) - 290px); max-height: calc(100vh / var(--z) - 190px); }
}

/* Sprint 99: cartão "Conectar uma IA" (Segurança). */
.s99-steps { margin: 8px 0 12px; padding-left: 20px; display: grid; gap: 6px; }
.s99-item { border: 1px solid var(--border-color, #1d3557); border-radius: 10px; padding: 10px 14px; margin: 8px 0; }
.s99-item > summary { cursor: pointer; font-weight: 650; }
.s99-code { max-width: 100%; overflow-x: auto; white-space: pre; margin: 8px 0; }

/* Sprint 100: tablet e celular.
   Tablet (761 a 1120 px): a busca da barra do topo encolhe em vez de empurrar o avatar para fora da tela. */
@media (min-width: 761px) and (max-width: 1120px) {
  body:has(.n3-dashboard) .n3-top-search { flex: 1 1 0; width: auto; min-width: 0; max-width: 492px; }
  body:has(.n3-dashboard) .top-actions { flex: 0 0 auto; }
}
/* Tablet em pé (até 880 px): o bloco do topo usa uma coluna, como no celular (as 3 colunas pedem pelo menos 702 px). */
@media (min-width: 761px) and (max-width: 880px) {
  body[data-theme] .n3-hero-layout { grid-template-columns: 1fr; grid-template-rows: auto 120px auto; }
  body[data-theme] .n3-hero:after { inset: 0; background: color-mix(in srgb, var(--app-bg), transparent 7%); }
  body[data-theme="light"] .n3-hero:after { background: #ffffffe9; }
  body[data-theme] .n3-hero-content { width: 100%; min-width: 0; padding: 20px 22px 8px; }
  body[data-theme] .n3-hero-stage { min-height: 120px; }
  body[data-theme] .n3-hero-benefit-rail { margin: 8px 12px 12px; grid-template: repeat(2, minmax(66px, auto)) / repeat(2, 1fr); }
  body[data-theme] .n3-hero, body[data-theme] .n3-hero-content { height: auto !important; min-height: 0 !important; }
}
/* Celular (até 760 px): o bloco do topo cresce com o conteúdo (tinha 420 px fixos e cortava logotipo e texto). */
@media (max-width: 760px) {
  body[data-theme] .n3-hero, body[data-theme] .n3-hero-content { height: auto !important; min-height: 0 !important; }
  body[data-theme] .n3-hero-content { justify-content: flex-start; }
  body[data-theme] .n3-hero-content p { white-space: normal !important; }
  /* logotipo: escudo de tamanho fixo ao lado do nome (a imagem ocupava 100% e empurrava o nome para fora da tela) */
  body[data-theme] .n3-hero-brand { width: 100%; gap: 12px; margin-bottom: 12px; }
  body[data-theme] .n3-hero-brand > img { width: 96px; height: auto; flex: none; }
  body[data-theme] .n3-hero-layout { grid-template-rows: auto 36px auto; }
  body[data-theme] .n3-hero-stage { min-height: 36px; }
}
/* Aparelho de toque: o atalho "Ctrl K" não existe, então sai da busca. */
@media (max-width: 760px), (hover: none) and (pointer: coarse) { .n3-top-search kbd { display: none; } }

/* O botão do menu fica sempre primeiro na barra do topo, mesmo quando outro script reconstrói a barra depois dele. */
.cdc-burger { order: -1; }
/* Tablet: o menu lateral vira uma coluna de ícones de 70 px; o nome "Kevlor Cloud" sai e o logotipo fica inteiro e centralizado. */
@media (min-width: 761px) and (max-width: 1120px) {
  body:has(.n3-dashboard) .n3-sidebar .kevlor-sidebar-wordmark { display: none !important; }
  body:has(.n3-dashboard) .n3-sidebar .n3-official-sidebar-logo { margin: 0 auto !important; position: static !important; transform: none !important; max-width: 44px; }
}

/* Celular: títulos e rodapés dos indicadores podem quebrar em duas linhas em vez de virar reticências. */
@media (max-width: 760px) {
  body[data-theme] .n3-kpi-title, body[data-theme] .n3-kpi-foot { white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.25; }
}
