/* ============================================================
   Apple Design System — 微信公众号内容投送系统
   遵循 apple-design 技能：半透明材质 / 临界阻尼弹簧 / 光学字号 / 减弱动效
   ============================================================ */

:root {
  /* 字体 */
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
               "PingFang SC", "Helvetica Neue", system-ui, sans-serif;

  /* 配色（系统色板） */
  --bg: #f5f5f7;
  --bg-elevated: #ffffff;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-strong: rgba(255, 255, 255, 0.86);
  --surface-dim: rgba(255, 255, 255, 0.5);
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #a1a1a6;
  --separator: rgba(60, 60, 67, 0.12);
  --separator-strong: rgba(60, 60, 67, 0.29);

  --accent: #007aff;
  --accent-pressed: #0066d6;
  --success: #34c759;
  --warning: #ff9500;
  --danger: #ff3b30;

  --status-pending:    #ff9500;
  --status-approved:   #34c759;
  --status-scheduled:  #007aff;
  --status-published:  #30b0c7;
  --status-rejected:   #ff3b30;
  --status-failed:     #ff3b30;
  --status-in_draft:   #af52de;

  /* 半径 */
  --r-card: 16px;
  --r-button: 10px;
  --r-input: 8px;
  --r-sheet: 24px;
  --r-chip: 8px;

  /* 阴影 — 大表面更深，小控件更轻（材质重量编码层级） */
  --shadow-card: 0 1px 3px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.06);
  --shadow-pop:  0 2px 8px rgba(0,0,0,0.08), 0 24px 48px rgba(0,0,0,0.18);
  --shadow-bar:  0 1px 0 rgba(0,0,0,0.04);

  /* 动效：默认临界阻尼弹簧 */
  --spring-default: 350ms cubic-bezier(0.32, 0.72, 0, 1);   /* ≈ damping 1.0, response 0.35 */
  --spring-bouncy:  400ms cubic-bezier(0.34, 1.56, 0.64, 1); /* ≈ damping 0.8 */
  --ease-instant:   100ms ease-out;
}

/* ---------- 基础重置 ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { font: 100%/1.5 var(--font-sans); -webkit-font-smoothing: antialiased; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  letter-spacing: 0;
  font-optical-sizing: auto;
}
a { color: var(--accent); text-decoration: none; }
a:active { opacity: 0.6; }

/* ---------- 排版 ---------- */
.display {
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-weight: 700;
}
h1 { font-size: 1.75rem; line-height: 1.1; letter-spacing: -0.015em; font-weight: 600; margin: 0; }
h2 { font-size: 1.375rem; line-height: 1.15; letter-spacing: -0.01em; font-weight: 600; margin: 0; }
h3 { font-size: 1.0625rem; line-height: 1.2; font-weight: 600; margin: 0; }
p  { line-height: 1.5; margin: 0; color: var(--text-secondary); }
small { font-size: 0.8125rem; letter-spacing: 0.01em; color: var(--text-tertiary); }

/* ---------- 半透明材质层 ---------- */
.material {
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
}
.material-strong {
  background: var(--surface-strong);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
}

/* ---------- 布局 ---------- */
.app-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 16px 12px;
  display: flex; flex-direction: column; gap: 4px;
  border-right: 1px solid var(--separator);
  z-index: 40;
}
.sidebar .brand { padding: 8px 12px 16px; display: flex; align-items: center; gap: 10px; }
.sidebar .brand .logo {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, #007aff, #5856d6);
  display: grid; place-items: center; color: #fff; font-weight: 700;
}
.sidebar .brand .name { font-weight: 600; font-size: 0.9375rem; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: var(--r-button);
  color: var(--text-secondary); font-size: 0.9375rem; cursor: pointer;
  transition: background var(--ease-instant), color var(--ease-instant);
  position: relative; user-select: none;
}
.nav-item:hover { background: var(--surface-dim); color: var(--text); }
.nav-item:active { transform: scale(0.98); }
.nav-item.active { background: var(--surface-strong); color: var(--accent); }
.nav-item.active::before {
  content: ""; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 2px; background: var(--accent);
}
.nav-item .icon { width: 20px; height: 20px; opacity: 0.9; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  padding: 12px 24px; display: flex; align-items: center; gap: 16px;
  border-bottom: 1px solid transparent;
  /* 滚动边缘渐变遮罩，替代 1px 分隔线 */
  mask-image: linear-gradient(to bottom, #000 calc(100% - 1px), transparent 100%);
}
.topbar .title { flex: 1; }
.topbar .spacer { flex: 1; }
.topbar .actions { display: flex; gap: 8px; align-items: center; }

.content { padding: 24px; max-width: 1280px; width: 100%; margin: 0 auto; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--bg-elevated);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--separator); display: flex; align-items: center; gap: 12px; }
.card-body { padding: 20px; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--separator); }

