/* 图片排版（工具箱 /tools/picpai/）专用样式。
 *
 * 来源：根目录 picpai.html（独立的纯前端设计稿）。接站时做了四件事：
 *
 * 1. **作用域隔离**：原稿用了 .card / .panel / .field / .help 这类通用类名，而
 *    app.css 里同名的就有 .card（6 处）、.panel（3 处）、.field（4 处）、.help（1 处）。
 *    所以本文件**每一条规则都挂在 .picpai-page 下** —— 既保证本页不被全站样式冲掉，
 *    也保证本页的样式不会泄漏到别的页面。改类名要同时改 static/js/tools_picpai.js，
 *    那个文件只认 ID 和这些类名。
 *
 * 2. **主题对齐站点**：原稿主色是亮蓝 #4a6cf7（自带紫色渐变 header），换成
 *    app.css 的深海军蓝（--navy #0d2540 → #14355c → #1d4a7c）+ 金色点缀，
 *    header/footer 交给 base.html（站点已有 sticky 顶栏与页脚），这里只留工具自己的 hero。
 *
 * 3. **内联样式清零**：原稿的 <style> 块和 <div style="..."> 全部移到这里 / JS。
 *    CSP 的 style-src 收在 'self'（见 middleware.build_csp），内联样式会被静默拦截 ——
 *    而开发档 CSP_ENABLED=False，**本地看不出问题，只有生产会掉样式**。
 *
 * 4. **窄屏自适应**：★ 所有 grid 轨道一律写 `minmax(0,1fr)`，不写 `1fr`。
 *    `1fr` 的轨道下限是 `auto` = 子项 min-content，压不下去会把布局视口撑大，
 *    表现为「手机端整页缩小、媒体查询写了却不生效」（SOP 坑 22，2026-10-11 实测过）。
 */

/* 整幅铺开：站点默认 main 只有 46rem（--measure），会把双栏压扁。 */
main.page-picpai { max-width: none; padding: 0; }

.picpai-page {
  --pp-navy: #0d2540;
  --pp-navy-2: #14355c;
  --pp-navy-3: #1d4a7c;
  --pp-gold: #c8a45c;
  --pp-ink: #24292f;
  --pp-muted: #6a737d;
  --pp-line: #e4e8ee;
  --pp-line-strong: #cdd6e0;
  --pp-soft: #eef3fa;
  --pp-focus: #b9cdf5;
  --pp-danger-line: #f5c6c6;
  --pp-danger-bg: #fde8e8;
  --pp-warn-line: #e6c35c;
  --pp-warn-bg: #fff8e6;
  color: var(--pp-ink);
}

