/* ============================================
   图富宝 H5 - 全站公共样式
   移动端优先 · 响应式 · 微信兼容
   ============================================ */

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #f59e0b;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 16px);
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  padding-bottom: calc(80px + var(--safe-bottom));
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Top Nav ── */
.navbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
  backdrop-filter: blur(10px);
}
.navbar .logo { font-size: 20px; font-weight: 700; color: var(--primary); }
.navbar .logo span { color: var(--text); font-weight: 400; font-size: 14px; }
.nav-back {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--bg); border: none; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text);
}

/* ── Main Content ── */
.container { max-width: 640px; margin: 0 auto; padding: 16px; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 24px; border-radius: var(--radius-sm);
  font-size: 16px; font-weight: 600; border: none; cursor: pointer;
  transition: all 0.2s; min-height: 44px; text-decoration: none;
  user-select: none; -webkit-user-select: none;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-outline { background: transparent; border: 2px solid var(--border); color: var(--text); }
.btn-block { display: flex; width: 100%; }
.btn-sm { padding: 8px 16px; font-size: 14px; min-height: 36px; }
.btn-lg { padding: 16px 32px; font-size: 18px; border-radius: var(--radius); }

/* ── Grid ── */
.func-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
}
.func-item {
  background: var(--surface); border-radius: var(--radius);
  padding: 20px 16px; text-align: center; cursor: pointer;
  border: 1px solid var(--border); box-shadow: var(--shadow);
  transition: all 0.2s; text-decoration: none; color: var(--text);
}
.func-item:active { transform: scale(0.96); background: #f1f5f9; }
.func-icon { font-size: 36px; margin-bottom: 8px; display: block; }
.func-label { font-size: 15px; font-weight: 600; }
.func-desc { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

/* ── Upload Zone ── */
.upload-zone {
  border: 3px dashed var(--border); border-radius: var(--radius);
  padding: 48px 24px; text-align: center; cursor: pointer;
  transition: all 0.2s; background: var(--bg);
  margin-bottom: 16px;
}
.upload-zone:active, .upload-zone.dragover { border-color: var(--primary); background: #eff6ff; }
.upload-icon { font-size: 48px; margin-bottom: 12px; }
.upload-text { font-size: 16px; color: var(--text-secondary); }
.upload-hint { font-size: 13px; color: #94a3b8; margin-top: 8px; }

/* ── Progress ── */
.progress-bar {
  width: 100%; height: 6px; background: var(--border);
  border-radius: 3px; overflow: hidden; margin: 12px 0;
}
.progress-fill {
  height: 100%; background: var(--primary);
  border-radius: 3px; transition: width 0.3s;
  width: 0%;
}

/* ── Image Preview ── */
.preview-container {
  position: relative; border-radius: var(--radius);
  overflow: hidden; background: #000; margin-bottom: 16px;
  min-height: 200px; display: flex; align-items: center; justify-content: center;
}
.preview-container img {
  max-width: 100%; max-height: 70vh; display: block;
  object-fit: contain; -webkit-user-drag: none;
}

/* ── Form Elements ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-input, .form-select {
  width: 100%; padding: 12px; border: 2px solid var(--border);
  border-radius: var(--radius-sm); font-size: 16px;
  background: var(--surface); color: var(--text);
  transition: border-color 0.2s; font-family: var(--font);
}
.form-input:focus, .form-select:focus { outline: none; border-color: var(--primary); }
input[type="range"] { width: 100%; margin: 8px 0; }

/* ── Toast ── */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  background: #1e293b; color: #fff; padding: 12px 24px;
  border-radius: 24px; font-size: 14px; z-index: 9999;
  box-shadow: var(--shadow-lg); animation: toastIn 0.3s ease;
  max-width: 90vw; text-align: center;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(-20px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ── Bottom Bar (CPS) ── */
.bottom-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 90;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 12px 16px calc(12px + var(--safe-bottom));
  display: flex; gap: 12px;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

/* ── ID Photo Specific ── */
.idcard-preview {
  width: 200px; height: 280px; margin: 20px auto;
  border: 2px solid #ccc; border-radius: 4px;
  overflow: hidden; position: relative; background: #fff;
}
.idcard-preview img { width: 100%; height: 100%; object-fit: cover; }
.bg-colors { display: flex; gap: 8px; justify-content: center; margin: 16px 0; }
.bg-color-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 3px solid transparent;
  cursor: pointer; transition: all 0.2s;
}
.bg-color-btn.active { border-color: var(--primary); transform: scale(1.1); }
.bg-color-btn.transparent-bg {
  background-image: repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 50% / 10px 10px;
}
.layout-options, .compress-options { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Watermark Templates ── */
.template-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.template-card {
  background: var(--surface); border-radius: var(--radius);
  overflow: hidden; border: 1px solid var(--border);
  cursor: pointer; transition: all 0.2s;
}
.template-card:active { transform: scale(0.97); }
.template-img {
  width: 100%; height: 120px; object-fit: cover;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); font-size: 32px;
}
.template-info { padding: 10px; }
.template-name { font-size: 14px; font-weight: 600; }
.template-price { font-size: 13px; color: var(--primary); font-weight: 700; }

/* ── Result Page ── */
.result-img { max-width: 100%; border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.result-info { font-size: 14px; color: var(--text-secondary); text-align: center; margin: 12px 0; }
.result-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }

/* ── Skeleton Loading ── */
.skeleton { background: linear-gradient(90deg, var(--border) 25%, #f1f5f9 50%, var(--border) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Responsive ── */
@media (min-width: 768px) {
  .container { padding: 24px; }
  .func-grid { grid-template-columns: repeat(4, 1fr); }
  .template-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ── WeChat Compat ── */
@media screen and (max-width: 320px) {
  .func-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .card { padding: 14px; }
}

/* ── Adjust / Slider / Filter (调色模块) ── */
.section-title { font-size: 15px; font-weight: 700; color: var(--text); margin: 20px 0 10px; padding-bottom: 6px; border-bottom: 2px solid var(--border); }
.slider-group { margin: 12px 0; }
.slider-group label { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-secondary); }
.slider-group input[type="range"] { width: 100%; margin-top: 4px; accent-color: var(--primary); }
.filter-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.filter-tab { padding: 6px 14px; border-radius: 16px; border: 1px solid var(--border); font-size: 13px; cursor: pointer; background: var(--surface); transition: all 0.2s; user-select: none; -webkit-user-select: none; }
.filter-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.filter-tab:active { transform: scale(0.95); }
.action-row { display: flex; gap: 10px; margin: 16px 0; }
.status-badge { font-size: 12px; padding: 4px 10px; border-radius: 12px; white-space: nowrap; }
.status-processing { background: #FEF3C7; color: #92400E; }
.status-completed { background: #D1FAE5; color: #065F46; }
.tools-panel { display: none; }
.tools-panel.show { display: block; }

/* ── Hidden ── */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 13px; }

/* ── 站点尾栏 ICP ── */
.site-footer {
  text-align: center; padding: 16px 16px calc(80px + var(--safe-bottom));
  font-size: 12px; color: var(--text-secondary); line-height: 1.8;
}
.site-footer a { color: var(--text-secondary); text-decoration: none; }
.text-muted { color: var(--text-secondary); }
.text-primary { color: var(--primary); }
