/* style.css —— 手机端资料库样式（简约高级、移动优先） */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 2px 12px rgba(17, 24, 39, .06);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: inherit; text-decoration: none; }
.svg-icon { display: inline-block; vertical-align: middle; flex: none; }

/* ---------- 顶部导航 ---------- */
.navbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex; align-items: center; gap: 10px;
}
.navbar .nav-back { color: var(--text); display: flex; align-items: center; }
.navbar .nav-title { font-size: 17px; font-weight: 600; flex: 1; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.navbar .nav-side { width: 24px; display: flex; justify-content: flex-end; }

.page { max-width: 640px; margin: 0 auto; padding: 16px; }

/* ---------- 首页头部 ---------- */
.hero {
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff; border-radius: var(--radius);
  padding: 22px 20px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.hero h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.hero .hero-sub { font-size: 13px; opacity: .9; }

/* ---------- 公告 ---------- */
.notice {
  display: flex; gap: 10px; align-items: flex-start;
  background: #fffbeb; border: 1px solid #fde68a;
  color: #92400e; border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 16px; font-size: 14px;
}
.notice .svg-icon { color: #d97706; margin-top: 2px; }

/* ---------- 搜索框 ---------- */
.search-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 999px; padding: 10px 16px; margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.search-bar .svg-icon { color: var(--muted); }
.search-bar input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 15px; color: var(--text);
}
.search-bar .clear-btn { color: var(--muted); display: none; }

/* ---------- 区块标题 ---------- */
.section-title { font-size: 16px; font-weight: 600; margin: 4px 0 12px; display: flex; align-items: center; gap: 6px; }

/* ---------- 分类卡片 ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.cat-card {
  background: var(--card); border-radius: var(--radius); padding: 18px 16px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px;
  border: 1px solid transparent; transition: transform .12s, border-color .12s;
}
.cat-card:active { transform: scale(.98); border-color: var(--primary); }
.cat-card .cat-ico {
  width: 42px; height: 42px; border-radius: 12px; background: #eff6ff; color: var(--primary);
  display: flex; align-items: center; justify-content: center;
}
.cat-card .cat-name { font-size: 15px; font-weight: 600; }
.cat-card .cat-count { font-size: 12px; color: var(--muted); }
.cat-card .cat-copy { margin-top: 2px; font-size: 12px; color: var(--primary); display: inline-flex; align-items: center; gap: 4px; }

/* ---------- 文件列表 ---------- */
.file-list { display: flex; flex-direction: column; gap: 10px; }
.file-item {
  background: var(--card); border-radius: var(--radius); padding: 14px;
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 12px;
}
.file-item .fi-ico {
  width: 44px; height: 44px; border-radius: 10px; flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: #fff;
}
.fi-type-pdf { background: #ef4444; }
.fi-type-doc, .fi-type-docx { background: #2563eb; }
.fi-main { flex: 1; min-width: 0; }
.fi-name { font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fi-meta { font-size: 12px; color: var(--muted); margin-top: 4px; display: flex; gap: 10px; flex-wrap: wrap; }
.fi-actions { display: flex; gap: 8px; flex: none; }
.fi-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border);
  background: #fff; color: var(--primary); display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.fi-btn.dl { color: #16a34a; }
.fi-btn.disabled { color: #cbd5e1; }

/* ---------- 文件详情 ---------- */
.detail-card { background: var(--card); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.detail-title { font-size: 18px; font-weight: 600; word-break: break-all; margin-bottom: 12px; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 13px; color: var(--muted); }
.detail-meta b { color: var(--text); font-weight: 500; }
.detail-actions { display: flex; gap: 12px; margin-top: 18px; }

.preview-frame {
  width: 100%; height: 78vh; border: none; border-radius: var(--radius);
  background: #fff; box-shadow: var(--shadow);
}
.preview-tip { font-size: 13px; color: var(--muted); text-align: center; margin: 10px 0; }

/* ---------- 页内预览（PDF.js / mammoth.js） ---------- */
.preview-box {
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  max-height: 72vh; overflow: auto; padding: 8px; -webkit-overflow-scrolling: touch;
}
.preview-box canvas {
  width: 100%; height: auto; display: block; margin: 0 auto 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .12); background: #fff;
}
.preview-doc { padding: 12px; font-size: 15px; line-height: 1.8; word-break: break-word; color: var(--text); }
.preview-doc img { max-width: 100%; height: auto; }
.preview-doc table { border-collapse: collapse; width: 100%; margin: 8px 0; }
.preview-doc td, .preview-doc th { border: 1px solid #ddd; padding: 6px; font-size: 14px; }
.preview-doc h1, .preview-doc h2, .preview-doc h3 { margin: 12px 0 6px; }
.preview-doc p { margin: 6px 0; }

/* ---------- 按钮 ---------- */
.btn {
  border: none; border-radius: 10px; padding: 11px 20px; font-size: 15px;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: inherit; transition: opacity .15s;
}
.btn:active { opacity: .85; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-plain { background: #f1f5f9; color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: #16a34a; color: #fff; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- 空状态 / 加载 ---------- */
.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.empty .svg-icon { color: #cbd5e1; margin-bottom: 12px; }
.loading { text-align: center; color: var(--muted); padding: 40px; }

/* ---------- 分页 ---------- */
.pager { display: flex; justify-content: center; align-items: center; gap: 6px; margin: 20px 0; flex-wrap: wrap; }
.pg-btn {
  min-width: 38px; height: 38px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--border);
  background: #fff; color: var(--text); font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.pg-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pg-btn[disabled] { color: #cbd5e1; cursor: not-allowed; }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; left: 0; right: 0; top: 20px; z-index: 9999; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 8px; max-width: 84%;
  background: rgba(17, 24, 39, .92); color: #fff; padding: 10px 16px; border-radius: 999px;
  font-size: 14px; opacity: 0; transform: translateY(-12px); transition: all .25s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: rgba(22, 163, 74, .95); }
.toast-error { background: rgba(220, 38, 38, .95); }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 9000;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .2s, visibility .2s;
}
.modal-mask.show { opacity: 1; visibility: visible; pointer-events: auto; }
.modal-box { background: #fff; border-radius: 16px; width: 100%; max-width: 360px; overflow: hidden; transform: scale(.94); transition: transform .2s; }
.modal-mask.show .modal-box { transform: scale(1); }
.modal-title { font-size: 16px; font-weight: 600; padding: 20px 20px 8px; text-align: center; }
.modal-body { font-size: 14px; color: var(--muted); padding: 0 20px 20px; text-align: center; line-height: 1.7; }
.modal-foot { display: flex; border-top: 1px solid var(--border); }
.modal-foot .btn { flex: 1; border-radius: 0; padding: 14px; background: #fff; color: var(--text); }
.modal-foot .btn:first-child { border-right: 1px solid var(--border); }
.modal-foot .btn-primary { color: var(--primary); font-weight: 600; }
.modal-foot .btn-danger { color: var(--danger); font-weight: 600; }

.footer { text-align: center; color: #9ca3af; font-size: 12px; padding: 24px 16px 8px; }
