/* ═══════════════════════════════════════════════════
   豫见AI助手 — 设计系统 v2 (现代极简)
   共享CSS：所有模板引用此文件
   ═══════════════════════════════════════════════════ */

/* ── CSS 变量 ─────────────────────────────────── */
:root {
  /* 主色 */
  --c-primary: #2563eb;
  --c-primary-dark: #1d4ed8;
  --c-primary-light: #3b82f6;
  --c-primary-faint: #eff6ff;
  --c-primary-ring: rgba(37, 99, 235, 0.12);

  /* 强调渐变 */
  --g-brand: linear-gradient(135deg, #2563eb, #7c3aed);
  --g-brand-hover: linear-gradient(135deg, #1d4ed8, #6d28d9);

  /* 中性色 */
  --c-bg: #fafafa;
  --c-bg-card: #ffffff;
  --c-bg-subtle: #f1f5f9;
  --c-text: #0f172a;
  --c-text-secondary: #64748b;
  --c-text-muted: #94a3b8;
  --c-border: #e2e8f0;
  --c-border-hover: #cbd5e1;

  /* 语义色 */
  --c-success: #10b981;
  --c-success-bg: #ecfdf5;
  --c-error: #ef4444;
  --c-error-bg: #fef2f2;
  --c-warning: #f59e0b;
  --c-warning-bg: #fffbeb;

  /* 字体（全用系统预装字体，零网络请求） */
  --f-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --f-serif: "Songti SC", "SimSun", "Noto Serif SC", Georgia, serif;

  /* 圆角 */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-full: 9999px;

  /* 阴影 */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.04), 0 2px 4px rgba(0, 0, 0, 0.02);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.04), 0 4px 6px rgba(0, 0, 0, 0.02);
  --shadow-primary: 0 4px 14px rgba(37, 99, 235, 0.2);

  /* 过渡 */
  --t-fast: 0.15s ease;
  --t-normal: 0.2s ease;
}

/* ── 全局基础 ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--f-sans);
  background: var(--c-bg);
  color: var(--c-text);
  margin: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

/* ── 排版 ─────────────────────────────────────── */
.font-serif { font-family: var(--f-serif); }
.font-sans { font-family: var(--f-sans); }

.text-primary { color: var(--c-primary); }
.text-secondary { color: var(--c-text-secondary); }
.text-muted { color: var(--c-text-muted); }
.text-success { color: var(--c-success); }
.text-error { color: var(--c-error); }

/* ── 按钮 ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--f-sans);
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  border: none;
  cursor: pointer;
  transition: all var(--t-fast);
  user-select: none;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--g-brand);
  color: #fff;
  border-radius: var(--r-md);
  padding: 12px 24px;
  box-shadow: var(--shadow-primary);
}
.btn-primary:hover:not(:disabled) {
  background: var(--g-brand-hover);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.28);
}

.btn-secondary {
  background: var(--c-bg-card);
  color: var(--c-text);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 11px 24px;
}
.btn-secondary:hover:not(:disabled) {
  background: var(--c-bg-subtle);
  border-color: var(--c-border-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--c-primary);
  border-radius: var(--r-md);
  padding: 8px 12px;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--c-primary-faint);
}

.btn-block { width: 100%; }

/* ── 输入框 ───────────────────────────────────── */
.field-input {
  width: 100%;
  padding: 12px 16px;
  font-family: var(--f-sans);
  font-size: 14px;
  color: var(--c-text);
  background: var(--c-bg-card);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.field-input::placeholder {
  color: var(--c-text-muted);
}
.field-input:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px var(--c-primary-ring);
}
textarea.field-input {
  resize: none;
  line-height: 1.7;
}

/* ── 卡片 ─────────────────────────────────────── */
.card {
  background: var(--c-bg-card);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--t-normal), box-shadow var(--t-normal);
}
.card:hover {
  border-color: var(--c-border-hover);
  box-shadow: var(--shadow-md);
}
.card-flat {
  background: var(--c-bg-card);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
}

