/* IT310RESPONSIVE_DEVICE_PASS2
   Ajuste final da Etapa 2.
   Escopo exclusivo: PWA/footer em Full HD, menus mobile, drawer de ferramentas, appbar mobile e proteção contra duplicidade visual.
   Preserva textos, rotas, ferramentas, motores, backend, QR, identidade e desktop aprovado. */

:root{
  --it-rdp2-safe-bottom:env(safe-area-inset-bottom,0px);
  --it-rdp2-safe-top:env(safe-area-inset-top,0px);
  --it-rdp2-mobile-appbar-h:70px;
  --it-rdp2-pwa-desktop-bottom:clamp(82px,8.2vh,112px);
}

html,body{
  max-width:100%;
  overflow-x:hidden!important;
}

/* PWA / footer — evita cobrir "Desenvolvido no Brasil" em Full HD e monitores desktop. */
@media (min-width:961px){
  html body .it-pwa-toast,
  html body .it-pwa-toast[data-kind="install"],
  html body .it-pwa-toast[data-kind="update"],
  html body .it-pwa-toast[data-kind="install-installed"]{
    right:24px!important;
    left:auto!important;
    bottom:var(--it-rdp2-pwa-desktop-bottom)!important;
    width:min(380px,calc(100vw - 48px))!important;
    max-width:380px!important;
    max-height:calc(100dvh - 176px)!important;
    overflow:auto!important;
    z-index:230!important;
  }

  html body .it-pwa-toast[data-kind="install-help"]{
    right:24px!important;
    left:auto!important;
    bottom:var(--it-rdp2-pwa-desktop-bottom)!important;
    width:min(500px,calc(100vw - 48px))!important;
    max-width:500px!important;
  }

  html body.it-sidebar-enabled:not(.it-sidebar-collapsed) .it-pwa-toast,
  html body.it-sidebar-enabled.it-sidebar-collapsed .it-pwa-toast{
    right:24px!important;
    left:auto!important;
  }

  body.infotech-public-page footer.foot,
  body.ixdesk-software-page footer.ixdesk-it-foot,
  body.fixturebridge-page footer,
  body.fixture-bridge-page footer,
  body.fixture-builder-page footer{
    scroll-margin-bottom:160px!important;
  }
}

@media (min-width:1366px) and (max-height:900px){
  html body .it-pwa-toast,
  html body .it-pwa-toast[data-kind="install-help"]{
    bottom:96px!important;
  }
}

@media (min-width:1900px) and (max-height:1120px){
  html body .it-pwa-toast,
  html body .it-pwa-toast[data-kind="install-help"]{
    bottom:102px!important;
  }
}

/* PWA em mobile: respeita appbar, safe-area e drawer aberto. */
@media (max-width:960px){
  html body .it-pwa-toast{
    left:10px!important;
    right:10px!important;
    bottom:calc(var(--it-rdp2-mobile-appbar-h) + 12px + var(--it-rdp2-safe-bottom))!important;
    width:auto!important;
    max-height:calc(100svh - 136px - var(--it-rdp2-safe-bottom))!important;
    overflow:auto!important;
    z-index:220!important;
  }

  body.it-sidebar-open .it-pwa-toast,
  body.it-sidebar-drawer-lock .it-pwa-toast{
    display:none!important;
  }
}

@media (max-width:430px){
  html body .it-pwa-toast{
    bottom:calc(var(--it-rdp2-mobile-appbar-h) + 8px + var(--it-rdp2-safe-bottom))!important;
    border-radius:16px!important;
  }
}

/* Menus institucionais mobile — impede quebra lateral e duplicação visual. */
@media (max-width:1024px){
  body.infotech-public-page header.it-top,
  body.ixdesk-software-page header.ixdesk-it-top,
  body.ixdesk-software-page .ixdesk-it-top{
    isolation:isolate!important;
    overflow:visible!important;
  }

  body.infotech-public-page header.it-top .it-topbar,
  body.ixdesk-software-page .ixdesk-it-topbar{
    width:100%!important;
    max-width:100%!important;
    overflow:hidden!important;
  }

  body.infotech-public-page header.it-top .it-nav,
  body.ixdesk-software-page .ixdesk-it-nav,
  body.infotech-public-page header.it-top .it-langs,
  body.ixdesk-software-page .ixdesk-it-langs{
    max-width:100%!important;
    overscroll-behavior-x:contain!important;
  }

  body.infotech-public-page header.it-top .it-nav a,
  body.ixdesk-software-page .ixdesk-it-nav a{
    flex:0 0 auto!important;
    white-space:nowrap!important;
  }

  body.infotech-public-page header.it-top nav.it-nav ~ nav.it-nav,
  body.ixdesk-software-page header.ixdesk-it-top nav.ixdesk-it-nav ~ nav.ixdesk-it-nav,
  body.infotech-public-page header.it-top .it-lang-row ~ .it-lang-row,
  body.ixdesk-software-page header.ixdesk-it-top .ixdesk-it-lang-row ~ .ixdesk-it-lang-row{
    display:none!important;
  }
}