/* ---------- 按钮（响应即按下） ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--r-button);
  border: none; cursor: pointer; font: inherit; font-size: 0.9375rem; font-weight: 500;
  background: var(--surface-strong); color: var(--text);
  transition: transform var(--ease-instant), background var(--ease-instant);
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:active { background: var(--accent-pressed); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-ghost:active { background: rgba(0,122,255,0.08); }
.btn-sm { padding: 4px 10px; font-size: 0.8125rem; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- 输入 ---------- */
.input, .select, .textarea {
  width: 100%; padding: 8px 12px; border-radius: var(--r-input);
  border: 1px solid var(--separator-strong); background: var(--bg-elevated);
  font: inherit; font-size: 0.9375rem; color: var(--text);
  transition: border-color var(--ease-instant), box-shadow var(--ease-instant);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,122,255,0.15);
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 0.8125rem; font-weight: 500; margin-bottom: 6px; color: var(--text-secondary); }

/* ---------- 状态标签 ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 99px;
  font-size: 0.75rem; font-weight: 500;
  background: var(--surface-dim); color: var(--text-secondary);
}
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag.pending   { color: var(--status-pending);    background: rgba(255,149,0,0.12); }
.tag.approved  { color: var(--status-approved);   background: rgba(52,199,89,0.12); }
.tag.scheduled { color: var(--status-scheduled);  background: rgba(0,122,255,0.12); }
.tag.published { color: var(--status-published);  background: rgba(48,176,199,0.12); }
.tag.rejected  { color: var(--status-rejected);   background: rgba(255,59,48,0.12); }
.tag.failed    { color: var(--status-failed);     background: rgba(255,59,48,0.12); }
.tag.in_draft  { color: var(--status-in_draft);   background: rgba(175,82,222,0.12); }

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; padding: 10px 16px; font-size: 0.75rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-tertiary);
  border-bottom: 1px solid var(--separator);
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--separator); font-size: 0.875rem; }
.table tr { transition: background var(--ease-instant); }
.table tbody tr:hover { background: rgba(0,0,0,0.02); cursor: pointer; }
.table tr:last-child td { border-bottom: none; }

/* ---------- 统计卡 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  padding: 18px 20px; border-radius: var(--r-card); background: var(--bg-elevated);
  box-shadow: var(--shadow-card);
}
.stat-card .label { font-size: 0.8125rem; color: var(--text-secondary); margin-bottom: 6px; }
.stat-card .value { font-size: 1.875rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1; }
.stat-card .delta { font-size: 0.75rem; color: var(--text-tertiary); margin-top: 6px; }

/* ---------- 抽屉（弹簧可中断，可拖拽关闭） ---------- */
.scrim {
  position: fixed; inset: 0; background: rgba(0,0,0,0.3);
  opacity: 0; pointer-events: none; transition: opacity var(--spring-default);
  z-index: 50;
}
.scrim.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw);
  background: var(--bg-elevated); box-shadow: var(--shadow-pop);
  transform: translateX(100%); z-index: 51;
  display: flex; flex-direction: column;
  border-radius: 0;
  /* 动画由 JS 弹簧驱动，此处仅 fallback */
}
.sheet .sheet-header {
  padding: 16px 20px; border-bottom: 1px solid var(--separator);
  display: flex; align-items: center; gap: 12px;
}
.sheet .sheet-body { flex: 1; overflow-y: auto; padding: 20px; }
.sheet .sheet-footer { padding: 12px 20px; border-top: 1px solid var(--separator); display: flex; gap: 8px; justify-content: flex-end; }
.sheet.open { /* JS 控制 transform */ }

