/* ============================================
   证件照制作 - 样式表
   参考scanner2紫蓝渐变风格
   ============================================ */

/* ---- 全局 ---- */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #1b1b1b;
  background: linear-gradient(135deg, #f6f7fb 0%, #f0f4f9 100%);
  min-height: 100vh;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
}

a { text-decoration: none; color: inherit; }

/* ---- 顶部导航 ---- */
.topbar {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 14px 0;
}

.topbar .content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

.brand {
  font-size: 1.5rem;
  font-weight: bold;
  color: white;
}

.nav-links {
  display: flex;
  gap: 24px;
}

.nav-links a {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.95rem;
  transition: color 0.2s ease;
}

.nav-links a:hover {
  color: white;
}

/* ---- 主容器 ---- */
#app {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 120px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ---- 上传区域 ---- */
.upload-section {
  width: 100%;
  max-width: 768px;
  margin: 32px 16px 16px 16px;
}

.file-selector {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  border-radius: 12px;
  margin: 0 auto;
  width: 100%;
  max-width: 768px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  text-align: center;
  transition: all 0.3s ease;
  border: 2px solid rgba(102, 126, 234, 0.3);
  position: relative;
  cursor: pointer;
  overflow: hidden;
  min-height: 140px;
}

.file-selector:hover {
  background: linear-gradient(135deg, #f6f7fb 0%, #ffffff 100%);
  border-color: #667eea;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.file-selector.highlight,
.file-selector.dragover {
  background: linear-gradient(135deg, #f6f7fb 0%, #ffffff 100%);
  border-color: #667eea;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.file-selector-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: #1b1b1b;
}

.file-selector-subtitle {
  font-size: 0.8rem;
  color: #6b7280;
  margin-bottom: 16px;
}

.file-selector-button {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
}

.file-selector-button:hover {
  background: linear-gradient(135deg, #764ba2 0%, #5a6bb8 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.file-selector-button:active {
  transform: translateY(1px);
}

.file-selector-button svg {
  width: 20px;
  height: 20px;
}

/* ---- 设置区域 ---- */
.settings-section {
  width: 100%;
  max-width: 768px;
  margin: 16px auto;
  display: none;
}

.settings-section.show {
  display: block;
}

.settings-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.settings-row {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

/* ---- 原图预览 ---- */
.preview-area {
  flex-shrink: 0;
  width: 180px;
  position: relative;
}

.preview-image-wrapper {
  width: 180px;
  height: 240px;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 2px solid rgba(102, 126, 234, 0.2);
  position: relative;
}

.preview-image-wrapper img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
}

.preview-label {
  text-align: center;
  font-size: 0.75rem;
  color: #717171;
  margin-top: 6px;
}

.change-image-btn {
  display: block;
  margin: 8px auto 0;
  background: none;
  border: 1px solid rgba(102, 126, 234, 0.4);
  color: #667eea;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.change-image-btn:hover {
  background: rgba(102, 126, 234, 0.08);
  border-color: #667eea;
}

/* ---- 设置面板 ---- */
.settings-panel {
  flex: 1;
  min-width: 0;
}

.settings-group {
  margin-bottom: 20px;
}

.settings-group:last-child {
  margin-bottom: 0;
}

.settings-group-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #1b1b1b;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.settings-group-title svg {
  width: 16px;
  height: 16px;
  color: #667eea;
}

/* ---- 规格选择 ---- */
.size-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.size-option {
  padding: 8px 6px;
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  border: 2px solid rgba(102, 126, 234, 0.2);
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.size-option:hover {
  border-color: #667eea;
  background: linear-gradient(135deg, #f6f7fb 0%, #ffffff 100%);
}

.size-option.active {
  border-color: #667eea;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.06) 0%, rgba(118, 75, 162, 0.06) 100%);
}

.size-option-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: #1b1b1b;
}

.size-option-dim {
  font-size: 0.7rem;
  color: #717171;
  margin-top: 2px;
}

/* ---- 自定义尺寸 ---- */
.custom-size-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.custom-size-input {
  width: 80px;
  padding: 6px 8px;
  border: 2px solid rgba(102, 126, 234, 0.3);
  border-radius: 8px;
  font-size: 0.85rem;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}

.custom-size-input:focus {
  border-color: #667eea;
}

.custom-size-sep {
  color: #717171;
  font-size: 0.85rem;
}

.custom-size-unit {
  color: #717171;
  font-size: 0.75rem;
}

/* ---- 底色选择 ---- */
.color-options {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.color-option {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.color-option:hover {
  transform: scale(1.1);
}

.color-option.active {
  border-color: #667eea;
  box-shadow: 0 0 0 2px #667eea;
}

.color-option.active::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 0 2px rgba(0,0,0,0.3);
}

.color-option-dark.active::after {
  background: #333;
}

.color-option-custom {
  background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.color-option-custom.active::after {
  display: none;
}

.color-option-custom.active {
  box-shadow: 0 0 0 2px #667eea;
}

.custom-color-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.custom-color-input {
  width: 60px;
  height: 32px;
  padding: 2px;
  border: 2px solid rgba(102, 126, 234, 0.3);
  border-radius: 6px;
  cursor: pointer;
  outline: none;
}

.custom-color-input:focus {
  border-color: #667eea;
}

.custom-color-hex {
  font-size: 0.8rem;
  color: #717171;
  font-family: monospace;
}

/* ---- 进度条 ---- */
.progress-section {
  margin: 16px auto;
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  width: 100%;
  max-width: 768px;
  display: none;
}

.progress-section.show {
  display: block;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 14px;
}

#progressText { color: #1b1b1b; }
#progressPercent { color: #667eea; font-weight: 600; }

.progress-bar {
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border-radius: 3px;
  width: 0;
  transition: width 0.4s ease;
}

/* ---- 结果区 ---- */
.result-section {
  background: #ffffff;
  border-radius: 12px;
  padding: 20px;
  margin: 16px auto;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  width: 100%;
  max-width: 768px;
  display: none;
}

.result-section.show {
  display: block;
}

.result-section h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 14px;
  color: #1b1b1b;
}

.result-cards {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.result-card {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.04) 0%, rgba(118, 75, 162, 0.04) 100%);
  border: 2px solid rgba(102, 126, 234, 0.15);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  flex: 1;
  min-width: 200px;
  max-width: 340px;
}

.result-card-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #1b1b1b;
  margin-bottom: 10px;
}

.result-card-canvas {
  width: 100%;
  max-width: 200px;
  aspect-ratio: auto;
  border-radius: 6px;
  margin: 0 auto 10px;
  display: block;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.result-card-info {
  font-size: 0.75rem;
  color: #717171;
  margin-bottom: 10px;
}

.result-card-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
  transition: all 0.2s;
}

.btn-download:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
  color: white;
}

.btn-download-outline {
  background: white;
  color: #667eea;
  border: 2px solid rgba(102, 126, 234, 0.4);
  box-shadow: none;
}

.btn-download-outline:hover {
  border-color: #667eea;
  color: #667eea;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

.btn-download svg {
  width: 14px;
  height: 14px;
}

/* ---- 底部固定操作栏 ---- */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(135deg, #ffffff 0%, #fafbfc 100%);
  border-top: 1px solid rgba(0,0,0,0.06);
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
  backdrop-filter: blur(10px);
  z-index: 10;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.bottom-bar.show {
  transform: translateY(0);
}

.bottom-bar .buttons {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  gap: 16px;
}

.bottom-bar .button {
  flex: 1;
  padding: 16px 0;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  color: white;
}

.bottom-bar .btn-generate {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.bottom-bar .btn-change {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.bottom-bar .button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0,0,0,0.07);
}

.bottom-bar .button:disabled {
  background: #e5e7eb;
  color: #9ca3af;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.bottom-bar .button svg {
  width: 20px;
  height: 20px;
}

/* ---- 使用说明 ---- */
.howto-section {
  margin-top: 24px;
  padding: 20px 0;
  width: 100%;
  max-width: 768px;
}

.howto-section h2 {
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  color: #1b1b1b;
  margin-bottom: 16px;
  position: relative;
  padding-top: 12px;
}

.howto-section h2::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 2px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 1px;
}

.howto-list {
  list-style: none;
  counter-reset: step-counter;
  padding: 0;
}

.howto-list li {
  counter-increment: step-counter;
  position: relative;
  padding: 14px 14px 14px 52px;
  margin-bottom: 10px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  font-size: 14px;
  color: #4f4f4f;
  line-height: 1.5;
}

.howto-list li::before {
  content: counter(step-counter);
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

.howto-list li strong {
  color: #1b1b1b;
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(27, 27, 27, 0.9);
  color: #fff;
  padding: 12px 28px;
  border-radius: 12px;
  font-size: 14px;
  z-index: 9999;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  animation: fadeInUp 0.3s ease;
  backdrop-filter: blur(10px);
}

.toast-error {
  background: rgba(239, 68, 68, 0.9);
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---- 其它工具导航链接 ---- */
.navigation-links {
  max-width: 800px;
  width: 100%;
  margin: 0 auto 16px auto;
  padding: 0 16px;
  box-sizing: border-box;
}

.navigation-section-title {
  font-size: 1rem;
  font-weight: 600;
  color: #1b1b1b;
  margin-bottom: 16px;
  text-align: center;
  padding-top: 24px;
  position: relative;
}

.navigation-section-title::before {
  content: '';
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 2px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 1px;
}

.navigation-links-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 0;
  width: 100%;
  box-sizing: border-box;
}

.navigation-link-item {
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  border: 2px solid rgba(102, 126, 234, 0.25);
  border-radius: 10px;
  text-align: center;
  transition: all 0.3s ease;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 6px;
  min-height: 60px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.navigation-link-item:hover {
  border-color: #667eea;
  background: linear-gradient(135deg, #f6f7fb 0%, #ffffff 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.navigation-link-item:active {
  transform: translateY(0);
}

.navigation-link-icon {
  width: 24px;
  height: 24px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.navigation-link-icon svg {
  width: 20px;
  height: 20px;
  transition: transform 0.3s ease;
}

.navigation-link-item:hover .navigation-link-icon svg {
  transform: scale(1.1);
}

.navigation-link-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: #1b1b1b;
  margin-bottom: 4px;
  line-height: 1.2;
}

.navigation-link-subtitle {
  font-size: 0.7rem;
  font-weight: 600;
  color: white;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 6px;
  padding: 4px 8px;
  margin-bottom: 0;
  line-height: 1.2;
  display: inline-block;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* ---- 响应式 ---- */
@media (max-width: 767px) {
  .file-selector {
    width: calc(100% - 32px);
    margin: 0 16px 16px 16px;
    padding: 16px;
  }

  .settings-row {
    flex-direction: column;
    gap: 16px;
  }

  .preview-area {
    width: 100%;
  }

  .preview-image-wrapper {
    width: 140px;
    height: 186px;
    margin: 0 auto;
  }

  .size-options {
    grid-template-columns: repeat(3, 1fr);
  }

  .result-cards {
    flex-direction: column;
    align-items: center;
  }

  .result-card {
    max-width: 100%;
  }

  .bottom-bar .button {
    padding: 12px 0;
    font-size: 0.95rem;
  }

  .navigation-links {
    padding: 0 16px;
  }

  .navigation-section-title {
    font-size: 0.9rem;
    padding-top: 16px;
    margin-bottom: 12px;
  }

  .navigation-section-title::before {
    width: 40px;
    top: 8px;
  }

  .navigation-links-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }

  .navigation-link-item {
    padding: 8px 4px;
    min-height: 50px;
  }

  .navigation-link-icon {
    width: 20px;
    height: 20px;
    margin-bottom: 4px;
  }

  .navigation-link-icon svg {
    width: 16px;
    height: 16px;
  }

  .navigation-link-title {
    font-size: 0.7rem;
    margin-bottom: 2px;
  }

  .navigation-link-subtitle {
    font-size: 0.65rem;
    padding: 3px 6px;
    margin-bottom: 0;
  }
}
/* 平板端适配 */
@media (min-width: 481px) and (max-width: 768px) {
  .navigation-link-item {
    padding: 10px 6px;
    min-height: 55px;
  }

  .navigation-link-icon svg {
    width: 18px;
    height: 18px;
  }

  .navigation-link-title {
    font-size: 0.72rem;
    margin-bottom: 3px;
  }

  .navigation-link-subtitle {
    font-size: 0.68rem;
    padding: 3px 7px;
  }
}

/* 桌面端适配 */
@media (min-width: 769px) {
  .navigation-links {
    padding: 0 16px;
  }

  .navigation-links-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
  }

  .navigation-link-item {
    padding: 16px 12px;
    min-height: 70px;
  }

  .navigation-link-icon {
    width: 28px;
    height: 28px;
    margin-bottom: 8px;
  }

  .navigation-link-icon svg {
    width: 24px;
    height: 24px;
  }

  .navigation-link-title {
    font-size: 0.82rem;
    margin-bottom: 4px;
  }

  .navigation-link-subtitle {
    font-size: 0.72rem;
    padding: 4px 10px;
  }
}