/**
 * GEO 管理端 / 公开报告 — 手机端适配补丁（v1.1.4）
 * 通过 admin.html / index.html 引入，不修改官方构建产物主体。
 */

:root {
  --geo-mobile-header-h: 52px;
  --geo-mobile-safe-bottom: env(safe-area-inset-bottom, 0px);
}

html {
  -webkit-text-size-adjust: 100%;
}

body.geo-mobile-mode {
  overflow-x: hidden;
}

/* ── 侧栏抽屉 ── */
.geo-mobile-nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(15, 23, 42, 0.45);
  opacity: 0;
  transition: opacity 0.25s ease;
}

body.geo-mobile-nav-open .geo-mobile-nav-overlay {
  display: block;
  opacity: 1;
}

.geo-mobile-menu-btn {
  display: none;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin-right: 8px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: #f1f5f9;
  color: #334155;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.geo-mobile-menu-btn:active {
  background: #e2e8f0;
}

/* ── 加载屏 / 登录页 ── */
#app-loading > div {
  width: calc(100% - 32px) !important;
  max-width: 400px !important;
  padding: 32px 24px !important;
  box-sizing: border-box !important;
}

[class*="login-box"] {
  box-sizing: border-box;
}

/* ── 平板及以下 ── */
@media (max-width: 1024px) {
  [class*="editor-layout"] {
    grid-template-columns: 1fr !important;
  }

  [class*="editor-side-panel"] {
    position: static !important;
  }

  [class*="membership-overview"] {
    flex-direction: column !important;
    gap: 16px !important;
  }

  [class*="membership-right"] {
    border-left: none !important;
    padding-left: 0 !important;
    border-top: 1px solid #f0f0f0;
    padding-top: 16px !important;
  }

  [class*="quota-grid"] {
    grid-template-columns: 1fr !important;
  }

  [class*="image-grid"] {
    grid-template-columns: repeat(3, 1fr) !important;
  }
}

/* ── 手机 ── */
@media (max-width: 768px) {
  .geo-mobile-menu-btn {
    display: inline-flex;
  }

  .layout-container {
    height: 100vh;
    height: 100dvh;
  }

  .layout-container .nav-aside {
    position: fixed !important;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 2001;
    width: min(280px, 86vw) !important;
    max-width: 86vw;
    transform: translateX(-105%);
    transition: transform 0.28s ease;
    box-shadow: none;
  }

  body.geo-mobile-nav-open .layout-container .nav-aside {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.18);
  }

  .layout-container > .el-container > .el-container {
    width: 100% !important;
    min-width: 0 !important;
  }

  .layout-container .header {
    flex-wrap: wrap;
    min-height: var(--geo-mobile-header-h);
    padding: 4px 8px;
    box-sizing: border-box;
  }

  .layout-container .header-left {
    gap: 8px;
    min-width: 0;
    flex: 1 1 auto;
  }

  .layout-container .header-title {
    font-size: 15px !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
  }

  .layout-container .header-center {
    display: none !important;
  }

  .layout-container .header-right {
    flex-shrink: 0;
    gap: 4px;
  }

  .layout-container .header-right .help-btn span:not(.iconfont) {
    display: none;
  }

  .layout-container .membership-badge {
    display: none;
  }

  .layout-container .global-task-progress .task-text {
    max-width: 120px;
  }

  .layout-container .main {
    padding: 0 !important;
    overflow-x: hidden;
  }

  .layout-container .main > .el-main,
  .layout-container .el-main {
    padding: 10px !important;
    min-width: 0;
  }

  .layout-container .main-copyright {
    padding: 12px 8px calc(10px + var(--geo-mobile-safe-bottom));
    font-size: 11px;
  }

  /* 登录 */
  [class*="login-container"] {
    padding: 16px;
    box-sizing: border-box;
  }

  [class*="login-box"] {
    width: 100% !important;
    max-width: 400px;
    padding: 28px 20px !important;
  }

  [class*="login-copyright"] {
    position: static !important;
    margin-top: 24px;
    padding-bottom: var(--geo-mobile-safe-bottom);
  }

  /* 仪表盘 */
  [class*="phase-steps"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  [class*="ai-platform-grid"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  [class*="libs-row"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  [class*="image-grid"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

  /* 流程导航 */
  [class*="process-nav"] {
    padding: 12px 8px !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  [class*="process-steps"] {
    justify-content: flex-start !important;
    min-width: max-content;
    padding-bottom: 4px;
  }

  [class*="step-item"] {
    padding: 6px 10px !important;
  }

  /* 媒体列表卡片 */
  [class*="card-body"] {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }

  [class*="col-info"],
  [class*="col-metrics"],
  [class*="col-action"] {
    width: 100% !important;
    max-width: 100% !important;
  }

  [class*="col-metrics"] {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  [class*="col-action"] {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  /* 子站开通 */
  [class*="entry-bar"] {
    flex-direction: column !important;
  }

  [class*="entry-main"] {
    grid-template-columns: 1fr !important;
  }

  /* Element Plus 通用 */
  .el-dialog {
    width: calc(100vw - 24px) !important;
    max-width: calc(100vw - 24px) !important;
    margin: 12px auto !important;
  }

  .el-drawer {
    width: min(92vw, 360px) !important;
  }

  .el-message-box {
    width: calc(100vw - 32px) !important;
    max-width: 420px;
  }

  .el-card {
    border-radius: 10px;
  }

  .el-card__header,
  .el-card__body {
    padding: 12px !important;
  }

  .el-table {
    font-size: 12px;
  }

  .el-table .cell {
    padding: 6px 8px !important;
    line-height: 1.4;
  }

  .el-table__body-wrapper,
  .el-scrollbar__wrap {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .el-form--inline .el-form-item {
    display: block;
    margin-right: 0 !important;
    width: 100%;
  }

  .el-form--inline .el-form-item .el-input,
  .el-form--inline .el-form-item .el-select {
    width: 100% !important;
  }

  .el-pagination {
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
  }

  .el-pagination .el-pagination__sizes,
  .el-pagination .el-pagination__jump {
    display: none;
  }

  .el-row {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  .page-toolbar,
  [class*="card-header"] {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* 富文本编辑器 */
  .w-e-toolbar {
    flex-wrap: wrap !important;
  }

  .w-e-bar-item {
    padding: 4px !important;
  }

  /* 公开报告（补充） */
  .public-report {
    padding: 0 12px !important;
  }

  .public-report::before {
    height: 160px !important;
  }

  .report-content {
    padding: 12px 0 !important;
  }
}

@media (max-width: 480px) {
  [class*="phase-steps"] {
    grid-template-columns: 1fr !important;
  }

  [class*="ai-platform-grid"],
  [class*="libs-row"],
  [class*="image-grid"] {
    grid-template-columns: 1fr !important;
  }

  [class*="col-metrics"] {
    grid-template-columns: 1fr !important;
  }

  .el-button + .el-button {
    margin-left: 0 !important;
  }

  .layout-container .user-info .el-dropdown-link span:not(.iconfont) {
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: bottom;
  }
}
