/**
 * Escala global da UI — equivalente a zoom ~75% no browser.
 * Assim a app fica utilizável a 100% sem o utilizador reduzir o zoom.
 *
 * Em páginas embed (iframe do shell) NÃO aplicar: o index já escala o iframe.
 *
 * Altura: com zoom < 1, 100vh fica curto — compensamos só na vertical
 * para o footer encostar ao rodapé.
 * Largura: NÃO expandir (senão tabelas ficam enormes e cortam à direita).
 */
:root {
  --ui-scale: 0.75;
}

html:not(.embed-mode) {
  zoom: var(--ui-scale);
  width: 100% !important;
  max-width: 100% !important;
  height: calc(100vh / var(--ui-scale)) !important;
  min-height: calc(100vh / var(--ui-scale)) !important;
  overflow-x: hidden !important;
}

html:not(.embed-mode) body {
  width: 100% !important;
  max-width: 100% !important;
  height: 100% !important;
  min-height: 100% !important;
  overflow-x: hidden !important;
}

/* Shell + sidebar: altura compensada, largura limitada ao ecrã */
html:not(.embed-mode) .app-shell {
  height: 100% !important;
  min-height: 100% !important;
  max-width: 100% !important;
  overflow-x: hidden !important;
}

html:not(.embed-mode) .app-sidebar {
  height: 100% !important;
  bottom: auto;
}

html:not(.embed-mode) .app-main,
html:not(.embed-mode) #moduleView,
html:not(.embed-mode) #moduleFrame {
  max-width: 100% !important;
  overflow-x: hidden !important;
}

/* Fundos fixed do index */
html:not(.embed-mode) body::before,
html:not(.embed-mode) body::after {
  width: 100%;
  height: 100%;
  inset: 0;
}

/*
 * Login: zoom no html desalinha o flex (origem top-left → card “sobe”/vai à esquerda).
 * Mantém viewport a 100% e escala só o wrapper, com origem no centro.
 */
html:not(.embed-mode):has(body.login-page) {
  zoom: 1 !important;
  width: 100% !important;
  max-width: 100% !important;
  height: 100vh !important;
  min-height: 100vh !important;
  overflow: hidden !important;
}

html:not(.embed-mode) body.login-page {
  zoom: 1 !important;
  width: 100% !important;
  max-width: 100% !important;
  height: 100vh !important;
  min-height: 100vh !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
}

html:not(.embed-mode) body.login-page .page-wrapper {
  transform: translateY(-3vh) scale(var(--ui-scale));
  transform-origin: center center;
}

/* Fallback quando zoom não é suportado */
@supports not (zoom: 1) {
  html:not(.embed-mode) {
    font-size: 75%;
    width: 100% !important;
    height: 100% !important;
    min-height: 100% !important;
  }

  html:not(.embed-mode) .app-shell,
  html:not(.embed-mode) .app-sidebar {
    height: 100vh !important;
    min-height: 100vh !important;
  }
}
