/* ==========================================================================
   Responsive Mobile & Sidebar Backdrop Enhancement
   ========================================================================== */

/* Dark transparent backdrop overlay for mobile sidebar */
.sidebar-backdrop {
  background-color: rgba(0, 0, 0, 0.65) !important;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  height: 100vh !important;
  height: 100dvh !important;
  left: 0 !important;
  position: fixed !important;
  top: 0 !important;
  width: 100vw !important;
  width: 100dvw !important;
  z-index: 1040 !important;
  touch-action: none !important;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  animation: sidebarBackdropFadeIn 0.2s ease-out;
}

body.theme-dark .sidebar-backdrop {
  background-color: rgba(0, 0, 0, 0.75) !important;
}

@keyframes sidebarBackdropFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Mobile Sidebar Wrapper Fixes */
@media screen and (max-width: 1199px) {
  #sidebar .sidebar-wrapper {
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    z-index: 1050 !important;
    left: -300px;
    box-shadow: none;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    -webkit-overflow-scrolling: touch;
  }

  #sidebar.active .sidebar-wrapper {
    left: 0 !important;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.4) !important;
  }

  /* Block ALL pointer events & triggers on background when sidebar is active or closing */
  #sidebar.active ~ #main,
  #sidebar.active ~ #main *,
  body.sidebar-closing #main,
  body.sidebar-closing #main *,
  body:has(#sidebar.active) #main,
  body:has(#sidebar.active) #main * {
    pointer-events: none !important;
    user-select: none !important;
    -webkit-user-select: none !important;
  }

  /* Prevent background interactions & scroll leakage when sidebar is active */
  body:has(#sidebar.active),
  body.sidebar-closing {
    overflow: hidden !important;
    touch-action: none !important;
  }
}
