/* ============================================
   证件照生成器 - 简洁风格
   ============================================ */

:root {
  --color-primary: #4f46e5;
  --color-primary-dark: #4338ca;
  --color-bg: #faf9f7;
  --color-bg-card: #ffffff;
  --color-bg-hover: #f5f3f0;
  --color-text: #1f2937;
  --color-text-light: #6b7280;
  --color-text-muted: #9ca3af;
  --color-success: #10b981;
  --color-error: #ef4444;
  --color-warning: #f59e0b;
  --color-border: #e5e7eb;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --transition: all 0.2s ease;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
  background: linear-gradient(135deg, var(--color-bg) 0%, #f0ebe3 100%);
  color: var(--color-text);
  min-height: 100vh;
  line-height: 1.6;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--color-bg);
}

/* Header */
.header {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  padding: 16px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  font-size: 28px;
}

.logo-text {
  font-size: 18px;
  font-weight: 600;
  color: white;
}

/* Credits Display */
.credits-display {
  background: rgba(255, 255, 255, 0.2);
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 4px;
}

.credits-display:hover {
  background: rgba(255, 255, 255, 0.3);
}

.credits-count {
  font-size: 18px;
  font-weight: 700;
  color: white;
}

.credits-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.9);
}

/* Main Content */
.main-content {
  padding: 24px 20px 40px;
}

/* Steps */
.step {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.step-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.step-number {
  width: 32px;
  height: 32px;
  background: var(--color-primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
}

.step-header h2 {
  font-size: 20px;
  font-weight: 600;
}

.back-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--color-bg-hover);
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  transition: var(--transition);
}

.back-btn:hover {
  background: var(--color-border);
}

/* Search Box */
.search-box {
  margin-bottom: 20px;
}

.search-input {
  width: 100%;
  padding: 14px 18px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 15px;
  background: white;
  transition: var(--transition);
}

.search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

/* Country Grid */
.country-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.country-card {
  background: white;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}

.country-card:hover {
  border-color: var(--color-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.country-flag {
  font-size: 32px;
  margin-bottom: 8px;
}

.country-name {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
}

.country-type {
  font-size: 12px;
  color: var(--color-text-light);
}

.country-size {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* Upload Section */
.upload-section {
  text-align: center;
}

.upload-area {
  background: white;
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: 40px 20px;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 20px;
}

.upload-area:hover {
  border-color: var(--color-primary);
  background: rgba(79, 70, 229, 0.02);
}

.upload-area.drag-over {
  border-color: var(--color-primary);
  background: rgba(79, 70, 229, 0.05);
}

.upload-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.upload-text {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 8px;
}

.upload-hint {
  font-size: 13px;
  color: var(--color-text-muted);
}


/* Requirements Brief */
.requirements-brief {
  background: white;
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.brief-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.brief-flag {
  font-size: 24px;
}

.brief-country {
  font-weight: 600;
  font-size: 15px;
}

.brief-size {
  margin-left: auto;
  font-size: 13px;
  color: var(--color-primary);
  font-weight: 500;
}

.brief-specs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 11px;
  color: var(--color-text-muted);
}

.brief-specs span {
  background: var(--color-bg-hover);
  padding: 2px 8px;
  border-radius: 4px;
}

.brief-bg {
  font-size: 12px;
  color: var(--color-text-light);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.color-preview {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid var(--color-border);
}

.brief-guidance {
  font-size: 12px;
  color: var(--color-text-muted);
  line-height: 1.5;
}

/* ============================================
   照片调整区域 - Crop
   ============================================ */

.adjust-hint {
  text-align: center;
  color: var(--color-text-light);
  margin-bottom: 16px;
  font-size: 14px;
}

.crop-container {
  position: relative;
  width: 100%;
  height: 400px;
  background: #2a2a2a;
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 16px;
  touch-action: none;
}

.crop-image-wrapper {
  position: absolute;
  cursor: grab;
  transform-origin: 0 0;
}

.crop-image-wrapper:active {
  cursor: grabbing;
}

.crop-image-wrapper img {
  display: block;
  max-width: none;
  user-select: none;
  -webkit-user-drag: none;
}

/* 裁剪框覆盖层 */
.crop-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 裁剪框 */
.crop-frame {
  position: relative;
  border: 3px dashed var(--color-primary);
  background: transparent;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6);
}

/* 头部参考线 - 动态位置由 JS 设置 */
.head-guide {
  position: absolute;
  left: 15%;
  right: 15%;
  border: 2px dashed rgba(255, 255, 255, 0.7);
  border-radius: 50% 50% 45% 45%;
  background: rgba(79, 70, 229, 0.1);
}

.head-label {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(79, 70, 229, 0.9);
  color: white;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
  font-weight: 500;
}

/* 尺寸指示器 */
.size-indicator {
  text-align: center;
  margin-bottom: 12px;
  padding: 8px 16px;
  background: var(--color-bg-hover);
  border-radius: var(--radius-sm);
}

.size-text {
  font-size: 13px;
  color: var(--color-text-light);
}

.size-text strong {
  color: var(--color-primary);
  font-weight: 600;
}

/* 缩放控制 */
.zoom-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
  padding: 12px;
  background: white;
  border-radius: var(--radius-md);
}

.zoom-btn {
  width: 36px;
  height: 36px;
  border: 2px solid var(--color-border);
  background: white;
  border-radius: 50%;
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.zoom-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

#zoomSlider {
  width: 120px;
  height: 6px;
  -webkit-appearance: none;
  background: var(--color-border);
  border-radius: 3px;
  outline: none;
}

#zoomSlider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: var(--color-primary);
  border-radius: 50%;
  cursor: pointer;
}

.zoom-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-light);
  min-width: 50px;
  text-align: right;
}

