/* ============================================================
   证件照制作器 - ID Photo Maker
   样式文件 | Style Sheet
   ============================================================ */

/* ---------- CSS 变量 (主题) ---------- */
:root {
  /* 浅色主题 */
  --bg-primary: #f5f7fa;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e8ecf1;
  --text-primary: #1a1a2e;
  --text-secondary: #4a4a6a;
  --text-muted: #8a8aaa;
  --border-color: #dde1e8;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
  --accent: #438edb;
  --accent-hover: #3278c5;
  --accent-light: rgba(67, 142, 219, 0.1);
  --success: #27ae60;
  --warning: #f39c12;
  --danger: #d00c0c;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --transition: 0.25s ease;
}

/* 深色主题 */
[data-theme="dark"] {
  --bg-primary: #0f1117;
  --bg-secondary: #1a1d2e;
  --bg-tertiary: #252840;
  --text-primary: #e8e8f0;
  --text-secondary: #b0b0cc;
  --text-muted: #6a6a8a;
  --border-color: #2e3248;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
  --accent: #5aa3e8;
  --accent-hover: #438edb;
  --accent-light: rgba(90, 163, 232, 0.15);
}

/* ---------- 基础重置 ---------- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial,
    sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
}

/* ---------- 头部导航 ---------- */
.site-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
}

.site-logo .logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent), #6c5ce7);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.1rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* 主题切换按钮 */
.theme-toggle {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all var(--transition);
  color: var(--text-secondary);
}

.theme-toggle:hover {
  background: var(--accent-light);
  color: var(--accent);
  border-color: var(--accent);
}

/* Pro 版横幅 */
.pro-badge {
  background: linear-gradient(135deg, #f39c12, #e74c3c);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  cursor: pointer;
  transition: transform var(--transition);
}

.pro-badge:hover {
  transform: scale(1.05);
}

/* ---------- 主内容区 ---------- */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 30px 20px;
}

/* ---------- 广告位 ---------- */
.ad-slot {
  background: var(--bg-tertiary);
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  max-width: 728px;
  height: 90px;
  margin: 20px auto;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.ad-slot-sidebar {
  max-width: 100%;
  height: 250px;
  margin: 16px 0;
}

/* ---------- 工作区布局 ---------- */
.workspace {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  margin-top: 24px;
}

/* ---------- 画布区域 ---------- */
.canvas-area {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
  min-height: 500px;
  display: flex;
  flex-direction: column;
}

/* 上传区域 */
.upload-zone {
  flex: 1;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  padding: 40px;
  text-align: center;
  min-height: 350px;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-light);
}

.upload-zone .upload-icon {
  font-size: 3.5rem;
  margin-bottom: 16px;
  opacity: 0.7;
}

