/**
 * Safe area apenas em PWA instalado (standalone / iOS home screen).
 * Evita sobreposição com status bar (hora, bateria) e home indicator.
 */
html.pwa-standalone {
    --pwa-safe-top: env(safe-area-inset-top, 0px);
    --pwa-safe-bottom: env(safe-area-inset-bottom, 0px);
    --pwa-safe-left: env(safe-area-inset-left, 0px);
    --pwa-safe-right: env(safe-area-inset-right, 0px);
}

/* Header fixo: conteúdo abaixo da status bar, fundo continua sob ela */
html.pwa-standalone header.header {
    padding-top: calc(12px + var(--pwa-safe-top)) !important;
    padding-left: max(16px, var(--pwa-safe-left)) !important;
    padding-right: max(16px, var(--pwa-safe-right)) !important;
}

/* Conteúdo principal: compensar header mais alto + home indicator */
html.pwa-standalone .inicio-section-new {
    padding-top: calc(100px + var(--pwa-safe-top)) !important;
    padding-bottom: calc(120px + var(--pwa-safe-bottom)) !important;
    padding-left: max(20px, var(--pwa-safe-left)) !important;
    padding-right: max(20px, var(--pwa-safe-right)) !important;
}

html.pwa-standalone .jogos-provedor-container {
    padding-top: calc(100px + var(--pwa-safe-top)) !important;
    padding-bottom: calc(30px + var(--pwa-safe-bottom)) !important;
    padding-left: max(20px, var(--pwa-safe-left)) !important;
    padding-right: max(20px, var(--pwa-safe-right)) !important;
}

html.pwa-standalone .conselheiros-container {
    padding-top: calc(100px + var(--pwa-safe-top)) !important;
    padding-bottom: calc(40px + var(--pwa-safe-bottom)) !important;
}

html.pwa-standalone .sortear-page,
html.pwa-standalone .sala-sinais-container,
html.pwa-standalone .admin-container,
html.pwa-standalone .dashboard-container,
html.pwa-standalone main {
    padding-top: max(0px, var(--pwa-safe-top));
    padding-bottom: max(0px, var(--pwa-safe-bottom));
}

html.pwa-standalone .sala-sinais-container {
    padding-top: calc(120px + var(--pwa-safe-top)) !important;
    padding-bottom: calc(40px + var(--pwa-safe-bottom)) !important;
}

html.pwa-standalone .sortear-page {
    padding-top: calc(24px + var(--pwa-safe-top)) !important;
    padding-bottom: calc(60px + var(--pwa-safe-bottom)) !important;
}

html.pwa-standalone .admin-container {
    padding-top: calc(100px + var(--pwa-safe-top)) !important;
    padding-bottom: calc(40px + var(--pwa-safe-bottom)) !important;
}

/* Seções genéricas com padding alto para o header */
html.pwa-standalone #gestao-section,
html.pwa-standalone #gestao-barao-section,
html.pwa-standalone #controle-mental-section,
html.pwa-standalone #calculadora-section,
html.pwa-standalone #aulas-section,
html.pwa-standalone #hall-fama-section,
html.pwa-standalone #registro-progresso-section,
html.pwa-standalone #bacbo-section,
html.pwa-standalone #jogos-section,
html.pwa-standalone #game-session {
    padding-top: var(--pwa-safe-top);
    padding-bottom: var(--pwa-safe-bottom);
}

/* Login: safe area sem header fixo */
html.pwa-standalone body.login-page,
html.pwa-standalone.login-page body {
    padding-top: var(--pwa-safe-top) !important;
    padding-bottom: var(--pwa-safe-bottom) !important;
    padding-left: var(--pwa-safe-left) !important;
    padding-right: var(--pwa-safe-right) !important;
}

html.pwa-standalone .login-container {
    padding-top: max(16px, var(--pwa-safe-top));
    padding-bottom: max(16px, var(--pwa-safe-bottom));
}

/* Modais fullscreen / overlays */
html.pwa-standalone .modal,
html.pwa-standalone .modal-content,
html.pwa-standalone [class*="overlay"] {
    padding-top: max(0px, var(--pwa-safe-top));
    padding-bottom: max(0px, var(--pwa-safe-bottom));
}

/* Footer e menus fixos no rodapé, se existirem */
html.pwa-standalone .site-footer,
html.pwa-standalone .bottom-menu,
html.pwa-standalone .bottom-nav {
    padding-bottom: max(8px, var(--pwa-safe-bottom)) !important;
}

/* Modal de jogo (slots) — header abaixo da status bar */
html.pwa-standalone .game-modal {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

html.pwa-standalone .game-modal-content {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    height: 100% !important;
    max-height: 100% !important;
}

html.pwa-standalone .game-modal-header {
    padding-top: calc(16px + var(--pwa-safe-top)) !important;
    padding-bottom: 16px !important;
    padding-left: max(20px, var(--pwa-safe-left)) !important;
    padding-right: max(20px, var(--pwa-safe-right)) !important;
}

html.pwa-standalone .game-modal-body {
    padding-bottom: var(--pwa-safe-bottom) !important;
}

/* Sessão de jogo ao vivo (iframe) */
html.pwa-standalone .game-session-header {
    padding-top: calc(12px + var(--pwa-safe-top)) !important;
    padding-left: max(16px, var(--pwa-safe-left)) !important;
    padding-right: max(16px, var(--pwa-safe-right)) !important;
}

html.pwa-standalone body.game-session-active .game-session {
    padding-bottom: calc(16px + var(--pwa-safe-bottom)) !important;
}

html.pwa-standalone .sala-sinais-page .game-header {
    padding-top: calc(12px + var(--pwa-safe-top)) !important;
}
