/* =====================================================
 * 雅惠阁 管理后台样式
 * 主色与小程序保持一致（黑白灰）
 * ===================================================== */
:root {
  --yhg-sidebar-bg: #161616;
  --yhg-sidebar-text: #a8a8a8;
  --yhg-sidebar-active: #ffffff;
  --yhg-page-bg: #f3f3f1;
  --yhg-border: #e6e6e3;

  /* Element Plus 主色：近黑色 */
  --el-color-primary: #1f1f1f;
  --el-color-primary-light-3: #626262;
  --el-color-primary-light-5: #8f8f8f;
  --el-color-primary-light-7: #bcbcbc;
  --el-color-primary-light-8: #d2d2d2;
  --el-color-primary-light-9: #ededed;
  --el-color-primary-dark-2: #000000;
  --el-border-radius-base: 6px;
  --el-font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body {
  font-family: var(--el-font-family);
  color: #1f1f1f;
  background: var(--yhg-page-bg);
  -webkit-font-smoothing: antialiased;
}
.boot-loading { display: flex; height: 100%; align-items: center; justify-content: center; color: #999; }

/* ---------- 登录 ---------- */
.login-page {
  display: flex;
  height: 100%;
  background: #121212;
}
.login-page__brand {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 64px;
  color: #fff;
  background: linear-gradient(160deg, rgba(0,0,0,.15), rgba(0,0,0,.75)), url("/uploads/seed/sample.jpg") center / cover no-repeat;
}
.login-page__brand h1 { margin: 0 0 8px; font-size: 40px; font-weight: 300; letter-spacing: 6px; }
.login-page__brand p { margin: 0; font-family: "Times New Roman", Georgia, serif; letter-spacing: 2px; opacity: .8; }
.login-page__form {
  width: 440px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 56px;
  background: #fff;
}
.login-page__form h2 { margin: 0 0 6px; font-size: 24px; font-weight: 600; }
.login-page__form .sub { margin: 0 0 32px; color: #888; font-size: 14px; }
@media (max-width: 860px) {
  .login-page__brand { display: none; }
  .login-page__form { width: 100%; }
}

/* ---------- 布局 ---------- */
.layout { display: flex; height: 100%; }
.sidebar {
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--yhg-sidebar-bg);
  overflow-y: auto;
}
.sidebar__logo {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 22px;
  color: #fff;
  font-size: 17px;
  letter-spacing: 2px;
  border-bottom: 1px solid #262626;
}
.sidebar__logo b {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 6px; background: #fff; color: #111; font-size: 15px; letter-spacing: 0;
}
.sidebar .el-menu { border-right: none; background: transparent; --el-menu-bg-color: transparent; --el-menu-hover-bg-color: #232323; --el-menu-text-color: var(--yhg-sidebar-text); --el-menu-active-color: var(--yhg-sidebar-active); --el-menu-item-height: 46px; --el-menu-sub-item-height: 42px; }
.sidebar .el-menu-item.is-active { background: #2a2a2a; font-weight: 500; }
.sidebar .el-sub-menu__title:hover { background: #232323; }
.sidebar .menu-badge .el-badge__content { border: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.header {
  height: 64px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: #fff;
  border-bottom: 1px solid var(--yhg-border);
}
.header__title { font-size: 16px; font-weight: 600; }
.header__user { display: flex; align-items: center; gap: 8px; cursor: pointer; color: #333; }
.header__avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: #1f1f1f; color: #fff; font-size: 13px;
}
.content { flex: 1; overflow-y: auto; padding: 20px 24px 40px; }

/* ---------- 页面元素 ---------- */
.panel {
  background: #fff;
  border: 1px solid var(--yhg-border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
}
.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}
.panel__title { font-size: 15px; font-weight: 600; }
.panel__desc { margin-top: 4px; font-size: 13px; color: #888; font-weight: 400; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.pager { display: flex; justify-content: flex-end; margin-top: 16px; }
.muted { color: #999; font-size: 12px; }
.tip { color: #999; font-size: 12px; line-height: 1.6; margin-top: 4px; }

.thumb {
  width: 64px; height: 64px; border-radius: 6px; object-fit: cover;
  background: #f2f2f2; display: block; border: 1px solid #eee;
}
.thumb--wide { width: 128px; height: 64px; }
.thumb--icon { width: 36px; height: 36px; object-fit: contain; background: #fafafa; padding: 4px; }

/* 统计卡片 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; margin-bottom: 16px; }
.stat-card {
  background: #fff; border: 1px solid var(--yhg-border); border-radius: 10px; padding: 18px 20px; cursor: pointer;
  transition: border-color .2s;
}
.stat-card:hover { border-color: #bbb; }
.stat-card__label { color: #888; font-size: 13px; }
.stat-card__value { margin-top: 8px; font-size: 28px; font-weight: 600; }
.stat-card__extra { margin-top: 4px; color: #999; font-size: 12px; }
.stat-card--alert .stat-card__value { color: #c0392b; }

/* 首页宫格预览 */
.grid-preview {
  display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: 120px; gap: 4px;
  grid-template-areas: "a b c d" "e e f d";
  max-width: 520px;
}
.grid-preview__cell { position: relative; overflow: hidden; border-radius: 4px; cursor: pointer; background: #ddd; }
.grid-preview__cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.grid-preview__cell span {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 6px; color: #fff; font-size: 12px; letter-spacing: 1px; text-shadow: 0 1px 4px rgba(0,0,0,.6);
  background: rgba(0,0,0,.12); transition: background .2s;
}
.grid-preview__cell:hover span { background: rgba(0,0,0,.45); }
.grid-preview__cell.is-active { outline: 3px solid #1f1f1f; outline-offset: 1px; }
.grid-preview__cell.is-hidden { opacity: .35; }

.entry-preview { display: flex; gap: 12px; }
.entry-preview__card {
  width: 150px; padding: 14px 8px; background: #fff; border: 1px solid #e5e5e5; border-radius: 6px;
  display: flex; flex-direction: column; align-items: center; gap: 8px; cursor: pointer;
}
.entry-preview__card.is-active { border-color: #1f1f1f; box-shadow: 0 0 0 1px #1f1f1f; }
.entry-preview__card img { width: 22px; height: 22px; object-fit: contain; }
.entry-preview__card .t { font-size: 13px; display: flex; align-items: center; gap: 4px; }
.entry-preview__card .b { font-size: 11px; color: #fff; background: #111; border-radius: 99px; padding: 1px 16px; }

/* ---------- 图片选择器 ---------- */
.img-picker { display: flex; flex-wrap: wrap; gap: 10px; }
.img-picker__item, .img-picker__add {
  position: relative; width: var(--w, 104px); height: var(--h, 104px); border-radius: 8px; overflow: hidden;
}
.img-picker__item { border: 1px solid #e5e5e5; background: #f6f6f6; }
.img-picker__item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-picker--contain .img-picker__item img { object-fit: contain; padding: 8px; }
.img-picker__mask {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 6px;
  background: rgba(0,0,0,.5); opacity: 0; transition: opacity .2s;
}
.img-picker__item:hover .img-picker__mask { opacity: 1; }
.img-picker__mask .el-icon { color: #fff; font-size: 16px; cursor: pointer; padding: 4px; border-radius: 4px; }
.img-picker__mask .el-icon:hover { background: rgba(255,255,255,.2); }
.img-picker__add {
  border: 1px dashed #c8c8c8; background: #fafafa; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 4px; color: #888; font-size: 12px; cursor: pointer; transition: border-color .2s;
}
.img-picker__add:hover { border-color: #1f1f1f; color: #1f1f1f; }
.img-picker__add .el-icon { font-size: 20px; }
.img-picker__lib { font-size: 12px; color: #666; text-decoration: underline; cursor: pointer; }
.img-picker__lib:hover { color: #000; }
.img-picker__index {
  position: absolute; left: 4px; top: 4px; background: rgba(0,0,0,.55); color: #fff; font-size: 11px;
  border-radius: 4px; padding: 0 5px; line-height: 18px;
}

/* 素材库 */
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; min-height: 200px; }
.lib-item { position: relative; border: 2px solid transparent; border-radius: 8px; overflow: hidden; cursor: pointer; background: #f4f4f4; }
.lib-item img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.lib-item.is-selected { border-color: #1f1f1f; }
.lib-item__check {
  position: absolute; right: 6px; top: 6px; width: 20px; height: 20px; border-radius: 50%; background: #1f1f1f; color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 12px;
}
.lib-item__name { padding: 4px 6px; font-size: 11px; color: #666; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: #fff; }
.lib-item__actions { position: absolute; left: 0; right: 0; top: 0; display: flex; justify-content: flex-end; gap: 4px; padding: 6px; opacity: 0; transition: opacity .2s; }
.lib-item:hover .lib-item__actions { opacity: 1; }

/* ---------- 跳转设置 ---------- */
.link-editor { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; width: 100%; }
.link-editor .el-select { width: 200px; }

/* ---------- 富文本 ---------- */
.rich-editor { border: 1px solid #dcdfe6; border-radius: 6px; overflow: hidden; width: 100%; }
.rich-editor__toolbar { border-bottom: 1px solid #e5e5e5; }
.rich-editor__body { height: 380px; overflow-y: hidden; }
.w-e-full-screen-container { z-index: 3000 !important; }
.w-e-modal, .w-e-drop-panel, .w-e-select-list { z-index: 3001 !important; }

/* 规格参数行 */
.spec-row { display: flex; gap: 8px; margin-bottom: 8px; width: 100%; }
.spec-row .el-input:first-child { width: 160px; flex-shrink: 0; }

/* 表单抽屉 */
.el-drawer__header { margin-bottom: 0; padding: 18px 24px; border-bottom: 1px solid #eee; color: #1f1f1f; font-weight: 600; }
.el-drawer__body { padding: 20px 24px; }
.el-drawer__footer { border-top: 1px solid #eee; padding: 12px 24px; }
.form-section-title { font-size: 13px; font-weight: 600; color: #666; margin: 8px 0 14px; padding-left: 8px; border-left: 3px solid #1f1f1f; }

.option-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.option-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 6px 5px 12px; border-radius: 99px;
  background: #f4f4f2; border: 1px solid #e8e8e4; font-size: 13px;
}
.option-chip.is-off { opacity: .45; text-decoration: line-through; }
.option-chip .n { color: #999; font-size: 12px; }
.option-chip .el-icon { cursor: pointer; color: #888; padding: 2px; border-radius: 50%; }
.option-chip .el-icon:hover { background: #e0e0e0; color: #000; }

.el-table .cell { line-height: 1.5; }
.el-table th.el-table__cell { background: #fafaf9; color: #555; font-weight: 600; }

/* =====================================================
 * 手机端适配
 * ---------------------------------------------------------
 * 下面所有规则都写在媒体查询里，只在窄屏（≤ 768px）或触屏设备上生效，
 * 电脑端（宽屏 + 鼠标）不会命中任何一条，样式与原来完全一致。
 * 新增的两个元素（顶部菜单按钮、侧栏遮罩）在电脑端是 display:none。
 * 以后改电脑端样式只改上面的部分；手机端问题只改这里。
 * ===================================================== */
.header__menu-btn, .sidebar-mask { display: none; }

@media (max-width: 768px) {
  /* ---- 布局：侧栏收成抽屉，点左上角按钮打开 ---- */
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 1500; width: 240px;
    transform: translateX(-100%); transition: transform .25s ease;
  }
  .layout.nav-open .sidebar { transform: translateX(0); box-shadow: 4px 0 24px rgba(0, 0, 0, .25); }
  .sidebar-mask {
    display: block; position: fixed; inset: 0; z-index: 1499; background: rgba(0, 0, 0, .45);
    opacity: 0; pointer-events: none; transition: opacity .25s;
  }
  .layout.nav-open .sidebar-mask { opacity: 1; pointer-events: auto; }

  .header { height: 52px; padding: 0 12px 0 6px; gap: 6px; }
  .header__menu-btn {
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    width: 40px; height: 40px; padding: 0; border: none; border-radius: 6px; background: none;
    color: #1f1f1f; font-size: 22px; cursor: pointer; -webkit-tap-highlight-color: transparent;
  }
  .header__menu-btn:active { background: #f0f0f0; }
  .header__title { flex: 1; min-width: 0; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .header__name, .header__user > .el-icon { display: none; }

  .content { padding: 12px 12px 32px; -webkit-overflow-scrolling: touch; }
  .panel { padding: 14px; margin-bottom: 12px; border-radius: 8px; }
  .panel__head { margin-bottom: 12px; }

  /* 搜索栏：输入框、下拉框自动换行铺满 */
  .toolbar { width: 100%; gap: 8px; }
  .toolbar > .el-input, .toolbar > .el-select { flex: 1 1 140px; width: auto !important; min-width: 0; }
  .toolbar > .el-radio-group { width: 100%; }

  /* 分页 */
  .pager { justify-content: center; }
  .el-pagination { flex-wrap: wrap; justify-content: center; row-gap: 8px; }

  /* 统计卡片两列 */
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
  .stat-card { padding: 14px; }
  .stat-card__value { font-size: 24px; }

  /* 栅格（el-col）在手机上一列一个 */
  .content .el-row > .el-col,
  .el-drawer .el-row > .el-col,
  .el-dialog .el-row > .el-col { flex: 0 0 100%; max-width: 100%; }

  /* ---- 弹窗 / 抽屉：占满屏幕宽度 ---- */
  .el-dialog {
    --el-dialog-width: calc(100vw - 24px) !important;
    --el-dialog-margin-top: 6vh !important;
    width: calc(100vw - 24px) !important;
    margin-bottom: 24px;
  }
  .el-message-box { max-width: calc(100vw - 32px); }
  .el-drawer.rtl, .el-drawer.ltr { width: 100% !important; }
  .el-drawer__header { padding: 14px 16px; }
  .el-drawer__body { padding: 14px 16px; }
  .el-drawer__footer { padding: 10px 16px; }

  /* ---- 表单：标签放到输入框上方，输入框占满一行 ---- */
  .el-form .el-form-item { flex-direction: column; align-items: stretch; margin-bottom: 16px; }
  .el-form .el-form-item__label {
    width: auto !important; height: auto; justify-content: flex-start; text-align: left;
    padding: 0; margin-bottom: 6px; line-height: 22px;
  }
  .el-form .el-form-item__content { margin-left: 0 !important; width: 100%; min-width: 0; }
  .el-form .el-form-item__content > .el-input,
  .el-form .el-form-item__content > .el-select { max-width: 100%; }
  .link-editor .el-select { width: 100%; }
  .spec-row .el-input:first-child { width: 38%; }
  .rich-editor__body { height: 320px; }

  /* ---- 首页设置的预览 ---- */
  .grid-preview { grid-auto-rows: 72px; max-width: 100%; }
  .entry-preview { flex-wrap: wrap; gap: 8px; }
  .entry-preview__card { flex: 1 1 90px; width: auto; }
  .el-tabs__item { padding: 0 12px !important; }

  /* ---- 图片 ---- */
  .img-picker__item, .img-picker__add { max-width: 100%; }
  .lib-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
}

/* 触屏设备没有鼠标悬停：图片上的操作按钮（预览 / 替换 / 删除）常显在底部 */
@media (hover: none) {
  .img-picker__mask { inset: auto 0 0 0; height: 30px; opacity: 1; background: rgba(0, 0, 0, .55); }
  .lib-item__actions { opacity: 1; }
}
