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

body {
  font-family: "Noto Sans SC", "Source Han Sans SC", "思源黑体", sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
  overflow-x: hidden;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  background: white;
  border-radius: 20px;
  padding: 40px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

/* 头部 */
header {
  text-align: center;
  margin-bottom: 40px;
}

header h1 {
  font-size: 2.5em;
  color: #333;
  margin-bottom: 10px;
}

header p {
  color: #666;
  font-size: 1.1em;
}

/* 进度步骤 */
.progress-steps {
  display: flex;
  justify-content: space-between;
  margin-bottom: 50px;
  position: relative;
}

.progress-steps::before {
  content: "";
  position: absolute;
  top: 20px;
  left: 0;
  right: 0;
  height: 2px;
  background: #e0e0e0;
  z-index: 0;
}

.step {
  flex: 1;
  text-align: center;
  position: relative;
  z-index: 1;
}

.step-number {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #e0e0e0;
  color: #999;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 10px;
  font-weight: bold;
  transition: all 0.3s ease;
}

.step.active .step-number {
  background: #667eea;
  color: white;
  transform: scale(1.1);
}

.step.completed .step-number {
  background: #4caf50;
  color: white;
}

.step-label {
  font-size: 0.9em;
  color: #999;
}

.step.active .step-label {
  color: #667eea;
  font-weight: bold;
}

/* 步骤内容 */
.step-content {
  display: none;
}

.step-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

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

.step-content h2 {
  color: #333;
  margin-bottom: 30px;
  font-size: 1.8em;
}

/* 上传区域 */
.upload-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 30px;
  margin-bottom: 30px;
}

.upload-box h3 {
  color: #333;
  margin-bottom: 15px;
  font-size: 1.2em;
}

.drop-zone {
  border: 3px dashed #ccc;
  border-radius: 15px;
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background: #f9f9f9;
}

.drop-zone:hover {
  border-color: #667eea;
  background: #f0f4ff;
}

.drop-zone.drag-over {
  border-color: #667eea;
  background: #e3eaff;
  transform: scale(1.02);
}

.upload-icon {
  font-size: 3em;
  display: block;
  margin-bottom: 15px;
}

.drop-zone p {
  color: #666;
  margin: 5px 0;
}

.hint {
  font-size: 0.85em;
  color: #999 !important;
}

.preview-box {
  position: relative;
  border-radius: 15px;
  overflow: hidden;
  background: #f9f9f9;
  padding: 20px;
}

.preview-box img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.btn-remove {
  position: absolute;
  top: 30px;
  right: 30px;
  background: #f44336;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9em;
  transition: all 0.3s ease;
}

.btn-remove:hover {
  background: #d32f2f;
  transform: scale(1.05);
}

/* 签名列表 */
.signature-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  margin-bottom: 10px;
  background: #f9f9f9;
}

.signature-item input[type="text"] {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}

.signature-item .signature-preview {
  width: 60px;
  height: 40px;
  object-fit: contain;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: white;
}

