/* 电子画册 · 管理后台样式 */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f4f6f9;
  --panel: #ffffff;
  --border: #e5e8ee;
  --text: #1f2937;
  --text-sub: #6b7280;
  --danger: #dc2626;
  --ok: #16a34a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
}

[v-cloak] { display: none; }
[hidden] { display: none !important; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }

/* ---------------- 登录 ---------------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 60%, #1e3a8a 100%);
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 16px;
  padding: 36px 32px 30px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
  text-align: center;
}
.login-logo { font-size: 40px; line-height: 1; }
.login-card h1 { font-size: 20px; margin: 12px 0 2px; }
.login-sub { color: var(--text-sub); font-size: 13px; margin: 0 0 22px; }
.login-card .btn-block { width: 100%; margin-top: 6px; padding: 11px; }

/* ---------------- 顶栏 ---------------- */
.app-shell { min-height: 100vh; }
.topbar {
  height: 58px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 16px; }
.brand-icon { font-size: 20px; }
.brand-tag {
  font-size: 11px;
  font-weight: 500;
  color: var(--primary);
  background: #eff4ff;
  border-radius: 4px;
  padding: 1px 6px;
}
.topbar-right { display: flex; gap: 6px; }

.banner-warn {
  background: #fff7ed;
  border-bottom: 1px solid #fed7aa;
  color: #9a3412;
  padding: 9px 22px;
  font-size: 13px;
}

