/* ============================================================
 * JustAI 营销码 — 商家后台共享样式
 * 视觉：奶油暖调 v4 定版（2026-11-02）
 *   纸色底 #faf6ec / 墨黑 #22211b / 信号黄 #ffd400
 *   旧变量名（--deep/--sky/--purple/--grad-*）保留为兼容别名，
 *   值已切到暖调，内页无需逐个改引用
 * ============================================================ */
:root {
  /* 定版色板 */
  --paper: #faf6ec;
  --paper-2: #f7eccd;
  --card: #fffefb;
  --card-2: #f5efdf;
  --ink: #1d1c17;
  --ink-2: #57534a;
  --ink-3: #8f8a7c;
  --line: rgba(62, 53, 34, .10);
  --line-soft: rgba(62, 53, 34, .07);
  --yellow: #ffd400;
  --yellow-deep: #e0a800;
  --yellow-soft: rgba(255,212,0, .16);
  --dark: #22211b;
  --dark-2: #33322a;
  --on-dark: #f6f3e9;

  /* 兼容旧变量名 */
  --deep: #8a6d1f;
  --sky: #e0a800;
  --purple: #22211b;
  --grad-main: linear-gradient(90deg, #22211b 0%, #3a382e 100%);
  --grad-chip: linear-gradient(135deg, #22211b 0%, #3a382e 100%);
  --txt: var(--ink);
  --txt2: var(--ink-3);
  --bg: var(--paper);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", -apple-system, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, var(--paper) 52%, var(--paper-2) 100%);
  background-attachment: fixed;
  font-size: 14px;
  /* 统一所有后台页内容区左缘，使大标题与首页对齐（首页原本靠 body 内边距推到 x≈26） */
  padding: clamp(10px, 2.2vw, 26px);
}
button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; outline: none; }

/* ===== 顶部公告条：墨黑胶囊 + 黄色标签 ===== */
.topbar {
  height: 40px;
  background: var(--dark);
  color: var(--on-dark);
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px;
  font-size: 12px;
  position: relative;
  overflow: hidden;
}
.topbar .pill {
  background: var(--yellow);
  color: var(--ink);
  border-radius: 20px;
  padding: 2px 10px;
  font-weight: 700;
  white-space: nowrap;
}
.topbar .msg { color: rgba(246, 243, 233, .72); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .close { margin-left: auto; cursor: pointer; color: rgba(246, 243, 233, .65); font-size: 14px; }
.topbar .close:hover { color: var(--on-dark); }
/* 子页面顶栏右侧的账号/退出（侧边栏下线后由 shell.js 注入） */
.topbar .topbar-user { margin-left: 12px; flex: none; display: flex; align-items: center; gap: 8px; font-size: 12px; }
.topbar .topbar-user b { font-weight: 600; color: var(--on-dark); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .topbar-user a { color: rgba(246, 243, 233, .68); text-decoration: underline; cursor: pointer; }
.topbar .topbar-user a:hover { color: var(--on-dark); }
.topbar .topbar-user a.profile-entry { text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.topbar .topbar-ava { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; background: var(--card); border: 1px solid rgba(246, 243, 233, .35); }

/* ===== 布局：侧边栏 + 主区 ===== */
.layout { display: flex; min-height: calc(100vh - 40px); }
.sidebar {
  width: 208px; flex: none;
  background: var(--card);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 18px 12px;
}
.logo { display: flex; align-items: center; gap: 8px; padding: 0 8px 20px; }
.logo .logo-img { max-width: 100%; height: 44px; object-fit: contain; }
.icp { margin-top: 4px; padding: 8px 8px 2px; font-size: 10px; text-align: center; }
.icp a { color: var(--ink-3); text-decoration: none; }
.logo .mark {
  width: 26px; height: 26px; border-radius: 8px;
  background: var(--dark);
  color: var(--yellow); font-weight: 800; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
}
.logo .name { font-weight: 800; font-size: 16px; color: var(--ink); }
.menu { display: flex; flex-direction: column; gap: 4px; }
.menu a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--ink-2); text-decoration: none; font-size: 14px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.menu a svg { width: 16px; height: 16px; stroke: currentColor; flex: none; }
.menu a.active { background: var(--dark); color: var(--on-dark); font-weight: 600; }
.menu a:hover:not(.active) { background: var(--card-2); color: var(--ink); }
.menu .divider { height: 1px; background: var(--line); margin: 8px 4px; }
.side-foot { margin-top: auto; padding: 10px 8px; display: flex; align-items: center; gap: 10px; }
.side-foot .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--dark); color: var(--yellow);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex: none;
}
.side-foot .who { min-width: 0; }
.side-foot .who .n { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.side-foot .who .s { font-size: 11px; color: var(--ink-3); cursor: pointer; }
.side-foot .who .s:hover { color: var(--yellow-deep); }

.main { flex: 1; min-width: 0; padding: 26px 32px 40px; }

/* ===== 通用组件 ===== */
.back-link {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--ink-2); font-size: 14px; cursor: pointer; text-decoration: none;
  margin-bottom: 18px;
}
.back-link:hover { color: var(--ink); }

.card {
  background: var(--card); border: 1px solid var(--line-soft);
  border-radius: 18px;
  box-shadow: 0 2px 10px -4px rgba(50, 42, 22, .07);
}
.btn-dark {
  background: var(--dark); color: var(--on-dark); border: none;
  height: 44px; padding: 0 46px; border-radius: 22px;
  font-size: 15px; font-weight: 600;
  transition: background .15s;
}
.btn-dark:hover { background: var(--dark-2); }
.btn-dark[disabled] { opacity: .45; cursor: default; }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--card); border: 1px solid var(--line); color: var(--ink-2);
  height: 32px; padding: 0 12px; border-radius: 9px; font-size: 13px;
  transition: border-color .15s, color .15s;
}
.btn-ghost:hover { border-color: rgba(224,168,0, .55); color: var(--ink); }
.btn-ghost svg { width: 14px; height: 14px; stroke: currentColor; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card);
  font-size: 13.5px; color: var(--ink-2); cursor: pointer;
  max-width: 100%;
  transition: background .15s, border-color .15s, color .15s;
}
.chip .v { color: var(--ink-3); }
.chip:hover { border-color: rgba(224,168,0, .5); }
.chip.on {
  background: var(--yellow-soft); border-color: rgba(224,168,0, .55); color: #7a5c12; font-weight: 600;
}
.chip.on .v { color: #9a7a24; }

.field-label { font-size: 13px; color: var(--ink-3); margin: 18px 0 8px; }
.input, .textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); padding: 11px 14px; font-size: 14px; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus { border-color: var(--yellow-deep); box-shadow: 0 0 0 3px var(--yellow-soft); }
.textarea { resize: vertical; min-height: 84px; line-height: 1.7; }

