/* Exact MEDCORE sidebar behavior adapted to the existing Mr.pharmacist sidebar. */

.mrph-sidebar-edge,
.mrph-sidebar-swipe-zone,
.mrph-sidebar-scrim {
  display: none !important;
}

html,
body {
  overscroll-behavior-x: none;
}

@media (min-width: 821px) {
  :root {
    --sidebar-w: 260px !important;
  }

  .mobile-menu,
  .topbar [data-action="menu"] {
    display: none !important;
  }

  .app-shell,
  .app-shell.mrph-medcore-layout,
  [dir="rtl"] .app-shell,
  [dir="rtl"] .app-shell.mrph-medcore-layout {
    display: grid !important;
    min-height: var(--mrph-visible-viewport-height, 100dvh) !important;
    align-items: start !important;
  }

  html:not([dir="rtl"]) .app-shell,
  html:not([dir="rtl"]) .app-shell.mrph-medcore-layout {
    grid-template-columns: 260px minmax(0, 1fr) !important;
  }

  html[dir="rtl"] .app-shell,
  html[dir="rtl"] .app-shell.mrph-medcore-layout {
    grid-template-columns: minmax(0, 1fr) 260px !important;
  }

  #sidebar.sidebar,
  #sidebar.sidebar.mrph-medcore-sidebar,
  #sidebar.sidebar.mrph-medcore-sidebar.mrph-medcore-closed,
  #sidebar.sidebar.mrph-medcore-sidebar.mrph-medcore-dragging {
    position: sticky !important;
    top: 0 !important;
    bottom: auto !important;
    inset-inline-start: auto !important;
    inset-inline-end: auto !important;
    align-self: start !important;
    grid-column: auto !important;
    width: 260px !important;
    min-width: 260px !important;
    max-width: 260px !important;
    height: var(--mrph-visible-viewport-height, 100dvh) !important;
    min-height: var(--mrph-visible-viewport-height, 100dvh) !important;
    max-height: var(--mrph-visible-viewport-height, 100dvh) !important;
    padding: 22px 14px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior-y: contain;
    scrollbar-gutter: stable;
    touch-action: pan-y !important;
    transform: none !important;
    opacity: 1 !important;
    transition: none !important;
  }

  html[dir="rtl"] #sidebar.sidebar {
    grid-column: 2 !important;
  }

  html[dir="rtl"] .main {
    grid-column: 1 !important;
    grid-row: 1 !important;
  }

  #sidebar.sidebar > *,
  #sidebar.sidebar.mrph-medcore-closed > *,
  #sidebar.sidebar.mrph-medcore-dragging > * {
    visibility: visible !important;
    pointer-events: auto !important;
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  /* MEDCORE sidebar swipe runtime styles — same 64px collapsed rail and finger-follow motion. */
  .app-shell.medcore-swipe-layout {
    transition: grid-template-columns .24s cubic-bezier(.2,.8,.2,1) !important;
  }

  #sidebar.sidebar.medcore-swipe-sidebar {
    touch-action: pan-y !important;
    transition:
      width .24s cubic-bezier(.2,.8,.2,1),
      min-width .24s cubic-bezier(.2,.8,.2,1),
      max-width .24s cubic-bezier(.2,.8,.2,1),
      padding .24s cubic-bezier(.2,.8,.2,1) !important;
  }

  #sidebar.sidebar.medcore-swipe-sidebar > * {
    transition:
      opacity .16s ease,
      transform .24s cubic-bezier(.2,.8,.2,1),
      visibility .16s ease !important;
  }

  html:not([dir="rtl"]) .app-shell.medcore-swipe-layout.medcore-swipe-dragging {
    grid-template-columns: var(--medcore-sidebar-drag-width) minmax(0,1fr) !important;
  }

  html[dir="rtl"] .app-shell.medcore-swipe-layout.medcore-swipe-dragging {
    grid-template-columns: minmax(0,1fr) var(--medcore-sidebar-drag-width) !important;
  }

  #sidebar.sidebar.medcore-swipe-sidebar.medcore-swipe-dragging {
    width: var(--medcore-sidebar-drag-width) !important;
    min-width: var(--medcore-sidebar-drag-width) !important;
    max-width: var(--medcore-sidebar-drag-width) !important;
    overflow: hidden !important;
    transition: none !important;
  }

  #sidebar.sidebar.medcore-swipe-sidebar.medcore-swipe-dragging > * {
    opacity: var(--medcore-sidebar-drag-opacity,1) !important;
    transition: none !important;
  }

  html:not([dir="rtl"]) .app-shell.medcore-swipe-layout.medcore-swipe-closed {
    grid-template-columns: 64px minmax(0,1fr) !important;
  }

  html[dir="rtl"] .app-shell.medcore-swipe-layout.medcore-swipe-closed {
    grid-template-columns: minmax(0,1fr) 64px !important;
  }

  #sidebar.sidebar.medcore-swipe-sidebar.medcore-swipe-closed {
    width: 64px !important;
    min-width: 64px !important;
    max-width: 64px !important;
    padding: 10px !important;
    overflow: hidden !important;
  }

  html:not([dir="rtl"]) #sidebar.sidebar.medcore-swipe-sidebar.medcore-swipe-closed > * {
    visibility: hidden !important;
    pointer-events: none !important;
    opacity: 0 !important;
    transform: translateX(-18px) !important;
  }

  html[dir="rtl"] #sidebar.sidebar.medcore-swipe-sidebar.medcore-swipe-closed > * {
    visibility: hidden !important;
    pointer-events: none !important;
    opacity: 0 !important;
    transform: translateX(18px) !important;
  }
}

@media (max-width: 820px) {
  :root {
    --sidebar-w: min(260px, 86vw) !important;
  }

  .app-shell,
  [dir="rtl"] .app-shell {
    display: block !important;
  }

  .mobile-menu,
  .topbar [data-action="menu"] {
    display: inline-flex !important;
  }

  #sidebar.sidebar {
    position: fixed !important;
    z-index: 50 !important;
    inset-block: 0 !important;
    width: min(260px, 86vw) !important;
    min-width: min(260px, 86vw) !important;
    max-width: min(260px, 86vw) !important;
    height: var(--mrph-visible-viewport-height, 100dvh) !important;
    min-height: var(--mrph-visible-viewport-height, 100dvh) !important;
    max-height: var(--mrph-visible-viewport-height, 100dvh) !important;
    padding: 22px 14px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-y !important;
    will-change: transform !important;
    transition: transform .24s ease !important;
  }

  html:not([dir="rtl"]) #sidebar.sidebar {
    left: 0 !important;
    right: auto !important;
    transform: translate3d(-105%, 0, 0) !important;
  }

  html[dir="rtl"] #sidebar.sidebar {
    right: 0 !important;
    left: auto !important;
    transform: translate3d(105%, 0, 0) !important;
  }

  #sidebar.sidebar.open,
  html:not([dir="rtl"]) #sidebar.sidebar.open,
  html[dir="rtl"] #sidebar.sidebar.open {
    transform: translate3d(0, 0, 0) !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  #sidebar.sidebar,
  .app-shell {
    transition: none !important;
  }
}