/* ===========================
   Watermark Tool — Styles
=========================== */

/* ── 全页布局 ── */
body.tool-page {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* 导航返回按钮 */
.nav-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  transition: all 0.2s;
}
.nav-back:hover { color: var(--text); border-color: var(--border-2); }
.nav-sep {
  color: var(--text-3);
  font-weight: 300;
  margin: 0 4px;
}
.nav-current {
  font-size: 0.9rem;
  color: var(--text-2);
}

/* ── 主布局：侧边栏 + 工作区 ── */
.wm-layout {
  flex: 1;
  display: flex;
  overflow: hidden;
  margin-top: 60px; /* navbar height */
}

/* ── 左侧面板 ── */
.wm-sidebar {
  width: 300px;
  flex: 0 0 300px;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  transition: width 0.25s ease, flex-basis 0.25s ease;
}
.wm-sidebar.collapsed {
  width: 0;
  flex-basis: 0;
  overflow: hidden;
}
.sidebar-toggle {
  position: absolute;
  top: 12px;
  right: -14px;
  width: 28px; height: 28px;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: 50%;
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: color 0.2s;
}
.sidebar-toggle:hover { color: var(--cyan); }
.sidebar-content { padding: 16px 14px 80px; }

/* ── 面板区块 ── */
.panel-section {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.panel-section:last-child { border-bottom: none; }
.section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-2);
  margin-bottom: 12px;
}
.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--cyan-dim);
  color: var(--cyan);
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── 上传区 ── */
.upload-zone {
  border: 1.5px dashed var(--border-2);
  border-radius: 10px;
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--surface);
}
.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--cyan);
  background: var(--cyan-dim);
}
.upload-icon {
  color: var(--text-3);
  margin-bottom: 8px;
  transition: color 0.2s;
}
.upload-zone:hover .upload-icon { color: var(--cyan); }
.upload-hint-main {
  font-size: 0.85rem;
  color: var(--text-2);
  margin-bottom: 4px;
}
.upload-link { color: var(--cyan); cursor: pointer; }
.upload-hint-sub { font-size: 0.72rem; color: var(--text-3); }

.upload-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--text-2);
}
.btn-text-danger {
  background: none;
  border: none;
  color: var(--red);
  font-size: 0.82rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.15s;
}
.btn-text-danger:hover { background: rgba(239,68,68,0.1); }

/* ── 类型切换 ── */
.type-switcher {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.type-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-2);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font);
}
.type-btn:hover { border-color: var(--border-2); color: var(--text); }
.type-btn.active {
  background: var(--cyan-dim);
  border-color: var(--cyan);
  color: var(--cyan);
}

/* ── 表单控件 ── */
.field-label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-3);
  margin-bottom: 6px;
  margin-top: 10px;
}
.field-value {
  color: var(--cyan);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.wm-input,
.wm-select,
.wm-textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 0.88rem;
  font-family: var(--font);
  padding: 8px 10px;
  outline: none;
  transition: border-color 0.2s;
  resize: none;
}
.wm-input:focus,
.wm-select:focus,
.wm-textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px var(--cyan-dim);
}
.wm-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2364748b' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
.wm-select option { background: var(--bg-2); }
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* ── Range 滑块 ── */
.wm-range {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.08);
  outline: none;
  cursor: pointer;
  margin: 4px 0;
}
.wm-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px rgba(0,212,255,0.5);
  cursor: pointer;
  border: 2px solid var(--bg-2);
  transition: transform 0.15s;
}
.wm-range::-webkit-slider-thumb:hover { transform: scale(1.2); }

/* ── 颜色选择器 ── */
.color-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.wm-color-picker {
  width: 36px; height: 36px;
  border: 1px solid var(--border-2);
  border-radius: 7px;
  background: none;
  cursor: pointer;
  padding: 2px;
}
.preset-colors {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.preset-dot {
  width: 20px; height: 20px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s;
  display: block;
}
.preset-dot:hover { transform: scale(1.2); border-color: rgba(255,255,255,0.4); }
.preset-dot.selected { border-color: var(--cyan); box-shadow: 0 0 6px var(--cyan); }

/* ── Logo 上传区 ── */
.logo-upload-zone {
  border: 1.5px dashed var(--border-2);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s;
}
.logo-upload-zone:hover { border-color: var(--cyan); }
.logo-preview-area {
  min-height: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  color: var(--text-3);
  font-size: 0.8rem;
  text-align: center;
}
.logo-preview-area img {
  max-height: 80px;
  max-width: 100%;
  object-fit: contain;
  border-radius: 6px;
}

/* ── 位置九宫格 ── */
.position-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  max-width: 140px;
}
.pos-btn {
  aspect-ratio: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-3);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
}
.pos-btn:hover { border-color: var(--border-2); color: var(--text); }
.pos-btn.active {
  background: var(--cyan-dim);
  border-color: var(--cyan);
  color: var(--cyan);
}

