/* ============================================================
   云图智算管理后台 · 样式
   ============================================================ */

:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --line: #e3e8ef;
  --line-strong: #cfd8e3;
  --text: #1c2536;
  --text-soft: #5b6779;
  --text-mute: #8b96a8;
  --primary: #2563eb;
  --primary-soft: #eaf1ff;
  --cyan: #0e9bb5;
  --violet: #7c3aed;
  --success: #0f9d58;
  --success-soft: #e8f7ef;
  --warn: #b45309;
  --warn-soft: #fef3e2;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #eef2f7; padding: 1px 6px; border-radius: 4px; font-size: 12px; }

/* ---------------- 登录页 ---------------- */

.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #eef4ff 0%, #f7f9fc 45%, #eefaf9 100%);
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 32px 30px 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.login-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 26px; }
.login-brand strong { display: block; font-size: 16px; }
.login-brand small { color: var(--text-mute); font-size: 11px; letter-spacing: .06em; }
.login-logo {
  display: grid; place-items: center;
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, #22d3ee, #6366f1 55%, #a855f7);
  color: #fff; font-weight: 700; letter-spacing: .02em;
}

.field { display: block; margin-bottom: 16px; }
.field > span { display: block; margin-bottom: 6px; color: var(--text-soft); font-size: 13px; }
.field input, .field select, .field textarea,
.form-grid input, .form-grid select, .form-grid textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus,
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.btn-primary {
  width: 100%;
  padding: 10px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: filter .15s;
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }

.login-error { margin: 0 0 14px; color: var(--danger); font-size: 13px; }
.login-tip { margin: 20px 0 0; color: var(--text-mute); font-size: 12px; line-height: 1.7; }
.login-foot { margin: 10px 0 0; font-size: 12px; }

/* ---------------- 布局 ---------------- */

.layout { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }

.sidebar {
  background: #0f172a;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar__brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; }
.sidebar__brand strong { color: #fff; font-size: 14px; display: block; }
.sidebar__brand small { color: #7c8ba1; font-size: 10px; letter-spacing: .08em; }
.sidebar__logo {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, #22d3ee, #6366f1 55%, #a855f7);
  color: #fff; font-weight: 700; font-size: 13px;
}

/* 站点 Logo（后台「站点设置」上传后自动应用） */
.sidebar__logo.has-logo,
.login-logo.has-logo { background: none; box-shadow: none; overflow: hidden; }
.admin-logo-img { display: block; width: 100%; height: 100%; object-fit: contain; }
.sidebar__group { padding: 12px 18px 4px; color: #64748b; font-size: 11px; letter-spacing: .08em; }
.sidebar__nav { display: flex; flex-direction: column; padding: 0 8px 20px; }
.sidebar__nav a {
  padding: 8px 12px;
  border-radius: 8px;
  color: #cbd5e1;
  font-size: 13.5px;
  text-decoration: none;
  margin: 1px 0;
}
.sidebar__nav a:hover { background: rgba(255, 255, 255, .06); text-decoration: none; }
.sidebar__nav a.is-active { background: var(--primary); color: #fff; font-weight: 600; }
.sidebar__nav a { display: flex; align-items: center; gap: 8px; }
.sidebar__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar__actions { display: none; align-items: center; gap: 2px; flex-shrink: 0; }
.sidebar__nav a:hover .sidebar__actions,
.sidebar__nav a.is-active .sidebar__actions { display: inline-flex; }
.nav-ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; padding: 0; border: 0; border-radius: 6px;
  background: transparent; color: inherit; opacity: .55; cursor: pointer;
}
.nav-ico:hover { opacity: 1; background: rgba(255, 255, 255, .14); color: #22d3ee; }
.nav-rename {
  flex: 1; min-width: 0; padding: 3px 7px; border-radius: 6px; border: 1px solid #22d3ee;
  background: rgba(2, 6, 23, .85); color: #fff; font-size: 13px; outline: none;
}
a.is-module-hidden { opacity: .45; }
a.is-module-hidden .sidebar__label { text-decoration: line-through; text-decoration-color: rgba(148, 163, 184, .7); }
.sidebar__group--dim { margin-top: 8px; opacity: .75; }
/* 触屏设备没有 hover，操作按钮常显 */
@media (hover: none) {
  .sidebar__actions { display: inline-flex; }
}
.sidebar__foot { margin-top: auto; padding: 14px 18px; border-top: 1px solid rgba(255, 255, 255, .08); font-size: 11.5px; color: #64748b; }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 26px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 { margin: 0; font-size: 17px; }
.topbar__desc { margin: 2px 0 0; color: var(--text-mute); font-size: 12.5px; }
.topbar__user { display: flex; align-items: center; gap: 10px; }
.avatar {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 13px;
}
.topbar__user-meta { text-align: right; line-height: 1.3; }
.topbar__user-meta strong { display: block; font-size: 13px; }
.topbar__user-meta small { color: var(--text-mute); font-size: 11.5px; }

.content { padding: 22px 26px 60px; }

/* ---------------- 通用组件 ---------------- */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.card__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.card__head h2 { margin: 0; font-size: 15px; }
.card__head p { margin: 2px 0 0; color: var(--text-mute); font-size: 12.5px; }
.card__body { padding: 16px 18px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar input[type="search"], .toolbar input[type="text"], .toolbar select {
  padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: 8px; font-size: 13px; background: #fff;
}
.toolbar .spacer { flex: 1; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border: 1px solid var(--line-strong); border-radius: 8px;
  background: #fff; color: var(--text); font-size: 13px; cursor: pointer;
  font-family: inherit; transition: background .15s, border-color .15s;
}
.btn:hover { background: #f8fafc; }
.btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn--primary:hover { filter: brightness(1.06); background: var(--primary); }
.btn--danger { color: var(--danger); border-color: #f3c2c2; }
.btn--danger:hover { background: var(--danger-soft); }
.btn--sm { padding: 4px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th, table.data td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data th { background: #fafbfd; color: var(--text-soft); font-weight: 600; font-size: 12.5px; white-space: nowrap; }
table.data tbody tr:hover { background: #fafcff; }
table.data td.actions { text-align: right; white-space: nowrap; }
table.data td.actions .btn { margin-left: 6px; }
.cell-title { font-weight: 600; }
.cell-sub { color: var(--text-mute); font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; color: var(--text-soft); }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; line-height: 1.7; white-space: nowrap;
}
.badge--on { background: var(--success-soft); color: var(--success); }
.badge--off { background: #eef1f5; color: var(--text-mute); }
.badge--info { background: var(--primary-soft); color: var(--primary); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }

.empty { padding: 40px 20px; text-align: center; color: var(--text-mute); }
.empty strong { display: block; color: var(--text-soft); margin-bottom: 6px; }

.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 12px 18px; color: var(--text-mute); font-size: 12.5px; }

/* 看板 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px;
}
.stat small { color: var(--text-mute); font-size: 12.5px; }
.stat strong { display: block; font-size: 26px; line-height: 1.3; margin-top: 4px; }
.stat em { font-style: normal; color: var(--text-soft); font-size: 12.5px; margin-left: 4px; }
.stat--primary strong { color: var(--primary); }
.stat--cyan strong { color: var(--cyan); }
.stat--violet strong { color: var(--violet); }
.stat--success strong { color: var(--success); }

.cols-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.trend { display: flex; align-items: flex-end; gap: 8px; height: 140px; padding-top: 10px; }
.trend__col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.trend__bar { width: 100%; max-width: 34px; background: linear-gradient(180deg, #22d3ee, #6366f1); border-radius: 6px 6px 2px 2px; min-height: 4px; }
.trend__label { font-size: 11px; color: var(--text-mute); }
.trend__value { font-size: 11.5px; color: var(--text-soft); }

/* 表单 */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-grid label { display: block; }
.form-grid label > span { display: block; margin-bottom: 5px; color: var(--text-soft); font-size: 12.5px; }
.form-grid label > span em { color: var(--danger); font-style: normal; margin-left: 3px; }
.form-grid .hint { margin: 5px 0 0; color: var(--text-mute); font-size: 12px; }
.form-grid textarea { min-height: 84px; resize: vertical; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { width: 16px; height: 16px; }
.image-field { display: flex; gap: 8px; }
.image-field input { flex: 1; }
.image-preview { margin-top: 8px; max-height: 110px; border-radius: 8px; border: 1px solid var(--line); display: block; }
.image-preview[hidden], .panel__video[hidden] { display: none !important; }

/* 抽屉 */
.drawer-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .42);
  display: flex; justify-content: flex-end; z-index: 60;
}
.drawer {
  width: min(620px, 100%); background: #fff; height: 100%; display: flex; flex-direction: column;
  box-shadow: -8px 0 30px rgba(15, 23, 42, .16);
}
.drawer__head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.drawer__head h2 { margin: 0; font-size: 16px; }
.drawer__body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.drawer__foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.form-error { margin: 0 0 14px; padding: 10px 12px; border-radius: 8px; background: var(--danger-soft); color: var(--danger); font-size: 13px; }

/* 提示条 */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(20px);
  background: #0f172a; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 13.5px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 90;
  max-width: 80vw;
}
.toast.is-on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 媒体库 */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.media-card { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; }
.media-card img,
.media-card video { width: 100%; height: 110px; object-fit: cover; display: block; background: #f1f5f9; }
.media-card__body { padding: 10px 12px; }
.media-card__body p { margin: 0 0 6px; font-size: 12.5px; word-break: break-all; color: var(--text-soft); }
.media-card__body .row { display: flex; gap: 6px; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .42); display: grid; place-items: center; z-index: 70; padding: 20px; }
.modal {
  width: min(520px, 100%); background: #fff; border-radius: 14px; padding: 22px;
  box-shadow: var(--shadow); max-height: 88vh; overflow-y: auto;
}
.modal h2 { margin: 0 0 4px; font-size: 16px; }
.modal p.desc { margin: 0 0 16px; color: var(--text-mute); font-size: 12.5px; }
.modal__foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }
.perm-grid label { display: flex; align-items: center; gap: 8px; font-size: 13px; }

/* ---------- 前台展示风格选择器 ---------- */
.style-field__label { display: block; margin-bottom: 8px; color: var(--text-soft); font-size: 12.5px; }
.style-field__label em { color: var(--danger); font-style: normal; margin-left: 3px; }
.style-picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.style-card {
  display: block; text-align: left; width: 100%; padding: 12px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); color: var(--text); font: inherit; cursor: pointer;
  transition: border-color .2s, box-shadow .2s, transform .2s;
}
.style-card:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.style-card.is-active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.style-card__swatch { display: flex; gap: 3px; margin-bottom: 10px; overflow: hidden; border-radius: 6px; }
.style-card__swatch i { flex: 1; height: 30px; display: block; }
.style-card strong { display: block; font-size: 13.5px; }
.style-card strong::before {
  content: '○'; margin-right: 6px; color: var(--text-mute); font-size: 11px; vertical-align: 1px;
}
.style-card.is-active strong::before { content: '●'; color: var(--primary); }
.style-card em {
  display: block; margin-top: 4px; font-style: normal;
  color: var(--text-mute); font-size: 11.5px; line-height: 1.55;
}

/* ---------- 卡片头操作区 ---------- */
.card__actions { display: flex; gap: 8px; align-items: center; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .sidebar__nav { flex-direction: row; flex-wrap: wrap; }
  .form-grid { grid-template-columns: 1fr; }
  .content { padding: 16px; }
}

/* 栏目页卡片头：就地编辑版块标题 */
.head-edit__inline { margin-bottom: 18px; padding: 14px 16px; border: 1px dashed var(--line); border-radius: var(--r, 10px); background: var(--surface-2, rgba(0,0,0,.02)); }
.head-edit__hint { margin-bottom: 10px; font-size: 12.5px; color: var(--text-mute, #8a90a0); }
.head-edit__actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }

/* ---------- 编辑工具栏（整页所见即所得编辑共用） ---------- */
.visual-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.visual-toolbar select {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--text); font-size: 13px; font-family: inherit;
}
.visual-toolbar__tip { font-size: 12.5px; color: var(--text-mute, #8a90a0); }

/* ---- 整页所见即所得编辑（导航菜单 → ✎ 编辑页面 / #/page/xxx.html） ---- */
.page-edit { display: flex; flex-direction: column; gap: 12px; height: calc(100vh - 188px); min-height: 520px; }
.page-edit__select {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--text); font-size: 13px; font-family: inherit;
}
.page-edit__status { font-size: 12.5px; color: var(--text-mute, #8a90a0); white-space: nowrap; }
.page-edit__frame {
  flex: 1; min-height: 0; width: 100%; display: block;
  border: 1px solid var(--line); border-radius: 12px;
  background: #05070e; box-shadow: 0 8px 28px rgba(0, 0, 0, .1);
}
@media (max-width: 1100px) {
  .page-edit { height: 80vh; }
  .page-edit__status { display: none; }
}