/* Crop Actions */
.crop-actions {
  display: flex;
  gap: 12px;
}

.crop-actions .btn {
  flex: 1;
}

/* ============================================
   处理中页面 - Step 3
   ============================================ */

.processing-section {
  text-align: center;
}

.processing-preview {
  width: 200px;
  height: 200px;
  margin: 0 auto 24px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-bg-hover);
}

.processing-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.processing-steps {
  background: white;
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
}

.processing-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
}

.processing-step:last-child {
  border-bottom: none;
}

.processing-step .step-icon {
  font-size: 20px;
  width: 28px;
  text-align: center;
}

.processing-step .step-text {
  font-size: 14px;
  color: var(--color-text-light);
}

.processing-step.active .step-text {
  color: var(--color-primary);
  font-weight: 500;
}

.processing-step.done .step-text {
  color: var(--color-success);
}

.processing-step.error .step-text {
  color: var(--color-error);
}

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

.processing-step.active .step-icon {
  animation: spin 1s linear infinite;
}

/* Buttons */
.btn {
  width: 100%;
  padding: 16px 24px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 8px;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  color: white;
  box-shadow: var(--shadow-md);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.btn-secondary {
  background: var(--color-bg-hover);
  color: var(--color-text);
}

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

/* Error Messages */
.error-message {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--color-error);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  margin-bottom: 16px;
  text-align: left;
}

/* Result Section */
.result-section {
  text-align: center;
}

.result-image-container {
  margin-bottom: 20px;
  display: inline-block;
  position: relative;
}

.result-image-container img {
  max-width: 100%;
  max-height: 350px;
}

/* 水印 */
.watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-30deg);
  font-size: 24px;
  font-weight: 700;
  color: rgba(255, 0, 100, 0.4);
  pointer-events: none;
  white-space: nowrap;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
  letter-spacing: 4px;
}

.result-info {
  background: var(--color-bg-hover);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 24px;
  text-align: left;
}

.result-success {
  text-align: center;
}

.success-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-success);
  margin-bottom: 16px;
}

.result-specs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  text-align: left;
}

.spec-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  background: white;
  border-radius: var(--radius-sm);
}

.spec-label {
  font-size: 13px;
  color: var(--color-text-muted);
}

.spec-value {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Responsive */
@media (max-width: 380px) {
  .country-grid {
    grid-template-columns: 1fr;
  }
  .crop-container {
    height: 350px;
  }
}

/* ============================================
   兑换码弹窗
   ============================================ */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

.modal-content {
  background: white;
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  width: 90%;
  max-width: 360px;
  position: relative;
  animation: slideUp 0.3s ease;
  text-align: center;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  background: var(--color-bg-hover);
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: var(--transition);
}

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

.modal-content h3 {
  font-size: 20px;
  margin-bottom: 8px;
}

.modal-desc {
  font-size: 14px;
  color: var(--color-text-light);
  margin-bottom: 20px;
}

.redeem-input {
  width: 100%;
  padding: 14px 18px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 16px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 16px;
  transition: var(--transition);
}

.redeem-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.modal-error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-error);
  padding: 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
}

.modal-content .btn {
  margin-top: 0;
}

.current-credits {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
  font-size: 14px;
  color: var(--color-text-light);
}

.current-credits strong {
  color: var(--color-primary);
  font-size: 18px;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #0f0f1a;
    --color-bg-card: #1a1a2e;
    --color-bg-hover: #252540;
    --color-text: #f0f0f5;
    --color-text-light: #a0a0b5;
    --color-text-muted: #6b6b80;
    --color-border: #2a2a45;
  }
  
  body {
    background: linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 100%);
  }
  
  .crop-container {
    background: #1a1a2e;
  }
}
