/* Osaka responsive layout v1.
   Presentation only: keep business state, API contracts and print dimensions intact. */

@media screen {
  html,
  body {
    max-width: 100%;
  }

  body.workbench-theme {
    overflow-x: hidden;
  }

  /* Keep the document root as the vertical scroller on every workbench view.
     A non-visible x overflow on body makes Chrome compute overflow-y as auto;
     because body grows with the page, wheel input then targets a non-scrolling
     body instead of the document root. */
  body.workbench-theme[data-active-view] {
    overflow-x: visible;
  }

  :where(img, video, canvas) {
    max-width: 100%;
  }

  :where(input, select, textarea, button) {
    max-width: 100%;
  }

  :where(
    .app-shell,
    .app-shell > section,
    .app-shell > article,
    .app-shell > .workspace,
    .app-shell > .split-results,
    .workspace,
    .order-workspace,
    .detail-layout,
    .order-result-grid,
    .workflow-layout,
    .workflow-flow-list,
    .workflow-detail-panel,
    .tracking-management-grid,
    .tracking-management-card,
    .tracking-management-form,
    .library-panel,
    .upload-panel,
    .queue-panel,
    .result-panel,
    .order-list-panel,
    .pinmail-center-panel,
    .pinmail-center-list,
    .pinmail-record,
    .purchase-confirm-panel,
    .purchase-confirm-list,
    .purchase-confirm-product-row,
    .wuliu-sandbox-layout,
    .wuliu-sandbox-main,
    .wuliu-form-block,
    .account-shell,
    .settings-shell,
    .account-layout,
    .settings-layout,
    .profile-layout,
    .account-panel,
    .option-section,
    .option-grid,
    .outsource-shell,
    .so-shell,
    .so-view,
    .so-panel
  ) {
    min-width: 0;
  }

  :where(
    .jan-coverage-table-wrap,
    .wuliu-sandbox-table-wrap,
    .wuliu-library-table-wrap,
    .order-table-wrap,
    .tracking-management-table-wrap,
    .so-product-table
  ) {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
  }

  :where(
    .modal-shell > section,
    .pinmail-modal-panel,
    .pinmail-list-modal-panel,
    .picking-jan-entry-dialog,
    .picking-repurchase-dialog,
    .product-detail-panel,
    .image-preview-panel,
    .so-dialog
  ) {
    max-width: calc(100vw - 24px);
    max-height: calc(100dvh - 24px);
  }

  :where(
    .section-head,
    .panel-title-row,
    .picking-panel-title,
    .pinmail-center-head,
    .tracking-management-card-head,
    .packing-trial-toolbar,
    .wuliu-ruoyi-toolbar,
    .print-toolbar,
    .toolbar-actions,
    .toolbar-side-actions
  ) {
    min-width: 0;
  }

  :where(.section-head, .panel-title-row, .picking-panel-title) > * {
    min-width: 0;
  }

  .manager-flow-step {
    min-width: 0;
    overflow: hidden;
  }
}

/* A desktop sidebar reduces the real content width. Adapt product rows before
   the viewport reaches the old 1180px page breakpoint. */
@media screen and (min-width: 901px) and (max-width: 1500px) {
  .purchase-confirm-product-row {
    grid-template-columns: 72px minmax(0, 1fr) minmax(180px, 240px) minmax(140px, auto) !important;
  }

  .purchase-confirm-product-row > .purchase-confirm-product-counts {
    display: none !important;
  }
}

/* Tablet and narrow desktop: retain the desktop navigation, but let every
   work surface shrink and stack within the remaining content column. */
