/* ============================================================
   后台管理主题 · 现代 SaaS 观感（自托管，无外部依赖）
   配色：深石板侧边栏 + 浅色内容区 + indigo 强调色
   ============================================================ */
:root {
  --accent: #6366f1;
  --accent-600: #4f46e5;
  --accent-700: #4338ca;
  --accent-soft: #eef2ff;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e6e8ee;
  --bg: #f5f6fa;
  --surface: #ffffff;
  --sidebar-bg: #0f172a;
  --sidebar-bg-2: #111c34;
  --sidebar-ink: #cbd5e1;
  --sidebar-ink-dim: #7c8aa5;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .05);
  --shadow: 0 6px 22px rgba(15, 23, 42, .08);
}

* { -webkit-font-smoothing: antialiased; }

body.bg-light { background: var(--bg) !important; }

/* ---------------- 侧边栏 ---------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 252px;
  flex: 0 0 252px;
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
  color: var(--sidebar-ink);
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  z-index: 1040;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  color: #fff; font-weight: 700; font-size: 1.02rem;
  padding: 6px 8px 16px;
}
.sidebar .brand .logo {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent) 0%, #8b5cf6 100%);
  display: grid; place-items: center; color: #fff; font-weight: 800;
  box-shadow: 0 4px 12px rgba(99, 102, 241, .45);
}
.sidebar .brand small { display: block; color: var(--sidebar-ink-dim); font-weight: 500; font-size: .72rem; }
.sidebar .nav-label {
  color: var(--sidebar-ink-dim); font-size: .68rem; letter-spacing: .08em;
  text-transform: uppercase; padding: 14px 10px 6px;
}
.sidebar .nav-link {
  display: flex; align-items: center; gap: 11px;
  color: var(--sidebar-ink); text-decoration: none;
  padding: 10px 12px; border-radius: var(--radius-sm);
  font-size: .92rem; font-weight: 500; margin-bottom: 2px;
  transition: background .15s, color .15s;
}
.sidebar .nav-link svg { width: 19px; height: 19px; flex: 0 0 19px; opacity: .85; }
.sidebar .nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar .nav-link.active {
  background: linear-gradient(90deg, rgba(99, 102, 241, .22), rgba(99, 102, 241, .05));
  color: #fff;
  box-shadow: inset 3px 0 0 var(--accent);
}
.sidebar .nav-link.active svg { opacity: 1; }
.sidebar .side-foot { margin-top: auto; padding: 12px 10px 4px; color: var(--sidebar-ink-dim); font-size: .72rem; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 1030;
}
.topbar .page-title { font-weight: 700; color: var(--ink); font-size: 1.05rem; }
.topbar .page-sub { color: var(--muted); font-size: .8rem; }
.topbar .user-chip {
  display: flex; align-items: center; gap: 9px;
  background: var(--bg); border: 1px solid var(--line);
  padding: 5px 6px 5px 12px; border-radius: 999px;
}
.topbar .user-chip .avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: #fff; display: grid; place-items: center; font-size: .8rem; font-weight: 700;
}

/* ---------------- 内容区 ---------------- */
.main {
  margin-left: 252px;
  flex: 1 1 auto;
  display: flex; flex-direction: column;
  min-width: 0;
}
.content { padding: 24px; flex: 1 1 auto; }
.content > h4, .content > .page-h { font-weight: 700; color: var(--ink); }

/* 卡片更现代 */
.card {
  border: 1px solid var(--line) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-sm);
  background: var(--surface);
}
.card-header {
  background: var(--surface) !important;
  border-bottom: 1px solid var(--line);
  font-weight: 600; color: var(--ink-2);
}
.card-header.py-2 { padding-top: .55rem !important; padding-bottom: .55rem !important; }

