/* Mobile merchant workbench, adapted from the reviewed Pangu admin interface.
   Load after admin-mobile.css. Existing forms, table handling and menu behavior
   remain owned by that layer; this file changes presentation only. */

/* The new blue skin is opt-in on desktop and selected independently on phones. */
html[data-admin-theme="pdd"] {
  --theme-primary: #407cff;
  --theme-primary-hover: #2866ed;
  --theme-on-primary: #fff;
  --theme-accent: #edf3ff;
  --theme-on-accent: #407cff;
  --theme-bg: #f2f3f5;
  --theme-surface: #fff;
  --theme-soft: #f1f5ff;
  --theme-ink: #333;
  --theme-muted: #666;
  --theme-line: #e8e8e8;
  --theme-nav: #fff;
  --theme-nav-secondary: #fff;
  --theme-nav-text: #555;
  --theme-nav-strong: #333;
  --theme-nav-hover: #f5f6f8;
  --theme-nav-line: #eee;
  --theme-hero: #fff;
  --theme-hero-ink: #333;
  --theme-hero-muted: #666;
  --theme-radius: 12px;
  --theme-control-radius: 8px;
  --theme-shadow: none;
  --theme-art-filter: none;
  --theme-pattern-opacity: 0;
  color-scheme: light;
}

/* These additions leave the existing desktop DOM layout visually unchanged. */
.admin-mobile-workbench-intro { display: none; }
.admin-mobile-shortcut-section { display: contents; }

html[data-admin-theme="pdd"] body.admin-ui .header-c {
  background: var(--theme-surface);
  border-color: var(--theme-line);
}
html[data-admin-theme="pdd"] body.admin-ui .first-bar .list .item.activated .iconfont {
  color: inherit;
}
html[data-admin-theme="pdd"] body.admin-ui .second-bar :is(.ant-menu-item-selected, .pm-admin-menu-link.active) {
  color: var(--theme-primary) !important;
  background: var(--theme-soft) !important;
}
html[data-admin-theme="pdd"] body.admin-ui[data-admin-extension] .second-bar .ant-menu-item-selected:not([data-admin-category]) {
  color: var(--theme-nav-text) !important;
  background: transparent !important;
}
html[data-admin-theme="pdd"] body.admin-ui :is(.ant-table-thead > tr > th, .ci-table th) {
  color: var(--theme-muted) !important;
  background: #f7f7f8 !important;
}
html[data-admin-theme="pdd"] body.admin-ui :is(.ant-table-tbody > tr > td, .ci-table td) {
  color: var(--theme-ink);
}
html[data-admin-theme="pdd"] body.admin-ui .admin-theme-option[aria-pressed="true"] {
  border-color: var(--theme-primary);
  box-shadow: 0 0 0 1px var(--theme-primary);
}
html[data-admin-theme="pdd"] body.admin-ui .admin-theme-option[aria-pressed="true"] .admin-theme-selected {
  color: var(--theme-primary);
  background: var(--theme-soft);
}
html[data-admin-theme="pdd"] body.admin-ui .admin-theme-done {
  color: var(--theme-on-primary);
  background: var(--theme-primary);
  border-color: var(--theme-primary);
}
html[data-admin-theme="pdd"] body.admin-ui .admin-theme-done:hover {
  background: var(--theme-primary-hover);
}
.admin-theme-option[data-admin-theme-option="pdd"] {
  --sample-bg: #f2f3f5;
  --sample-nav: #fff;
  --sample-nav-text: #555;
  --sample-primary: #407cff;
  --sample-accent: #edf3ff;
  --sample-hero: #fff;
  --sample-hero-ink: #333;
  --sample-hero-muted: #666;
  --sample-ink: #333;
  --sample-radius: 5px;
  --sample-paper: #fff;
  --sample-line: #e8e8e8;
}

