/*
  Legacy admin modals in older screens still render inside the admin route with
  Tailwind's z-50. The admin shell/sidebar/header also use z-50/z-40, so the
  overlay can appear underneath or visually clipped by the chrome.

  Keep this scoped to full-screen fixed overlays only. Dropdowns/tooltips that use
  z-50 but are not `fixed inset-0` are not affected.
*/
.fixed.inset-0.z-50,
.fixed.inset-0[class*="z-50"] {
  position: fixed !important;
  inset: 0 !important;
  z-index: 2147483647 !important;
  isolation: isolate !important;
}

/*
  When a legacy full-screen modal is open, demote the admin chrome below the modal.
  This handles routes where the modal is not yet portaled and shares the same app
  stacking context as the fixed sidebar/header.
*/
body:has(.fixed.inset-0.z-50) aside.fixed,
body:has(.fixed.inset-0.z-50) header.fixed,
body:has(.fixed.inset-0.z-50) header.sticky,
body:has(.fixed.inset-0[class*="z-50"]) aside.fixed,
body:has(.fixed.inset-0[class*="z-50"]) header.fixed,
body:has(.fixed.inset-0[class*="z-50"]) header.sticky {
  z-index: 1 !important;
}

/*
  The Quiz Collection page nests legacy modals inside a `relative z-0` content
  wrapper. That parent stacking context traps the modal below the fixed sidebar,
  even if the modal itself has a huge z-index. Lift the admin main/content wrapper
  only while a fullscreen modal exists.
*/
body:has(.fixed.inset-0.z-50) main,
body:has(.fixed.inset-0[class*="z-50"]) main,
body:has(.fixed.inset-0.z-50) main > .relative.z-0,
body:has(.fixed.inset-0[class*="z-50"]) main > .relative.z-0 {
  position: relative !important;
  z-index: 2147483646 !important;
}

/* Compact admin route header: title only, no subtitle. */
main > header.hidden.lg\:block > div {
  padding-top: 0.75rem !important;
  padding-bottom: 0.75rem !important;
}

main > header.hidden.lg\:block h1 {
  font-size: 1.5rem !important;
  line-height: 2rem !important;
  letter-spacing: -0.025em !important;
}

main > header.hidden.lg\:block p.mt-1.text-sm.font-medium.text-gray-500,
main > header.hidden.lg\:block p.max-w-3xl {
  display: none !important;
}

header.lg\:hidden.fixed > div {
  min-height: 3.25rem !important;
  padding-top: 0.5rem !important;
  padding-bottom: 0.5rem !important;
}

/* Admin-wide sharper UI: reduce oversized Tailwind radii without affecting pills/avatars. */
body:has(aside.fixed) .rounded-3xl {
  border-radius: 0.875rem !important;
}

body:has(aside.fixed) .rounded-2xl {
  border-radius: 0.625rem !important;
}

body:has(aside.fixed) .rounded-xl {
  border-radius: 0.5rem !important;
}

body:has(aside.fixed) .rounded-lg {
  border-radius: 0.375rem !important;
}

body:has(aside.fixed) .rounded-md {
  border-radius: 0.25rem !important;
}

body:has(aside.fixed) .rounded,
body:has(aside.fixed) .rounded-sm {
  border-radius: 0.1875rem !important;
}

/* Keep badges, avatars, dots, and circular controls fully round. */
body:has(aside.fixed) .rounded-full {
  border-radius: 9999px !important;
}
