/* chat108 后台管理 —— 设计令牌取自 temp/mg-design/DESIGN.md (Skyline Modern)。
 *
 * 手写 CSS 而不是引 Tailwind CDN, 两个原因:
 * 1. 服务器在境外, 后台多半从国内访问, Google Fonts / CDN 又慢又可能连不上;
 * 2. 不上构建步骤(见 README), Tailwind CDN 版是浏览器里现编译的, 首屏会闪一下未样式化内容。
 * 字体和图标都是本地 woff2(从 public/h5/assets 复制过来), 全程零外部请求。
 */

/* ---------- 字体 ---------- */
@font-face {
  font-family: 'Plus Jakarta Sans';
  src: url('fonts/pjs-400.woff2') format('woff2');
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  src: url('fonts/pjs-600.woff2') format('woff2');
  font-weight: 600; font-display: swap;
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  src: url('fonts/pjs-700.woff2') format('woff2');
  font-weight: 700; font-display: swap;
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  src: url('fonts/pjs-800.woff2') format('woff2');
  font-weight: 800; font-display: swap;
}
@font-face {
  font-family: 'Material Icons Outlined';
  src: url('fonts/material-icons-outlined.woff2') format('woff2');
  font-weight: 400; font-display: block;
}

.mi {
  font-family: 'Material Icons Outlined';
  font-weight: normal; font-style: normal;
  font-size: 22px; line-height: 1;
  letter-spacing: normal; text-transform: none;
  display: inline-block; white-space: nowrap;
  word-wrap: normal; direction: ltr;
  -webkit-font-feature-settings: 'liga'; font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

/* ---------- 设计令牌 ---------- */
:root {
  --primary: #0369a1;
  --primary-container: #0ea5e9;
  --on-primary: #ffffff;
  --secondary: #4648d4;
  --error: #ba1a1a;
  --error-container: #ffdad6;
  --on-error-container: #93000a;
  --success: #15803d;
  --success-container: #dcfce7;

  --background: #f8fafc;
  --surface: #f8fafc;
  --surface-lowest: #ffffff;
  --surface-variant: #f1f5f9;
  --inverse-surface: #1e293b;

  --on-surface: #0f172a;
  --on-surface-variant: #475569;
  --outline: #94a3b8;
  --outline-variant: #cbd5e1;

  --slate-400: #94a3b8;
  --slate-800: #1e293b;

  --radius: 16px;
  --radius-sm: 8px;
  --radius-lg: 24px;

  /* 设计稿的招牌阴影: 带品牌蓝色调, 比灰色阴影显得干净 */
  --shadow: 0 4px 20px rgba(14, 165, 233, 0.08);
  --shadow-premium: 0 10px 25px -5px rgba(0,0,0,.05), 0 8px 10px -6px rgba(0,0,0,.05);

  --sidebar-w: 272px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--background);
  color: var(--on-surface);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; }
button { font-family: inherit; }