/* ---------- Modal（从触发源缩放进入） ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 60; display: none; align-items: center; justify-content: center; padding: 24px; }
.modal-wrap.open { display: flex; }
.modal {
  background: var(--bg-elevated); border-radius: var(--r-sheet);
  box-shadow: var(--shadow-pop); width: min(420px, 100%);
  transform: scale(0.85); opacity: 0;
  transition: transform var(--spring-bouncy), opacity var(--spring-default);
  transform-origin: var(--modal-origin, center center);
  overflow: hidden;
}
.modal-wrap.open .modal { transform: scale(1); opacity: 1; }
.modal .modal-header { padding: 18px 20px 8px; }
.modal .modal-body { padding: 0 20px 12px; }
.modal .modal-footer { padding: 12px 20px; display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  padding: 10px 16px; border-radius: var(--r-button);
  background: rgba(40,40,42,0.92); color: #fff; font-size: 0.875rem;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-pop);
  transform: translateY(-12px); opacity: 0;
  transition: transform var(--spring-bouncy), opacity var(--spring-default);
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: rgba(52,199,89,0.95); }
.toast.error { background: rgba(255,59,48,0.95); }

/* ---------- 登录页 ---------- */
.login-screen {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(ellipse at top, #e3f0ff 0%, var(--bg) 60%);
}
.login-card {
  width: min(380px, 100%); padding: 32px 28px; border-radius: var(--r-sheet);
  background: var(--surface-strong);
  backdrop-filter: blur(40px) saturate(180%); -webkit-backdrop-filter: blur(40px) saturate(180%);
  box-shadow: var(--shadow-pop);
}
.login-card .logo { width: 56px; height: 56px; border-radius: 14px; margin: 0 auto 16px;
  background: linear-gradient(135deg, #007aff, #5856d6); display: grid; place-items: center; color: #fff; font-size: 24px; font-weight: 700; }
.login-card h1 { text-align: center; margin-bottom: 4px; }
.login-card p { text-align: center; margin-bottom: 24px; }

/* ---------- 空状态 ---------- */
.empty { text-align: center; padding: 48px 24px; color: var(--text-tertiary); }
.empty .icon { width: 48px; height: 48px; margin: 0 auto 12px; opacity: 0.4; }

/* ---------- 图表（SVG 自绘） ---------- */
.chart { width: 100%; height: 200px; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: url(#grad); opacity: 0.18; }
.chart .axis { stroke: var(--separator); stroke-width: 1; }
.chart .dot { fill: var(--accent); }

/* ---------- 响应式 ---------- */
@media (max-width: 880px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -240px; width: 240px; transition: left var(--spring-default); }
  .sidebar.open { left: 0; }
  .content { padding: 16px; }
  .sheet { width: 100vw; }
}

/* ---------- 减弱动效（Apple 风格核心：交叉淡入，去弹簧/过冲） ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 200ms !important;
    animation-duration: 200ms !important;
    animation-iteration-count: 1 !important;
  }
  .btn:active { transform: none; }
  .modal { transform: none; opacity: 0; }
  .modal-wrap.open .modal { opacity: 1; }
  .sheet { transform: translateX(100%); }
  .sheet.open { transform: none; }
}

/* ---------- 减弱透明度：材质转实色 ---------- */
@media (prefers-reduced-transparency: reduce) {
  .material, .material-strong, .login-card, .topbar, .sidebar, .sheet, .modal {
    background: var(--bg-elevated) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
}

/* ---------- 高对比度 ---------- */
@media (prefers-contrast: more) {
  :root {
    --text-secondary: #3a3a3c;
    --text-tertiary: #6e6e73;
    --separator: rgba(0,0,0,0.3);
    --separator-strong: rgba(0,0,0,0.5);
    --surface: #ffffff;
    --surface-strong: #ffffff;
  }
}
