/* =============================================================================
 * 启飞商城管理后台 · 手机端适配层
 * 版本: v1.0  日期: 2026-10-29
 * 说明: 不重新构建前端, 通过 index.html 追加本文件实现移动端优化。
 *       仅在 <=768px 生效, PC 端表现完全不变。
 * 回滚: 删除 index.html 中对应的 <link> 即可。
 * ============================================================================= */

/* ---------- 通用(全尺寸): 修复表格卡片模式的基础样式 ---------- */
.m-view-toggle {
  position: fixed;
  right: 10px;
  bottom: calc(70px + env(safe-area-inset-bottom, 0px));
  z-index: 2999;
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(64, 158, 255, 0.8);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.16);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.m-mobile .m-view-toggle.m-show {
  display: flex;
}

@media (max-width: 768px) {
  /* ---------- 1. 基础变量 ---------- */
  :root {
    --tags-view-height: 0px;
    --app-content-padding: 10px;
    --top-tool-p-x: 6px;
  }

  html,
  body {
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden;
  }

  /* ---------- 2. 顶栏精简: 只保留 折叠按钮 / 消息 / 头像 ---------- */
  .v-tool-header {
    padding: 0 6px !important;
  }

  .v-tool-header > div:last-child > *:not(:nth-last-child(1)):not(:nth-last-child(2)) {
    display: none !important;
  }

  .v-tool-header .lt-md\:hidden {
    display: none !important;
  }

  /* ---------- 3. 标签页隐藏, 把高度让给内容 ---------- */
  .v-tags-view {
    display: none !important;
  }

  /* ---------- 4. 内容区 ---------- */
  .v-layout-content,
  .v-layout-classic .v-layout-content {
    overflow-x: hidden;
  }

  .v-layout-content-scrollbar {
    -webkit-overflow-scrolling: touch;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .v-app-view,
  .app-view,
  .v-layout-content-scrollbar > div {
    padding: 0 !important;
  }

  .v-content-wrap {
    margin-bottom: 10px !important;
    border-radius: 8px;
  }

  .el-card {
    border-radius: 8px;
  }

  /* 页面常用内边距类压缩 */
  .p-20px {
    padding: 10px !important;
  }

  .mb-15px {
    margin-bottom: 10px !important;
  }

  /* ---------- 5. 侧边菜单抽屉 ---------- */
  .v-layout > .absolute.top-0.left-0 {
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.25);
    border-radius: 0 10px 10px 0;
    overflow: hidden;
  }

  /* ---------- 6. 搜索表单: 竖向铺满 ---------- */
  .el-form--inline .el-form-item {
    display: block;
    width: 100%;
    margin-right: 0 !important;
    margin-bottom: 10px !important;
  }

  .el-form--inline .el-form-item__label {
    display: block;
    float: none;
    width: auto !important;
    padding: 0 0 4px 0 !important;
    text-align: left;
    line-height: 20px;
  }

  .el-form--inline .el-form-item__content {
    width: 100%;
    margin-left: 0 !important;
  }

  /* 覆盖 tailwind 固定宽度 (如 !w-280px), 避免横向溢出 */
  .el-form--inline .el-select,
  .el-form--inline .el-input,
  .el-form--inline .el-date-editor,
  .el-form--inline .el-cascader,
  .el-form--inline .el-input-number,
  .el-form--inline .el-tree-select,
  .el-form--inline .el-autocomplete {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* iOS 输入框聚焦缩放规避 */
  .el-input__inner,
  .el-textarea__inner {
    font-size: 16px !important;
  }

  /* ---------- 7. 表格: 紧凑 + 可横滑 ---------- */
  .el-table {
    font-size: 12px;
  }

  .el-table th.el-table__cell {
    padding: 6px 0;
  }

  .el-table td.el-table__cell {
    padding: 6px 0;
  }

  .el-table .cell {
    padding: 0 8px !important;
    line-height: 1.45;
    word-break: break-word;
  }

  .el-table__body-wrapper,
  .el-scrollbar__wrap {
    -webkit-overflow-scrolling: touch;
  }

  .el-table__empty-block {
    min-height: 120px;
  }

  /* 表格内按钮紧凑 */
  .el-table .el-button.is-link,
  .el-table .el-button.is-text {
    padding: 0 4px;
    font-size: 12px;
  }

  /* ---------- 8. 卡片模式(由 mobile.js 加 .m-cards) ---------- */
  .el-table.m-cards {
    border: 0;
    background: transparent;
  }

  .el-table.m-cards .el-table__header-wrapper,
  .el-table.m-cards .el-table__footer-wrapper {
    display: none;
  }

  .el-table.m-cards .el-table__body-wrapper,
  .el-table.m-cards .el-table__body,
  .el-table.m-cards .el-table__body tbody {
    display: block;
    width: 100% !important;
  }

  .el-table.m-cards .el-table__body tbody tr.el-table__row {
    display: block;
    margin: 0 0 10px;
    padding: 8px 10px;
    border-radius: 10px;
    background: var(--el-bg-color, #fff);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  }

  .el-table.m-cards .el-table__body tbody tr.el-table__row:hover > td.el-table__cell {
    background: transparent !important;
  }

  .el-table.m-cards .el-table__body tbody tr.el-table__row > td.el-table__cell {
    display: flex;
    align-items: flex-start;
    width: auto !important;
    padding: 3px 0 !important;
    border-bottom: 0 !important;
    background: transparent !important;
  }

  .el-table.m-cards .el-table__body tbody tr.el-table__row > td.el-table__cell::before {
    content: attr(data-label);
    flex: 0 0 72px;
    padding-right: 8px;
    color: var(--el-text-color-secondary);
    font-size: 12px;
    line-height: 20px;
    word-break: keep-all;
  }

  /* 无表头的列(操作列/选择列) */
  .el-table.m-cards .el-table__body tbody tr.el-table__row > td.el-table__cell:not([data-label]) {
    display: block;
    padding-top: 6px !important;
    border-top: 1px dashed var(--el-border-color-lighter) !important;
    margin-top: 6px;
  }

  .el-table.m-cards .el-table__body tbody tr.el-table__row > td.el-table__cell:not([data-label])::before {
    display: none;
  }

  .el-table.m-cards .el-table__body tbody tr.el-table__row > td.el-table__cell:not([data-label]) .cell {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
  }

  .el-table.m-cards .cell {
    padding: 0 !important;
    flex: 1 1 auto;
    min-width: 0;
    font-size: 13px;
  }

  /* 表格内图片统一限制尺寸, 避免拉宽表格后图片撑高行 */
  .el-table img,
  .el-table .el-image,
  .el-table .el-image img {
    max-width: 60px !important;
    max-height: 60px !important;
  }

  /* 固定列在卡片模式下取消吸附 */
  .el-table.m-cards .el-table-fixed-column--left,
  .el-table.m-cards .el-table-fixed-column--right {
    position: static !important;
    left: auto !important;
    right: auto !important;
  }

  /* 展开行(商品详情等)在卡片模式下的呈现 */
  .el-table.m-cards .el-table__body tbody tr:not(.el-table__row) {
    display: block;
  }

  .el-table.m-cards .el-table__body tbody tr:not(.el-table__row) > td {
    display: block;
    width: auto !important;
    border: 0 !important;
    padding: 0 !important;
  }

  .el-table.m-cards .el-table__expanded-cell {
    padding: 8px 0 0 !important;
  }

  /* 展开按钮浮动到卡片右上角 */
  .el-table.m-cards .el-table__body tbody tr.el-table__row {
    position: relative;
  }

  .el-table.m-cards td.m-expand-cell {
    position: absolute !important;
    top: 6px;
    right: 6px;
    display: block !important;
    width: 26px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
  }

  .el-table.m-cards td.m-expand-cell::before {
    display: none;
  }

  /* 卡片标题不换行(如"会员概览"被挤成竖排) */
  .card-title {
    white-space: nowrap;
    flex-shrink: 0;
    margin-right: 8px;
  }

  /* 卡片头部放不下时换行(标题 + 时间范围选择器) */
  .el-card__header > div {
    flex-wrap: wrap;
    row-gap: 6px;
  }

  .el-card__header .el-date-editor {
    max-width: 100%;
  }

  /* 统计数字在窄屏缩小, 避免末尾被裁 */
  .el-card .text-2xl,
  .el-card .text-3xl,
  .el-card .text-4xl {
    font-size: 18px !important;
    line-height: 1.3 !important;
  }

  /* 首页数据总览四宫格: 压缩留白 + 缩小数字 */
  .el-row.summary .el-col > div {
    padding: 10px !important;
    gap: 8px !important;
  }

  .el-row.summary .h-12.w-12 {
    width: 36px !important;
    height: 36px !important;
    font-size: 14px !important;
  }

  .el-row.summary .v-count-to {
    font-size: 18px !important;
    line-height: 1.35 !important;
    white-space: nowrap;
  }

  .el-row.summary .text-3xl,
  .el-row.summary .text-2xl,
  .el-row.summary .text-xl {
    font-size: 18px !important;
    line-height: 1.35 !important;
  }

  /* 横向滑动提示 */
  .m-scroll-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin: 0 0 6px;
    padding: 4px 8px;
    border-radius: 6px;
    background: var(--el-color-primary-light-9, #ecf5ff);
    color: var(--el-color-primary, #409eff);
    font-size: 12px;
  }

  /* 无法卡片化(有合并单元格)的表格: 保持原始列宽, 横向滚动查看 */
  .el-table:not(.m-cards) table {
    min-width: 760px;
  }

  .el-table:not(.m-cards) .el-table__body-wrapper .el-scrollbar__wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* 卡片内容横向溢出时局部滚动, 避免整页左右晃动 */
  .el-card > .el-card__body {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* PC 专属的"设置"浮层会挡住手机上的内容 */
  .v-setting {
    display: none !important;
  }

  /* 修复固定 900px 最小宽度导致的整页横滚 */
  .min-w-225 {
    min-width: 0 !important;
  }

  /* ---------- 搜索区折叠 ---------- */
  .m-filter-hidden {
    display: none !important;
  }

  .m-filter-open .m-filter-hidden {
    display: block !important;
  }

  .m-filter-toggle {
    margin-left: 8px !important;
    padding: 0 4px !important;
    border: 0 !important;
    background: transparent !important;
    color: var(--el-color-primary) !important;
    font-size: 13px;
    box-shadow: none !important;
  }

  /* ---------- 9. 弹窗 / 抽屉 / 消息框 ---------- */
  .el-dialog {
    width: 94vw !important;
    max-width: 94vw !important;
    margin: 6vh auto !important;
    border-radius: 10px;
  }

  .el-dialog__header {
    padding: 12px 14px 8px;
  }

  .el-dialog__body {
    max-height: 68vh;
    overflow-y: auto;
    padding: 12px 14px;
    -webkit-overflow-scrolling: touch;
  }

  .el-dialog__footer {
    padding: 8px 14px 12px;
  }

  .el-drawer {
    width: 92vw !important;
  }

  .el-message-box {
    width: 88vw !important;
    max-width: 88vw;
  }

  /* 表单弹窗里的 label 也改为顶部 */
  .el-dialog .el-form-item__label {
    float: none;
    display: block;
    width: auto !important;
    text-align: left;
    padding: 0 0 4px !important;
    line-height: 20px;
  }

  .el-dialog .el-form-item__content {
    margin-left: 0 !important;
  }

  .el-dialog .el-form-item {
    margin-bottom: 14px;
  }

  /* ---------- 10. 分页 ---------- */
  .el-pagination {
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 6px;
    padding: 8px 0;
  }

  .el-pagination .el-pagination__sizes,
  .el-pagination .el-pagination__jump {
    display: none !important;
  }

  /* ---------- 11. 描述列表 / 标签页 / 其它 ---------- */
  .el-descriptions__body .el-descriptions__table {
    table-layout: fixed;
  }

  .el-tabs__item {
    padding: 0 10px !important;
    font-size: 13px;
  }

  .el-button {
    padding: 8px 12px;
  }

  /* 统计卡片 */
  .el-statistic__number,
  .el-statistic .el-statistic__head {
    font-size: 14px !important;
  }

  /* ---------- 12. 登录页 ---------- */
  .v-login {
    padding: 0 10px;
  }

  .v-login .login-form {
    padding: 14px !important;
  }

  .v-login .h-48px.w-48px {
    height: 38px;
    width: 38px;
  }

  .v-login .text-20px {
    font-size: 17px !important;
  }
}
