/* =====================================================
   PRD 文档与原型管理系统 — 全局样式
   ===================================================== */
:root {
  --bg: #f5f7fa;
  --card-bg: #ffffff;
  --border: #e4e7ed;
  --border-hover: #c6ccd6;
  --text: #2b3440;
  --text-sub: #6b7684;
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-light: #eff6ff;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --warning: #d97706;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/*
 * 关键：hidden 属性必须能压过组件自身的 display 规则。
 * 浏览器默认的 [hidden]{display:none} 属于 UA 样式，优先级低于作者样式，
 * 一旦某个类写了 display:flex，hidden 就会失效（弹窗关不掉、占位元素常驻）。
 * 这里用 !important 统一兜底。
 */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: "Microsoft YaHei", "微软雅黑", "PingFang SC", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

/* ---------- 顶栏 ---------- */
.topbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 700; }
.brand-icon { font-size: 20px; }

/* ---------- 布局 ---------- */
.container { max-width: 1080px; margin: 0 auto; padding: 24px 20px 60px; }

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-bottom: 20px;
}
.card-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.card-desc { color: var(--text-sub); margin-bottom: 16px; font-size: 13px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, opacity .15s;
  white-space: nowrap;
  line-height: 1.4;
}
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: #fff; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--border-hover); background: #fafbfc; }
.btn-danger-ghost { background: #fff; border-color: var(--border); color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-bg); border-color: #fca5a5; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn[disabled], .btn.disabled {
  background: #f1f3f5 !important;
  border-color: var(--border) !important;
  color: #b0b7c0 !important;
  cursor: not-allowed;
  opacity: 1;
}