.upload-zone h3 {
  font-size: 1.2rem;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.upload-zone p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.upload-zone .upload-hint {
  margin-top: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* 画布容器 */
.canvas-wrapper {
  flex: 1;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.canvas-wrapper.visible {
  display: flex;
}

.canvas-container {
  position: relative;
  background: repeating-conic-gradient(
    #ccc 0% 25%, #fff 0% 50%
  ) 50% / 20px 20px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  max-width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.canvas-container canvas {
  display: block;
  max-width: 100%;
  max-height: 450px;
  object-fit: contain;
}

.canvas-info {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

/* 画布工具栏 */
.canvas-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

/* ---------- 侧边栏 ---------- */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.panel-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}

.panel-title .panel-icon {
  font-size: 1.1rem;
}

/* ---------- 尺寸选择 ---------- */
.size-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.size-option {
  background: var(--bg-tertiary);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}

.size-option:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.size-option.active {
  border-color: var(--accent);
  background: var(--accent-light);
}

.size-option .size-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.size-option .size-dim {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* 自定义尺寸 */
.custom-size {
  margin-top: 12px;
  display: none;
}

.custom-size.visible {
  display: block;
}

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

.custom-size-row label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  min-width: 40px;
}

.custom-size-row input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.9rem;
  width: 100%;
}

.custom-size-row input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

/* ---------- 背景色选择 ---------- */
.color-options {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.color-btn {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  border: 3px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

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

.color-btn.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}

.color-btn.white {
  background: #ffffff;
  border: 3px solid var(--border-color);
}

.color-btn.white.active {
  border-color: var(--accent);
}

.color-btn.blue {
  background: #438edb;
}

.color-btn.red {
  background: #d00c0c;
}

.color-btn.gradient-blue {
  background: linear-gradient(180deg, #438edb 0%, #6ba3e6 100%);
}

.color-btn.gradient-gray {
  background: linear-gradient(180deg, #e0e0e0 0%, #ffffff 100%);
  border: 3px solid var(--border-color);
}

.color-btn.transparent {
  background: repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 50% / 12px 12px;
}

.color-btn .color-label {
  position: absolute;
  bottom: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* 容差滑块 */
.tolerance-control {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--border-color);
}

.tolerance-control label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.tolerance-control input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

/* ---------- 按钮通用样式 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  font-family: inherit;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-success:hover:not(:disabled) {
  filter: brightness(1.1);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  filter: brightness(1.1);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
}

/* ---------- 操作面板 ---------- */
.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ---------- 打印排版 ---------- */
.print-layout-section {
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--border-color);
}

.print-layout-section .print-info {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* 打印预览弹窗 */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.visible {
  display: flex;
}

.modal-content {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  font-size: 1.2rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.print-canvas-wrapper {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.print-canvas-wrapper canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: center;
  padding: 0 24px 24px;
}

/* ---------- 支持我们区域 ---------- */
.support-section {
  margin-top: 40px;
  text-align: center;
  padding: 30px 20px;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.support-section h3 {
  font-size: 1.1rem;
  margin-bottom: 8px;
}

.support-section p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.support-links {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

/* ---------- 页脚 ---------- */
.site-footer {
  margin-top: 40px;
  padding: 24px 20px;
  text-align: center;
  border-top: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.85rem;
}

.site-footer a {
  color: var(--text-muted);
  margin: 0 8px;
}

.site-footer a:hover {
  color: var(--accent);
}

/* ---------- Toast 通知 ---------- */
.toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--accent);
  font-size: 0.9rem;
  color: var(--text-primary);
  animation: slideInRight 0.3s ease;
  max-width: 360px;
}

.toast.success {
  border-left-color: var(--success);
}

.toast.error {
  border-left-color: var(--danger);
}

.toast.warning {
  border-left-color: var(--warning);
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ---------- 加载状态 ---------- */
.loading-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.8);
  border-radius: var(--radius-md);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  z-index: 10;
}

[data-theme="dark"] .loading-overlay {
  background: rgba(26, 29, 46, 0.8);
}

.loading-overlay.visible {
  display: flex;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-overlay .loading-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* ---------- 英雄区域 ---------- */
.hero-section {
  text-align: center;
  padding: 30px 0 10px;
}

.hero-section h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 10px;
  background: linear-gradient(135deg, var(--accent), #6c5ce7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-section p {
  color: var(--text-secondary);
  font-size: 1.05rem;
  max-width: 600px;
  margin: 0 auto;
}

.features-row {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.feature-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.feature-item .feature-icon {
  font-size: 1.2rem;
}

/* ---------- 步骤指引 ---------- */
.steps-bar {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 20px 0;
  flex-wrap: wrap;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
}

.step-item.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-light);
}

.step-item .step-num {
  background: var(--bg-tertiary);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
}

.step-item.active .step-num {
  background: var(--accent);
  color: #fff;
}

.step-arrow {
  color: var(--text-muted);
  display: flex;
  align-items: center;
}

/* ---------- 响应式布局 ---------- */
@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .canvas-container canvas {
    max-height: 350px;
  }

  .hero-section h1 {
    font-size: 1.5rem;
  }

  .ad-slot {
    height: 60px;
    font-size: 0.75rem;
  }
}

@media (max-width: 600px) {
  .header-inner {
    height: 50px;
  }

  .site-logo {
    font-size: 1rem;
  }

  .site-logo .logo-icon {
    width: 30px;
    height: 30px;
    font-size: 0.9rem;
  }

  .main-content {
    padding: 16px 12px;
  }

  .canvas-area {
    padding: 16px;
  }

  .panel {
    padding: 16px;
  }

  .size-grid {
    grid-template-columns: 1fr 1fr;
  }

  .upload-zone {
    min-height: 250px;
    padding: 24px;
  }

  .upload-zone .upload-icon {
    font-size: 2.5rem;
  }

  .features-row {
    gap: 16px;
  }

  .steps-bar {
    gap: 4px;
  }

  .step-item {
    font-size: 0.75rem;
    padding: 4px 10px;
  }

  .modal-content {
    max-height: 95vh;
  }

  .modal-body {
    padding: 16px;
  }

  .print-canvas-wrapper canvas {
    max-height: 60vh;
  }

  .ad-slot-sidebar {
    height: 150px;
  }
}

/* ---------- 打印样式 ---------- */
@media print {
  .site-header,
  .site-footer,
  .sidebar,
  .ad-slot,
  .support-section,
  .canvas-toolbar,
  .hero-section,
  .steps-bar,
  .modal-overlay {
    display: none !important;
  }

  .workspace {
    display: block;
  }

  .canvas-area {
    box-shadow: none;
    padding: 0;
  }
}
