/* V34 — correção definitiva de contraste e comportamento dos mega menus */

/* Regra-base: todo mega menu é uma superfície clara */
.mega-menu-layer .mega-panel,
.mega-menu-layer .mega-panel section,
.mega-menu-layer .mega-panel article,
.mega-menu-layer .mega-panel div {
  text-shadow: none !important;
}
.mega-menu-layer .mega-panel {
  background: #fff !important;
  color: #173d71 !important;
}
.mega-menu-layer .mega-panel :where(h1,h2,h3,h4,h5,h6,strong,b) {
  color: #173d71 !important;
}
.mega-menu-layer .mega-panel :where(p,small,li,label) {
  color: #65718a !important;
}
.mega-menu-layer .mega-panel a {
  color: #173d71 !important;
}

/* Cards brancos e claros */
.mega-menu-layer :where(
  .company-link-grid > a,
  .brand-hub-card,
  .ti-clean-card,
  .lab-test-list > a,
  .help-action-card,
  .help-v16-whatsapp,
  .person-tile.tile-light,
  .person-tile.tile-cyan,
  .lab-side-actions > a:not(.lab-budget)
) :where(strong,b,h3,h4,h5,span) {
  color: #173d71 !important;
}
.mega-menu-layer :where(
  .company-link-grid > a,
  .brand-hub-card,
  .ti-clean-card,
  .lab-test-list > a,
  .help-action-card,
  .help-v16-whatsapp,
  .person-tile.tile-light,
  .person-tile.tile-cyan,
  .lab-side-actions > a:not(.lab-budget)
) :where(small,p) {
  color: #6f7d96 !important;
}

/* Superfícies azuis, roxas, vermelhas e gradientes: texto sempre claro */
.mega-menu-layer :where(
  .company-bottom-bar,
  .brand-hub-contact,
  .lab-primary-action,
  .lab-budget,
  .mega-solid-btn,
  .person-tile.tile-blue,
  .person-tile.tile-purple
) {
  color: #fff !important;
}
.mega-menu-layer :where(
  .company-bottom-bar,
  .brand-hub-contact,
  .lab-primary-action,
  .lab-budget,
  .mega-solid-btn,
  .person-tile.tile-blue,
  .person-tile.tile-purple
) :where(a,span,strong,b,small,p,h3,h4,h5,i) {
  color: #fff !important;
}
.mega-menu-layer .company-bottom-bar > span,
.mega-menu-layer .company-bottom-bar > span * {
  color: rgba(255,255,255,.82) !important;
}
.mega-menu-layer .company-bottom-bar > a,
.mega-menu-layer .brand-hub-contact > a {
  color: #fff !important;
  font-weight: 800 !important;
}
.mega-menu-layer .person-tile.tile-blue small,
.mega-menu-layer .person-tile.tile-purple small,
.mega-menu-layer .lab-budget small {
  color: rgba(255,255,255,.78) !important;
}