/* ── 标签芯片 ─────────────────────────────────── */
.tag-btn {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  font-size: 13px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-full);
  background: var(--c-bg-card);
  color: var(--c-text-secondary);
  cursor: pointer;
  transition: all var(--t-fast);
  user-select: none;
}
.tag-btn:hover {
  border-color: var(--c-border-hover);
  background: var(--c-bg-subtle);
}
.tag-btn.selected {
  border-color: var(--c-primary);
  background: var(--c-primary-faint);
  color: var(--c-primary);
  font-weight: 500;
}

/* ── Toast 通知 ───────────────────────────────── */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  padding: 10px 24px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  backdrop-filter: blur(12px);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}
.toast.error {
  background: var(--c-error-bg);
  color: var(--c-error);
  border: 1px solid #fecaca;
}
.toast.success {
  background: var(--c-success-bg);
  color: var(--c-success);
  border: 1px solid #bbf7d0;
}

/* ── 进度条 ───────────────────────────────────── */
.progress-track {
  height: 4px;
  border-radius: 2px;
  background: var(--c-bg-subtle);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--g-brand);
  transition: width 0.3s ease;
}

/* ── 匹配头像 ─────────────────────────────────── */
.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-lg);
  font-family: var(--f-serif);
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.avatar-sm { width: 36px; height: 36px; font-size: 14px; }
.avatar-md { width: 44px; height: 44px; font-size: 16px; }
.avatar-lg { width: 56px; height: 56px; font-size: 20px; }

/* ── 底部导航栏（全局统一） ────────────────────── */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  height: 56px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--c-border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 100;
}
.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 0;
  color: var(--c-text-muted);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: color 0.2s;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.tab-item.active {
  color: var(--c-primary);
  font-weight: 500;
}
.tab-item:hover {
  color: var(--c-primary);
}
.tab-item svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tab-item.active svg {
  stroke-width: 2;
}
.tab-item span {
  line-height: 1;
}

/* ── 模态框 ───────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(4px);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}
.modal-sheet {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  background: var(--c-bg-card);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  z-index: 201;
  overflow-y: auto;
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}
.modal-backdrop.active .modal-sheet {
  transform: translateX(-50%) translateY(0);
}

/* ── 动画 ─────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.animate-in {
  animation: fadeInUp 0.35s ease both;
}
.animate-in:nth-child(2) { animation-delay: 0.06s; }
.animate-in:nth-child(3) { animation-delay: 0.12s; }
.animate-in:nth-child(4) { animation-delay: 0.18s; }
.animate-in:nth-child(5) { animation-delay: 0.24s; }

/* ── 视图切换 ─────────────────────────────────── */
.view { display: none !important; }
.view.active { display: block !important; }

/* ── 滚动条隐藏 ──────────────────────────────── */
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { scrollbar-width: none; }