/* ── 顶部提示条（组件加载失败 / 脚本报错） ───────────────────────────── */
.picpai-page .pp-bar { padding: 10px 20px; font-size: 13px; }
.picpai-page .pp-bar-warn { background: var(--pp-warn-bg); color: #8a5a00; border-bottom: 1px solid var(--pp-warn-line); }
.picpai-page .pp-bar-err { background: var(--pp-danger-bg); color: #b42318; border-bottom: 1px solid var(--pp-danger-line); word-break: break-all; }

/* ── Hero：站点深蓝渐变（与 /tools/fee/ 同一套语言） ─────────────────── */
.picpai-page .pp-hero {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--pp-navy) 0%, var(--pp-navy-2) 55%, var(--pp-navy-3) 100%);
  color: #fff; padding: 26px 16px; text-align: center;
}
/* 装饰水印：纯视觉，用 ::after 而不是真实元素，免得被读屏念出来。 */
.picpai-page .pp-hero::after {
  content: '🖼'; position: absolute; right: -26px; top: -34px;
  font-size: 200px; opacity: .08; transform: rotate(-12deg);
}
.picpai-page .pp-hero h1 { position: relative; margin: 0; font-size: 26px; font-weight: 800; letter-spacing: 1px; color: #fff; }
.picpai-page .pp-hero p { position: relative; margin-top: 8px; font-size: 13px; opacity: .88; }

/* ── 双栏布局 ────────────────────────────────────────────────────────── */
/* ★ 右列 `minmax(0,1fr)`：写 `1fr` 会让轨道下限变成子项 min-content，
 *   窄屏压不下去 → 布局视口被撑大 → 手机整页缩小。详见文件头第 4 条。 */
.picpai-page .pp-wrap {
  max-width: 1400px; margin: 0 auto; padding: 16px;
  display: grid; grid-template-columns: 370px minmax(0, 1fr);
  gap: 16px; align-items: start;
}
/* 栅格项同样要 min-width:0，否则内容（长文件名 / 预览页）会把轨道顶开。 */
.picpai-page .pp-panel { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.picpai-page .pp-work { min-width: 0; }

/* ── 卡片 / 表单 ─────────────────────────────────────────────────────── */
.picpai-page .card {
  background: #fff; border: 1px solid var(--pp-line); border-radius: var(--pp-radius);
  padding: 16px; box-shadow: 0 1px 3px rgba(16, 24, 40, .06);
}
.picpai-page .card h2 { font-size: 14px; margin: 0 0 12px; color: #1a2233; }
.picpai-page .field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.picpai-page span.lbl { font-size: 12px; color: #5c6470; }
.picpai-page select,
.picpai-page input[type=text],
.picpai-page input[type=number] {
  height: 34px; border: 1px solid var(--pp-line); border-radius: 8px; padding: 0 9px;
  font-size: 13px; background: #fff; color: var(--pp-ink); width: 100%;
}
.picpai-page select:focus,
.picpai-page input:focus { outline: 2px solid var(--pp-focus); border-color: var(--pp-navy); }
/* ★ 两列同样用 minmax(0,1fr)，理由见文件头第 4 条。 */
.picpai-page .grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px 12px; }
.picpai-page .checks { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 13px; margin-bottom: 10px; }
.picpai-page .check { display: flex; align-items: center; gap: 5px; cursor: pointer; font-size: 13px; }
/* 下面两个类是原稿里 `style="display:flex;justify-content:space-between"` 与
   `style="margin-top:10px"` 的替身 —— 内联样式会被 CSP 的 style-src 拦掉。 */
.picpai-page .pp-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.picpai-page .pp-gap { margin-top: 10px; }
.picpai-page .check.pp-gap { margin: 8px 0 12px; }
.picpai-page .hint { font-size: 12px; color: var(--pp-muted); line-height: 1.6; margin-top: 8px; }
.picpai-page .stats { font-size: 13px; color: #3a4353; }

/* ── 上传区 ──────────────────────────────────────────────────────────── */
.picpai-page .dropzone {
  display: block; border: 2px dashed #c5cdea; border-radius: 10px; padding: 22px 12px;
  text-align: center; cursor: pointer; color: #5c6470; font-size: 13px;
  background: var(--pp-soft); transition: .15s;
}
.picpai-page .dropzone:hover,
.picpai-page .dropzone.drag { border-color: var(--pp-navy); background: #e3ebf7; color: var(--pp-navy); }
.picpai-page .dz-main { display: block; }
.picpai-page .dz-sub { display: block; font-size: 11.5px; opacity: .7; margin-top: 5px; }

/* ── 按钮 ────────────────────────────────────────────────────────────── */
.picpai-page .btn { border: none; border-radius: 8px; cursor: pointer; font-size: 13px; transition: .15s; }
.picpai-page .btn-primary { background: var(--pp-navy); color: #fff; }
.picpai-page .btn-primary:hover:not(:disabled) { background: var(--pp-navy-2); }
.picpai-page .btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.picpai-page .btn-ghost { background: #fff; border: 1px solid var(--pp-line); color: #3a4353; }
.picpai-page .btn-ghost:hover:not(:disabled) { background: var(--pp-soft); border-color: var(--pp-line-strong); }
.picpai-page .btn-ghost:disabled { opacity: .4; cursor: default; }
.picpai-page .btn-sm { padding: 6px 12px; }
.picpai-page .btn-block { width: 100%; height: 42px; font-size: 14px; font-weight: 600; }

.picpai-page .sample {
  margin-top: 10px; background: var(--pp-soft); border: 1px dashed #d5dcf2;
  border-radius: 8px; padding: 8px 10px; font-size: 13px;
}
.picpai-page .sample span { color: var(--pp-navy); font-weight: 600; word-break: break-all; }

/* ── 标签页 ──────────────────────────────────────────────────────────── */
.picpai-page .tabs-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 8px; }
.picpai-page .tabs { display: flex; gap: 8px; }
.picpai-page .tab-btn {
  padding: 8px 16px; border: 1px solid var(--pp-line); background: #fff;
  border-radius: 8px; cursor: pointer; font-size: 13px;
}
.picpai-page .tab-btn.active { background: var(--pp-navy); color: #fff; border-color: var(--pp-navy); }

/* ── 预览区 ──────────────────────────────────────────────────────────── */
.picpai-page .preview-toolbar { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 12px; }
.picpai-page .page-info { font-size: 13px; color: var(--pp-muted); min-width: 70px; text-align: center; }
/* ★ 用 min(x, 100%) 而不是固定 px：JS 原先写的是内联 max-width:620px，
 *   内联样式优先级最高，窄屏会把容器顶出屏幕。改成类切换 + min() 后天然自适应。 */
.picpai-page .page-holder { display: flex; justify-content: center; max-width: min(620px, 100%); margin: 0 auto; }
.picpai-page .page-holder.is-landscape { max-width: min(880px, 100%); }
.picpai-page .preview-page {
  width: 100%; background: #fff; box-shadow: 0 2px 14px rgba(20, 30, 60, .14);
  display: grid; padding: var(--padpct, 8%); gap: 2px;
}
.picpai-page .preview-page.no-items { display: flex; align-items: center; justify-content: center; }
.picpai-page .pv-hint { color: #9aa3b2; font-size: 14px; text-align: center; padding: 20px; }
.picpai-page .pv-cell { display: flex; flex-direction: column; min-width: 0; min-height: 0; align-items: center; }
.picpai-page .pv-cell.empty {
  border: 1px dashed var(--pp-line); margin: 2px; border-radius: 4px;
  background: repeating-linear-gradient(45deg, #fafbfd, #fafbfd 8px, #f3f5f9 8px, #f3f5f9 16px);
}
.picpai-page .pv-img { flex: 1 1 0; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; }
.picpai-page .pv-img img {
  max-width: 100%; max-height: 100%; aspect-ratio: var(--ar, 4/3);
  object-fit: var(--of, contain); background: #fff;
}
.picpai-page .pv-cap {
  width: 100%; text-align: center;
  font-size: calc(var(--u, 10) * var(--capsize, 0.37) * 1px);
  font-weight: var(--capbold, 400); font-family: var(--capfont, inherit);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding: 0 2px; line-height: 1.35;
}

/* ── 图片管理列表 ────────────────────────────────────────────────────── */
.picpai-page .file-list { display: flex; flex-direction: column; gap: 8px; max-height: 74vh; overflow: auto; padding-right: 4px; }
.picpai-page .file-item {
  display: flex; align-items: center; gap: 10px; background: #fff;
  border: 1px solid var(--pp-line); border-radius: 10px; padding: 8px 10px;
}
.picpai-page .fi-idx {
  min-width: 56px; max-width: 96px; font-size: 12.5px; color: var(--pp-navy);
  font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex-shrink: 0;
}
.picpai-page .fi-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; background: #f0f2f7; flex-shrink: 0; }
.picpai-page .fi-meta { flex: 1; min-width: 0; }
.picpai-page .fi-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picpai-page .fi-size { font-size: 11.5px; color: #8a919e; margin-top: 2px; }
.picpai-page .fi-ops { display: flex; gap: 4px; flex-shrink: 0; }
.picpai-page .fi-ops button {
  width: 28px; height: 28px; border: 1px solid var(--pp-line); background: #fff;
  border-radius: 6px; cursor: pointer; font-size: 13px; color: #4a5568;
}
.picpai-page .fi-ops button:hover:not(:disabled) { background: var(--pp-soft); border-color: var(--pp-line-strong); }
.picpai-page .fi-ops button:disabled { opacity: .35; cursor: default; }
.picpai-page .empty { color: #9aa3b2; font-size: 13px; text-align: center; padding: 30px 0; }

/* ── 底部说明（站点页脚之上，只放本工具自己的隐私说明） ──────────────── */
.picpai-page .pp-note {
  max-width: 1400px; margin: 0 auto; padding: 0 16px 28px; font-size: 12.5px;
  color: var(--pp-muted); line-height: 1.8;
}
.picpai-page .pp-note strong { color: var(--pp-ink); }
.picpai-page .pp-note ul { margin: 6px 0 0; padding-left: 1.2em; }

.picpai-page .toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: var(--pp-ink); color: #fff; padding: 9px 18px; border-radius: 8px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: .25s; z-index: 99;
}
.picpai-page .toast.show { opacity: 1; transform: translateX(-50%); }

/* ── 窄屏 ────────────────────────────────────────────────────────────── */
/* 单列断点同样写 minmax(0,1fr)，理由见文件头第 4 条。 */
@media (max-width: 980px) {
  .picpai-page .pp-wrap { grid-template-columns: minmax(0, 1fr); padding: 12px; }
  .picpai-page .pp-panel { width: 100%; }
}
@media (max-width: 560px) {
  .picpai-page .pp-hero { padding: 20px 14px; }
  .picpai-page .pp-hero h1 { font-size: 21px; }
  .picpai-page .pp-hero::after { display: none; }
  .picpai-page .pp-wrap { padding: 10px; gap: 12px; }
  .picpai-page .card { padding: 12px; }
  /* 两列在 <360px 会挤：改成单列，字段仍是全宽，读起来比硬压舒服。 */
  .picpai-page .grid2 { grid-template-columns: minmax(0, 1fr); }
  .picpai-page .file-list { max-height: none; }
  .picpai-page .tabs-row { flex-direction: column; align-items: stretch; }
  .picpai-page .tabs { justify-content: center; }
}