/* ---------- 表单 ---------- */
.form-row { margin-bottom: 16px; }
.form-row > label { display: block; font-weight: 600; margin-bottom: 6px; }
.opt { font-weight: 400; color: var(--text-sub); font-size: 12px; }
.req { color: var(--danger); font-weight: 400; font-size: 12px; }
input[type="text"], input[type="search"], .select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
input[type="text"]:focus, input[type="search"]:focus, .select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .15);
}
.field-label { display: block; font-weight: 600; margin: 4px 0 6px; }
.form-actions { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.upload-tip, .modal-tip { font-size: 13px; color: var(--text-sub); }
.upload-tip.ok { color: var(--success); }
.upload-tip.warn { color: var(--warning, #d97706); }
.upload-tip.err { color: var(--danger); }

/* ---------- 拖拽上传区 ---------- */
.dropzone {
  border: 1.5px dashed var(--border-hover);
  border-radius: var(--radius);
  background: #fafbfc;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  position: relative;
}
.dropzone:hover { border-color: var(--primary); background: var(--primary-light); }
.dropzone.dragover { border-color: var(--primary); background: var(--primary-light); }
.dz-inner {
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--text-sub);
  pointer-events: none;
}
.dz-icon { font-size: 26px; }
.dz-text { font-size: 13px; }
.dz-file {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  pointer-events: none;
}
.dz-file .fsize { color: var(--text-sub); }
.dz-file .fclear { color: var(--primary); margin-left: auto; font-size: 12px; }

/* ---------- 列表 ---------- */
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.list-tools { display: flex; gap: 8px; align-items: center; }
.search-input { width: 220px; }

.doc-list { list-style: none; }
.doc-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
.doc-item:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.doc-item:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.doc-icon {
  flex: 0 0 42px;
  width: 42px; height: 42px;
  border-radius: 8px;
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.doc-main { flex: 1 1 auto; min-width: 0; }
.doc-name { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-meta { font-size: 12px; color: var(--text-sub); margin-top: 2px; display: flex; gap: 12px; flex-wrap: wrap; }
.doc-side { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-linked { background: var(--success-bg); color: var(--success); border: 1px solid #bbf7d0; }
.badge-unlinked { background: #f8fafc; color: var(--text-sub); border: 1px solid var(--border); }

.empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-sub);
}
.empty-icon { font-size: 40px; display: block; margin-bottom: 8px; opacity: .6; }
.loading { text-align: center; padding: 40px; color: var(--text-sub); }

/* ---------- 预览页 ---------- */
.preview-head {
  display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap;
  padding: 18px 24px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 40;
}
.preview-title-block { flex: 1 1 auto; min-width: 240px; }
.preview-title { font-size: 17px; font-weight: 700; }
.preview-meta { font-size: 12px; color: var(--text-sub); margin-top: 3px; display: flex; gap: 12px; flex-wrap: wrap; }
.preview-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.tip-wrap { position: relative; display: inline-flex; }
.tip-text {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: #303a46;
  color: #fff;
  font-size: 12px;
  line-height: 1.5;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  transition: opacity .15s, visibility .15s;
  z-index: 60;
  white-space: normal;
}
.tip-wrap:hover .tip-text, .tip-wrap:focus-within .tip-text { visibility: visible; opacity: 1; }

.doc-viewer {
  max-width: 900px;
  margin: 24px auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 48px 56px;
  min-height: 300px;
}

/* ---------- mammoth 渲染出的 docx 内容排版 ---------- */
.doc-content { font-size: 15px; color: #262626; line-height: 1.85; word-break: break-word; }
.doc-content h1 { font-size: 24px; margin: 22px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.doc-content h2 { font-size: 20px; margin: 20px 0 10px; }
.doc-content h3 { font-size: 17px; margin: 16px 0 8px; }
.doc-content h4, .doc-content h5, .doc-content h6 { font-size: 15px; margin: 14px 0 6px; font-weight: 700; }
.doc-content h1, .doc-content h2, .doc-content h3, .doc-content h4 { color: #1f2937; line-height: 1.4; }
.doc-content p { margin: 0 0 10px; }
.doc-content ul, .doc-content ol { margin: 0 0 12px; padding-left: 26px; }
.doc-content li { margin-bottom: 4px; }
.doc-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 14px 0;
  font-size: 13.5px;
}
.doc-content table td, .doc-content table th {
  border: 1px solid #d0d5dd;
  padding: 7px 10px;
  vertical-align: top;
}
.doc-content table th, .doc-content table tr:first-child td { background: #f5f7fa; font-weight: 600; }
.doc-content img { max-width: 100%; height: auto; border-radius: 4px; margin: 6px 0; }
.doc-content a { color: var(--primary); }
.doc-content blockquote { border-left: 3px solid var(--border-hover); padding-left: 14px; color: var(--text-sub); margin: 10px 0; }
.doc-content hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.doc-content pre, .doc-content code { background: #f5f7fa; border-radius: 4px; font-family: Consolas, monospace; }
.doc-content code { padding: 1px 5px; font-size: 13px; }
.doc-content pre { padding: 12px; overflow-x: auto; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90dvh;
  overflow: auto;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 16px; }
.modal-close { background: none; border: none; font-size: 15px; cursor: pointer; color: var(--text-sub); padding: 4px 8px; border-radius: 4px; }
.modal-close:hover { background: #f1f3f5; color: var(--text); }
.modal-body { padding: 18px 20px; }
.modal-doc { font-weight: 600; margin-bottom: 14px; color: var(--text); }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab {
  background: none; border: none; border-bottom: 2px solid transparent;
  padding: 8px 12px; font-size: 14px; font-family: inherit;
  color: var(--text-sub); cursor: pointer;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.hint { font-size: 12px; color: var(--text-sub); margin-top: 8px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%; bottom: 36px;
  transform: translateX(-50%);
  background: #303a46;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  max-width: 80vw;
  animation: toastIn .2s ease-out;
}
.toast.err { background: var(--danger); }
.toast.ok { background: var(--success); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- 展示页 / 管理页 ---------- */

/* 只读行的「查看」提示 */
.row-hint { font-size: 12px; color: var(--text-sub); white-space: nowrap; }
.doc-item:hover .row-hint { color: var(--primary); }

/* 展示页列表说明（与标题同区块，间距收紧） */
.list-desc { margin-bottom: 0; }

/* 管理页顶栏标识 */
.admin-flag {
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #c2410c;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

/* 未登录守卫遮罩 */
.guard-mask {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.guard-sub { font-size: 12px; color: var(--text-sub); }

/* 密码弹窗：更窄的紧凑变体 */
.modal-sm { max-width: 400px; }
.form-row-tight { margin-bottom: 8px; }

/* 密码输入错误态 */
input[type="password"] {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
input[type="password"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .15);
}
.modal-tip.err { color: var(--danger); }
.modal-tip.ok { color: var(--success); }

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .container { padding: 16px 12px 48px; }
  .card { padding: 16px; }
  .doc-viewer { padding: 24px 18px; margin: 12px; }
  .search-input { width: 100%; }
  .list-tools { width: 100%; }
  .doc-item { flex-wrap: wrap; }
  .brand-text { font-size: 15px; }
  .admin-flag { display: none; }
}
