/* ============================================
   小程序转H5 - 样式文件
   ============================================ */
:root {
  --primary: #4f46e5;
  --primary-light: #818cf8;
  --primary-bg: #eef2ff;
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #1e293b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
  --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 80px;
  min-height: 100vh;
}

/* ===== Header ===== */
.header {
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  padding: 40px 20px 60px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.header::before {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: radial-gradient(circle at 30% 50%, rgba(255,255,255,0.1) 0%, transparent 60%);
  pointer-events: none;
}
.header h1 { color: #fff; font-size: 24px; font-weight: 700; }
.header p { color: rgba(255,255,255,0.8); font-size: 14px; margin-top: 6px; }

/* ===== Container ===== */
.container { max-width: 600px; margin: -40px auto 0; padding: 0 16px; position: relative; }

/* ===== Search ===== */
.search-box {
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.search-box input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  color: var(--text);
  background: transparent;
  cursor: pointer;
}
.search-box input::placeholder { color: var(--text-muted); }

/* ===== Quick Tools ===== */
.tools-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.tool-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s;
}
.tool-card:active { transform: scale(0.97); }
.tool-card .icon { font-size: 28px; margin-bottom: 8px; display: block; }
.tool-card .name { font-size: 15px; font-weight: 600; }
.tool-card .desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.tool-card.featured {
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: #fff;
}
.tool-card.featured .desc { color: rgba(255,255,255,0.7); }

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0;
}
.tab {
  flex-shrink: 0;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 13px;
  background: var(--card);
  color: var(--text-muted);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
}
.tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ===== Spec Grid ===== */
.spec-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.spec-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all 0.15s;
}
.spec-card:active { transform: scale(0.97); }
.spec-card .name { font-size: 15px; font-weight: 600; }
.spec-card .size-info { font-size: 12px; color: var(--text-muted); margin-top: 4px; line-height: 1.6; }
.spec-card .tag { display: inline-block; padding: 1px 6px; border-radius: 4px; background: var(--primary-bg); color: var(--primary); font-size: 11px; margin-right: 4px; }

/* ===== Steps ===== */
.steps-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--card);
  margin-bottom: 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.step-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}
.step-item.active { color: var(--primary); font-weight: 600; }
.step-number {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}
.step-item.active .step-number {
  background: var(--primary);
  color: #fff;
}
.step-arrow { color: var(--border); font-size: 18px; }

/* ===== Upload Area ===== */
.upload-area {
  background: var(--card);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  box-shadow: var(--shadow);
  border: 2px dashed var(--border);
  cursor: pointer;
  transition: all 0.2s;
  background-repeat: no-repeat;
  background-position: center 24px;
}
.upload-area:hover { border-color: var(--primary); }
.upload-area p { margin-top: 12px; color: var(--text-muted); font-size: 14px; }
.upload-area .btn-group { display: flex; gap: 12px; justify-content: center; margin-top: 16px; }

/* ===== Buttons ===== */
.btn {
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #4338ca; }
.btn-outline { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-lg { padding: 14px 32px; font-size: 16px; border-radius: 10px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== Preview ===== */
.preview-area {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  text-align: center;
}
.preview-area canvas { max-width: 100%; border-radius: 8px; }
.preview-info { font-size: 13px; color: var(--text-muted); margin-top: 8px; }
.spec-detail {
  background: var(--primary-bg);
  border-radius: 8px;
  padding: 10px 14px;
  margin-top: 12px;
  text-align: left;
}
.spec-detail .row { display: flex; justify-content: space-between; font-size: 13px; padding: 2px 0; }
.spec-detail .label { color: var(--text-muted); }

/* ===== Color Picker ===== */
.color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 36px);
  gap: 10px;
  justify-content: center;
  margin: 12px 0;
}
.color-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}
.color-btn.active { border-color: var(--primary); transform: scale(1.15); }
.color-btn:hover { transform: scale(1.1); }

/* ===== Download Section ===== */
.download-section { text-align: center; }
.download-section h3 { font-size: 18px; margin-bottom: 8px; }
.final-image {
  max-width: 360px;
  width: 100%;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  cursor: pointer;
  margin: 12px auto;
  display: block;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-content {
  background: var(--card);
  border-radius: 16px;
  padding: 24px;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.modal-content h3 { font-size: 18px; margin-bottom: 16px; text-align: center; }

/* ===== Photo Album ===== */
.album-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.album-item {
  background: var(--card);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
  position: relative;
}
.album-item img { width: 100%; height: 120px; object-fit: cover; display: block; }
.album-item .info { padding: 8px; font-size: 12px; color: var(--text-muted); text-align: center; }
.album-item .delete-btn {
  position: absolute; top: 4px; right: 4px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== Custom Size ===== */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.form-group input {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus { border-color: var(--primary); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ===== Search Results ===== */
.search-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.search-header input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
}
.search-header input:focus { border-color: var(--primary); }
.search-back { font-size: 20px; cursor: pointer; color: var(--text-muted); }

/* ===== Loading ===== */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}
.spinner {
  display: inline-block;
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Toast ===== */
.toast {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.75);
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 2000;
  animation: fadeIn 0.2s;
}
@keyframes fadeIn { from { opacity: 0; transform: translate(-50%, -50%) scale(0.9); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }

/* ===== 加载覆盖层（持久显示，不会自动消失） ===== */
.loading-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45);
  z-index: 2500;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s;
}
.loading-overlay .spinner {
  width: 48px; height: 48px;
  border: 4px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.loading-overlay .loading-text {
  color: #fff;
  font-size: 15px;
  margin-top: 14px;
}
.loading-overlay .loading-elapsed {
  color: rgba(255,255,255,0.6);
  font-size: 13px;
  margin-top: 8px;
}

/* ===== 确认弹窗 ===== */
.confirm-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s;
  overflow-y: auto;
}
.confirm-box {
  background: var(--card);
  border-radius: 16px;
  padding: 24px;
  max-width: 360px;
  width: 100%;
  max-height: calc(100vh - 40px);
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
  text-align: center;
  animation: popIn 0.25s;
  display: flex;
  flex-direction: column;
}
.confirm-box .icon { font-size: 48px; margin-bottom: 8px; flex-shrink: 0; }
.confirm-box .title { font-size: 17px; font-weight: 600; margin-bottom: 8px; color: var(--text); flex-shrink: 0; }
.confirm-box .desc {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 20px;
  text-align: left;
  white-space: pre-line;
  word-break: break-all;
  overflow-y: auto;
  max-height: 50vh;
  flex: 1;
  min-height: 40px;
}
.confirm-box .actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
  margin-top: auto;
}
.confirm-box .actions .btn { flex: 1; justify-content: center; }
.confirm-box .actions .btn { flex: 1; justify-content: center; }
@keyframes popIn { from { opacity: 0; transform: scale(0.85); } to { opacity: 1; transform: scale(1); } }

/* ===== Responsive ===== */
@media (max-width: 400px) {
  .spec-grid { grid-template-columns: 1fr; }
  .tools-grid { grid-template-columns: 1fr; }
  .album-grid { grid-template-columns: repeat(2, 1fr); }
}
