/* ============================================================
   PhotoStudio.css —— 编辑与导出中台「独立控制层」外观（2026-11-26）
   编排 ImageViewer 已有的中台 DOM，不改其事件/状态真源：
     · 三栏：左=控件、中=照片预览、右=照片缩略图侧栏
     · 尺寸向 AI 对话面板对齐（贴边大面板，不再是 460/1080 居中小窗）
     · 缩略图侧栏：平台筛选结果 + 本地上传，点击联动水印内容
   设计令牌全部从 .iv-container / :root 继承（与 ImageViewer 同一套 light-dark）。
   ============================================================ */

/* ── 中台卡片：贴边大面板（对齐 .ac-shell 的 inset:18px）── */
.iv-modal-card.ps-studio {
  width: min(1500px, calc(100vw - 36px));
  /* 2026-11-26：整体再降一档（视口高 -160px，950 视口 → 790px）。
     高度仍固定，左右栏才能 height:100% 内部滚动；预览棋盘格自己按 4:3 居中。 */
  max-height: calc(100dvh - 160px);
  height: calc(100dvh - 160px);
}
/* 预览棋盘格固定 4:3（按中栏宽度缩放），在中栏里垂直居中 —— 图片铺满 4:3，
   上下留白与左右一致，不再因卡片高而在上下堆出大片空棋盘格。 */
.iv-modal-card.ps-studio .iv-preview-pane {
  padding: 6px;
  flex: 0 0 auto;
  width: 100%;
  max-height: 100%;
  aspect-ratio: 4 / 3;
  height: auto;
  margin: auto;
}
/* 加载态占位与预览区同尺寸并居中，避免图片未到时棋盘格上下跳动 */
.iv-modal-card.ps-studio .iv-stage-loading {
  flex: 0 0 auto;
  width: 100%;
  max-height: 100%;
  aspect-ratio: 4 / 3;
  height: auto;
  margin: auto;
}
.iv-modal-card.ps-studio .iv-modal-body {
  padding: 10px 14px 12px;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
}

/* ── 三栏网格：控件(左) / 预览(中) / 照片列表(右) ── */
.iv-modal-card.ps-studio .iv-studio-grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 320px;
  gap: 14px;
  width: 100%;
  height: 100%;
  min-height: 0;
  align-items: stretch;
}
/* 中栏垂直居中预览棋盘格（4:3 固定高，剩余空间上下均分） */
.iv-modal-card.ps-studio .iv-studio-stage {
  justify-content: center;
}
/* 顶部范围 radio 由右栏四个按钮接管；状态仍写回原 radio（导出/信息表同源） */
.iv-modal-card.ps-studio .iv-head-scope { display: none; }
/* 左栏控件（原 .iv-studio-panel）用 order 移到最前 */
.iv-modal-card.ps-studio .iv-studio-panel {
  grid-column: 1;
  grid-row: 1;
  flex: none;
  width: auto;
  height: 100%;
  overflow-y: auto;
  padding-right: 6px;
}
/* 中栏预览（原 .iv-studio-stage） */
.iv-modal-card.ps-studio .iv-studio-stage {
  grid-column: 2;
  grid-row: 1;
  height: 100%;
  min-height: 0;
}
/* 右栏缩略图侧栏由 PhotoStudio.js 注入，grid-column:3 */