@media screen and (min-width: 761px) and (max-width: 1180px) {
  body.workbench-theme .app-shell,
  body.workbench-theme .app-shell.tencent-shell {
    --wb-side-width: clamp(168px, 20vw, 208px);
    --shell-side-width: var(--wb-side-width);
    padding-left: var(--wb-side-width) !important;
  }

  body.workbench-theme .topbar-main > .brand-block,
  body.workbench-theme .main-topbar > .quick-nav {
    width: var(--wb-side-width) !important;
  }

  body.workbench-theme .topbar-main > .brand-block {
    padding-inline: 12px !important;
  }

  body.workbench-theme .main-topbar > .quick-nav {
    padding: 16px 8px 24px !important;
  }

  body.workbench-theme .main-topbar > .quick-nav a,
  body.workbench-theme .main-topbar > .quick-nav a.nav-action-link:not(.is-active) {
    gap: 7px !important;
    padding-inline: 8px !important;
    font-size: 12px !important;
  }

  body.workbench-theme .main-topbar > .quick-nav .quick-nav-icon {
    width: 26px !important;
    height: 26px !important;
    flex-basis: 26px !important;
  }

  body.workbench-theme .app-shell > :is(
    #home-section,
    #workflow-section,
    #library-section,
    #purchase-confirm-section,
    #pinmail-section,
    #wuliu-library-section,
    #blocked-shipping-section,
    #tracking-management-section,
    #wuliu-sandbox-section,
    #wuliu-template-section,
    #import-section,
    #import-result-section,
    #order-section,
    #result-section,
    #packing-trial-section,
    #osaka-stock-section
  ) {
    padding: 18px clamp(12px, 2vw, 20px) 32px !important;
  }

  .workspace,
  .order-workspace,
  .detail-layout,
  body.workflow-view .workflow-layout,
  .tracking-management-grid,
  .blocked-shipping-layout,
  .wuliu-template-layout {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .detail-layout {
    padding: 14px !important;
  }

  body.workflow-view .workflow-stage-strip,
  body.workflow-view #workflow-mobile-process {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    overflow: visible !important;
  }

  body.workflow-view :is(.workflow-stage-card, .workflow-mobile-process-step) {
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
  }

  .tracking-management-card,
  .tracking-management-form,
  .tracking-management-file-zone {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .pinmail-toolbar {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
  }

  .pinmail-toolbar input {
    grid-column: 1 / -1;
  }

  .pinmail-record {
    grid-template-areas:
      "check product quantity"
      ". source uploader"
      ". dates method"
      ". actions actions" !important;
    grid-template-columns: 28px minmax(0, 1fr) minmax(180px, 240px) !important;
    gap: 10px !important;
    padding: 11px !important;
  }

  .pinmail-record > [data-pinmail-select] {
    position: static !important;
    grid-area: check !important;
    align-self: start;
    margin-top: 14px;
  }

  .pinmail-record-product {
    grid-area: product !important;
  }

  .pinmail-record-quantity {
    grid-area: quantity !important;
    width: 100%;
    max-width: 360px;
  }

  .pinmail-record-source {
    grid-area: source !important;
  }

  .pinmail-record-uploader {
    grid-area: uploader !important;
  }

  .pinmail-record-dates {
    grid-area: dates !important;
  }

  .pinmail-method {
    grid-area: method !important;
  }

  .pinmail-record-actions {
    grid-area: actions !important;
    justify-content: flex-start;
  }

  :where(
    .library-toolbar,
    .library-search-toolbar,
    .purchase-confirm-toolbar,
    .wuliu-library-toolbar,
    .packing-trial-toolbar,
    .wuliu-ruoyi-search
  ) {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  :where(.section-head, .panel-title-row, .picking-panel-title, .pinmail-center-head) {
    flex-wrap: wrap;
  }

  :where(.section-actions, .picking-title-actions, .pinmail-center-head .section-actions) {
    max-width: 100%;
    flex-wrap: wrap;
  }
}

@media screen and (min-width: 761px) and (max-width: 900px) {
  body.workbench-theme .shell-console-label {
    display: none !important;
  }

  body.workbench-theme .shell-global-tools {
    padding-inline: 6px;
  }

  body.workbench-theme .shell-global-tools a,
  body.workbench-theme .shell-global-tools button {
    padding-inline: 8px !important;
  }

  .purchase-confirm-product-row {
    grid-template-columns: 64px minmax(0, 1fr) !important;
  }

  .purchase-confirm-product-locations {
    grid-column: 2;
  }

  .purchase-confirm-product-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .purchase-confirm-product-row > .purchase-confirm-product-counts {
    display: none !important;
  }

  .wuliu-ruoyi-search {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

@media screen and (max-width: 760px) {
  /* Mobile theme rules loaded earlier use overflow-x:hidden!important on both
     the root and body. That creates a second vertical scroll container and can
     make iOS WebKit anchor fixed controls to a stale, keyboard-sized viewport.
     Keep the document root as the only page scroller on SPA workbench views. */
  html,
  body.workbench-theme[data-active-view] {
    overflow-x: visible !important;
    overflow-y: visible !important;
  }

  :where(.section-head, .panel-title-row, .picking-panel-title, .pinmail-center-head) {
    max-width: 100%;
    flex-wrap: wrap;
  }

  :where(.section-actions, .picking-title-actions, .pinmail-center-head .section-actions) {
    max-width: 100%;
    flex-wrap: wrap;
  }

  :where(.modal-shell > section, .so-dialog) {
    width: calc(100vw - 18px) !important;
    max-width: calc(100vw - 18px) !important;
  }

  :where(.print-toolbar, .toolbar-actions, .toolbar-side-actions, .top) {
    flex-wrap: wrap;
  }
}