/* 表格 */
.table { color: var(--ink-2); }
.table thead.table-light th {
  background: #f8fafc !important; color: var(--muted);
  font-weight: 600; font-size: .78rem; letter-spacing: .02em;
  border-bottom: 1px solid var(--line); text-transform: uppercase;
}
.table td, .table th { border-color: var(--line) !important; vertical-align: middle; }

/* 徽章配色微调，更柔和 */
.badge.bg-primary { background: var(--accent) !important; }
.badge.bg-light.text-secondary.border { border-color: var(--line) !important; }

/* 按钮强调色 */
.btn-primary {
  background: var(--accent) !important; border-color: var(--accent) !important;
}
.btn-primary:hover { background: var(--accent-600) !important; border-color: var(--accent-600) !important; }
.btn-outline-primary { color: var(--accent) !important; border-color: var(--accent) !important; }
.btn-outline-primary:hover { background: var(--accent-soft) !important; }
a { color: var(--accent-600); }
a.text-decoration-none.text-dark { color: var(--ink) !important; }

/* 表单控件聚焦 */
.form-control:focus, .form-select:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 .2rem rgba(99, 102, 241, .15) !important;
}

/* KPI / 小卡片网格 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
}
.stat-card .k { font-size: 1.7rem; font-weight: 800; color: var(--ink); line-height: 1.1; }
.stat-card .l { color: var(--muted); font-size: .82rem; margin-top: 4px; }
.stat-card .sub { color: var(--muted); font-size: .76rem; margin-top: 8px; }
/* 彩色变体（统计看板用） */
.stat-card.is-brand { background: var(--accent-soft); border-color: transparent; }
.stat-card.is-brand .k { color: var(--accent); }
.stat-card.is-success { background: #ecfdf3; border-color: transparent; }
.stat-card.is-success .k { color: #1a7f37; }
.stat-card.is-warning { background: #fff8eb; border-color: transparent; }
.stat-card.is-warning .k { color: #bf8700; }
.stat-card.is-info { background: #eff6ff; border-color: transparent; }
.stat-card.is-info .k { color: #0969da; }
.stat-card .btn-sm { font-size: .72rem; padding: .15rem .5rem; }

/* ---------------- 发布日历 ---------------- */
.cal-weekdays { border-bottom: 1px solid var(--line); }
.cal-week { border-top: 1px solid var(--line); }
.cal-week:first-child { border-top: none; }
.cal-cell {
  min-height: 92px; padding: 6px 7px; border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line); background: var(--surface);
}
.cal-week .col-6, .cal-week [class*="col"] { border-right: 1px solid var(--line); }
.cal-cell.empty { background: #fbfcfe; }
.cal-cell.is-today { background: var(--accent-soft); }
.cal-date {
  display: flex; align-items: center; justify-content: space-between;
  font-size: .82rem; font-weight: 600; color: var(--ink-2); margin-bottom: 4px;
}
.cal-dot {
  background: var(--accent); color: #fff; font-size: .68rem; font-weight: 700;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  display: inline-grid; place-items: center;
}
.cal-items { display: flex; flex-direction: column; gap: 3px; }
.cal-item {
  display: block; font-size: .72rem; line-height: 1.25; color: var(--ink-2);
  background: #f1f5f9; border-radius: 6px; padding: 2px 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-decoration: none;
}
.cal-item:hover { background: #e2e8f0; color: var(--ink); }
.cal-more { font-size: .68rem; color: var(--muted); padding-left: 2px; }
@media (max-width: 767px) {
  .cal-cell { min-height: 64px; }
  .cal-item { font-size: .66rem; }
}

/* 区块标题 */
.section-h { font-weight: 700; color: var(--ink); font-size: 1.02rem; }

/* 移动端：侧边栏收起为顶部 */
@media (max-width: 768px) {
  .sidebar { position: static; width: 100%; flex: none; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar .nav-label, .sidebar .side-foot { display: none; }
  .sidebar .nav-link { margin: 0 4px; }
  .main { margin-left: 0; }
}