@media (max-width:768px){
  body.infotech-public-page header.it-top .it-specialist-btn,
  body.ixdesk-software-page .ixdesk-it-specialist-btn{
    max-width:100%!important;
    min-width:0!important;
    white-space:normal!important;
    text-align:center!important;
  }

  body.infotech-public-page header.it-top .it-lang-row,
  body.ixdesk-software-page .ixdesk-it-lang-row{
    gap:7px!important;
    width:100%!important;
  }
}

/* Ferramentas sem JS ainda carregado: menu vira trilho horizontal em vez de vários blocos quebrados. */
@media (max-width:960px){
  body:not(.it-sidebar-enabled).fixturebridge-page .it-global-header,
  body:not(.it-sidebar-enabled).fixture-bridge-page .it-global-header,
  body:not(.it-sidebar-enabled).fixture-builder-page .it-global-header,
  body:not(.it-sidebar-enabled).it-tools-bg .it-global-header{
    width:calc(100vw - 24px)!important;
    max-width:calc(100vw - 24px)!important;
    margin:10px auto 14px!important;
    padding:10px!important;
    border-radius:18px!important;
    overflow:hidden!important;
  }

  body:not(.it-sidebar-enabled).fixturebridge-page .it-global-nav,
  body:not(.it-sidebar-enabled).fixture-bridge-page .it-global-nav,
  body:not(.it-sidebar-enabled).fixture-builder-page .it-global-nav,
  body:not(.it-sidebar-enabled).it-tools-bg .it-global-nav,
  body:not(.it-sidebar-enabled).fixturebridge-page .it-global-lang,
  body:not(.it-sidebar-enabled).fixture-bridge-page .it-global-lang,
  body:not(.it-sidebar-enabled).fixture-builder-page .it-global-lang,
  body:not(.it-sidebar-enabled).it-tools-bg .it-global-lang{
    display:flex!important;
    flex-wrap:nowrap!important;
    overflow-x:auto!important;
    overflow-y:hidden!important;
    gap:8px!important;
    max-width:100%!important;
    -webkit-overflow-scrolling:touch!important;
    scrollbar-width:thin!important;
  }

  body:not(.it-sidebar-enabled) .it-global-nav a,
  body:not(.it-sidebar-enabled) .it-global-lang a{
    flex:0 0 auto!important;
    min-width:max-content!important;
    white-space:nowrap!important;
  }
}