/* Checkbox */
.wm-checkbox {
  width: 14px; height: 14px;
  accent-color: var(--cyan);
  cursor: pointer;
  vertical-align: middle;
  margin-right: 4px;
}

/* ── 右侧工作区 ── */
.wm-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative; /* 让弹窗定位相对于工作区 */
  background: var(--bg);
}

/* 工具栏 */
.workspace-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(13,18,32,0.6);
  backdrop-filter: blur(8px);
  flex-shrink: 0;
}
.toolbar-left { display: flex; align-items: center; gap: 10px; }
.toolbar-title { font-size: 0.9rem; color: var(--text-2); font-weight: 500; }
.toolbar-count {
  font-size: 0.75rem;
  padding: 2px 8px;
  background: var(--cyan-dim);
  color: var(--cyan);
  border-radius: 20px;
  border: 1px solid var(--border-2);
}
.toolbar-right { display: flex; gap: 8px; }
.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-2);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.2s;
}
.btn-action:hover:not(:disabled) {
  border-color: var(--border-2);
  color: var(--text);
}
.btn-download-zip {
  background: var(--cyan-dim);
  border-color: var(--cyan);
  color: var(--cyan);
}
.btn-download-zip:hover:not(:disabled) {
  background: rgba(0,212,255,0.25);
  box-shadow: var(--glow-cyan);
}
.btn-action:disabled { opacity: 0.4; cursor: not-allowed; }

/* 空状态 */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-3);
  text-align: center;
  padding: 40px;
}
.empty-icon { font-size: 4rem; opacity: 0.4; margin-bottom: 8px; }
.empty-state h3 { font-size: 1.1rem; font-weight: 600; color: var(--text-2); }
.empty-state p { font-size: 0.9rem; line-height: 1.7; }

/* 缩略图网格 */
.thumb-grid {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  align-content: start;
}
.thumb-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: all 0.2s;
  cursor: pointer;
  position: relative;
}
.thumb-card:hover {
  border-color: var(--border-2);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.thumb-img-wrap {
  position: relative;
  aspect-ratio: 4/3;
  background: rgba(0,0,0,0.3);
  overflow: hidden;
}
.thumb-canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.thumb-processing {
  position: absolute;
  inset: 0;
  background: rgba(8,12,20,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
}
.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(0,212,255,0.2);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.thumb-info {
  padding: 8px 10px;
  border-top: 1px solid var(--border);
}
.thumb-name {
  font-size: 0.75rem;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}
.thumb-actions {
  display: flex;
  gap: 6px;
}
.thumb-btn {
  flex: 1;
  padding: 4px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-3);
  font-size: 0.7rem;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.15s;
  text-align: center;
}
.thumb-btn:hover { color: var(--text); border-color: var(--border-2); }
.thumb-btn.dl { color: var(--cyan); border-color: rgba(0,212,255,0.2); }
.thumb-btn.dl:hover { background: var(--cyan-dim); }
.thumb-btn.rm:hover { color: var(--red); border-color: rgba(239,68,68,0.3); }

/* 进度条 */
.progress-bar-wrap {
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: rgba(13,18,32,0.8);
}
.progress-bar-bg {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--purple));
  border-radius: 2px;
  width: 0%;
  transition: width 0.2s;
}
.progress-text { font-size: 0.78rem; color: var(--text-3); white-space: nowrap; }

/* ── 预览弹窗 ── */
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: 16px;
  max-width: 90vw;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}
.modal-filename {
  font-size: 0.88rem;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.modal-actions { display: flex; gap: 8px; align-items: center; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.15s;
}
.modal-close:hover { color: var(--text); background: var(--surface-2); }
.modal-body {
  flex: 1;
  overflow: auto;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
#modal-canvas {
  max-width: 100%;
  max-height: calc(90vh - 80px);
  border-radius: 8px;
  object-fit: contain;
}

/* ── 工具类 ── */
.hidden { display: none !important; }

/* ── 响应式 ── */
@media (max-width: 768px) {
  .wm-sidebar { width: 100%; flex: 0 0 100%; max-height: 50vh; }
  .wm-layout { flex-direction: column; }
  .thumb-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}
