/**
 * Mobile chrome (≤767.98px): hide DRM top bar, show bottom nav.
 * Parent MConnect PWA keeps its own top/bottom chrome outside the iframe.
 */

#drm-mobile-bottom-nav {
  display: none;
}

/* Host is a no-op on desktop; button uses d-md-none */
.drm-page-menu-host {
  display: none;
}

@media (max-width: 767.98px) {
  html,
  body {
    overscroll-behavior-y: contain;
  }

  #page-topbar {
    display: none !important;
  }

  .page-content {
    padding-top: 1.5rem;
    padding-bottom: calc(6.5rem + env(safe-area-inset-bottom, 0px) + 60px);
  }

  /* Title row hosts the shared menu button on the right */
  .page-title-box {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
  }

  .page-title-box .page-title-right {
    display: none !important;
  }

  /* Fallback when JS cannot find a .page-title-box */
  .drm-page-menu-host:has(#drm-page-menu-btn) {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.5rem;
  }

  #drm-page-menu-btn {
    flex-shrink: 0;
    background-color: #fff !important;
    color: #212529;
    -webkit-tap-highlight-color: transparent;
  }

  /* Pull-to-refresh indicator */
  #drm-ptr-indicator {
    position: fixed;
    top: 0;
    left: 50%;
    z-index: 1100;
    width: 2.25rem;
    height: 2.25rem;
    margin-top: 0.35rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    transform: translate(-50%, -100%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
  }

  #drm-ptr-indicator.is-visible {
    opacity: 1;
  }

  #drm-ptr-indicator.is-ready .drm-ptr-spinner {
    border-top-color: #405189;
  }

  .drm-ptr-spinner {
    width: 1.15rem;
    height: 1.15rem;
    border: 2px solid #e9ebec;
    border-top-color: #878a99;
    border-radius: 50%;
  }

  #drm-ptr-indicator.is-refreshing .drm-ptr-spinner {
    animation: drm-ptr-spin 0.7s linear infinite;
    border-top-color: #405189;
  }

  @keyframes drm-ptr-spin {
    to {
      transform: rotate(360deg);
    }
  }

  .drm-ptr-toast {
    position: fixed;
    top: calc(0.75rem + env(safe-area-inset-top, 0px));
    left: 50%;
    z-index: 1101;
    max-width: calc(100% - 2rem);
    padding: 0.5rem 0.9rem;
    border-radius: 999px;
    background: #212529;
    color: #fff;
    font-size: 0.8125rem;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
    transform: translate(-50%, -120%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
  }

  .drm-ptr-toast.is-shown {
    opacity: 1;
    transform: translate(-50%, 0);
  }

  .footer {
    padding-bottom: calc(6.5rem + env(safe-area-inset-bottom, 0px));
  }

  #drm-mobile-bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1001;
    align-items: stretch;
    justify-content: space-around;
    gap: 0;
    min-height: calc(3.5rem + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background-color: #fff;
    border-top: 1px solid #e9ebec;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
  }

  .drm-mobile-nav-item {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    min-height: 44px;
    padding: 0.4rem 0.25rem;
    border: 0;
    background: transparent;
    color: #878a99;
    font-size: 0.6875rem;
    font-weight: 500;
    text-decoration: none;
    line-height: 1.2;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
  }

  .drm-mobile-nav-item i {
    font-size: 1.25rem;
    line-height: 1;
  }

  .drm-mobile-nav-item:hover,
  .drm-mobile-nav-item:focus-visible {
    color: #405189;
    outline: none;
  }

  .drm-mobile-nav-item.is-active {
    color: #405189;
  }

  .drm-mobile-nav-item:disabled,
  .drm-mobile-nav-item.is-disabled {
    opacity: 0.4;
    pointer-events: none;
  }

  /* FAB Back replaced by bottom nav Back on mobile */
  #drm-history-back {
    display: none !important;
  }

  #back-to-top {
    bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px));
  }
}
