/* 傲宇小助手后台管理样式 —— 纯 CSS，无框架依赖 */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #ff5126;
  --primary-hover: #e6431c;
  --primary-soft: #fff1ec;
  --bg: #f7f3ec;
  --card: #ffffff;
  --surface: #fffdfa;
  --surface-2: #f6f2ea;
  --text: #2b2620;
  --ink-2: #5c554b;
  --ink-3: #cfc6b8;
  --ink-4: #b7ad9f;
  --muted: #8b8378;
  --line: #efe7db;
  --line-2: #e2d9cb;
  --green: #1fa15d;
  --red: #e5484d;
  --radius: 14px;
  --shadow: 0 2px 12px rgba(43, 38, 32, .06);
  --sticky-tint: rgba(247,243,236,.55);
  --toast-ok-bg: #e7f6ee; --toast-ok-border: #bfe6d0;
  --toast-err-bg: #fdebec; --toast-err-border: #f5c6c8;
  --toast-info-bg: #fff7e8; --toast-info-border: #f0dcae; --toast-info-ink: #9a6b00;
  --track: #d9d0c2;
}
[data-theme="dark"] {
  --primary: #ff7a4a;
  --primary-hover: #ff8d63;
  --primary-soft: rgba(255,122,74,.16);
  --bg: #14110f;
  --card: #1f1b18;
  --surface: #26221e;
  --surface-2: #1a1714;
  --text: #ece4d6;
  --ink-2: #b9b0a0;
  --ink-3: #7a7165;
  --ink-4: #6a6155;
  --muted: #8b8378;
  --line: #2f2a25;
  --line-2: #3a342e;
  --green: #4fd28e;
  --red: #ff7575;
  --shadow: 0 2px 14px rgba(0, 0, 0, .55);
  --sticky-tint: rgba(20,17,15,.7);
  --toast-ok-bg: rgba(79,210,142,.14); --toast-ok-border: rgba(79,210,142,.4);
  --toast-err-bg: rgba(255,117,117,.14); --toast-err-border: rgba(255,117,117,.4);
  --toast-info-bg: rgba(255,180,80,.14); --toast-info-border: rgba(255,180,80,.4); --toast-info-ink: #ffb450;
  --track: #3a342e;
  color-scheme: dark;
}
html { background: var(--bg); }
body { transition: background-color .2s, color .2s; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; }

/* ---------- 布局 ---------- */
.admin-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex-shrink: 0; background: var(--card); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px 14px; border-bottom: 1px solid var(--line); }
.side-brand-text { flex: 1; min-width: 0; }
.side-logo { font-size: 28px; }
.side-name { font-weight: 700; font-size: 15px; }
.side-sub { font-size: 11px; color: var(--muted); }
.side-nav { flex: 1; padding: 12px 10px; }
.side-group { font-size: 11px; color: var(--muted); padding: 14px 10px 6px; }
.side-link {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 10px;
  color: var(--text); font-size: 13.5px; margin-bottom: 2px;
}
.side-link span { width: 20px; text-align: center; }
.side-link:hover { background: var(--primary-soft); }
.side-link.active { background: var(--primary); color: #fff; font-weight: 600; }
.side-footer { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.hamburger { display: none; }
.scrim { display: none; }
.side-user { font-size: 12px; color: var(--muted); }
.side-logout { font-size: 12px; }
.main { flex: 1; padding: 26px 32px 60px; }
.main-inner { max-width: 1080px; margin: 0 auto; }

/* ---------- 页头 ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; gap: 16px; }
.page-head h1 { font-size: 22px; margin-bottom: 2px; }
.page-head p { color: var(--muted); font-size: 13px; }
.sticky-head { position: sticky; top: 0; z-index: 50; background: var(--bg); padding: 12px 0; }

/* ---------- 卡片 ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; border: 1px solid var(--line); scroll-margin-top: 84px; }
.card.narrow { max-width: 460px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-title { font-size: 15px; font-weight: 700; }
.card-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }
.card-body { padding: 18px 20px; }
.disabled-section { opacity: .92; }
.disabled-section .card-head { opacity: 1; }
.disabled-section .card-body { position: relative; pointer-events: none; }
.disabled-section .card-body::after {
  content: "已停用 · 内部不可编辑"; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--muted); background: var(--sticky-tint);
  border-radius: 0 0 var(--radius) var(--radius);
}
.tag-always { font-size: 11px; color: var(--muted); background: var(--bg); padding: 3px 10px; border-radius: 20px; white-space: nowrap; }

/* 折叠按钮（改进点1） */
.collapse-btn { background: var(--card); border: 1px solid var(--line); cursor: pointer; color: var(--muted); font-size: 22px; font-weight: 800; width: 38px; height: 38px; border-radius: 10px; line-height: 1; transition: transform .2s, background .15s, color .15s, border-color .15s, box-shadow .15s; box-shadow: 0 1px 2px rgba(60,40,20,.04); display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.collapse-btn:hover { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); box-shadow: 0 2px 6px rgba(255,107,53,.18); }
.collapse-btn:active { box-shadow: 0 0 0 3px rgba(255,107,53,.18) inset; background: var(--primary-soft); }
.card.collapsed { border-style: dashed; }
.card.collapsed .card-body { display: none; }
.card.collapsed .collapse-btn { transform: rotate(180deg); }
.item-row.collapsed .item-fields { display: none; }
.item-row.collapsed [data-role="collapse-item"] { transform: rotate(180deg); }
.item-row.dragging { opacity: .5; box-shadow: 0 0 0 2px var(--primary); }

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; min-width: 0; }
.field-label { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 5px; font-weight: 600; }
.field-label.inline { margin-bottom: 0; }
.field-help { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line-2); border-radius: 9px;
  font-size: 13.5px; background: var(--surface); color: var(--text); font-family: inherit;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(255, 81, 38, .12); }
