/* ============ 后台样式 ============ */
:root {
  --primary: #1a56db;
  --primary-dark: #1243b0;
  --dark: #0b1b33;
  --text: #2b3445;
  --text-light: #6b7688;
  --bg: #f0f3f9;
  --border: #e2e8f0;
  --danger: #dc2626;
  --radius: 10px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: "PingFang SC", "Microsoft YaHei", Arial, sans-serif; color: var(--text); background: var(--bg); }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 14px; }

/* ---------- 登录页 ---------- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0b1b33, #1a56db);
}
.login-card {
  width: 380px; max-width: calc(100vw - 40px); background: #fff; border-radius: 16px;
  padding: 44px 40px; box-shadow: 0 30px 80px rgba(0, 0, 0, .35); text-align: center;
}
.login-logo {
  width: 56px; height: 56px; margin: 0 auto 18px; border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), #3b82f6); color: #fff;
  font-weight: 800; font-size: 20px; display: flex; align-items: center; justify-content: center;
}
.login-card h1 { font-size: 22px; color: var(--dark); margin-bottom: 6px; }
.login-sub { font-size: 13px; color: var(--text-light); margin-bottom: 28px; }
.login-card label { display: block; text-align: left; font-size: 13px; font-weight: 600; margin-bottom: 16px; }
.login-card input {
  width: 100%; margin-top: 6px; padding: 11px 14px; border: 1px solid var(--border);
  border-radius: 8px; outline: none; transition: border-color .2s;
}
.login-card input:focus { border-color: var(--primary); }
.login-error { color: var(--danger); font-size: 13px; min-height: 20px; margin-bottom: 8px; text-align: left; }
.login-tip { margin-top: 18px; font-size: 12px; color: var(--text-light); }

.btn-primary {
  background: var(--primary); color: #fff; border: none; border-radius: 8px;
  padding: 11px 22px; font-size: 14px; font-weight: 600; transition: background .2s;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-block { width: 100%; }

/* ---------- 布局 ---------- */
.admin-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: var(--dark); color: #fff; display: flex; flex-direction: column;
  position: fixed; top: 0; bottom: 0; left: 0;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px; padding: 22px 20px;
  font-weight: 700; font-size: 15px; border-bottom: 1px solid rgba(255, 255, 255, .1);
}
.sidebar-brand .logo-mark {
  width: 34px; height: 34px; border-radius: 8px; font-size: 13px; font-weight: 800;
  background: linear-gradient(135deg, var(--primary), #3b82f6);
  display: flex; align-items: center; justify-content: center;
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.sidebar-nav button {
  display: block; width: 100%; text-align: left; background: none; border: none;
  color: rgba(255, 255, 255, .72); font-size: 14px; padding: 12px 20px; transition: all .2s;
}
.sidebar-nav button:hover { color: #fff; background: rgba(255, 255, 255, .06); }
.sidebar-nav button.active { color: #fff; background: var(--primary); font-weight: 600; }
.sidebar-foot { padding: 16px 20px; display: flex; flex-direction: column; gap: 8px; border-top: 1px solid rgba(255, 255, 255, .1); }
.btn-ghost-sm {
  display: block; text-align: center; padding: 9px; border-radius: 8px; font-size: 13px;
  border: 1px solid rgba(255, 255, 255, .25); color: rgba(255, 255, 255, .85);
  background: none; text-decoration: none; transition: all .2s;
}
.btn-ghost-sm:hover { background: rgba(255, 255, 255, .1); color: #fff; }

.main { flex: 1; margin-left: 220px; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 10; background: #fff; border-bottom: 1px solid var(--border);
  padding: 16px 32px; display: flex; align-items: center; justify-content: space-between;
}
.topbar h2 { font-size: 18px; color: var(--dark); }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.save-status { font-size: 13px; color: var(--text-light); }
.save-status.ok { color: #16a34a; }
.save-status.err { color: var(--danger); }

.panel-body { padding: 28px 32px 80px; max-width: 900px; }

/* ---------- 表单元素 ---------- */
.field { margin-bottom: 20px; }
.field > label { display: block; font-size: 13px; font-weight: 600; color: var(--dark); margin-bottom: 6px; }
.field input[type="text"], .field input[type="number"], .field textarea, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; outline: none; transition: border-color .2s;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--primary); }
.field textarea { min-height: 90px; resize: vertical; }
.field .hint { font-size: 12px; color: var(--text-light); margin-top: 4px; }

.fieldset {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 20px;
}
.fieldset > legend, .fieldset > .fieldset-title {
  font-size: 14px; font-weight: 700; color: var(--dark); margin-bottom: 14px; display: block;
}

/* 列表条目卡片 */
.list-item {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 14px; overflow: hidden;
}
.list-item-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  background: #f8fafc; border-bottom: 1px solid var(--border);
}
.list-item-head .item-title { flex: 1; font-size: 13px; font-weight: 600; color: var(--dark); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item-head .item-ops button {
  border: 1px solid var(--border); background: #fff; border-radius: 6px;
  font-size: 12px; padding: 4px 10px; color: var(--text); transition: all .2s;
}
.list-item-head .item-ops button:hover { border-color: var(--primary); color: var(--primary); }
.list-item-head .item-ops button.del:hover { border-color: var(--danger); color: var(--danger); }
.list-item-body { padding: 16px 14px; }
.list-add {
  width: 100%; padding: 12px; border: 1.5px dashed var(--border); border-radius: var(--radius);
  background: none; color: var(--text-light); font-size: 14px; transition: all .2s; margin-bottom: 20px;
}
.list-add:hover { border-color: var(--primary); color: var(--primary); background: rgba(26, 86, 219, .04); }

/* 图片字段 */
.image-field { display: flex; align-items: flex-start; gap: 14px; }
.image-field .preview {
  width: 160px; height: 96px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--border); background: #f1f5f9;
}
.image-field .preview.square { height: 120px; width: 120px; }
.image-field .ops { display: flex; flex-direction: column; gap: 8px; }
.image-field .path { font-size: 12px; color: var(--text-light); word-break: break-all; max-width: 300px; }
.upload-btn {
  display: inline-block; padding: 8px 16px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; font-size: 13px; color: var(--text); transition: all .2s;
}
.upload-btn:hover { border-color: var(--primary); color: var(--primary); }

/* 模块开关 */
.module-row {
  display: flex; align-items: center; gap: 14px; background: #fff;
  border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 10px;
}
.module-row .mod-name { flex: 1; font-weight: 600; font-size: 14px; }
.module-row .mod-id { font-size: 12px; color: var(--text-light); }
.module-row .mod-ops button {
  border: 1px solid var(--border); background: #fff; border-radius: 6px; padding: 4px 10px; font-size: 12px;
}
.module-row .mod-ops button:hover { border-color: var(--primary); color: var(--primary); }
/* 开关 */
.switch { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; background: #cbd5e1; border-radius: 24px; transition: .2s; cursor: pointer;
}
.switch .slider::before {
  content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .2s;
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* 提示气泡 */
.toast {
  position: fixed; bottom: 32px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--dark); color: #fff; padding: 12px 26px; border-radius: 10px;
  font-size: 14px; opacity: 0; transition: all .3s; z-index: 999; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }

/* 取色器字段 */
.color-field { display: flex; align-items: center; gap: 12px; }
.color-field input[type="color"] {
  width: 56px; height: 36px; padding: 2px; border: 1px solid var(--border);
  border-radius: 8px; background: #fff; cursor: pointer;
}
.color-hex { font-size: 13px; color: var(--text-light); font-family: monospace; }

/* 预设主色板 */
.color-swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.color-swatch {
  width: 26px; height: 26px; padding: 0; border: 2px solid #fff; border-radius: 50%;
  box-shadow: 0 0 0 1px var(--border);
  transition: transform .15s ease, box-shadow .15s ease;
}
.color-swatch:hover { transform: scale(1.18); }
.color-swatch.active { box-shadow: 0 0 0 2px var(--primary); transform: scale(1.1); }

@media (max-width: 860px) {
  .sidebar { width: 64px; }
  .sidebar-brand span:last-child, .sidebar-nav button { font-size: 0; }
  .sidebar-nav button::before { content: "•"; font-size: 18px; }
  .main { margin-left: 64px; }
}