.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.switch .track {
  width: 38px; height: 21px; border-radius: 11px; background: #ddd8ca; position: relative; transition: background .2s;
}
.switch .track::after {
  content: ""; position: absolute; top: 2.5px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  transition: left .2s; box-shadow: 0 1px 3px rgba(62, 53, 34, .25);
}
.switch.on .track { background: var(--dark); }
.switch.on .track::after { left: 19px; background: var(--yellow); }

/* tabs（店铺页/图库页通用 pill 风格） */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs .tab {
  padding: 7px 16px; border-radius: 18px; font-size: 13.5px;
  color: var(--ink-2); background: transparent; border: none;
  transition: background .15s, color .15s;
}
.tabs .tab:hover { background: var(--card-2); color: var(--ink); }
.tabs .tab.active { background: var(--dark); color: var(--on-dark); font-weight: 700; }

/* 上传虚线框 */
.upload-box {
  border: 1.5px dashed rgba(62, 53, 34, .18); border-radius: 12px; background: var(--card-2);
  min-height: 56px; display: flex; align-items: center; justify-content: center;
  color: var(--ink-3); font-size: 13px; cursor: pointer; gap: 6px;
  transition: border-color .15s, color .15s, background .15s;
}
.upload-box:hover { border-color: var(--yellow-deep); color: var(--ink); background: var(--yellow-soft); }
.upload-box svg { width: 15px; height: 15px; stroke: currentColor; }

