.mobile-footer,
.mobile-footer-backdrop,
.mobile-bell-sheet {
  display: none;
}

@media only screen and (max-width: 845px) {
  :root {
    --mobile-footer-height: 64px;
    --mobile-footer-fab-size: 56px;
    --mobile-footer-fab-lift: 12px;
  }

  #notification-button {
    display: none !important;
  }

  .header-button-container > button:has(.fa-bars) {
    display: none !important;
  }

  #announcements-button,
  #announcement-items {
    display: none !important;
  }

  .header-container .v-sep {
    display: none !important;
  }

  /* iOS Safari excludes a scroll container's padding-bottom from the
     scrollable area, so padding-bottom can't push content above the fixed
     footer once the content overflows. An ::after spacer is treated as a
     real flow child and is reliably part of scrollHeight everywhere.
     safe-area-inset-top is included because the body's content-box
     padding-top shifts #pagecontent's bottom edge off-screen by that
     amount; without it the last item is still hidden behind the footer. */
  body.pagetype-gridheadercontentfooter #pagecontent::after,
  body.pagetype-gridheadersidebarcontentfooter #pagecontent::after {
    content: '';
    display: block;
    height: calc(var(--mobile-footer-height) + var(--mobile-footer-fab-lift) + env(safe-area-inset-top) + env(safe-area-inset-bottom));
    pointer-events: none;
  }

  body.mobile-footer-open #pagecontent,
  body.mobile-menu-open #pagecontent,
  body.mobile-bell-open #pagecontent,
  body.mobile-announcements-open #pagecontent {
    overflow: hidden !important;
    touch-action: none;
  }

  /* ---------- Bar ---------- */
  .mobile-footer {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    pointer-events: none; /* children re-enable */
  }

  .mobile-footer-bar {
    pointer-events: auto;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: var(--mobile-footer-height);
    padding-bottom: env(safe-area-inset-bottom);
    background: #ffffff;
    box-shadow: 0 -2px 12px rgba(34, 49, 63, 0.1);
  }

  .mobile-footer-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #0071bc;
    font-size: 22px;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
  }

  /* The header's `.fa-bars` rule paints all bar icons white for the dark
     header. Reset for the footer's hamburger tab. */
  .mobile-footer-tab .fa-bars {
    color: inherit;
  }

  .mobile-footer-tab:active {
    transform: scale(0.95);
    transition: transform 0.08s ease-out;
  }

  .mobile-footer-tab-icon-wrap {
    position: relative;
    display: inline-flex;
  }

  .mobile-footer-tab-badge {
    display: none;
    position: absolute;
    top: -2px;
    right: -4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #e53935;
    border: 1.5px solid #ffffff;
  }

  .mobile-footer-tab-badge.is-visible {
    display: block;
  }

  /* ---------- FAB slot (the middle "spacer" that holds the + button) ---------- */
  .mobile-footer-fab-slot {
    position: relative;
    flex: 1;
    height: 100%;
  }

  .mobile-footer-fab {
    pointer-events: auto;
    position: absolute;
    left: 50%;
    bottom: calc((var(--mobile-footer-height) - var(--mobile-footer-fab-size)) / 2 + var(--mobile-footer-fab-lift));
    transform: translateX(-50%);
    box-sizing: border-box;
    width: var(--mobile-footer-fab-size);
    height: var(--mobile-footer-fab-size);
    padding: 0;
    line-height: 1;
    border-radius: 50%;
    border: 4px solid #ffffff;
    background: #22313f;
    color: #ffffff;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(34, 49, 63, 0.3);
    transition:
      transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1.2),
      background 0.18s ease;
    z-index: 2;
  }

  .mobile-footer-fab:active {
    background: #0d1822;
  }

  .mobile-footer.is-open .mobile-footer-fab {
    transform: translateX(-50%) rotate(45deg);
  }

  /* ---------- Backdrop ---------- */
  .mobile-footer-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(34, 49, 63, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
    z-index: 999;
  }

  .mobile-footer.is-open ~ .mobile-footer-backdrop,
  body.mobile-footer-open .mobile-footer-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  /* ---------- Quick-actions stack ---------- */
  .mobile-footer-actions {
    pointer-events: none;
    position: absolute;
    left: 50%;
    bottom: calc(var(--mobile-footer-height) + env(safe-area-inset-bottom) + var(--mobile-footer-fab-lift) + 12px);
    transform: translateX(-50%);
    display: flex;
    flex-direction: column; /* array order reads top-to-bottom */
    align-items: center;
    gap: 12px;
    opacity: 0;
    transition: opacity 0.18s ease;
  }

  .mobile-footer.is-open .mobile-footer-actions {
    pointer-events: auto;
    opacity: 1;
  }

  .mobile-footer-action {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 180px;
    padding: 12px 22px 12px 14px;
    border: 0;
    border-radius: 999px;
    background: #ffffff;
    color: #22313f;
    font-size: 15px;
    font-weight: 500;
    box-shadow: 0 6px 18px rgba(34, 49, 63, 0.18);
    cursor: pointer;
    transform: translateY(8px);
    transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1.2);
  }

  .mobile-footer.is-open .mobile-footer-action {
    transform: translateY(0);
  }

  .mobile-footer.is-open .mobile-footer-action:nth-last-child(1) {
    transition-delay: 0.02s;
  }
  .mobile-footer.is-open .mobile-footer-action:nth-last-child(2) {
    transition-delay: 0.06s;
  }
  .mobile-footer.is-open .mobile-footer-action:nth-last-child(3) {
    transition-delay: 0.1s;
  }
  .mobile-footer.is-open .mobile-footer-action:nth-last-child(4) {
    transition-delay: 0.14s;
  }

  .mobile-footer-action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    color: #0071bc;
    font-size: 17px;
  }

  /* ---------- Close (X) shown when open ---------- */
  .mobile-footer-close {
    pointer-events: auto;
    position: fixed;
    top: calc(env(safe-area-inset-top) + 14px);
    left: 14px;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #ffffff;
    font-size: 22px;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
    z-index: 1001;
  }

  .mobile-footer.is-open .mobile-footer-close {
    opacity: 1;
    pointer-events: auto;
  }

  /* Keep the bar above the backdrop while open */
  .mobile-footer.is-open .mobile-footer-bar {
    position: relative;
    z-index: 1000;
  }

  /* ---------- Bell bottom sheet ---------- */
  .mobile-bell-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1001;
    max-height: 80vh;
    background: #ffffff;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    box-shadow: 0 -8px 24px rgba(34, 49, 63, 0.2);
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
    display: flex;
    flex-direction: column;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .mobile-bell-sheet.is-open {
    transform: translateY(0);
  }

  /* Re-use the same backdrop for the bell sheet */
  body.mobile-bell-open .mobile-footer-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  /* On large-content devices or landscape where max-height: 80vh extends the
     sheet close to the top of the viewport, env(safe-area-inset-top) keeps
     the handle and header clear of the notch / Dynamic Island. */
  .mobile-bell-sheet-handle {
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: #d4d8dc;
    margin: calc(env(safe-area-inset-top, 0px) + 8px) auto 4px;
    flex-shrink: 0;
  }

  .mobile-bell-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px 12px;
    border-bottom: 1px solid #eef0f2;
    flex-shrink: 0;
  }

  .mobile-bell-sheet-title {
    font-size: 17px;
    font-weight: 600;
    color: #22313f;
  }

  .mobile-bell-sheet-close {
    width: 36px;
    height: 36px;
    border: 0;
    background: transparent;
    color: #6b7780;
    font-size: 20px;
    border-radius: 50%;
    cursor: pointer;
  }

  .mobile-bell-sheet-close:active {
    background: #f1f3f5;
  }

  .mobile-bell-sheet-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 4px 0 8px;
  }

  .mobile-bell-sheet-empty {
    padding: 32px 16px;
    text-align: center;
    color: #6b7780;
    font-size: 15px;
  }

  /* Style the cloned items from #notification-dropdown */
  .mobile-bell-sheet-body .center {
    text-align: left;
  }

  .mobile-bell-sheet-body .header-dropdown-inner.header {
    display: block;
    padding: 14px 16px 6px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6b7780;
  }

  .mobile-bell-sheet-body .header-dropdown-inner.company-title {
    padding: 10px 16px 4px;
    font-size: 13px;
    color: #22313f;
  }

  .mobile-bell-sheet-body .header-dropdown-inner.company-title strong {
    font-weight: 600;
  }

  .mobile-bell-sheet-body a.header-dropdown-inner.notification-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid #f4f5f7;
    color: #22313f;
    text-decoration: none;
    font-size: 15px;
    line-height: 1.35;
  }

  .mobile-bell-sheet-body a.header-dropdown-inner.notification-item:active {
    background: #f4f7fa;
  }

  .mobile-bell-sheet-body a.header-dropdown-inner.notification-item::before {
    content: '';
    flex-shrink: 0;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #e53935;
  }

  /* ---------- Menu sheet (overrides for cloned sidebar / user-dropdown) ---------- */
  body.mobile-menu-open .mobile-footer-backdrop,
  body.mobile-announcements-open .mobile-footer-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  /* ---------- Announcements sheet (cloned #announcement-items) ---------- */
  .mobile-announcements-sheet-body #notification-container > div {
    padding: 14px 16px;
    border-bottom: 1px solid #f4f5f7;
  }

  .mobile-announcements-sheet-body .position-relative {
    position: relative;
  }

  .mobile-announcements-sheet-body .d-flex {
    display: flex !important;
  }

  .mobile-announcements-sheet-body .justify-content-between {
    justify-content: space-between;
  }

  .mobile-announcements-sheet-body .align-items-center {
    align-items: center;
  }

  .mobile-announcements-sheet-body .text-primary {
    color: #0071bc !important;
    font-weight: 600;
  }

  .mobile-announcements-sheet-body .text-muted {
    color: #6b7780 !important;
    font-size: 12px;
  }

  .mobile-announcements-sheet-body .notification-body {
    color: #22313f;
    font-size: 14px;
    line-height: 1.4;
    margin: 6px 0;
  }

  .mobile-announcements-sheet-body .stretched-link {
    color: #0071bc;
    text-decoration: none;
    font-size: 13px;
  }

  .mobile-announcements-sheet-body .stretched-link::after {
    content: '';
    position: absolute;
    inset: 0;
  }

  .mobile-announcements-sheet-body .dropdown-item.text-center {
    display: block;
    padding: 14px 16px;
    text-align: center;
    color: #0071bc;
    text-decoration: none;
    font-weight: 600;
    border-top: 1px solid #eef0f2;
  }

  .mobile-announcements-sheet-body .dropdown-item-text {
    display: block;
    padding: 24px 16px;
    text-align: center;
    color: #6b7780;
  }

  .mobile-menu-sheet-body .mh-logocontainer,
  .mobile-menu-sheet-body .nav-spacer,
  .mobile-menu-sheet-body .mobile-nav-spacer,
  .mobile-menu-sheet-body .mh-version {
    display: none;
  }

  .mobile-menu-section-header {
    padding: 14px 16px 6px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6b7780;
    border-top: 1px solid #eef0f2;
    margin-top: 4px;
  }

  .mobile-menu-section-header:first-child {
    border-top: 0;
    margin-top: 0;
  }

  /* Cloned sidebar nav buttons — defaults to vertical stack on mobile from
     sidebar.css, override to a flat horizontal list row. Border-box is
     mandatory: the global `* { box-sizing: content-box }` would otherwise
     make a width:100% button overflow by 2× the padding. */
  .mobile-menu-sheet-body .nav-button {
    box-sizing: border-box;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 14px;
    height: auto;
    min-height: 0;
    padding: 14px 16px !important;
    color: #22313f;
    font-size: 15px !important;
    text-decoration: none;
    border-bottom: 1px solid #f4f5f7;
    background: transparent;
    width: 100%;
    margin: 0;
  }

  .mobile-menu-sheet-body .nav-button:hover,
  .mobile-menu-sheet-body .nav-dropdown-button:hover {
    background: transparent;
    color: #22313f;
  }

  .mobile-menu-sheet-body .nav-button:active,
  .mobile-menu-sheet-body .nav-dropdown-button:active {
    background: #f4f7fa;
  }

  /* nav-expanded marks the open parent — the global rule paints it
     blue, which clashes with sidebar.css hover. Keep text dark in the sheet. */
  .mobile-menu-sheet-body .nav-dropdown-button.nav-expanded {
    color: #22313f;
    background: #f4f7fa;
  }

  .mobile-menu-sheet-body .nav-button .sidebar-icon {
    color: #0071bc;
    font-size: 18px !important;
    width: 22px;
    min-width: 22px;
    margin-left: 0;
    text-align: center;
  }

  .mobile-menu-sheet-body .nav-button .nav-text,
  .mobile-menu-sheet-body .nav-dropdown-button .nav-text {
    flex: 1;
    text-align: left;
  }

  /* Collapsible parent buttons (Inventory, SMS, Scheduling) */
  .mobile-menu-sheet-body .nav-dropdown-button {
    box-sizing: border-box;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 14px;
    height: auto;
    min-height: 0;
    padding: 14px 16px !important;
    color: #22313f;
    font-size: 15px !important;
    border-bottom: 1px solid #f4f5f7;
    background: transparent;
    width: 100%;
    margin: 0;
    cursor: pointer;
  }

  .mobile-menu-sheet-body .nav-dropdown-button i.sidebar-icon {
    color: #0071bc;
    font-size: 18px !important;
    width: 22px;
    min-width: 22px;
    margin-left: 0;
    text-align: center;
  }

  .mobile-menu-sheet-body .nav-dropdown-button .nav-text {
    flex: 1;
    text-align: left;
  }

  .mobile-menu-sheet-body .nav-dropdown-button .caret {
    color: #6b7780;
    font-size: 14px !important;
  }

  /* Submenu container under a collapsible parent. The jQuery slideToggle
     handler animates display:none → block, so we don't need to force open
     state in CSS — just style the child items when shown. */
  .mobile-menu-sheet-body .nav-dropdown-container .nav-button {
    padding-left: 52px !important;
    background: #fbfcfd;
    font-size: 14px !important;
  }

  /* Override sidebar.css mobile rule that adds margin-left:25px on submenu
     icons — that breaks the indented-padding layout above. */
  .mobile-menu-sheet-body .nav-dropdown-container .nav-button i.sidebar-icon {
    margin-left: 0;
  }

  /* Cloned user-dropdown items */
  .mobile-menu-sheet-body .header-dropdown-inner {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    color: #22313f;
    font-size: 15px;
    text-decoration: none;
    border-bottom: 1px solid #f4f5f7;
  }

  .mobile-menu-sheet-body .header-dropdown-inner:active {
    background: #f4f7fa;
  }

  .mobile-menu-sheet-body .header-dropdown-inner i {
    color: #0071bc;
    font-size: 18px;
    width: 22px;
    text-align: center;
  }

  .mobile-menu-sheet-body .header-dropdown-inner.header-current-company {
    background: #f4f7fa;
    font-weight: 600;
  }

  .mobile-menu-sheet-body .header-dropdown-label {
    display: block;
    padding: 14px 16px 6px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6b7780;
  }
}

@media print {
  .mobile-footer,
  .mobile-footer-backdrop,
  .mobile-bell-sheet {
    display: none !important;
  }
}
