/* ==========================================================================
   components.css — 卡片 / 按钮 / 表单 / 模态框 / PDF 预览 / 反馈组件
   ========================================================================== */

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  height: 38px;
  padding: 0 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: all var(--speed-fast) var(--ease);
  white-space: nowrap;
}
.btn:hover {
  border-color: var(--brand-300);
  color: var(--brand-300);
  text-decoration: none;
  box-shadow: 0 0 0 3px var(--glow);
}
.btn-primary {
  background: linear-gradient(135deg, var(--brand-500), var(--brand-400));
  border-color: transparent;
  color: #fff;
}
.btn-primary:hover { color: #fff; filter: brightness(1.1); }
.btn-accent {
  background: linear-gradient(135deg, var(--brand-400), var(--cat-yuanzi));
  border-color: transparent;
  color: #fff;
}
.btn-accent:hover { color: #fff; filter: brightness(1.08); }
.btn-danger { border-color: color-mix(in srgb, var(--danger) 45%, transparent); color: var(--danger); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 8%, transparent); color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); box-shadow: none; }
.btn-sm { height: 30px; padding: 0 0.7rem; font-size: var(--fs-xs); }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- 模块卡片 ---------- */
.module-card {
  position: relative;
  padding: 1.1rem 1.1rem 1rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--speed) var(--ease), box-shadow var(--speed) var(--ease),
              border-color var(--speed) var(--ease);
  animation: rise-in 0.5s var(--ease) both;
}
.module-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent, var(--brand-300));
}
.module-card .mc-accent {
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: var(--accent);
}
.module-card .mc-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 45%, transparent);
}
.module-card h3 {
  margin: 0.8rem 0 0.15rem;
  font-size: var(--fs-lg);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.module-card .mc-desc {
  margin: 0.1rem 0 0.6rem;
  font-size: var(--fs-sm);
  color: var(--text-2);
}
.module-card .mc-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--fs-xs);
  color: var(--text-3);
}
.module-card .mc-thumb {
  width: 56px; height: 56px;
  border-radius: var(--radius);
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

/* 模块强调色类：.cat-力 等 */
.cat-力 { --accent: var(--cat-li); }
.cat-电 { --accent: var(--cat-dian); }
.cat-热 { --accent: var(--cat-re); }
.cat-光 { --accent: var(--cat-guang); }
.cat-原子 { --accent: var(--cat-yuanzi); }

/* ---------- 推文卡片 ---------- */
.article-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
  transition: transform var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
  animation: rise-in 0.5s var(--ease) both;
}
.article-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}
.article-card .cover {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--surface-3);
}
.article-card .cover img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.45s var(--ease);
}
.article-card:hover .cover img { transform: scale(1.05); }
.article-card .cover .cat-badge {
  position: absolute;
  top: 0.6rem; left: 0.6rem;
  padding: 0.18rem 0.55rem;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 700;
  color: #fff;
  background: var(--accent, var(--brand-500));
  box-shadow: var(--shadow-sm);
}
.article-card .body {
  padding: 0.9rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}
.article-card h3 { font-size: var(--fs-lg); margin: 0; }
.article-card h3 a { color: var(--text); }
.article-card h3 a:hover { color: var(--brand-300); }
.article-card .summary {
  font-size: var(--fs-sm);
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0;
}
.article-card .tags { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.article-card .foot {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--fs-xs);
  color: var(--text-3);
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border);
}
.article-card .actions { display: flex; gap: 0.3rem; }
.article-card .actions a,
.article-card .actions button {
  padding: 0.28rem 0.6rem;
  font-size: var(--fs-xs);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
}
.article-card .actions a:hover,
.article-card .actions button:hover {
  border-color: var(--brand-300);
  color: var(--brand-300);
  text-decoration: none;
}

/* ---------- 标签 ---------- */
.tag {
  display: inline-block;
  padding: 0.12rem 0.55rem;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 600;
}
.tag:hover { color: var(--brand-300); border-color: var(--brand-300); }

/* 标签云 */
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.tag-cloud .tag {
  cursor: pointer;
  padding: 0.3rem 0.75rem;
  transition: all var(--speed-fast) var(--ease);
}
.tag-cloud .tag:hover { transform: translateY(-2px); }

