/* Sidebar width — keep in sync with .app-sidebar width */
.app-shell {
  --app-sidebar-width: 260px;
  --top-navbar-height: 52px;
  position: relative;
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
  background: linear-gradient(180deg, var(--app-canvas) 0%, var(--app-canvas-mid) 100%);
}

@media (max-width: 900px) {
  .app-shell {
    --app-sidebar-width: 240px;
  }
}

@media (max-width: 600px) {
  .app-shell {
    --top-navbar-height: 48px;
  }
}

/* Tap outside sidebar (mobile) — light scrim + dismiss */
.app-shell-backdrop {
  position: fixed;
  inset: 0;
  z-index: 25;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.06);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (max-width: 900px) {
  .app-shell--sidebar-open .app-shell-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
}

.app-shell-content {
  position: relative;
  z-index: 1;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin-left: 0;
  transition: margin-left 0.52s cubic-bezier(0.32, 0.72, 0, 1);
}

.app-shell--sidebar-open .app-shell-content {
  margin-left: var(--app-sidebar-width);
}

.app-shell--sidebar-open {
  --app-page-pad-x: 40px;
}

@media (max-width: 600px) {
  .app-shell--sidebar-open {
    --app-page-pad-x: 28px;
  }
}

@media (max-width: 900px) {
  .app-shell--sidebar-open .app-shell-content {
    margin-left: 0;
  }
}

.app-shell-content > .top-navbar {
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

/* Main scroll region */
.app-shell-content-main {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--theme-gray-400) transparent;
}

.app-shell-content-main::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.app-shell-content-main::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--theme-gray-400) 85%, transparent);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.app-shell-content-main::-webkit-scrollbar-track {
  background: transparent;
}

/* Route wrapper (Suspense child in App.jsx) */
.app-shell-content-main .page-content-enter {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
}

.app-shell-content-main .dashboard-main {
  flex: 1 1 auto;
  min-width: 0;
  min-height: min-content;
}

/* Pages that scroll inside dashboard-main instead of the shell */
.app-shell-content-main .dashboard-main.admin-section-detail,
.app-shell-content-main .dashboard-main.snap-create {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.app-shell-content-main .dashboard-main.rp-shell {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

@media (prefers-reduced-motion: reduce) {
  .app-shell-backdrop,
  .app-shell-content {
    transition-duration: 0.01ms;
  }
}
