/* =========================================================
 * 公共样式：设计变量 / 重置 / 基础组件 / 顶部导航 / 弹窗
 * 页面专属样式放在各自的 css 文件中
 * ========================================================= */

/* ---------- 设计变量 ---------- */
:root {
  /* 品牌主色：与 logo 的红底一致 */
  --primary: #b33b2e;
  --primary-hover: #9c3227;
  --primary-light: #f8ecea;
  --orange: #ff6a2b;
  --success: #16a34a;
  --danger: #ef4444;

  --text: #1f2329;
  --text-2: #4b5563;
  --text-3: #8a909c;
  --border: #e5e7eb;
  --bg: #f4f5f7;
  --card: #fff;

  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgba(179, 59, 46, .10);
  --header-h: 72px;
}

/* ---------- 重置 ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
  /* 整站纵向布局：内容不足一屏时页脚也贴在窗口底部 */
  min-height: 100vh; display: flex; flex-direction: column;
}
/* 主内容区撑满剩余高度，把页脚推到最底部；min-width:0 防止横向滚动条把内容撑宽 */
body > main { flex: 1 0 auto; min-width: 0; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
img { display: block; max-width: 100%; }
ul { list-style: none; }
[hidden] { display: none !important; }

/* ---------- 布局 / 文字工具类 ---------- */
.container { width: 100%; max-width: 1328px; margin: 0 auto; padding: 0 24px; }
.icon { flex-shrink: 0; vertical-align: middle; }
.text-primary { color: var(--primary); }
.text-3 { color: var(--text-3); }
.text-danger { color: var(--danger); }
.dot { font-style: normal; margin: 0 10px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 22px; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 500; white-space: nowrap; transition: .2s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-default { background: #fff; border: 1px solid var(--border); }
.btn-default:hover { border-color: var(--primary); color: var(--primary); }
.btn-outline { background: #fff; border: 1px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-light { background: var(--primary-light); color: var(--primary); border: 1px solid transparent; }
.btn-lg { height: 48px; font-size: 16px; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* ---------- 表单 ---------- */
.input {
  width: 100%; height: 44px; padding: 0 14px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); outline: none; background: #fff; transition: border-color .2s;
}
.input:focus { border-color: var(--primary); }
.input:disabled { background: var(--bg); color: var(--text-3); }
.select { height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; outline: none; cursor: pointer; }

/* 自定义复选框 */
.checkbox {
  appearance: none; position: relative; flex-shrink: 0; cursor: pointer;
  width: 20px; height: 20px; border: 1.5px solid #c9cdd4; border-radius: 5px; background: #fff; transition: .15s;
}
.checkbox:checked { background: var(--primary); border-color: var(--primary); }
.checkbox:checked::after {
  content: ""; position: absolute; left: 6px; top: 2px; width: 5px; height: 10px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}

/* ---------- 卡片 / 标签 / 头像 ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 28px; }
.tag { display: inline-block; padding: 5px 12px; border-radius: 6px; background: var(--bg); color: var(--text-2); font-size: 13px; }
.avatar { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; border-radius: 50%; color: #fff; font-weight: 600; }
.vip-badge {
  font-style: normal; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 4px;
  color: #7a4a00; background: linear-gradient(90deg, #ffe2a8, #ffc56b);
}
.empty { padding: 64px 0; text-align: center; color: var(--text-3); }
.empty .btn { margin-top: 16px; }

/* ---------- 文档网格卡片 ---------- */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }
.doc-card { background: #fff; border-radius: var(--radius); overflow: hidden; transition: .2s; }
.doc-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.doc-card img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }
.doc-card-body { padding: 14px 16px; }
.doc-card-title { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-card-meta { margin-top: 12px; display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--text-3); }

/* 格式标签：颜色由 --c 传入 */
.type-tag {
  display: inline-block; padding: 2px 10px; border-radius: 4px; font-size: 12px; font-weight: 600;
  color: var(--c); background: color-mix(in srgb, var(--c) 10%, #fff);
}

/* ---------- 顶部导航 ---------- */
.header { position: sticky; top: 0; z-index: 50; height: var(--header-h); background: #fff; }
.header-inner { height: 100%; padding: 0 40px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.logo { display: flex; align-items: center; gap: 10px; font-size: 24px; font-weight: 800; }
/* 品牌图标：使用项目根目录的 logo.png，尺寸随断点调整 */
.logo-img { display: block; flex: none; width: 36px; height: 36px; border-radius: 9px; object-fit: contain; }
.nav { display: flex; gap: 36px; font-size: 16px; color: var(--text-2); }
.nav a { transition: color .2s; }
.nav a:hover, .nav a.active { color: var(--primary); }
.header-right { justify-self: end; }
.header-user { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 500; }

/* ---------- 页脚 ---------- */
.footer { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 44px 16px; background: #1f2229; color: #c9ced8; text-align: center; flex: none; }
.footer .logo { color: #fff; font-size: 20px; }
.footer .logo-img { width: 28px; height: 28px; border-radius: 7px; }
.footer-links { font-size: 15px; }
.footer-links a:hover { color: #fff; }
.footer-copy { font-size: 13px; color: #7d8492; }
/* 备案号：与版权行同色，悬停变白并加下划线，提示可点进工信部 */
.footer-icp { color: inherit; }
.footer-icp:hover { color: #fff; text-decoration: underline; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background: rgba(17, 24, 39, .45); animation: fade .2s;
}
.modal { width: 480px; max-width: calc(100% - 32px); background: #fff; border-radius: 16px; box-shadow: 0 24px 60px rgba(0, 0, 0, .2); animation: pop .2s; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 24px 28px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 18px; }
.modal-close { display: flex; color: var(--text-3); }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 22px 28px; font-size: 15px; color: var(--text-2); }
.modal-info { margin-top: 16px; padding: 16px 18px; border-radius: 10px; background: var(--bg); line-height: 2; }
.modal-foot { display: flex; justify-content: flex-end; gap: 12px; padding: 0 28px 24px; }

/* ---------- 轻提示 ---------- */
.toast {
  position: fixed; top: 88px; left: 50%; z-index: 200; transform: translateX(-50%);
  padding: 10px 20px; border-radius: 8px; background: rgba(31, 35, 41, .9); color: #fff; animation: fade .2s;
}

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.95); } }

/* ---------- 移动端 ---------- */
@media (max-width: 768px) {
  .container { padding: 0 16px; }
  .header-inner { padding: 0 16px; grid-template-columns: 1fr auto; }
  .nav { display: none; }
  .card { padding: 20px; }
}

/* ---------- 手机端（≤640px）：对齐 H5 设计稿的紧凑版式 ---------- */
@media (max-width: 640px) {
  :root { --header-h: 54px; --radius: 12px; }
  body { font-size: 13.5px; }
  .container { padding: 0 14px; }

  /* 顶部栏：左 logo，右登录按钮 */
  .header-inner { padding: 0 14px; gap: 8px; }
  .logo { gap: 8px; font-size: 20px; font-weight: 800; }
  .logo-img { width: 30px; height: 30px; border-radius: 8px; }
  .header-right .btn { height: 32px; padding: 0 14px; font-size: 13px; border-radius: 8px; }
  .header-user span, .header-user .vip-badge { display: none; }

  /* 页脚压缩，避免占满一屏 */
  .footer { gap: 10px; padding: 24px 14px; }
  .footer .logo { font-size: 16px; }
  .footer-links { font-size: 12.5px; }
  .footer-copy { font-size: 11px; line-height: 1.7; }

  .card { padding: 16px; border-radius: 12px; }
  .tag { padding: 4px 10px; font-size: 12px; }
  .empty { padding: 40px 0; font-size: 13px; }

  /* 文档卡片：两列紧凑网格 */
  .doc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .doc-card { border-radius: 10px; }
  .doc-card img { aspect-ratio: 16 / 11; }
  .doc-card-body { padding: 8px 10px 10px; }
  .doc-card-title {
    font-size: 12.5px; line-height: 1.45; white-space: normal;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  }
  .doc-card-meta { margin-top: 6px; font-size: 11px; }
  .type-tag { padding: 1px 6px; font-size: 10px; }

  /* 弹窗改为贴底面板 */
  .modal-mask { align-items: flex-end; }
  .modal {
    width: 100%; max-width: 100%; border-radius: 16px 16px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .modal-head { padding: 16px 18px 12px; }
  .modal-head h3 { font-size: 16px; }
  .modal-body { padding: 14px 18px; font-size: 14px; }
  .modal-foot { padding: 0 18px 16px; }
  .modal-foot .btn { flex: 1; }

  .toast { top: 62px; max-width: calc(100% - 28px); font-size: 13px; }
  .btn { height: 36px; padding: 0 16px; font-size: 14px; border-radius: 8px; }
  .btn-lg { height: 44px; font-size: 15px; }
}