/* ---------- 表单 ---------- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem 1.2rem;
}
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.form-field { display: flex; flex-direction: column; gap: 0.32rem; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.form-field .req::after { content: " *"; color: var(--danger); }
.form-field input[type="text"],
.form-field input[type="password"],
.form-field input[type="month"],
.form-field input[type="file"],
.form-field select,
.form-field textarea {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: var(--fs-sm);
  width: 100%;
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--brand-300);
  box-shadow: 0 0 0 3px var(--glow);
}
.form-field textarea { min-height: 90px; resize: vertical; }
.form-field .help { font-size: var(--fs-xs); color: var(--text-3); }
.form-error { color: var(--danger); font-size: var(--fs-sm); margin-top: 0.4rem; }
.form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
  margin-top: 0.3rem;
}

/* ---------- 模态框 ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(8, 14, 28, 0.55);
  backdrop-filter: blur(4px);
  padding: 1rem;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  width: min(560px, 100%);
  max-height: 88vh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: rise-in 0.25s var(--ease);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: var(--fs-lg); }
.modal-close {
  border: none;
  background: transparent;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-3);
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
}
.modal-close:hover { background: var(--surface-3); color: var(--text); }
.modal-body { padding: 1.1rem 1.2rem 1.3rem; }

/* ---------- 口令面板 ---------- */
.admin-gate { text-align: center; padding: 1.4rem 0; }
.admin-gate .gate-msg { color: var(--text-2); font-size: var(--fs-sm); margin-bottom: 0.9rem; }
.admin-gate input { max-width: 260px; }

/* ---------- PDF 预览 ---------- */
.pdf-frame-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface-3);
}
.pdf-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}
.skeleton {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding: 1.2rem;
  background: var(--surface-2);
}
.skeleton .sk-line {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--border) 50%, var(--surface-3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite linear;
}
.skeleton .sk-line.w60 { width: 60%; }
.skeleton .sk-line.w80 { width: 80%; }
.skeleton .sk-line.w40 { width: 40%; }

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed;
  bottom: 1.2rem;
  right: 1.2rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(360px, calc(100vw - 2rem));
}
.toast {
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
  background: var(--brand-800);
  color: #eaf1fc;
  font-size: var(--fs-sm);
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--brand-300);
  animation: slide-in 0.25s var(--ease);
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }

/* ---------- 二维码 / 分享 ---------- */
.share-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.qr-box {
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}
.qr-box img { width: 128px; height: 128px; }
.share-links { display: flex; flex-direction: column; gap: 0.45rem; font-size: var(--fs-sm); }
.copy-link {
  cursor: pointer;
  color: var(--brand-300);
  background: none;
  border: none;
  font-size: var(--fs-sm);
  padding: 0;
}
.copy-link:hover { text-decoration: underline; }

/* ---------- 学习进度 ---------- */
.progress-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.progress-track {
  flex: 1;
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--brand-500), var(--cat-yuanzi));
  width: 0%;
  transition: width 0.4s var(--ease);
}
.bookmark-btn.on {
  background: var(--brand-500);
  border-color: var(--brand-500);
  color: #fff;
}

/* ---------- 统计面板（管理页） ---------- */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.9rem;
}
@media (max-width: 900px) { .stat-cards { grid-template-columns: repeat(2, 1fr); } }
.stat-card {
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.stat-card .num {
  font-size: var(--fs-3xl);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--brand-300);
}
.stat-card .label { font-size: var(--fs-sm); color: var(--text-2); }
.month-alert {
  padding: 0.8rem 1rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: var(--fs-sm);
}
.month-alert.warn {
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
  color: var(--warn);
}
.month-alert.ok {
  background: color-mix(in srgb, var(--ok) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--ok) 45%, transparent);
  color: var(--ok);
}

/* ---------- 表格 ---------- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
  table-layout: fixed;
}
.data-table th, .data-table td {
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.data-table th {
  color: var(--text-3);
  font-weight: 600;
  background: var(--surface-2);
}
.data-table tr:hover td { background: var(--surface-2); }

/* ---------- 状态徽章 ---------- */
.status-badge {
  display: inline-block;
  padding: 0.14rem 0.5rem;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 700;
}
.status-badge.published { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.status-badge.pending { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); }
.status-badge.rejected { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }

/* ---------- 空状态 ---------- */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-3);
}
.empty-state svg { margin: 0 auto 0.8rem; opacity: 0.55; }

/* ---------- 动画 ---------- */
@keyframes rise-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slide-in {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---------- 移动端适配 ---------- */
@media (max-width: 760px) {
  .header-search input { width: 150px; }
  .nav-toggle { display: grid; }
  .main-nav {
    position: absolute;
    top: var(--header-h);
    left: 0; right: 0;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.6rem 1rem 0.9rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    display: none;
  }
  .main-nav.open { display: flex; }
  .pdf-frame-wrap { aspect-ratio: 3 / 4; }
  .toast-wrap { left: 1rem; right: 1rem; }
  .qr-box img { width: 100px; height: 100px; }
}