/* ── 工具类 ───────────────────────────────────── */
.container { width: 100%; max-width: 420px; margin: 0 auto; }
.gap-stack > * + * { margin-top: 16px; }
.gap-stack-sm > * + * { margin-top: 12px; }
.gap-stack-xs > * + * { margin-top: 8px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── 聊天气泡 ─────────────────────────────────── */
.bubble-self {
  background: var(--c-primary);
  color: #fff;
  border-radius: 16px 16px 4px 16px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.6;
}
.bubble-other {
  background: var(--c-bg-card);
  border: 1px solid var(--c-border);
  color: var(--c-text);
  border-radius: 16px 16px 16px 4px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.6;
}
.msg-wrap { max-width: 75%; min-width: 60px; }

/* ── 状态标签 ─────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  border-radius: var(--r-full);
}
.badge-blue { background: var(--c-primary-faint); color: var(--c-primary); }
.badge-green { background: var(--c-success-bg); color: var(--c-success); }
.badge-red { background: var(--c-error-bg); color: var(--c-error); }
.badge-gray { background: var(--c-bg-subtle); color: var(--c-text-secondary); }

/* ── 筛选芯片 ─────────────────────────────────── */
.filter-chip {
  padding: 6px 14px;
  font-size: 13px;
  border-radius: var(--r-full);
  border: 1px solid var(--c-border);
  background: var(--c-bg-card);
  color: var(--c-text-secondary);
  cursor: pointer;
  transition: all var(--t-fast);
  white-space: nowrap;
}
.filter-chip.active, .filter-chip:hover {
  border-color: var(--c-primary);
  background: var(--c-primary-faint);
  color: var(--c-primary);
}

/* ── FAB 浮动按钮 ─────────────────────────────── */
.fab {
  position: fixed;
  bottom: 84px;
  right: 20px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--g-brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-primary);
  cursor: pointer;
  z-index: 99;
  border: none;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.fab:hover { transform: scale(1.05); box-shadow: 0 6px 24px rgba(37, 99, 235, 0.3); }
.fab:active { transform: scale(0.95); }

/* ── 星级评分 ─────────────────────────────────── */
.star-rating { display: inline-flex; gap: 2px; }
.star-rating span {
  cursor: pointer;
  font-size: 20px;
  color: var(--c-border);
  transition: color var(--t-fast);
}
.star-rating span.active { color: #f59e0b; }

/* ── 共读卡片（暗色星空风格） ──────────────────── */
.group-card {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  min-height: 180px;
  cursor: pointer;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.group-card:active { transform: scale(0.98); }

/* 星空背景 */
.group-card-bg {
  position: absolute; inset: 0;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 40%, #312e81 70%, #1e293b 100%);
  z-index: 0;
}
.group-card-bg::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    radial-gradient(1px 1px at 10% 20%, rgba(255,255,255,0.6) 0%, transparent 100%),
    radial-gradient(1px 1px at 30% 65%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 55% 15%, rgba(255,255,255,0.7) 0%, transparent 100%),
    radial-gradient(1px 1px at 70% 80%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 85% 35%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 20% 85%, rgba(255,255,255,0.6) 0%, transparent 100%),
    radial-gradient(1px 1px at 45% 45%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 90% 60%, rgba(255,255,255,0.5) 0%, transparent 100%);
}
/* 半透明渐变叠加层 */
.group-card-bg::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.35) 100%);
}

/* 卡片内容 */
.group-card-content {
  position: relative;
  z-index: 1;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 180px;
  color: #fff;
}

/* 右上角统计标签 */
.group-card-stats {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.group-card-stats .stat-tag {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 20px;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(4px);
  color: rgba(255,255,255,0.9);
  white-space: nowrap;
  line-height: 1.4;
}
.group-card-stats .stat-tag.highlight {
  background: rgba(16,185,129,0.3);
  color: #6ee7b7;
}

/* 中间引用语 */
.group-card-quote {
  font-family: 'Noto Serif SC', serif;
  font-size: 17px;
  line-height: 1.7;
  color: rgba(255,255,255,0.95);
  padding: 12px 0;
  flex: 1;
  display: flex;
  align-items: center;
}

/* 底部信息 */
.group-card-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}
.group-card-meta {
  font-size: 12px;
  color: rgba(255,255,255,0.6);
  line-height: 1.5;
}
.group-card-meta .book-title {
  font-size: 13px;
  color: rgba(255,255,255,0.85);
  font-weight: 500;
}
.group-card-join {
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: #fff;
  background: rgba(255,255,255,0.2);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,0.25);
  transition: background var(--t-fast);
}
.group-card-join:active { background: rgba(255,255,255,0.35); }

/* 打卡日历小组件 */
.group-card-date {
  text-align: center;
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(4px);
  border-radius: 10px;
  padding: 6px 10px;
  min-width: 46px;
}
.group-card-date .date-day {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
  color: #fff;
}
.group-card-date .date-month {
  font-size: 10px;
  color: rgba(255,255,255,0.7);
  margin-top: 2px;
}

/* 进度条（暗色版） */
.group-card-progress {
  height: 3px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  margin-top: 10px;
  overflow: hidden;
}
.group-card-progress .fill {
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, #6ee7b7, #3b82f6);
  transition: width 0.3s;
}

/* 打卡状态标签 */
.checkin-badge {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.checkin-badge.done {
  background: rgba(16,185,129,0.25);
  color: #6ee7b7;
}
.checkin-badge.pending {
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.7);
}
