/* layout.css: casca da aplicacao (sidebar, topbar, conteudo) e a tela de login.
 * Fonte da verdade: Padrao_Menu_Sidebar.md, Padrao_Elevacao_Zindex.md,
 * Padrao_Espacamento_e_Respiro.md, Responsividade_Sempre.md. */

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--borda);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: var(--z-sidebar);
  transition: transform .2s ease;
}

.sidebar-marca {
  padding: var(--sp-5) var(--sp-4) var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  border-bottom: 1px solid var(--borda);
}

.sidebar-marca .marca-nome {
  font-family: var(--font-titulo);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -.02em;
  line-height: 1.1;
}

.sidebar-nav {
  flex: 1;
  padding: var(--sp-3);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--raio-sm);
  color: var(--text-dim);
  font-weight: 500;
  font-size: var(--fs-sm);
}

.nav-item .ph, .nav-item .ph-bold {
  font-size: 16px;
  opacity: .85;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-item.ativo {
  background: var(--accent-suave);
  color: var(--accent-escura);
  font-weight: 600;
}

.nav-item.ativo .ph, .nav-item.ativo .ph-bold {
  opacity: 1;
}

.nav-grupo {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: var(--sp-3);
}

.nav-grupo-titulo {
  padding: var(--sp-2) var(--sp-3) 2px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-mudo);
}

.sidebar-rodape {
  padding: var(--sp-3);
  border-top: 1px solid var(--borda);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.rodape-usuario {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
}

.avatar {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: var(--raio-full);
  background: var(--accent-suave);
  color: var(--accent-escura);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-xs);
  font-weight: 700;
}

.rodape-info {
  min-width: 0;
}

.rodape-nome {
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rodape-perfil {
  font-size: var(--fs-xs);
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-sair {
  width: 100%;
  justify-content: flex-start;
}

/* ---------- Main / topbar / content ---------- */

.main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 var(--sp-5);
  background: var(--surface);
  border-bottom: 1px solid var(--borda);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}

.btn-menu {
  display: none;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: var(--raio-sm);
  color: var(--text);
  flex-shrink: 0;
}

.btn-menu:hover {
  background: var(--surface-2);
}

.titulo-pagina {
  font-family: var(--font-titulo);
  font-weight: 700;
  font-size: var(--fs-xl);
  letter-spacing: -.02em;
  flex: 1;
  min-width: 0;
}

.tb-acoes {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-shrink: 0;
}

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  padding: var(--sp-5);
  min-width: 0;
}

.content > * {
  min-width: 0;
}

/* ---------- Overlay do drawer mobile ---------- */

.overlay-mob {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: var(--z-overlay);
}

/* ---------- Login (tela standalone) ---------- */

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-5);
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--borda);
  border-radius: var(--raio-lg);
  box-shadow: var(--sombra);
  padding: var(--sp-6) var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.login-marca {
  font-family: var(--font-titulo);
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -.02em;
  text-align: center;
}

/* ---------- Responsivo ---------- */

/* 880px: sidebar recolhe pra só ícones (continua fixa, sem virar drawer). */
@media (max-width: 880px) {
  .sidebar {
    width: 72px;
  }

  .sidebar-marca {
    justify-content: center;
    padding: var(--sp-4) 0;
  }

  .sidebar-marca .marca-nome,
  .nav-grupo-titulo,
  .nav-item-texto,
  .rodape-info {
    display: none;
  }

  .nav-item {
    justify-content: center;
  }

  .rodape-usuario {
    justify-content: center;
  }

  .sidebar-sair {
    width: 40px;
    height: 40px;
    padding: 0;
    justify-content: center;
  }

  .main {
    margin-left: 72px;
  }
}

/* 720px: sidebar vira drawer (some, abre com o hambúrguer 44x44). */
@media (max-width: 720px) {
  .sidebar {
    width: var(--sidebar-width);
    transform: translateX(-100%);
  }

  .sidebar-marca .marca-nome,
  .nav-grupo-titulo,
  .nav-item-texto,
  .rodape-info {
    display: revert;
  }

  .sidebar-marca,
  .nav-item,
  .rodape-usuario {
    justify-content: flex-start;
  }

  .sidebar-sair {
    width: 100%;
    height: var(--controle-h);
    padding: 0 var(--sp-3);
    justify-content: flex-start;
  }

  body.sidebar-aberta .sidebar {
    transform: translateX(0);
  }

  body.sidebar-aberta .overlay-mob {
    display: block;
  }

  .main {
    margin-left: 0;
  }

  .btn-menu {
    display: inline-flex;
  }

  .content {
    padding: var(--sp-4);
    gap: var(--sp-4);
  }

  .topbar {
    padding: 0 var(--sp-4);
  }
}

@media (max-width: 520px) {
  .content {
    padding: var(--sp-3);
    gap: var(--sp-3);
  }

  .titulo-pagina {
    font-size: var(--fs-lg);
  }

  .login-card {
    padding: var(--sp-5) var(--sp-4);
  }
}