@media (max-width: 900px) {
  /* Keep a calm fixed app header above the existing page navigation. */
  body.admin-ui .container-23234 { padding: 0 6px; gap: 0; }
  body.admin-ui .container-23234 .logo-c { font-size: 14px !important; letter-spacing: 0; }
  html[data-admin-theme="pdd"] body.admin-ui .container-23234 :is(.admin-search-trigger, .admin-menu-toggle, .admin-theme-trigger) {
    color: var(--theme-ink);
    background: transparent;
    border: 0;
    box-shadow: none;
    font-weight: 500;
  }
  html[data-admin-theme="pdd"] body.admin-ui .container-23234 :is(.admin-search-trigger, .admin-menu-toggle, .admin-theme-trigger):hover {
    color: var(--theme-primary);
    background: var(--theme-soft);
  }
  html[data-admin-theme="pdd"] body.admin-ui .container-23234 .logo-c,
  html[data-admin-theme="pdd"] body.admin-ui .container-23234 .user-dropdown-menu {
    color: var(--theme-ink) !important;
    background: var(--theme-surface) !important;
  }
  body.admin-ui .main-c { margin-top: 104px; }
  body.admin-ui .main-c > .page-header {
    height: 48px;
    padding: 0 12px;
    background: var(--theme-surface);
    border-bottom: 1px solid var(--theme-line);
  }
  body.admin-ui .main-c > .page-header .back-c .title { font-weight: 600; }
  body.admin-ui .main-content {
    max-width: calc(100% - 24px);
    margin: 12px !important;
    padding: 14px !important;
    border-radius: 12px;
    box-shadow: none !important;
  }
  body.admin-ui.admin-home .main-content {
    padding: 0 !important;
    border: 0;
    background: transparent !important;
  }

  /* Keep the original data widgets and shortcut buttons mounted and reorder
     their visual groups for one-handed daily work. */
  body.admin-ui .admin-workbench {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 0 0 12px;
    padding: 0;
    border: 0;
  }
  body.admin-ui .admin-workbench > .admin-tech-hero { display: none; }
  body.admin-ui .admin-mobile-workbench-intro {
    display: block;
    order: 0;
    min-width: 0;
    margin: 3px 2px 0;
  }
  body.admin-ui .admin-mobile-workbench-intro :is(h1, .admin-workbench-title) {
    max-width: none;
    margin: 0;
    color: var(--theme-ink);
    font-size: 22px;
    font-weight: 600;
    line-height: 1.45;
    letter-spacing: 0;
  }
  body.admin-ui .admin-mobile-workbench-intro :is(p, .admin-workbench-subtitle) {
    max-width: none;
    margin: 5px 0 0;
    color: var(--theme-muted);
    font-size: 13px;
    line-height: 1.65;
  }
  body.admin-ui .admin-mobile-shortcut-section {
    display: block;
    order: 1;
    min-width: 0;
    margin: 0;
    padding: 16px;
    color: var(--theme-ink);
    background: var(--theme-surface);
    border: 1px solid var(--theme-line);
    border-radius: 12px;
    box-shadow: none;
  }
  body.admin-ui .admin-workbench > .admin-overview-today { order: 2; }
  body.admin-ui .admin-workbench > .admin-overview-history { order: 3; }
  body.admin-ui .admin-workbench .admin-section-heading {
    align-items: center;
    gap: 10px;
    margin: 0 0 12px;
  }
  body.admin-ui .admin-workbench .admin-section-heading h2 {
    min-width: 0;
    margin: 0;
    color: var(--theme-ink);
    font-size: 16px;
    line-height: 1.6;
    font-weight: 600;
  }
  body.admin-ui .admin-workbench .admin-section-heading > span {
    color: var(--theme-muted);
    font-size: 11px;
    line-height: 1.5;
  }
  body.admin-ui .admin-mobile-shortcut-section .admin-shortcuts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  body.admin-ui .admin-mobile-shortcut-section .admin-shortcut {
    min-width: 0;
    min-height: 72px;
    margin: 0;
    padding: 10px;
    gap: 10px;
    color: var(--theme-ink);
    background: var(--theme-surface);
    border: 1px solid var(--theme-line);
    border-radius: 8px;
    box-shadow: none;
    text-align: left;
    transform: none;
  }
  body.admin-ui .admin-mobile-shortcut-section .admin-shortcut:hover,
  body.admin-ui .admin-mobile-shortcut-section .admin-shortcut:active {
    background: var(--theme-soft);
    border-color: var(--theme-primary);
    box-shadow: none;
    transform: none;
  }
  body.admin-ui .admin-mobile-shortcut-section .admin-shortcut .iconfont {
    flex: 0 0 auto;
    padding: 8px;
    color: var(--theme-primary);
    background: var(--theme-soft);
    border-radius: 6px;
    font-size: 20px;
    line-height: 1;
  }
  body.admin-ui .admin-mobile-shortcut-section .admin-shortcut strong {
    color: var(--theme-ink);
    font-size: 14px;
    line-height: 1.5;
    font-weight: 500;
    overflow-wrap: anywhere;
  }
  body.admin-ui .admin-mobile-shortcut-section .admin-shortcut small,
  body.admin-ui .admin-mobile-shortcut-section .admin-shortcut-arrow { display: none; }

  /* Each summary is one surface with divided metrics, rather than a stack of
     differently colored tiles. Figures and refresh actions are unchanged. */
  body.admin-ui .admin-workbench .admin-overview {
    min-width: 0;
    margin: 0;
    padding: 16px;
    color: var(--theme-ink);
    background: var(--theme-surface);
    border: 1px solid var(--theme-line);
    border-radius: 12px;
    box-shadow: none;
  }
  body.admin-ui .admin-workbench .admin-overview .admin-overview-heading { margin: 0 0 12px; }
  body.admin-ui .admin-workbench .admin-overview .admin-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    margin: 0;
    overflow: hidden;
    background: var(--theme-surface);
    border: 1px solid var(--theme-line);
    border-radius: 4px;
  }
  body.admin-ui .admin-workbench .admin-overview .admin-metric {
    min-width: 0;
    padding: 14px 10px;
    background: var(--theme-surface);
    border: 0;
    border-right: 1px solid var(--theme-line);
    border-radius: 0;
    box-shadow: none;
  }
  body.admin-ui .admin-workbench .admin-overview .admin-metric:nth-child(2n) { border-right: 0; }
  body.admin-ui .admin-workbench .admin-overview .admin-metric:nth-child(n+3) { border-top: 1px solid var(--theme-line); }
  body.admin-ui .admin-workbench .admin-overview .admin-metric:first-child::after,
  body.admin-ui .admin-workbench .admin-metric-index { display: none; }
  body.admin-ui .admin-workbench .admin-metric-label {
    color: var(--theme-muted);
    font-size: 12px;
    line-height: 1.6;
  }
  body.admin-ui .admin-workbench .admin-metric strong {
    margin: 8px 0 4px;
    color: var(--theme-ink);
    font-size: 24px;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: 0;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
  }
  body.admin-ui .admin-workbench .admin-metric:first-child strong { color: var(--theme-primary); }
  body.admin-ui .admin-workbench .admin-metric-foot {
    margin-top: 4px;
    color: var(--theme-muted);
    font-size: 11px;
    line-height: 1.5;
  }
  body.admin-ui .admin-workbench :is(.admin-overview-refresh, .admin-overview-periods button) {
    min-height: 44px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
  }
  body.admin-ui .admin-workbench .admin-overview-periods { gap: 6px; }
  body.admin-ui .admin-workbench .admin-overview-periods button[aria-pressed="true"] {
    color: var(--theme-primary);
    background: var(--theme-soft);
    border-color: var(--theme-primary);
  }
  body.admin-ui .admin-workbench .admin-overview-periods > span {
    flex-basis: 100%;
    margin: 3px 0 0;
  }
  body.admin-ui .admin-workbench .admin-overview-range { margin-bottom: 12px; }
  body.admin-ui .admin-workbench .admin-finance {
    margin-top: 12px;
    padding: 14px;
    border-radius: 8px;
    box-shadow: none;
  }
  body.admin-ui .admin-workbench .admin-finance-equation {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }
  body.admin-ui .admin-workbench .admin-finance-operator { display: none; }
  body.admin-ui .admin-workbench .admin-finance-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
    align-items: center;
    width: 100%;
    padding: 12px 0;
    gap: 4px 8px;
  }
  body.admin-ui .admin-workbench .admin-finance-item strong {
    grid-column: 2;
    grid-row: 1 / span 2;
    font-size: 22px;
    text-align: right;
  }
  body.admin-ui .admin-workbench .admin-finance-item small { grid-column: 1; }
  body.admin-ui .admin-workbench .admin-finance-profit {
    margin-top: 0;
    padding: 12px 0;
    background: transparent;
    border-top: 1px solid var(--theme-line);
    border-radius: 0;
  }
  body.admin-ui .admin-workbench .admin-finance-note { font-size: 12px; line-height: 1.7; }
  body.admin-ui.admin-home #admin-workbench + .list { padding: 16px; border-radius: 12px; }
  body.admin-ui.admin-home #admin-workbench + .list .admin-data-heading { top: 16px; left: 16px; }

  /* Existing navigation sizing, safe areas and keyboard hiding are preserved. */
  body.admin-ui .admin-mobile-tab { margin: 0 2px; border-radius: 10px; }
  body.admin-ui .admin-mobile-tab .iconfont { font-size: 22px; }
  body.admin-ui .admin-mobile-tab.is-active { color: var(--theme-primary); background: var(--theme-soft); }
}

@media (max-width: 360px) {
  body.admin-ui .admin-mobile-shortcut-section .admin-shortcut { gap: 6px; padding: 8px; }
  body.admin-ui .admin-mobile-shortcut-section .admin-shortcut strong { font-size: 13px; }
  body.admin-ui .admin-workbench .admin-metric strong { font-size: 20px; }
  body.admin-ui .admin-workbench .admin-finance-item strong { font-size: 20px; }
}