/* Drawer mobile das ferramentas — um único menu visível e controlado. */
@media (max-width:960px){
  body.it-sidebar-enabled.it-sidebar-mobile:not(.it-sidebar-open) > header.it-global-header.it-sidebar-upgraded{
    width:calc(100vw - 24px)!important;
    max-width:calc(100vw - 24px)!important;
    min-height:58px!important;
    height:auto!important;
    margin:10px auto 14px!important;
    padding:9px 10px!important;
    display:grid!important;
    grid-template-columns:minmax(0,1fr) auto!important;
    grid-template-areas:"brand toggle"!important;
    align-items:center!important;
    gap:10px!important;
    overflow:hidden!important;
    border-radius:18px!important;
    z-index:180!important;
  }

  body.it-sidebar-enabled.it-sidebar-mobile:not(.it-sidebar-open) > header.it-global-header.it-sidebar-upgraded .it-global-brand{
    grid-area:brand!important;
    min-width:0!important;
    max-width:100%!important;
  }

  body.it-sidebar-enabled.it-sidebar-mobile:not(.it-sidebar-open) > header.it-global-header.it-sidebar-upgraded .it-sidebar-toggle{
    grid-area:toggle!important;
    position:static!important;
    align-self:center!important;
    justify-self:end!important;
    min-width:44px!important;
    height:42px!important;
    margin:0!important;
  }

  body.it-sidebar-enabled.it-sidebar-mobile:not(.it-sidebar-open) > header.it-global-header.it-sidebar-upgraded .it-side-search,
  body.it-sidebar-enabled.it-sidebar-mobile:not(.it-sidebar-open) > header.it-global-header.it-sidebar-upgraded .it-global-nav,
  body.it-sidebar-enabled.it-sidebar-mobile:not(.it-sidebar-open) > header.it-global-header.it-sidebar-upgraded .it-global-lang,
  body.it-sidebar-enabled.it-sidebar-mobile:not(.it-sidebar-open) > header.it-global-header.it-sidebar-upgraded .it-lang-toggle,
  body.it-sidebar-enabled.it-sidebar-mobile:not(.it-sidebar-open) > header.it-global-header.it-sidebar-upgraded .it-install-app-cta,
  body.it-sidebar-enabled.it-sidebar-mobile:not(.it-sidebar-open) > header.it-global-header.it-sidebar-upgraded .it-search-empty-note{
    display:none!important;
  }

  body.it-sidebar-enabled.it-sidebar-mobile.it-sidebar-open > header.it-global-header.it-sidebar-upgraded{
    position:fixed!important;
    top:0!important;
    left:0!important;
    bottom:0!important;
    width:min(360px,94vw)!important;
    max-width:94vw!important;
    height:100dvh!important;
    max-height:100dvh!important;
    margin:0!important;
    padding:16px 14px calc(18px + var(--it-rdp2-safe-bottom))!important;
    overflow-y:auto!important;
    overflow-x:hidden!important;
    overscroll-behavior:contain!important;
    border-radius:0 24px 24px 0!important;
    z-index:240!important;
  }

  body.it-sidebar-enabled.it-sidebar-mobile.it-sidebar-open > header.it-global-header.it-sidebar-upgraded .it-install-app-cta{
    display:flex!important;
    width:100%!important;
    margin:8px 0 4px!important;
    grid-column:1/-1!important;
  }

  body.it-sidebar-enabled.it-sidebar-mobile.it-sidebar-open > header.it-global-header.it-sidebar-upgraded .it-global-nav{
    max-height:none!important;
    overflow:visible!important;
  }

  body.it-sidebar-enabled.it-sidebar-mobile.it-sidebar-open > header.it-global-header.it-sidebar-upgraded .it-global-nav a,
  body.it-sidebar-enabled.it-sidebar-mobile.it-sidebar-open > header.it-global-header.it-sidebar-upgraded .it-sidebar-label{
    max-width:100%!important;
    box-sizing:border-box!important;
  }

  body.it-sidebar-drawer-lock{
    overflow:hidden!important;
    touch-action:none!important;
  }

  body.it-sidebar-enabled.it-sidebar-mobile.it-sidebar-open .it-sidebar-backdrop{
    display:block!important;
    position:fixed!important;
    inset:0!important;
    z-index:230!important;
    background:rgba(0,0,0,.42)!important;
    backdrop-filter:blur(2px)!important;
    -webkit-backdrop-filter:blur(2px)!important;
  }

  body.it-sidebar-enabled.it-sidebar-mobile:not(.it-sidebar-open) .it-sidebar-backdrop{
    display:none!important;
  }
}

/* Appbar inferior das ferramentas — evita múltiplas barras/menus no celular. */
@media (max-width:960px){
  body.it-sidebar-enabled .it-mobile-appbar{
    position:fixed!important;
    left:10px!important;
    right:10px!important;
    bottom:calc(8px + var(--it-rdp2-safe-bottom))!important;
    height:58px!important;
    min-height:58px!important;
    max-height:58px!important;
    display:grid!important;
    grid-template-columns:repeat(5,minmax(0,1fr))!important;
    align-items:center!important;
    gap:4px!important;
    z-index:210!important;
    overflow:hidden!important;
    border-radius:18px!important;
  }

  body.it-sidebar-enabled.it-sidebar-open .it-mobile-appbar{
    display:none!important;
  }

  body.it-sidebar-enabled .it-mobile-appbar .it-appbar-item{
    min-width:0!important;
    max-width:100%!important;
    height:100%!important;
    padding:6px 2px!important;
    overflow:hidden!important;
    text-overflow:ellipsis!important;
  }

  body.it-sidebar-enabled .it-mobile-appbar .it-appbar-item em{
    max-width:100%!important;
    overflow:hidden!important;
    text-overflow:ellipsis!important;
    white-space:nowrap!important;
  }

  body.it-sidebar-enabled .it-mobile-appbar ~ .it-mobile-appbar,
  body.it-sidebar-enabled .it-sidebar-backdrop ~ .it-sidebar-backdrop{
    display:none!important;
  }

  body.it-sidebar-enabled main,
  body.it-sidebar-enabled footer{
    padding-bottom:calc(var(--it-rdp2-mobile-appbar-h) + var(--it-rdp2-safe-bottom))!important;
  }
}

@media (max-width:390px){
  body.it-sidebar-enabled .it-mobile-appbar{
    left:8px!important;
    right:8px!important;
    height:56px!important;
    min-height:56px!important;
    border-radius:16px!important;
  }

  body.it-sidebar-enabled .it-mobile-appbar .it-appbar-item span{
    font-size:13px!important;
  }

  body.it-sidebar-enabled .it-mobile-appbar .it-appbar-item em{
    font-size:10px!important;
  }
}
