/*
 * PMD Admin Mobile Shell v1
 * Purpose: mobile-only guard for PMD admin shell/sidebar/header after Playwright QA.
 * Scope: body.page.pmd-admin-theme-v1 only.
 * Reason for !important: older PMD sidebar/header patches use high-specificity selectors
 * and existing !important rules, so this final mobile guard must win only below 640px.
 */

@media (max-width: 640px) {
  html body.page.pmd-admin-theme-v1 {
    overflow-x: hidden !important;
    width: 100vw !important;
    max-width: 100vw !important;
  }

  html body.page.pmd-admin-theme-v1 .page-wrapper {
    left: 0 !important;
    right: 0 !important;
    top: 64px !important;
    width: 100vw !important;
    max-width: 100vw !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }

  html body.page.pmd-admin-theme-v1 .page-wrapper *,
  html body.page.pmd-admin-theme-v1 .pmd-menu-form-shell *,
  html body.page.pmd-admin-theme-v1 .pmd-menu-clean-header * {
    box-sizing: border-box !important;
  }

  html body.page.pmd-admin-theme-v1 .pmd-menu-form-shell,
  html body.page.pmd-admin-theme-v1 form .pmd-menu-form-shell {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding-left: 14px !important;
    padding-right: 14px !important;
  }

  html body.page.pmd-admin-theme-v1 .pmd-menu-clean-header {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 8px !important;
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  html body.page.pmd-admin-theme-v1 .pmd-admin-header-actions,
  html body.page.pmd-admin-theme-v1 .pmd-menu-form-actions {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 8px !important;
    max-width: 100% !important;
  }

  html body.page.pmd-admin-theme-v1 .pmd-admin-header-actions .btn,
  html body.page.pmd-admin-theme-v1 .pmd-menu-form-actions .btn,
  html body.page.pmd-admin-theme-v1 .pmd-menu-clean-header .btn {
    min-height: 36px !important;
    max-width: 100% !important;
    white-space: nowrap !important;
  }

  html body.page.pmd-admin-theme-v1 .pmd-menu-clean-header h1,
  html body.page.pmd-admin-theme-v1 .pmd-menu-clean-header .page-title,
  html body.page.pmd-admin-theme-v1 .pmd-menu-clean-header [class*="title"] {
    min-width: 0 !important;
    max-width: 100% !important;
    overflow-wrap: anywhere !important;
  }

  /*
   * Hide old left-edge sidebar tabs on mobile.
   * The native/top mobile menu remains available; these old edge tabs caused the
   * visible yellow/black strip and visual crowding in 390px screenshots.
   */
  html body.page.pmd-admin-theme-v1 [id^="pmd-sidebar-edge-toggle-"] {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  html body.page.pmd-admin-theme-v1 #sidebar,
  html body.page.pmd-admin-theme-v1 .sidebar,
  html body.page.pmd-admin-theme-v1 .pmd-sidebar,
  html body.page.pmd-admin-theme-v1 .pmd-admin-sidebar {
    max-width: min(280px, 84vw) !important;
  }
}
