/* 工作台统一样式 - 干净版 */
:root {
  --bg: #f7f8fa;
  --card: #ffffff;
  --text: #1a1a1a;
  --text-muted: #6b7280;
  --brand: #10b981;
  --brand-dark: #059669;
  --border: #e5e7eb;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-hover: 0 4px 12px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* Topbar */
.topbar {
  background: linear-gradient(135deg, #fff 0%, #f0fdf4 100%);
  padding: 20px 40px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo { font-size: 28px; }
.brand h1 { font-size: 22px; font-weight: 600; }
.brand .subtitle { color: var(--text-muted); font-size: 14px; }
.sync-info {
  font-size: 13px;
  color: var(--text-muted);
  padding: 6px 12px;
  background: #f3f4f6;
  border-radius: 999px;
}

/* Main */
main { max-width: 1200px; margin: 0 auto; padding: 32px 40px; }
section { margin-bottom: 40px; }
section h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

/* Overview stats */
.overview {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.stat-card {
  background: var(--card);
  padding: 20px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.stat-label { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--brand-dark); }

/* Workspaces */
.ws-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
.ws-card {
  background: var(--card);
  padding: 24px;
  border-radius: 12px;
  border: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: all 0.2s;
  box-shadow: var(--shadow);
}
.ws-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: var(--brand);
}
.ws-icon { font-size: 36px; margin-bottom: 12px; }
.ws-name { font-size: 17px; font-weight: 600; margin-bottom: 8px; }
.ws-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; min-height: 40px; }
.ws-status {
  display: inline-block;
  padding: 4px 10px;
  font-size: 12px;
  background: #d1fae5;
  color: var(--brand-dark);
  border-radius: 999px;
}

/* Month view */
.month-view-container {
  background: var(--card);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 16px;
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
}
.month-view-container img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}
.placeholder {
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  padding: 40px;
}

/* Archives */
.archive-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
.archive-card {
  background: var(--card);
  padding: 20px;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.archive-icon { font-size: 24px; margin-bottom: 8px; }
.archive-title { font-size: 15px; font-weight: 600; margin-bottom: 12px; }
.archive-list { font-size: 13px; }
.archive-list a {
  display: block;
  padding: 4px 0;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px dashed transparent;
}
.archive-list a:hover { color: var(--brand-dark); border-bottom-color: var(--brand); }
.muted { color: var(--text-muted); }

/* Footer */
footer {
  text-align: center;
  padding: 24px 40px;
  color: var(--text-muted);
  font-size: 13px;
  border-top: 1px solid var(--border);
  margin-top: 40px;
  display: flex;
  justify-content: space-between;
}

/* 工作区子页面通用 */
.workspace-header {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: white;
  padding: 32px 40px;
  border-radius: 12px;
  margin-bottom: 24px;
}
.workspace-header h1 { font-size: 24px; margin-bottom: 8px; }
.workspace-header p { opacity: 0.9; }
.back-link {
  display: inline-block;
  margin-bottom: 16px;
  color: var(--brand-dark);
  text-decoration: none;
  font-size: 14px;
}
.back-link:hover { text-decoration: underline; }

@media (max-width: 768px) {
  .overview, .ws-grid, .archive-grid { grid-template-columns: 1fr; }
  main { padding: 20px; }
  .topbar { padding: 16px 20px; flex-wrap: wrap; gap: 12px; }
}

/* ===== UI States（由"AI 会写页面但它不会替你想这 8 种情况"笔记落地）===== */
/* [Empt...] 空态 / [Loading] 加载态 / [Error] 错误态 / [Offline] 离线态
   [Disabled] 禁用态 / [NoPermission] 权限态 / [Success] 成功态 + Happy Path */

/* 统一状态容器：异步区块（stat/spark/archives/month-view）专用 */
[data-state] {
  position: relative;
  min-height: 1px;
  transition: opacity .15s;
}
[data-state="loading"] .state-body,
[data-state="error"] .state-body,
[data-state="empty"] .state-body,
[data-state="offline"] .state-body,
[data-state="disabled"] .state-body,
[data-state="noperm"] .state-body { display: none; }

/* 骨架屏：加载态 */
.skeleton {
  background: linear-gradient(90deg, #f1f3f5 25%, #e6e8ea 37%, #f1f3f5 63%);
  background-size: 400% 100%;
  animation: skeleton 1.4s ease infinite;
  border-radius: 8px;
  height: 14px;
  margin: 6px 0;
}
@keyframes skeleton { 0%{background-position:100% 0} 100%{background-position:0 0} }

/* 状态面板：统一插画区 */
.state-view {
  display: none;
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
}
[data-state="error"] .state-view.error,
[data-state="empty"] .state-view.empty,
[data-state="offline"] .state-view.offline,
[data-state="disabled"] .state-view.disabled,
[data-state="noperm"] .state-view.noperm,
[data-state="success"] .state-view.success {
  display: block;
}
.state-view[data-loading="true"] { display: flex; flex-direction: column; gap: 10px; }
.state-emoji { font-size: 34px; margin-bottom: 8px; }
.state-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.state-desc { font-size: 13px; line-height: 1.6; }

/* 状态徽标配色 */
.state-view.error .state-title { color: #dc2626; }
.state-view.empty .state-title { color: var(--text); }
.state-view.offline .state-title { color: #d97706; }
.state-view.disabled .state-title { color: var(--text-muted); }
.state-view.noperm .state-title { color: #7c3aed; }
.state-view.success .state-title { color: var(--brand-dark); }

/* 重试按钮 */
.state-btn {
  margin-top: 12px;
  padding: 8px 18px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: all .15s;
}
.state-btn:hover { border-color: var(--brand); color: var(--brand-dark); }

/* 顶部同步徽标状态着色 */
.sync-info[data-sync="error"] { background: #fee2e2; color: #b91c1c; }
.sync-info[data-sync="offline"] { background: #fef3c7; color: #b45309; }
.sync-info[data-sync="success"] { background: #d1fae5; color: var(--brand-dark); }
.sync-info[data-sync="loading"] { background: #e0e7ff; color: #4338ca; }

/* 工作区入口状态（Disabled/NoPermission） */
.ws-card.is-disabled { opacity: .55; pointer-events: none; filter: grayscale(.6); }
.ws-card.is-noperm { border-color: #ddd6fe; }
.ws-status.na { background: #f3f4f6; color: var(--text-muted); }
.ws-status.warn { background: #fef3c7; color: #b45309; }
.ws-status.ok { background: #d1fae5; color: var(--brand-dark); }