/* Botões gradientes */
.mega-menu-layer .lab-primary-action,
.mega-menu-layer .mega-solid-btn {
  background: linear-gradient(135deg,#087eea,#7f42bf) !important;
  border-color: transparent !important;
}
.mega-menu-layer .lab-primary-action:hover,
.mega-menu-layer .mega-solid-btn:hover {
  filter: brightness(1.05);
}

/* Faixa de parceria: base clara, apenas o botão é gradiente */
.mega-menu-layer .ti-partner-strip {
  background: #f6f7fb !important;
  border-color: #e3e7ef !important;
}
.mega-menu-layer .ti-partner-strip > span,
.mega-menu-layer .ti-partner-strip > span b {
  color: #4f5870 !important;
}
.mega-menu-layer .ti-text-link,
.mega-menu-layer .ti-text-link i {
  color: #173d71 !important;
}
.mega-menu-layer .ti-text-link:hover,
.mega-menu-layer .ti-text-link:hover i {
  color: #6f42c1 !important;
}

/* Laboratório */
.mega-menu-layer .lab-feature-card,
.mega-menu-layer .lab-feature-card :where(h3,h4,strong,b) {
  color: #173d71 !important;
}
.mega-menu-layer .lab-feature-card :where(p,small,span) {
  color: #65718a !important;
}
.mega-menu-layer .lab-label {
  color: #265fa2 !important;
}

/* Ícones continuam com a cor de destaque adequada */
.mega-menu-layer :where(.company-link-grid,.brand-hub-grid,.ti-clean-grid,.lab-test-list,.help-v16-actions) i {
  color: #6f42c1 !important;
}
.mega-menu-layer .person-tile.tile-blue > i,
.mega-menu-layer .person-tile.tile-purple > i,
.mega-menu-layer .lab-budget > i,
.mega-menu-layer .lab-primary-action i,
.mega-menu-layer .mega-solid-btn i {
  color: #fff !important;
}

/* Mobile/notebook: nenhum painel abre sozinho ou se mistura ao menu */
@media (max-width:1199.98px) {
  .mega-menu-layer .mega-panel:not(.is-open) {
    display: none !important;
  }
  .mega-menu-layer .mega-panel.is-open {
    display: block !important;
    position: static !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 16px !important;
    background: #f8faff !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    overflow: visible !important;
    max-height: none !important;
  }
  .mega-menu-layer .companies-panel.is-open,
  .mega-menu-layer .person-panel.is-open,
  .mega-menu-layer .ti-panel-clean.is-open,
  .mega-menu-layer .brand-panel-light.is-open {
    display: block !important;
  }
  .mega-menu-layer[aria-hidden="true"] .mega-panel {
    display: none !important;
  }
  .mega-menu-layer .creative-panel:not(.is-open),
  .mega-menu-layer .companies-panel:not(.is-open),
  .mega-menu-layer .person-panel:not(.is-open),
  .mega-menu-layer .lab-panel:not(.is-open),
  .mega-menu-layer .ti-panel:not(.is-open),
  .mega-menu-layer .brand-panel:not(.is-open),
  .mega-menu-layer .help-mega-panel:not(.is-open) {
    display: none !important;
  }
  .mega-menu-layer .company-bottom-bar,
  .mega-menu-layer .brand-hub-contact,
  .mega-menu-layer .ti-partner-strip,
  .mega-menu-layer .person-tip {
    width: 100% !important;
  }
}

/* V35 — garantia final: botões de ação com fundo colorido sempre usam texto branco */
.mega-menu-layer .companies-graphic-message a.mega-solid-btn,
.mega-menu-layer .companies-graphic-message a.mega-solid-btn:link,
.mega-menu-layer .companies-graphic-message a.mega-solid-btn:visited,
.mega-menu-layer .companies-graphic-message a.mega-solid-btn:hover,
.mega-menu-layer .companies-graphic-message a.mega-solid-btn:focus,
.mega-menu-layer .companies-graphic-message a.mega-solid-btn:active,
.mega-menu-layer a.mega-solid-btn,
.mega-menu-layer a.mega-solid-btn:link,
.mega-menu-layer a.mega-solid-btn:visited,
.mega-menu-layer a.mega-solid-btn:hover,
.mega-menu-layer a.mega-solid-btn:focus,
.mega-menu-layer a.mega-solid-btn:active {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}
.mega-menu-layer .companies-graphic-message a.mega-solid-btn *,
.mega-menu-layer a.mega-solid-btn * {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}

/* V36 — correção direta dos cards e faixas coloridas do mega menu */
.person-tile.tile-blue,
.person-tile.tile-purple,
.person-tile.tile-blue:link,
.person-tile.tile-purple:link,
.person-tile.tile-blue:visited,
.person-tile.tile-purple:visited,
.person-tile.tile-blue:hover,
.person-tile.tile-purple:hover,
.person-tile.tile-blue:focus,
.person-tile.tile-purple:focus {
  color:#fff!important;
  -webkit-text-fill-color:#fff!important;
}
.person-tile.tile-blue :where(strong,span,small,i),
.person-tile.tile-purple :where(strong,span,small,i) {
  color:#fff!important;
  -webkit-text-fill-color:#fff!important;
}
.person-tile.tile-blue span,
.person-tile.tile-purple span {
  color:rgba(255,255,255,.82)!important;
  -webkit-text-fill-color:rgba(255,255,255,.82)!important;
}

.lab-primary-action,
.lab-primary-action:link,
.lab-primary-action:visited,
.lab-primary-action:hover,
.lab-primary-action:focus,
.lab-primary-action:active,
.lab-primary-action * {
  color:#fff!important;
  -webkit-text-fill-color:#fff!important;
}

.brand-hub-contact,
.brand-hub-contact :where(span,strong,a,i),
.brand-hub-contact a:link,
.brand-hub-contact a:visited,
.brand-hub-contact a:hover,
.brand-hub-contact a:focus,
.brand-hub-contact a:active {
  color:#fff!important;
  -webkit-text-fill-color:#fff!important;
}
.brand-hub-contact span {
  color:rgba(255,255,255,.78)!important;
  -webkit-text-fill-color:rgba(255,255,255,.78)!important;
}
.brand-hub-contact strong,
.brand-hub-contact a {
  color:#fff!important;
  -webkit-text-fill-color:#fff!important;
}

.company-bottom-bar,
.company-bottom-bar :where(span,strong,a,i),
.company-bottom-bar a:link,
.company-bottom-bar a:visited,
.company-bottom-bar a:hover,
.company-bottom-bar a:focus,
.company-bottom-bar a:active {
  color:#fff!important;
  -webkit-text-fill-color:#fff!important;
}
.company-bottom-bar > span {
  color:rgba(255,255,255,.82)!important;
  -webkit-text-fill-color:rgba(255,255,255,.82)!important;
}

/* V37 — menu mobile independente em acordeão; desktop preservado */
@media (max-width:1199.98px) {
  html,
  body {
    max-width:100%;
    overflow-x:hidden;
  }

  .mega-nav-shell {
    width:100%;
    overflow:visible!important;
  }

  .mega-nav-shell .navbar {
    width:100%;
    padding-left:16px!important;
    padding-right:16px!important;
  }

  .mega-nav-shell .navbar-collapse {
    width:100%;
    max-height:calc(100dvh - 76px);
    overflow-y:auto;
    overflow-x:hidden;
    overscroll-behavior:contain;
    -webkit-overflow-scrolling:touch;
  }

  .mega-nav-shell .navbar-collapse:not(.show):not(.collapsing) {
    display:none!important;
  }

  .mega-nav-links {
    width:100%;
    display:flex!important;
    flex-direction:column!important;
    align-items:stretch!important;
    gap:0!important;
  }

  .mega-nav-links .nav-link,
  .mega-nav-links .mega-trigger {
    box-sizing:border-box;
    width:100%!important;
    min-width:0!important;
    margin:0!important;
    padding:14px 4px!important;
    display:flex!important;
    align-items:center!important;
    justify-content:space-between!important;
    gap:12px;
    border:0!important;
    border-bottom:1px solid #e9edf5!important;
    background:#fff!important;
    color:#173d71!important;
    font-size:1rem!important;
    line-height:1.3!important;
    text-align:left!important;
    white-space:normal!important;
    overflow-wrap:anywhere;
  }

  .mega-nav-links .mega-trigger i {
    flex:0 0 auto;
    margin-left:auto!important;
  }

  .mega-nav-links .mega-trigger[aria-expanded="true"] {
    color:#6f42c1!important;
    background:#f7f4fc!important;
  }

  .mega-contact-btn {
    box-sizing:border-box;
    width:100%!important;
    max-width:100%!important;
    margin:14px 0 8px!important;
    white-space:normal!important;
  }

  /* O conjunto de categorias só existe visualmente enquanto o menu principal está aberto. */
  .mega-menu-layer {
    display:none!important;
    position:static!important;
    width:100%!important;
    max-width:100%!important;
    overflow:visible!important;
    pointer-events:auto!important;
    background:#fff;
  }

  .mega-nav-shell.mobile-menu-open.mobile-category-open .mega-menu-layer {
    display:block!important;
  }

  .mega-menu-container {
    width:100%!important;
    max-width:100%!important;
    padding:0!important;
    margin:0!important;
  }

  .mega-menu-layer .mega-panel,
  .mega-menu-layer .mega-panel.is-open {
    box-sizing:border-box!important;
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    margin:0!important;
    padding:16px!important;
    position:static!important;
    border:0!important;
    border-bottom:1px solid #dfe5ef!important;
    border-radius:0!important;
    box-shadow:none!important;
    background:#f8faff!important;
    overflow-x:hidden!important;
    overflow-y:visible!important;
    max-height:none!important;
    animation:none!important;
  }

  .mega-menu-layer .mega-panel:not(.is-open),
  .mega-menu-layer[aria-hidden="true"] .mega-panel {
    display:none!important;
  }

  .mega-menu-layer .mega-panel.is-open {
    display:block!important;
  }

  .mega-menu-layer .mega-panel *,
  .mega-menu-layer .mega-panel *::before,
  .mega-menu-layer .mega-panel *::after {
    box-sizing:border-box;
    max-width:100%;
  }

  .mega-menu-layer .mega-panel :where(a,button,p,small,strong,span,h1,h2,h3,h4,h5,h6) {
    overflow-wrap:anywhere;
    word-break:normal;
  }

  .mega-menu-layer .mega-panel :where(
    .companies-feature,
    .companies-options,
    .companies-graphic-grid,
    .company-link-grid,
    .person-intro,
    .person-actions,
    .lab-top,
    .lab-content-grid,
    .lab-test-list,
    .lab-side-actions,
    .ti-overview,
    .ti-solutions,
    .ti-clean-grid,
    .help-v16-layout,
    .help-v16-actions,
    .brand-hub-grid,
    .brand-columns
  ) {
    width:100%!important;
    min-width:0!important;
    grid-template-columns:1fr!important;
  }

  .mega-menu-layer .mega-panel :where(
    .company-bottom-bar,
    .person-tip,
    .ti-partner-strip,
    .brand-hub-contact
  ) {
    width:100%!important;
    min-width:0!important;
    flex-direction:column!important;
    align-items:flex-start!important;
    gap:10px!important;
  }

  .mega-menu-layer .mega-panel :where(a,button) {
    touch-action:manipulation;
  }

  .mega-menu-backdrop {
    display:none!important;
  }
}

@media (max-width:575.98px) {
  .mega-nav-shell .navbar {
    padding-left:12px!important;
    padding-right:12px!important;
  }

  .mega-menu-layer .mega-panel,
  .mega-menu-layer .mega-panel.is-open {
    padding:13px 12px!important;
  }
}


/* V40 — estabilidade do menu mobile e responsividade global, sem alterar desktop */
@media (max-width:1199.98px) {
  /* A própria área do menu rola; a página permanece estável enquanto ele está aberto. */
  body.maresty-mobile-menu-open {
    overflow-x:hidden!important;
  }

  .mega-nav-shell.mobile-menu-open {
    position:relative;
    z-index:1055;
  }

  .mega-nav-shell.mobile-menu-open .navbar-collapse {
    display:block!important;
    max-height:calc(100svh - 72px)!important;
    max-height:calc(100dvh - 72px)!important;
    scrollbar-gutter:stable;
  }

  .mega-nav-shell.mobile-menu-open.mobile-category-open .mega-menu-layer {
    position:static!important;
    inset:auto!important;
    transform:none!important;
  }

  .mega-menu-layer .mega-panel.is-open {
    contain:layout paint;
  }

  /* Evita que animações de entrada deixem conteúdo invisível após mudança de viewport. */
  .wow {
    visibility:visible!important;
  }

  /* Proteções gerais contra estouro horizontal em todas as páginas. */
  main,
  section,
  header,
  footer,
  .container,
  .container-fluid,
  .row,
  [class*="col-"] {
    min-width:0;
  }

  img,
  svg,
  video,
  iframe,
  canvas {
    max-width:100%!important;
    height:auto;
  }

  table {
    max-width:100%;
  }

  .table-responsive,
  .responsive-table,
  .overflow-auto {
    -webkit-overflow-scrolling:touch;
  }

  :where(h1,h2,h3,h4,h5,h6,p,a,span,strong,small,button,label) {
    overflow-wrap:anywhere;
  }

  .btn,
  button,
  input,
  select,
  textarea {
    max-width:100%;
  }
}

@media (max-width:767.98px) {
  html {
    scroll-padding-top:72px;
  }

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

  .container,
  .container-fluid {
    padding-left:16px!important;
    padding-right:16px!important;
  }

  .row {
    --bs-gutter-x:1.25rem;
  }

  h1,
  .display-1,
  .display-2,
  .display-3,
  .display-4,
  .display-5 {
    font-size:clamp(2rem,9vw,3rem)!important;
    line-height:1.12!important;
  }

  h2 {
    font-size:clamp(1.65rem,7vw,2.35rem)!important;
    line-height:1.18!important;
  }

  .lead {
    font-size:1.05rem!important;
  }

  .d-flex.flex-wrap.gap-3 > .btn,
  .hero-actions .btn {
    flex:1 1 100%;
    width:100%;
    text-align:center;
    white-space:normal;
  }

  .card,
  [class*="-card"],
  [class*="-panel"] {
    min-width:0;
  }

  .back-to-top {
    right:16px!important;
    bottom:16px!important;
  }
}

@media (max-width:575.98px) {
  .container,
  .container-fluid {
    padding-left:13px!important;
    padding-right:13px!important;
  }

  .mega-nav-shell .navbar-brand img {
    max-width:min(190px,58vw)!important;
    height:auto!important;
  }

  .mega-nav-shell .navbar-toggler {
    flex:0 0 auto;
    padding:8px 12px!important;
  }

  .mega-nav-links .nav-link,
  .mega-nav-links .mega-trigger {
    padding:13px 2px!important;
    font-size:.96rem!important;
  }

  .mega-menu-layer .mega-panel,
  .mega-menu-layer .mega-panel.is-open {
    padding:12px 10px!important;
  }
}

/* V42 — menu realmente fixo ao alcançar o topo, sem salto de conteúdo */
.mega-nav-shell.maresty-nav-fixed {
  position: fixed !important;
  top: 0 !important;
  right: 0 !important;
  left: 0 !important;
  width: 100% !important;
  z-index: 1055 !important;
  isolation: isolate;
}

.mega-nav-shell.maresty-nav-fixed > .navbar {
  background: #fff !important;
}

.maresty-nav-placeholder {
  display: none;
  width: 100%;
  height: 0;
  pointer-events: none;
}

.maresty-nav-placeholder.is-active {
  display: block;
}

@media (max-width: 1199.98px) {
  .mega-nav-shell .navbar-collapse {
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }

  .mega-nav-shell.mobile-menu-open .navbar-collapse {
    max-height: calc(100svh - 72px) !important;
    max-height: calc(100dvh - 72px) !important;
    overflow-y: auto !important;
  }
}

/* V43 — rolagem correta do menu fixo em celulares e tablets */
@media (max-width: 1199.98px) {
  /* Enquanto o menu principal estiver aberto, a página fica parada e
     o conjunto completo do menu (links + acordeão) ganha sua própria rolagem. */
  body.maresty-mobile-menu-open {
    overflow: hidden !important;
    height: 100svh;
    height: 100dvh;
    touch-action: none;
  }

  .mega-nav-shell.mobile-menu-open {
    position: fixed !important;
    inset: 0 0 auto 0 !important;
    width: 100% !important;
    height: 100svh !important;
    height: 100dvh !important;
    max-height: 100svh !important;
    max-height: 100dvh !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    background: #fff;
    z-index: 1060 !important;
  }

  /* A rolagem não pode ficar limitada apenas ao collapse, pois os painéis
     do acordeão são irmãos dele dentro do cabeçalho. */
  .mega-nav-shell.mobile-menu-open .navbar-collapse {
    max-height: none !important;
    overflow: visible !important;
    overscroll-behavior: auto;
  }

  .mega-nav-shell.mobile-menu-open .mega-menu-layer,
  .mega-nav-shell.mobile-menu-open .mega-panel,
  .mega-nav-shell.mobile-menu-open .mega-panel.is-open {
    overflow-y: visible !important;
    max-height: none !important;
  }

  /* Espaço final para que o último link não fique encostado na borda da tela. */
  .mega-nav-shell.mobile-menu-open .mega-menu-layer {
    padding-bottom: max(24px, env(safe-area-inset-bottom)) !important;
  }
}