.textarea { resize: vertical; min-height: 64px; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 18px; }
.field.col-span { grid-column: 1 / -1; }
.img-preview { display: block; max-width: 160px; max-height: 100px; margin-top: 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); object-fit: contain; }

/* ---------- 图片上传字段 ---------- */
.upload-field { margin-top: 6px; }
.upload-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.upload-btn {
  background: var(--primary-soft); color: var(--primary); border: 1px solid transparent;
  white-space: nowrap; font-size: 12.5px;
}
.upload-btn:hover { background: var(--primary); color: #fff; }
.upload-btn.done { background: var(--green); color: #fff; }
.upload-btn:disabled { opacity: .5; cursor: not-allowed; }
.upload-manual { flex: 1; min-width: 200px; }
.upload-clear {
  width: 28px; height: 28px; padding: 0; border: 1px solid var(--line-2); background: var(--card);
  border-radius: 7px; cursor: pointer; color: var(--muted); font-size: 14px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.upload-clear:hover { color: var(--red); border-color: var(--red); }
.upload-preview {
  margin-top: 8px; padding: 8px; border: 1px dashed var(--line); border-radius: 9px;
  background: var(--surface); min-height: 44px; display: flex; align-items: center; justify-content: flex-start;
}
.upload-preview.img-empty {
  background: var(--surface-2); color: var(--muted); font-size: 12px; justify-content: center;
}
.upload-progress {
  margin-top: 8px; display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted);
}
.upload-progress .bar {
  flex: 1; height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden;
  position: relative;
}
.upload-progress .bar::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 0%;
  background: linear-gradient(90deg, var(--primary), #ff8b26);
  transition: width .25s ease;
}
.upload-progress span { white-space: nowrap; }

/* ---------- 上传 toast ---------- */
.upload-toast {
  position: fixed; top: 24px; left: 50%; transform: translate(-50%, -12px);
  padding: 10px 18px; border-radius: 22px; font-size: 13px; z-index: 9999;
  box-shadow: 0 8px 24px rgba(0,0,0,.16); opacity: 0; transition: .25s;
  pointer-events: none; font-weight: 600;
}
.upload-toast.show { opacity: 1; transform: translate(-50%, 0); }
.upload-toast-success { background: var(--toast-ok-bg); color: var(--green); border: 1px solid var(--toast-ok-border); }
.upload-toast-error   { background: var(--toast-err-bg); color: var(--red);   border: 1px solid var(--toast-err-border); }
.upload-toast-info    { background: var(--toast-info-bg); color: var(--toast-info-ink);       border: 1px solid var(--toast-info-border); }

/* ---------- 开关 ---------- */
.switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  width: 40px; height: 22px; background: var(--track); border-radius: 22px; transition: .2s; position: relative; flex-shrink: 0;
}
.switch .slider::after {
  content: ''; position: absolute; width: 18px; height: 18px; background: var(--card); border-radius: 50%;
  top: 2px; left: 2px; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::after { transform: translateX(18px); }
.switch.small .slider { width: 32px; height: 18px; }
.switch.small .slider::after { width: 14px; height: 14px; }
.switch.small input:checked + .slider::after { transform: translateX(14px); }
.switch-text { font-size: 12px; color: var(--muted); margin-left: 8px; white-space: nowrap; }
.switch.big input:checked ~ .switch-text { color: var(--green); font-weight: 600; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; cursor: pointer; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-block; padding: 9px 20px; border-radius: 10px; border: 1px solid transparent;
  font-size: 13.5px; cursor: pointer; font-family: inherit; font-weight: 600; transition: .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: var(--card); border-color: var(--line-2); color: var(--muted); }
.btn-ghost:hover { color: var(--red); border-color: var(--red); }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 12px; font-size: 12.5px; border-radius: 8px; }
.btn-add { background: var(--primary-soft); color: var(--primary); }
.btn-add:hover { background: var(--primary); color: #fff; }
.icon-btn {
  width: 26px; height: 26px; border: 1px solid var(--line-2); background: var(--card); border-radius: 7px;
  cursor: pointer; font-size: 13px; color: var(--muted); line-height: 1;
}
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }
.icon-btn.danger:hover { border-color: var(--red); color: var(--red); }

/* ---------- 列表编辑器 ---------- */
.items-editor { margin-top: 6px; border-top: 1px dashed var(--line); padding-top: 14px; }
.items-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.items-title { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.item-row { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; background: var(--surface); }
.item-row.item-off { opacity: .55; background: var(--surface-2); }
.item-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.item-drag { color: var(--primary); cursor: grab; font-size: 15px; touch-action: none; }
.item-drag:active { cursor: grabbing; }
.item-index { font-size: 12px; color: var(--muted); }
.item-actions { margin-left: auto; display: flex; gap: 6px; }
.item-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0 16px; }

/* ---------- 模块导航 ---------- */
.section-toc { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.toc-chip {
  font-size: 12px; padding: 5px 13px; background: var(--card); border: 1px solid var(--line);
  border-radius: 20px; color: var(--text);
}
.toc-chip:hover { border-color: var(--primary); color: var(--primary); }
.toc-chip.off { color: var(--ink-4); text-decoration: line-through; }
.form-footer { display: flex; gap: 12px; padding: 8px 0 30px; }

/* ---------- 控制台 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stat-num { font-size: 24px; font-weight: 800; color: var(--primary); }
.stat-num.small { font-size: 14px; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; }
.entry-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.entry-card {
  display: flex; align-items: center; gap: 14px; padding: 16px; border: 1px solid var(--line);
  border-radius: 12px; color: var(--text); transition: .15s; background: var(--surface);
}
.entry-card:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.entry-icon { font-size: 26px; }
.entry-title { font-weight: 700; font-size: 14px; }
.entry-desc { font-size: 12px; color: var(--muted); }
.entry-meta { font-size: 11px; color: var(--green); margin-top: 3px; }
.entry-arrow { margin-left: auto; color: var(--ink-3); font-size: 20px; }
.doc-list { padding-left: 18px; font-size: 13px; color: var(--ink-2); }
.doc-list li { margin-bottom: 6px; }
.doc-list code { background: var(--bg); padding: 2px 7px; border-radius: 6px; font-size: 12px; color: var(--primary); }

/* ---------- 表格 / 提示 ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid var(--line); }
.empty-tip { color: var(--muted); text-align: center; padding: 26px 0; font-size: 13px; }
.link { font-size: 12.5px; }
.flash { padding: 11px 16px; border-radius: 10px; margin-bottom: 16px; font-size: 13px; }
.flash-success { background: var(--toast-ok-bg); color: var(--green); border: 1px solid var(--toast-ok-border); }
.flash-error { background: var(--toast-err-bg); color: var(--red); border: 1px solid var(--toast-err-border); }
.flash-info { background: var(--toast-info-bg); color: var(--toast-info-ink); border: 1px solid var(--toast-info-border); }

/* ---------- 登录页 ---------- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(150deg, #ff5126 0%, #ff8b26 45%, #f7f3ec 45.1%); }
.login-box { width: 380px; background: var(--card); border-radius: 18px; padding: 34px 34px 24px; box-shadow: 0 16px 50px rgba(43,38,32,.18); }
.login-brand { text-align: center; margin-bottom: 22px; }
.login-logo { font-size: 44px; }
.login-name { font-size: 19px; font-weight: 800; margin-top: 6px; }
.login-sub { font-size: 12px; color: var(--muted); }
.login-foot { text-align: center; font-size: 11px; color: var(--ink-4); margin-top: 18px; }

/* 顶栏/侧栏：主题切换按钮 */
.theme-toggle {
  flex-shrink: 0; width: 36px; height: 36px; border-radius: 10px; cursor: pointer;
  background: var(--surface); color: var(--ink-2); border: 1px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
  font-size: 17px; line-height: 1;
  transition: background .15s, color .15s, border-color .15s, transform .2s, box-shadow .15s;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.theme-toggle:hover { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.theme-toggle:active { transform: scale(.92); }
.theme-toggle .theme-icon-sun, .theme-toggle .theme-icon-moon { line-height: 1; }
.theme-toggle .theme-icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .theme-icon-sun { display: inline; }
[data-theme="dark"] .theme-toggle .theme-icon-moon { display: none; }

@media (max-width: 860px) {
  .admin-shell { flex-direction: column; }
  .hamburger {
    display: inline-flex; align-items: center; gap: 6px; margin-bottom: 12px;
    padding: 8px 14px; border: 1px solid var(--line); background: var(--card);
    border-radius: 10px; font-size: 13px; cursor: pointer; color: var(--text); font-weight: 600;
  }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 260px; z-index: 300;
    transform: translateX(-100%); transition: transform .25s;
    box-shadow: 0 0 40px rgba(0,0,0,.25); height: 100vh;
  }
  .sidebar.open { transform: translateX(0); }
  .scrim { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 250; }
  .scrim.open { display: block; }
  .main { padding: 18px 14px 50px; }
  .main-inner { max-width: none; }
  .field-grid, .item-fields { grid-template-columns: 1fr; }
}