/* 缩略图网格 */
.thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, 92px); gap: 10px; margin-top: 12px; }
.thumb {
  width: 92px; height: 92px; border-radius: 10px; object-fit: cover;
  border: 1px solid var(--line); display: block; cursor: pointer; position: relative;
}
.thumb-wrap { position: relative; width: 92px; }
.thumb-wrap .del {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px;
  border-radius: 50%; background: var(--dark); color: var(--on-dark); border: none;
  font-size: 11px; line-height: 20px; text-align: center; display: none;
}
.thumb-wrap:hover .del { display: block; }
.badge-src {
  position: absolute; left: 4px; bottom: 4px; font-size: 10px;
  background: rgba(29, 28, 23, .62); color: #fff; padding: 1px 6px; border-radius: 8px;
}

/* 空态 */
.empty { text-align: center; color: var(--ink-3); padding: 60px 0; }
.empty svg { width: 54px; height: 54px; stroke: rgba(62, 53, 34, .18); margin-bottom: 12px; }

/* toast */
#toast {
  position: fixed; left: 50%; top: 56px; transform: translateX(-50%);
  background: rgba(34, 33, 27, .94); color: var(--on-dark); font-size: 13.5px;
  padding: 9px 20px; border-radius: 20px; z-index: 999; display: none;
  max-width: 80vw;
}

/* modal */
.mask {
  position: fixed; inset: 0; background: rgba(29, 28, 23, .42);
  display: none; align-items: center; justify-content: center; z-index: 100;
}
.mask.show { display: flex; }
.modal {
  background: var(--card); border-radius: 20px; padding: 26px 28px;
  width: min(420px, 92vw); position: relative;
  box-shadow: 0 30px 60px -30px rgba(35, 32, 22, .5);
}
.modal h3 { font-size: 16px; margin-bottom: 16px; color: var(--ink); }
.modal .x {
  position: absolute; right: 16px; top: 14px; border: none; background: none;
  font-size: 18px; color: var(--ink-3);
}

/* ===== 手机端适配（≤768px：微信内打开 / 窄屏），PC 端完全不受影响 ===== */
@media (max-width: 768px) {
  /* 侧边栏 → 紧凑顶栏：logo + 菜单横排 + 用户/退出 */
  .layout { flex-direction: column; }
  .topbar .topbar-user { display: none; } /* 窄屏顶栏放不下，退出登录回首页操作 */
  .sidebar {
    width: 100%; flex-direction: row; align-items: center;
    padding: 8px 12px; border-right: none; border-bottom: 1px solid var(--line);
    position: sticky; top: 40px; z-index: 50;
  }
  .logo { padding: 0 8px 0 0; }
  .logo .logo-img { height: 32px; }
  .menu { flex-direction: row; gap: 2px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .menu a { padding: 8px 10px; font-size: 13px; white-space: nowrap; }
  .side-foot { margin: 0 0 0 auto; padding: 0; gap: 7px; }
  .side-foot .avatar { width: 27px; height: 27px; font-size: 11px; }
  .side-foot .who .n { display: none; }   /* 手机上只留「退出登录」入口 */
  .side-foot .who .s { font-size: 12.5px; }
  .icp { display: none; }

  /* 主区收窄内边距 */
  .main { padding: 18px 14px 40px; }

  /* 触屏没有 hover：窄屏下图库删除按钮直接常显 */
  .thumb-wrap .del { display: block; }

  /* iOS 聚焦输入框时页面自动放大，字号 ≥16px 可避免 */
  .input, .textarea { font-size: 16px; }

  /* 弹窗更贴边 */
  .modal { padding: 20px 18px; }
}