.signature-item .btn-upload,
.signature-item .btn-delete {
  padding: 6px 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.signature-item .btn-upload {
  background: #667eea;
  color: white;
}

.signature-item .btn-upload:hover {
  background: #5568d3;
}

.signature-item .btn-delete {
  background: #f44336;
  color: white;
}

.signature-item .btn-delete:hover {
  background: #d32f2f;
}

/* 配置区域 */
.config-section {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 30px;
  margin-bottom: 30px;
  align-items: start;
}

.canvas-container {
  background: #f9f9f9;
  border-radius: 15px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0; /* 防止溢出 */
  overflow: hidden;
}

#certificateCanvas {
  max-width: 100%;
  height: auto;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.canvas-hint {
  margin-top: 15px;
  text-align: center;
}

.canvas-hint-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.canvas-hint p {
  color: #666;
  font-size: 0.9em;
  margin: 0;
}

.date-presets {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.date-preset-btn {
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #374151;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  line-height: 1.4;
  cursor: pointer;
  transition: all 0.2s;
}

.date-preset-btn:hover {
  border-color: #9ca3af;
  background: #f9fafb;
}

.date-preset-btn.active {
  border-color: #4f46e5;
  background: #eef2ff;
  color: #3730a3;
}

.config-panel {
  background: #f9f9f9;
  border-radius: 15px;
  padding: 25px;
  max-height: calc(100vh - 250px);
  overflow-y: auto;
  position: sticky;
  top: 20px;
}

.config-panel h3 {
  color: #333;
  margin-bottom: 20px;
  font-size: 1.3em;
}

.config-group {
  margin-bottom: 25px;
  padding-bottom: 25px;
  border-bottom: 1px solid #e0e0e0;
}

.config-group:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.config-group > label {
  display: block;
  font-weight: bold;
  color: #555;
  margin-bottom: 15px;
}

.input-row {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
  gap: 10px;
}

.input-row label {
  min-width: 90px;
  color: #666;
  font-size: 0.95em;
}

.input-row input[type="number"],
.input-row input[type="color"],
.input-row select {
  flex: 1;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.95em;
}

.input-row input.size-input {
  flex: 0 0 60px;
  margin-left: 10px;
  text-align: center;
  padding: 6px;
}

.input-row input.coord-input {
  flex: 1;
  max-width: 100px;
}

.center-x-btn {
  flex: 0 0 auto;
  padding: 6px 10px;
  border: 1px solid #c7d2fe;
  border-radius: 8px;
  background: #eef2ff;
  color: #374151;
  font-size: 0.82em;
  cursor: pointer;
  white-space: nowrap;
}

.center-x-btn:hover {
  background: #e0e7ff;
}

.input-row input[type="range"] {
  flex: 1;
}

.input-row span {
  color: #999;
  font-size: 0.9em;
  min-width: 30px;
  text-align: left;
}

.csv-upload h3,
.csv-preview h3 {
  color: #333;
  margin-bottom: 15px;
  font-size: 1.2em;
}

.csv-info {
  background: #f0f4ff;
  border-left: 4px solid #667eea;
  padding: 15px;
  margin-top: 15px;
  border-radius: 8px;
}

.csv-info p {
  font-weight: bold;
  color: #667eea;
  margin-bottom: 10px;
}

.csv-info ul {
  list-style: none;
  padding-left: 0;
}

.csv-info li {
  color: #666;
  margin: 5px 0;
  padding-left: 20px;
  position: relative;
}

.csv-info li::before {
  content: "•";
  position: absolute;
  left: 5px;
  color: #667eea;
}

.download-link {
  display: inline-block;
  margin-top: 10px;
  color: #667eea;
  text-decoration: none;
  font-weight: bold;
}

.download-link:hover {
  text-decoration: underline;
}

.csv-preview {
  background: #f9f9f9;
  border-radius: 15px;
  padding: 20px;
}

#csvPreviewTable {
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 15px;
}

.preview-table {
  width: 100%;
  border-collapse: collapse;
}

.preview-table th,
.preview-table td {
  padding: 10px;
  text-align: left;
  border-bottom: 1px solid #e0e0e0;
}

.preview-table th {
  background: #667eea;
  color: white;
  font-weight: bold;
  position: sticky;
  top: 0;
}

.preview-table tr:hover {
  background: #f0f4ff;
}

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

.csv-stats p {
  color: #666;
}

.csv-stats strong {
  color: #667eea;
  font-size: 1.2em;
}

/* 生成区域 */
.generate-section {
  margin-bottom: 30px;
}

.format-selection h3 {
  color: #333;
  margin-bottom: 20px;
  font-size: 1.3em;
}

.format-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.format-option {
  cursor: pointer;
}

.format-option input[type="radio"] {
  display: none;
}

.format-card {
  border: 3px solid #e0e0e0;
  border-radius: 15px;
  padding: 30px;
  text-align: center;
  transition: all 0.3s ease;
  background: #f9f9f9;
}

.format-option input[type="radio"]:checked + .format-card {
  border-color: #667eea;
  background: #f0f4ff;
  transform: scale(1.05);
}

.format-icon {
  font-size: 3em;
  display: block;
  margin-bottom: 15px;
}

.format-card strong {
  display: block;
  color: #333;
  font-size: 1.2em;
  margin-bottom: 10px;
}

.format-card p {
  color: #666;
  font-size: 0.9em;
}

.generate-controls {
  text-align: center;
  margin-bottom: 30px;
}

.progress-section h3,
.download-section h3 {
  color: #333;
  margin-bottom: 20px;
  font-size: 1.3em;
}

.progress-bar-container {
  width: 100%;
  height: 30px;
  background: #e0e0e0;
  border-radius: 15px;
  overflow: hidden;
  margin-bottom: 15px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
  width: 0%;
  transition: width 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
}

.progress-text {
  text-align: center;
  color: #666;
  font-size: 1.1em;
}

.download-section {
  text-align: center;
  background: #e8f5e9;
  border-radius: 15px;
  padding: 30px;
}

.download-hint {
  color: #666;
  margin-top: 15px;
}

/* 按钮样式 */
.button-group {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  margin-top: 30px;
}

.button-group-vertical {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-primary,
.btn-secondary {
  padding: 12px 30px;
  border: none;
  border-radius: 10px;
  font-size: 1em;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.btn-primary:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.btn-secondary {
  background: #f0f0f0;
  color: #333;
}

.btn-secondary:hover {
  background: #e0e0e0;
  transform: translateY(-2px);
}

.btn-large {
  padding: 18px 50px;
  font-size: 1.2em;
}

/* 加载动画 */
.spinner {
  border: 4px solid #f3f3f3;
  border-top: 4px solid #667eea;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