/* ── 右侧照片列表：与 AI 对话右栏同款「分组头 + 三列缩略图」 ── */
.ps-thumbs {
  grid-column: 3;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--iv-line);
  border-radius: var(--iv-radius-sm);
  background: var(--iv-bg);
  overflow: hidden;
}
.ps-thumbs.over { border-color: var(--iv-shoot-fg); background: var(--iv-accent-soft, var(--iv-bg)); }
.ps-thumbs-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border-bottom: 1px solid var(--iv-line);
  flex: 0 0 auto;
}
.ps-thumbs-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--iv-fg);
  font-weight: 600;
}
.ps-thumbs-title b { color: var(--iv-day-dim); font-weight: 500; }
/* 四个范围按钮：当前这张 / 点位照片 / 文件夹 / 本地照片 */
.ps-scope-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 3px;
}
.ps-scope-tabs button {
  min-width: 0;
  padding: 5px 2px;
  border: 1px solid var(--iv-line-strong);
  border-radius: 5px;
  background: var(--iv-surface);
  color: var(--iv-fg);
  font-family: inherit;
  font-size: 10.5px;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
}
.ps-scope-tabs button:hover { border-color: var(--iv-shoot-fg); }
.ps-scope-tabs button[aria-pressed="true"] {
  background: var(--iv-accent);
  border-color: var(--iv-accent);
  color: light-dark(#fff, #06263f);
}
.ps-scope-tabs button.off { opacity: 0.4; cursor: default; pointer-events: none; }
/* 文件夹下拉移到列表上方（DOM 真源仍是 ImageViewer 的 #iv-exp-folder） */
.ps-folder-slot:empty { display: none; }
.ps-folder-slot .iv-folder-row { margin-top: 0; }
.ps-thumbs-tools { display: flex; flex-wrap: wrap; gap: 4px; }
.ps-thumbs-tools .ps-tbtn {
  flex: 1 1 auto;
  min-width: 56px;
  padding: 4px 6px;
  border: 1px solid var(--iv-line-strong);
  border-radius: 5px;
  background: var(--iv-surface);
  color: var(--iv-fg);
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  text-align: center;
}
.ps-thumbs-tools .ps-tbtn:hover { border-color: var(--iv-shoot-fg); }
.ps-thumbs-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px;
}
.ps-thumbs-list::-webkit-scrollbar { width: 6px; }
.ps-thumbs-list::-webkit-scrollbar-thumb { background: var(--iv-scrollbar); border-radius: 3px; }
.ps-group + .ps-group { margin-top: 8px; }
/* 分页后分组头是列表直接子节点（不再套 .ps-group），自己留段间距 */
.ps-group-head { margin-top: 8px; }
.ps-group-head:first-child { margin-top: 0; }
.ps-group-head, .ps-day-head {
  padding: 4px 2px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--iv-fg);
}
.ps-day-head { font-size: 10.5px; color: var(--iv-day-dim); font-weight: 500; }
.ps-photo-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}
.ps-thumb {
  position: relative;
  aspect-ratio: 1;
  border: 1px solid var(--iv-line);
  border-radius: 4px;
  overflow: hidden;
  background: var(--iv-surface);
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.ps-thumb:hover { border-color: var(--iv-shoot-fg); }
.ps-thumb.on {
  border-color: var(--iv-shoot-fg);
  box-shadow: inset 0 0 0 2px var(--iv-shoot-fg);
}
.ps-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
/* 缩略图加载失败：不显示浏览器破图图标，用文字占位（与平台时间线同口径） */
.ps-thumb.broken img { display: none; }
.ps-thumb.broken::after {
  content: "无缩略图";
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;
  background: var(--iv-bg); color: var(--iv-fg-dim); font-size: 10px;
}
.ps-thumb-badge {
  position: absolute;
  left: 3px; bottom: 3px;
  max-width: calc(100% - 6px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 9px;
  line-height: 1.2;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
}
/* 分页提示：滚动到底自动加载下一页，不是按钮 */
.ps-thumbs-more {
  padding: 10px 4px 14px;
  text-align: center;
  font-size: 11px;
  color: var(--iv-day-dim);
}
.ps-thumbs-empty {
  padding: 24px 8px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--iv-day-dim);
  text-align: center;
}
.ps-thumbs-file { display: none; }

/* ── 中台打开时的全屏拖拽接管遮罩（2026-11-26）──
   与 Leaflet.UserLayers 的矢量导入遮罩同款层级策略：只看得见、不接事件；
   真正的文件接收在 window 捕获阶段由 PhotoStudio 统一处理。z-index 比
   UserLayers 99998 再高一档，保证拖到 AI 面板/地图上也不会被矢量层抢走。 */
.ps-drop-veil {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 16, 26, 0.5);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease;
}
.ps-drop-veil.on { opacity: 1; }
.ps-drop-veil .ps-drop-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 26px 40px;
  border: 2px dashed rgba(255, 255, 255, 0.72);
  border-radius: 14px;
  max-width: 78vw;
  background: rgba(18, 24, 34, 0.78);
  color: #fff;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.36);
}
.ps-drop-veil .ps-drop-ico { font-size: 28px; line-height: 1; }
.ps-drop-veil .ps-drop-t { font-size: 16px; font-weight: 600; }
.ps-drop-veil .ps-drop-s {
  font-size: 12px;
  line-height: 1.6;
  opacity: 0.76;
  max-width: 420px;
  word-break: break-word;
}

