/* ============================================================
   照片排版打印工具 — 样式（浅色主题）
   ============================================================ */
:root {
  --bg: #eef1f6;
  --surface: #ffffff;
  --border: #e3e8ef;
  --border-strong: #cbd5e1;
  --text: #1e293b;
  --text-2: #64748b;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --danger: #dc2626;
  --warn: #b45309;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 顶栏 ---------- */
.app-header {
  height: 56px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-logo {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}
.brand-text h1 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: 0.2px; }
.brand-text p { margin: 1px 0 0; font-size: 11px; color: var(--text-2); }
.header-actions { display: flex; gap: 8px; flex: none; }

/* ---------- 主区域 ---------- */
.app-main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 304px 1fr;
}

/* ---------- 左侧边栏 ---------- */
.sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg);
  overflow-y: auto;
  padding: 14px;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.panel-head h2 { margin: 0; font-size: 13.5px; font-weight: 700; display: flex; align-items: center; gap: 7px; }
.count-badge {
  min-width: 20px; height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  background: #f8fafc;
  padding: 16px 12px;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone.hot { border-color: var(--accent); background: var(--accent-soft); }
.dz-icon { color: var(--text-2); display: inline-flex; }
.dz-title { margin: 6px 0 2px; font-weight: 600; font-size: 13px; }
.dz-sub { margin: 0; font-size: 11.5px; color: var(--text-2); }
.link-btn {
  border: 0; background: none; padding: 0;
  color: var(--accent); cursor: pointer;
  font-size: inherit; font-family: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-btn:hover { color: var(--accent-hover); }

.image-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: calc(100vh - 400px);
  overflow-y: auto;
}
.image-list li {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: default;
}
.image-list li:hover { border-color: var(--border-strong); }
.image-list li.dragging { opacity: 0.4; }
.image-list li.drop-before { box-shadow: 0 -2px 0 0 var(--accent); }
.image-list li.drop-after { box-shadow: 0 2px 0 0 var(--accent); }
.image-list li.low .thumb { outline: 2px solid #f59e0b; outline-offset: -1px; }
.thumb {
  width: 40px; height: 40px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #f8fafc;
  flex: none;
}
.meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.name {
  font-size: 12px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dims { font-size: 10.5px; color: var(--text-2); }
.ops { display: flex; gap: 2px; flex: none; }
.lowres-flag {
  position: absolute;
  right: 8px; bottom: 3px;
  font-size: 9.5px; line-height: 1;
  color: var(--warn);
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 4px;
  padding: 2px 4px;
}
.empty-tip { margin: 10px 2px 0; font-size: 11.5px; color: var(--text-2); line-height: 1.6; }

/* ---------- 右侧内容 ---------- */
.content { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.toolbar {
  flex: none;
  margin: 14px 14px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 22px;
}
.tg { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tg-label { font-size: 12px; font-weight: 600; color: var(--text-2); white-space: nowrap; }

/* ---------- 表单控件 ---------- */
.field {
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 8px;
  background: var(--surface);
  font-size: 12.5px;
  font-family: inherit;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field:hover { border-color: var(--border-strong); }
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12); }
select.field {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 26px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 7px center;
  background-size: 12px;
  cursor: pointer;
}
.field-wide { min-width: 148px; }
.field-num { width: 58px; text-align: center; }
.quad { display: flex; gap: 6px; }
.quad label {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 10.5px; color: var(--text-2);
}
.quad .field-num { width: 42px; height: 28px; }
.dim-pair { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); font-style: normal; font-size: 11.5px; }

.seg {
  display: inline-flex;
  background: #eef2f7;
  border-radius: 8px;
  padding: 2px;
}
.seg button {
  border: 0; background: transparent;
  padding: 4px 11px;
  border-radius: 6px;
  font-size: 12px; font-family: inherit;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.seg button.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }

.chk {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-2);
  cursor: pointer; user-select: none; white-space: nowrap;
}
.chk input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

/* ---------- 按钮 ---------- */
.btn {
  height: 32px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 12.5px; font-family: inherit;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.btn:hover { background: #f8fafc; border-color: var(--border-strong); }
.btn:active { transform: translateY(0.5px); }
.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.28);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-text {
  border: 0; background: none;
  color: var(--accent);
  font-size: 12px; font-family: inherit;
  cursor: pointer;
  padding: 3px 5px;
  border-radius: 6px;
}
.btn-text:hover { background: var(--accent-soft); }
.btn-text.danger { color: var(--danger); }
.btn-text.danger:hover { background: #fef2f2; }

.icon-btn {
  width: 26px; height: 26px;
  border: 0; border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: #eef2f7; color: var(--text); }
.icon-btn.danger:hover { background: #fef2f2; color: var(--danger); }

/* ---------- 预览区 ---------- */
.preview-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 20px 26px 26px;
}
.preview-stage {
  filter: drop-shadow(0 10px 26px rgba(15, 23, 42, 0.16));
  flex: none;
}
#preview-canvas { display: block; background: #fff; }

/* ---------- 状态栏 ---------- */
.statusbar {
  flex: none;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 18px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  color: var(--text-2);
  font-size: 12px;
}
.status-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-text b { color: var(--text); }
.status-text .warn { color: var(--warn); margin-left: 8px; }
.status-text .err { color: var(--danger); font-weight: 600; }
.zoom-ctl { display: flex; align-items: center; gap: 4px; flex: none; }
.zoom-label { min-width: 52px; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------- 拖拽遮罩 / 提示 ---------- */
.drop-overlay {
  position: fixed; inset: 0;
  background: rgba(79, 70, 229, 0.14);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.drop-overlay.show { display: flex; }
.drop-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 30px;
  font-weight: 600;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.2);
}

.toast {
  position: fixed;
  left: 50%; bottom: 30px;
  transform: translateX(-50%) translateY(10px);
  background: #0f172a;
  color: #fff;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 12.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 60;
  max-width: 72vw;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.3);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { background: #065f46; }
.toast.warn { background: #92400e; }
.toast.err { background: #991b1b; }

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 窄屏适配 ---------- */
@media (max-width: 1080px) {
  .app-main { grid-template-columns: 260px 1fr; }
  .field-wide { min-width: 120px; }
}
@media (max-width: 860px) {
  body { overflow: auto; }
  .app-main { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
  .image-list { max-height: 300px; }
}
