/*
  v6.5.32 Admin scroll and footer lock
  Preservation patch only. Keeps the existing Admin markup and cards, but makes
  the Atticus owner console a real scroll container that ends above the legal footer.
*/

:root {
  --admin-footer-clearance: 8px;
  --admin-bottom-pad: clamp(36px, 5vh, 64px);
}

/* The Admin view is dynamically created by master-console.js. It must own its
   own scroll instead of inheriting the generic page-view overflow:hidden rules. */
body .stage > section.view.page-view.master-console-view[data-view="atticus"].is-active,
body .stage > section.view.master-console-view[data-view="atticus"].is-active,
body .stage > section.view.page-view[data-view="atticus"].is-active {
  position: absolute !important;
  z-index: 5 !important;
  top: var(--base-topbar-height, var(--topbar-height, 72px)) !important;
  right: 0 !important;
  bottom: calc(var(--fm-footer-h, var(--base-footer-height, 72px)) + var(--admin-footer-clearance)) !important;
  left: 0 !important;
  width: auto !important;
  height: auto !important;
  min-width: 0 !important;
  min-height: 0 !important;
  max-width: none !important;
  max-height: none !important;
  display: block !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  padding:
    clamp(16px, 2.1vh, 28px)
    clamp(18px, 2.2vw, 34px)
    var(--admin-bottom-pad) !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  pointer-events: auto !important;
  transform: none !important;
  -webkit-overflow-scrolling: touch !important;
  overscroll-behavior: contain !important;
  scrollbar-gutter: stable !important;
  scroll-padding-top: clamp(16px, 2vh, 26px) !important;
  scroll-padding-bottom: calc(var(--admin-bottom-pad) + var(--admin-footer-clearance)) !important;
}

body .stage > section.view.master-console-view[data-view="atticus"]:not(.is-active) {
  overflow: hidden !important;
  pointer-events: none !important;
}

/* Let the actual admin content be naturally taller than the viewport. The outer
   view above is the scroll container. */
body .stage > section.view.master-console-view[data-view="atticus"].is-active > .master-console,
body .stage > section.view.master-console-view[data-view="atticus"].is-active .master-console {
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow: visible !important;
  margin: 0 !important;
  padding: 0 0 var(--admin-bottom-pad) !important;
  align-content: start !important;
}

body .stage > section.view.master-console-view[data-view="atticus"].is-active .master-console-shell,
body .stage > section.view.master-console-view[data-view="atticus"].is-active .master-section-main,
body .stage > section.view.master-console-view[data-view="atticus"].is-active .master-section-view,
body .stage > section.view.master-console-view[data-view="atticus"].is-active .master-command-center,
body .stage > section.view.master-console-view[data-view="atticus"].is-active .master-outreach-console,
body .stage > section.view.master-console-view[data-view="atticus"].is-active .master-user-console,
body .stage > section.view.master-console-view[data-view="atticus"].is-active .master-analytics-console,
body .stage > section.view.master-console-view[data-view="atticus"].is-active .master-revenue-console,
body .stage > section.view.master-console-view[data-view="atticus"].is-active .master-conversations-console,
body .stage > section.view.master-console-view[data-view="atticus"].is-active .master-files-console,
body .stage > section.view.master-console-view[data-view="atticus"].is-active .master-apps-console,
body .stage > section.view.master-console-view[data-view="atticus"].is-active .master-engine-console,
body .stage > section.view.master-console-view[data-view="atticus"].is-active .master-support-console,
body .stage > section.view.master-console-view[data-view="atticus"].is-active .master-health-console,
body .stage > section.view.master-console-view[data-view="atticus"].is-active .master-queues-console,
body .stage > section.view.master-console-view[data-view="atticus"].is-active .master-audit-console,
body .stage > section.view.master-console-view[data-view="atticus"].is-active .master-settings-console {
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow: visible !important;
}

/* Keep the bottom of the final admin card clear of the fixed footer. */
body .stage > section.view.master-console-view[data-view="atticus"].is-active .master-section-view:last-child,
body .stage > section.view.master-console-view[data-view="atticus"].is-active .master-section-card:last-child,
body .stage > section.view.master-console-view[data-view="atticus"].is-active .master-rollup-card:last-child,
body .stage > section.view.master-console-view[data-view="atticus"].is-active .master-command-card:last-child {
  margin-bottom: clamp(18px, 3vh, 42px) !important;
}

/* Footer stays centered and remains the hard visual boundary for admin. */
body .app .core-legal-footer,
body .app.compact-nav .core-legal-footer {
  top: auto !important;
  bottom: 0 !important;
  height: var(--fm-footer-h, 72px) !important;
  min-height: var(--fm-footer-h, 72px) !important;
  max-height: var(--fm-footer-h, 72px) !important;
  z-index: 70 !important;
}

@media (max-width: 820px) {
  body .stage > section.view.page-view.master-console-view[data-view="atticus"].is-active,
  body .stage > section.view.master-console-view[data-view="atticus"].is-active,
  body .stage > section.view.page-view[data-view="atticus"].is-active {
    top: 0 !important;
    bottom: 0 !important;
    height: 100% !important;
    padding:
      calc(var(--topbar-height, 56px) + 14px)
      var(--mobile-content-pad, 12px)
      calc(var(--mobile-nav-height, 68px) + 32px + var(--safe-bottom, 0px)) !important;
  }
}