/* ── 批量信息表独立中台（由头部「📋 信息表」按钮打开，默认隐藏）── */
.ps-batch-stage {
  position: absolute;
  inset: 52px 14px 14px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  overflow: hidden;          /* 顶部固定，只有 .iv-batch-table 内部滚动 */
  padding: 12px 14px;
  border: 1px solid var(--iv-line);
  border-radius: var(--iv-radius-sm);
  background: var(--iv-overlay, var(--iv-bg));
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}
.ps-batch-stage[hidden] { display: none; }
/* 表格：前半「图片+图名」固定宽，后半信息列均分；横向可滚动、表头 sticky */
.ps-batch-stage .iv-batch-table { flex: 1 1 auto; max-height: none; }
.ps-batch-stage .iv-batch-row {
  grid-template-columns: 200px repeat(6, minmax(96px, 1fr)) 52px;
  min-width: 940px;
  padding: 6px 8px;
}
.ps-batch-stage .iv-batch-name img { width: 40px; height: 30px; }
.ps-batch-stage .iv-batch-name { font-size: 11px; }
.ps-batch-stage .iv-batch-row input { font-size: 12px; padding: 5px 6px; }
/* 信息表标题：加粗居中 + 实底（原透明底压在按钮行上不清楚） */
.ps-batch-stage .iv-batch-top {
  position: relative; justify-content: flex-end; min-height: 34px;
}
.ps-batch-stage .iv-batch-title {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  margin: 0; flex: none; white-space: nowrap; text-align: center;
  font-size: 15px; font-weight: 800; color: var(--iv-fg);
  padding: 4px 14px;
  border: 1px solid var(--iv-line-strong);
  border-radius: 6px;
  background: var(--iv-surface);
}
@media (max-width: 720px) {
  .ps-batch-stage .iv-batch-title {
    position: static; transform: none; width: 100%; margin-bottom: 4px;
  }
}

/* 侧栏接管上传入口后，隐藏 LocalPhotoStudio 注入在顶部的旧 UI（后台 addFiles 能力仍保留） */
.iv-modal-card.ps-studio .lps-root { display: none; }

/* “打开中台”工具按钮（可挂页面任意处；PhotoStudio.js 也会自动注入一个到顶栏） */
.ps-open-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 9px;
  border: 1px solid var(--iv-line-strong);
  border-radius: 6px;
  background: var(--iv-surface);
  color: var(--iv-fg);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}
.ps-open-btn:hover { border-color: var(--iv-shoot-fg); }
/* 按钮住在备案条里（index.html），跟随备案条的低调外观，别被地图亮底吃掉 */
#beianBar .ps-open-btn {
  padding: 2px 6px;
  font-size: 11px;
  color: #fff;
  background: rgba(0, 0, 0, 0.34);
  border-color: rgba(255, 255, 255, 0.42);
  vertical-align: middle;
}
#beianBar .ps-open-btn:hover { background: rgba(0, 0, 0, 0.55); border-color: #fff; }

/* ── 窄屏（≤1080）：改纵向滚动。
   ⚠️ 旧写法用 grid 三行 + panel 放隐式第 3 行，1fr 会把预览压成 0 高、
   panel 又被 max-height:220px 裁掉 ⇒ 手机端几乎不可用（2026-11-26 实测）。
   现在：预览 / 照片列表 / 控件各给确定高度，body 统一纵向滚动，header/footer 固定。 */
@media (max-width: 1080px) {
  .iv-modal-card.ps-studio .iv-modal-body { overflow-y: auto; }
  .iv-modal-card.ps-studio .iv-studio-grid {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 0;
    gap: 10px;
  }
  .iv-modal-card.ps-studio .iv-studio-stage {
    order: 1;
    flex: 0 0 auto;
    height: 260px;
    min-height: 260px;
  }
  .iv-modal-card.ps-studio .iv-preview-pane { min-height: 180px; }
  .ps-thumbs {
    order: 2;
    flex: 0 0 auto;
    width: 100%;
    height: 280px;
  }
  .ps-scope-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .iv-modal-card.ps-studio .iv-studio-panel {
    order: 3;
    width: 100%;
    height: auto;
    max-height: none;
    flex: 0 0 auto;
    overflow-y: visible;
    padding-right: 0;
  }
}
@media (max-width: 720px) {
  .iv-modal-card.ps-studio {
    /* 别用 100vw + 父级 padding：会溢出居中容器，左侧被裁（实测 x=-38） */
    width: calc(100vw - 20px);
    height: calc(100dvh - 20px);
    max-height: calc(100dvh - 20px);
    border-radius: 8px;
  }
  .iv-modal-card.ps-studio .iv-studio-stage { height: 190px; min-height: 190px; }
  .iv-modal-card.ps-studio .iv-preview-pane { min-height: 130px; }
  .ps-thumbs { height: 230px; }
  .iv-modal-card.ps-studio .iv-modal-body { padding: 8px 10px 10px; }
  /* 窄屏页脚必须换行：否则「原格式/JPEG/PNG + 取消/开始导出」横向溢出，
     聚焦「开始导出」会把卡片 scrollLeft 推走，整块内容左偏被裁。 */
  .iv-modal-card.ps-studio .iv-modal-foot { flex-wrap: wrap; }
  .iv-modal-card.ps-studio .iv-foot-formats { flex: 1 1 100%; justify-content: center; }
  .iv-modal-card.ps-studio .iv-modal-head { padding: 10px 12px; }
}