/* ---------- 侧边栏 ---------- */
.sidebar {
  position: fixed; left: 0; top: 0;
  width: var(--sidebar-w); height: 100vh;
  background: var(--inverse-surface);
  display: flex; flex-direction: column;
  padding: 32px 0; z-index: 50;
  overflow-y: auto;
}
.sidebar__brand {
  display: flex; align-items: center; gap: 14px;
  padding: 0 28px; margin-bottom: 44px;
}
.sidebar__logo {
  width: 46px; height: 46px; border-radius: 14px;
  background: linear-gradient(135deg, var(--primary-container), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 18px; letter-spacing: -0.03em;
  box-shadow: 0 8px 16px rgba(3, 105, 161, .3);
}
.sidebar__title { color: #fff; font-size: 19px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; }
.sidebar__subtitle { color: var(--slate-400); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .16em; opacity: .75; margin-top: 2px; }

.nav { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.nav__item {
  display: flex; align-items: center; gap: 14px;
  margin: 0 12px; padding: 12px 18px;
  color: var(--slate-400); font-size: 14px; font-weight: 600;
  border-radius: 12px; cursor: pointer;
  transition: background .2s, color .2s;
  border: none; background: none; width: calc(100% - 24px); text-align: left;
}
.nav__item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav__item--active { background: rgba(14, 165, 233, .16); color: #fff; }
.nav__item--active .mi { color: var(--primary-container); }
.nav__spacer { margin-top: auto; padding-top: 24px; }
.nav__divider { border-top: 1px solid var(--slate-800); margin: 24px 24px 12px; }

/* ---------- 主区域 ---------- */
.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  height: 76px; padding: 0 40px;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid #e2e8f0;
  display: flex; align-items: center; justify-content: space-between;
}
.topbar__user { display: flex; align-items: center; gap: 14px; }
.topbar__name { font-size: 14px; font-weight: 700; line-height: 1.2; }
.topbar__role { font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--outline); }
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
}

.content { padding: 36px 40px 64px; max-width: 1440px; width: 100%; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 32px; flex-wrap: wrap; }
.page-title { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; }
.page-desc { color: var(--on-surface-variant); font-size: 15px; margin-top: 6px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface-lowest);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}
.card__head { margin-bottom: 20px; }
.card__title { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.card__desc { color: var(--on-surface-variant); font-size: 14px; margin-top: 4px; }

/* ---------- 统计卡 ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 20px; margin-bottom: 32px; }
.stat { background: var(--surface-lowest); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.stat__icon {
  width: 42px; height: 42px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(14,165,233,.1); color: var(--primary);
  margin-bottom: 16px;
}
.stat__icon--violet { background: rgba(70,72,212,.1); color: var(--secondary); }
.stat__icon--amber { background: rgba(245,158,11,.12); color: #b45309; }
.stat__icon--rose { background: var(--error-container); color: var(--on-error-container); }
.stat__label { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--outline); }
.stat__value { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; margin-top: 4px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: 14px;
  font-size: 14px; font-weight: 700; font-family: inherit;
  border: 1px solid transparent; cursor: pointer;
  transition: transform .15s, box-shadow .2s, background .2s, opacity .2s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn--primary { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(3,105,161,.25); }
.btn--primary:hover:not(:disabled) { box-shadow: 0 8px 20px rgba(3,105,161,.32); }
.btn--ghost { background: var(--surface-lowest); color: var(--on-surface-variant); border-color: var(--outline-variant); }
.btn--ghost:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.btn--danger { background: transparent; color: var(--error); }
.btn--danger:hover:not(:disabled) { background: var(--error-container); }
.btn--sm { padding: 7px 14px; font-size: 13px; border-radius: 10px; }
.btn--block { width: 100%; }
.btn .mi { font-size: 19px; }

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; padding: 0 16px 12px;
  font-size: 11px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--outline);
  border-bottom: 1px solid #e2e8f0;
}
.table td { padding: 16px; border-bottom: 1px solid #f1f5f9; font-size: 14px; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table__empty { text-align: center; color: var(--outline); padding: 40px 0; }

.chip {
  display: inline-block; padding: 4px 11px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
}
.chip--on { background: var(--success-container); color: var(--success); }
.chip--off { background: var(--surface-variant); color: var(--outline); }
.chip--official { background: rgba(14,165,233,.12); color: var(--primary); }

/* ---------- 官方房间四宫格 ---------- */
.rooms { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.room {
  border: 1px solid var(--outline-variant); border-radius: var(--radius);
  padding: 20px; display: flex; flex-direction: column; gap: 10px;
  transition: border-color .2s, box-shadow .2s;
}
.room--exists { border-color: transparent; box-shadow: var(--shadow); background: var(--surface-lowest); }
.room--missing { border-style: dashed; background: transparent; }
.room__icon {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(14,165,233,.1); color: var(--primary);
}
.room--missing .room__icon { background: var(--surface-variant); color: var(--outline); }
.room__name { font-size: 15px; font-weight: 700; }
.room__topic { font-size: 12.5px; color: var(--on-surface-variant); line-height: 1.5; }
.room__meta { font-size: 12px; color: var(--outline); margin-top: auto; padding-top: 6px; }

/* ---------- 登录页 ---------- */
.login {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: linear-gradient(140deg, #eef6ff 0%, #f8fafc 45%, #eef0ff 100%);
}
.login__card {
  width: 100%; max-width: 400px;
  background: var(--surface-lowest);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(14,165,233,.12);
  padding: 40px;
}
.login__brand { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.login__title { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.login__desc { color: var(--on-surface-variant); font-size: 14px; margin-top: 6px; }

.field { margin-bottom: 18px; }
.field__label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 7px; color: var(--on-surface-variant); }
.field__input {
  width: 100%; padding: 13px 15px;
  border: 1px solid var(--outline-variant); border-radius: 14px;
  font-size: 15px; font-family: inherit; color: var(--on-surface);
  background: var(--surface-lowest);
  transition: border-color .2s, box-shadow .2s;
}
.field__input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(14,165,233,.2); /* 设计稿指定的 4px 柔光 */
}

/* ---------- 提示 ---------- */
.alert { padding: 12px 16px; border-radius: 12px; font-size: 13.5px; font-weight: 600; margin-bottom: 18px; }
.alert--error { background: var(--error-container); color: var(--on-error-container); }
.alert--ok { background: var(--success-container); color: var(--success); }
.alert[hidden] { display: none; }

.toast {
  position: fixed; right: 28px; bottom: 28px; z-index: 100;
  padding: 14px 22px; border-radius: 14px;
  background: var(--inverse-surface); color: #fff;
  font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-premium);
  opacity: 0; transform: translateY(12px);
  transition: opacity .25s, transform .25s;
  pointer-events: none; max-width: 380px;
}
.toast--show { opacity: 1; transform: translateY(0); }
.toast--error { background: var(--error); }

.muted { color: var(--outline); }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

[hidden] { display: none !important; }

/* ---------- 窄屏 ----------
 * 后台以桌面为主, 窄屏只保证「能看能用」: 侧边栏收成图标条, 不做抽屉。
 */
@media (max-width: 900px) {
  :root { --sidebar-w: 68px; }
  .sidebar { padding: 20px 0; }
  .sidebar__brand { padding: 0 11px; margin-bottom: 28px; }
  .sidebar__brand > div:last-child, .nav__item span:not(.mi) { display: none; }
  .nav__item { justify-content: center; padding: 12px 0; margin: 0 8px; width: calc(100% - 16px); }
  .content, .topbar { padding-left: 20px; padding-right: 20px; }
  .page-title { font-size: 26px; }
}