/* ---------------- 容器 ---------------- */
.container { max-width: 1280px; margin: 0 auto; padding: 24px 22px 60px; }
.toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.toolbar-actions { display: flex; gap: 10px; align-items: center; }
.page-title { font-size: 20px; font-weight: 600; margin: 0; }
.page-sub { color: var(--text-sub); font-size: 13px; margin: 2px 0 0; }
.search { width: 220px; }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all .16s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { border-color: #cbd5e1; background: #f8fafc; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-ghost { border-color: transparent; }
.btn-ghost:hover { background: #f1f5f9; border-color: transparent; }
.btn-sm { padding: 4px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-danger-ghost { color: var(--danger); }
.btn-danger-ghost:hover { background: #fef2f2; border-color: #fecaca; }
.btn-block { display: flex; width: 100%; }

/* ---------------- 表单 ---------------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--text-sub); margin-bottom: 5px; font-weight: 500; }
.input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color .16s, box-shadow .16s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
textarea.input { resize: vertical; }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }
.input.color { padding: 3px; height: 34px; cursor: pointer; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.check { display: flex; align-items: center; gap: 7px; font-size: 13.5px; cursor: pointer; }
.check input { width: 15px; height: 15px; accent-color: var(--primary); }
.hint { font-size: 12.5px; color: var(--text-sub); margin: 6px 0 0; }
.err { color: var(--danger); font-size: 13px; margin: 8px 0 0; }
.muted { color: var(--text-sub); }
.muted-link { color: var(--text-sub); font-size: 13px; }

/* ---------------- 卡片网格 ---------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
}
.book-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .18s, box-shadow .18s;
}
.book-card:hover { transform: translateY(-3px); box-shadow: 0 8px 26px rgba(16, 24, 40, .12); }
.cover {
  position: relative;
  aspect-ratio: 3 / 4;
  background: linear-gradient(150deg, #334155, #0f172a);
  cursor: pointer;
  overflow: hidden;
}
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 46px;
  font-weight: 700;
  color: rgba(255, 255, 255, .35);
  background: linear-gradient(150deg, #475569, #1e293b);
}
.badge {
  position: absolute;
  top: 9px;
  right: 9px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  color: #fff;
  backdrop-filter: blur(3px);
}
.badge-live { background: rgba(22, 163, 74, .9); }
.badge-draft { background: rgba(100, 116, 139, .92); }
.badge-expired { background: rgba(220, 38, 38, .9); }
.card-body { padding: 12px 13px 13px; }
.card-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-meta { font-size: 12.5px; color: var(--text-sub); margin-bottom: 10px; display: flex; align-items: center; gap: 5px; }
.card-meta .dot { color: #cbd5e1; }
.card-meta .lock { margin-left: auto; }
.card-actions { display: flex; flex-wrap: wrap; gap: 5px; }

/* ---------------- 空状态 ---------------- */
.empty { color: var(--text-sub); padding: 40px; text-align: center; }
.empty-state { text-align: center; padding: 70px 20px; }
.empty-art { font-size: 54px; opacity: .8; }
.empty-title { font-size: 17px; font-weight: 600; margin: 12px 0 4px; }
.empty-desc { color: var(--text-sub); margin: 0 0 20px; }

/* ---------------- 编辑页 ---------------- */
.edit-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.edit-head .spacer { flex: 1; }
.edit-layout { display: grid; grid-template-columns: 1fr 320px; gap: 18px; align-items: start; }
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.panel-title { font-size: 14.5px; font-weight: 600; margin: 0 0 14px; padding-bottom: 10px; border-bottom: 1px solid #f1f3f7; }
.edit-side { position: sticky; top: 78px; }

.upload-inline, .upload-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.uploading { font-size: 12.5px; color: var(--primary); }
.file-info { background: #f8fafc; border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
.file-name { font-size: 13px; font-weight: 500; word-break: break-all; }
.file-size { font-size: 12px; color: var(--text-sub); }

.theme-row { display: flex; gap: 8px; flex-wrap: wrap; }
.theme-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  color: #fff;
  font-size: 12.5px;
  transition: border-color .15s;
}
.theme-chip span { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.theme-chip.active { border-color: var(--primary); }

.toc-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.toc-item { display: grid; grid-template-columns: 1fr 90px auto; gap: 8px; }
.toc-page { text-align: center; }

.share-link { display: flex; gap: 8px; }
.share-link .input { font-size: 12.5px; }
.qr-mini { text-align: center; margin-top: 12px; }
.qr-mini img { width: 150px; height: 150px; border: 1px solid var(--border); border-radius: 8px; padding: 6px; background: #fff; }
.logo-preview {
  background: repeating-conic-gradient(#f1f5f9 0% 25%, #fff 0% 50%) 50% / 16px 16px;
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}
.logo-preview img { max-width: 100%; max-height: 90px; object-fit: contain; }

/* ---------------- 模态 ---------------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  background: #fff;
  border-radius: 14px;
  padding: 24px;
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .3);
}
.modal-wide { max-width: 860px; }
.modal-center { max-width: 420px; text-align: center; }
.modal-title { font-size: 16.5px; font-weight: 600; margin: 0 0 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.sub-title { font-size: 13px; font-weight: 600; margin: 20px 0 10px; color: var(--text-sub); }

.dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: 10px;
  padding: 26px 16px;
  text-align: center;
  cursor: pointer;
  transition: all .16s;
  background: #fafbfc;
}
.dropzone:hover, .dropzone.over { border-color: var(--primary); background: #f5f8ff; }
.dz-icon { font-size: 30px; }
.dz-text { margin: 8px 0 0; font-size: 13px; color: var(--text-sub); word-break: break-all; }
.progress { height: 6px; background: #eef2f7; border-radius: 4px; overflow: hidden; margin-top: 14px; }
.progress .bar { height: 100%; background: var(--primary); transition: width .2s; }

.qr-box { display: flex; justify-content: center; min-height: 220px; align-items: center; }
.qr-box img { width: 220px; height: 220px; border: 1px solid var(--border); border-radius: 10px; padding: 8px; background: #fff; }
.qr-tip { font-size: 13px; color: var(--text-sub); margin: 12px 0; }

/* ---------------- 统计 ---------------- */
.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat-card { background: #f8fafc; border-radius: 10px; padding: 14px; text-align: center; }
.stat-num { font-size: 21px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 12px; color: var(--text-sub); margin-top: 2px; }
.chart { display: flex; align-items: flex-end; gap: 4px; height: 130px; padding: 10px; background: #f8fafc; border-radius: 10px; overflow-x: auto; }
.chart-col { flex: 1 0 14px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.chart-bar { width: 100%; max-width: 22px; background: linear-gradient(180deg, #60a5fa, #2563eb); border-radius: 3px 3px 0 0; min-height: 3px; }
.chart-label { font-size: 9px; color: var(--text-sub); margin-top: 4px; white-space: nowrap; }
.kv-list { list-style: none; margin: 0; padding: 0; }
.kv-list li { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed #eef2f7; font-size: 13px; }
.kv-k { color: var(--text-sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 74%; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th { background: #f8fafc; text-align: left; padding: 8px 10px; font-weight: 600; color: var(--text-sub); white-space: nowrap; }
.table td { padding: 8px 10px; border-top: 1px solid #f1f3f7; white-space: nowrap; }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translate(-50%, 20px);
  background: #1f2937;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: all .25s;
  z-index: 200;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #b91c1c; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 900px) {
  .edit-layout { grid-template-columns: 1fr; }
  .edit-side { position: static; }
  .row-2, .row-3 { grid-template-columns: 1fr; }
  .stat-cards { grid-template-columns: 1fr 1fr; }
  .container { padding: 16px 14px 50px; }
  .topbar { padding: 0 14px; }
  .brand-tag { display: none; }
  .toolbar { align-items: stretch; }
  .search { width: 100%; }
  .toolbar-actions { width: 100%; }
}

/* ---------------- 拖拽排序 ---------------- */
.book-card[draggable="true"] { cursor: grab; }
.book-card.dragging { opacity: .45; }
.book-card.drop-target { outline: 2px dashed var(--primary); outline-offset: 2px; }
.drag-handle {
  position: absolute;
  top: 8px;
  left: 9px;
  z-index: 3;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: rgba(15, 23, 42, .55);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: grab;
  user-select: none;
}
.book-card { position: relative; }

/* ---------------- 批量上传文件列表 ---------------- */
.picked-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  max-height: 180px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.picked-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.picked-list li:last-child { border-bottom: none; }
.picked-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mini-x {
  border: none;
  background: transparent;
  color: var(--text-sub);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  border-radius: 4px;
}
.mini-x:hover { background: #fee2e2; color: var(--danger); }
.mini-x:disabled { opacity: .4; cursor: not-allowed; }

/* ---------------- 封面编辑 ---------------- */
.cover-editor { display: flex; gap: 16px; align-items: flex-start; }
.cover-thumb {
  width: 96px;
  aspect-ratio: 3 / 4;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #f1f5f9;
  flex: none;
}
.cover-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-ph {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--text-sub);
}
.cover-ops { flex: 1; min-width: 0; }

/* ---------------- 顶部导航 ---------------- */
.main-nav { display: flex; gap: 4px; }
.main-nav button {
  border: none;
  background: transparent;
  color: var(--text-sub);
  font-size: 13.5px;
  font-family: inherit;
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s;
}
.main-nav button:hover { background: #f1f5f9; color: var(--text); }
.main-nav button.active { background: #eff4ff; color: var(--primary); font-weight: 600; }

/* ---------------- 看板 ---------------- */
.stat-6 { grid-template-columns: repeat(6, 1fr); }
.dash-grid { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 24px; margin-top: 6px; }
.dash-grid .kv-k a { color: var(--text); }
.dash-grid .kv-k a:hover { color: var(--primary); }

/* ---------------- 功能开关网格 ---------------- */
.feat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px 14px;
  background: #f8fafc;
  border-radius: 10px;
  padding: 12px 14px;
}

/* ---------------- 联系方式编辑 ---------------- */
.ct-edit { display: flex; flex-direction: column; gap: 8px; }
.ct-row { display: grid; grid-template-columns: 92px 1fr 1.4fr auto; gap: 8px; align-items: center; }
.ct-type { padding-right: 26px; }

/* ---------------- 留言 ---------------- */
.msg-cell { white-space: normal !important; max-width: 340px; word-break: break-all; }

@media (max-width: 900px) {
  .main-nav { order: 3; width: 100%; justify-content: center; }
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 14px; gap: 6px; }
  .stat-6 { grid-template-columns: repeat(3, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
  .feat-grid { grid-template-columns: 1fr 1fr; }
  .ct-row { grid-template-columns: 1fr; }
}
