/* CSS Reset & Variables */
:root {
  /* Colors */
  --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --primary-color: #667eea;
  --primary-dark: #5a6fd8;
  --primary-color-dark: #5a6fd8;
  --primary-light: #8b9ef7;
  
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --green-100: #dcfce7;
  --green-700: #15803d;
  --blue-100: #dbeafe;
  --blue-700: #1d4ed8;
  --red-500: #ef4444;
  --radius-full: 9999px;
  
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  
  --white: #ffffff;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  
  /* Typography */
  --font-family: 'PingFang SC', -apple-system, BlinkMacSystemFont, 'Microsoft YaHei', '微软雅黑', sans-serif;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  
  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-12: 3rem;
  --space-16: 4rem;
  
  /* Border radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  
  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Layout */
  --sidebar-width: 320px;
  --header-height: 72px;
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
}

* {
  margin: 0;
  padding: 0;
}

body {
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

input, button, textarea, select {
  font: inherit;
}

/* Base Styles */
body {
  font-family: var(--font-family);
  background: var(--gray-50);
  color: var(--gray-900);
  font-size: var(--text-base);
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
}

.header-content {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 var(--space-6);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.logo-icon {
  font-size: var(--text-2xl);
}

.logo-text {
  font-size: var(--text-xl);
  font-weight: 700;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.version {
  font-size: var(--text-sm);
  color: var(--gray-500);
  background: var(--gray-100);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-md);
}

/* Main Layout */
.main {
  flex: 1;
  padding: var(--space-8) 0;
}

.container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 var(--space-6);
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-8);
  min-height: calc(100vh - var(--header-height) - var(--space-16));
}

@media (min-width: 1024px) {
  .container {
    grid-template-columns: var(--sidebar-width) 1fr;
  }
}

/* 大屏幕模板列表优化 */
@media (min-width: 1440px) {
  .template-list {
    max-height: 480px; /* 大屏幕可以显示更多模板 */
  }
  
  .dynamic-config-section {
    max-height: 400px; /* 大屏幕可以显示更多配置项 */
  }
}

/* Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  max-width: var(--sidebar-width);
  height: calc(100vh - 120px); /* 固定侧边栏总高度 */
  align-items: stretch;
}

.section-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--gray-900);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.section-icon {
  width: 20px;
  height: 20px;
  color: var(--primary-color);
}

/* Template Section */
.template-section {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--gray-200);
  flex: 1;
  min-height: 400px;
  display: flex;
  flex-direction: column;
}

/* Filter Section */
.filter-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--gray-200);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.filter-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--gray-700);
}

.filter-select {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  background: var(--white);
  font-size: var(--text-sm);
  color: var(--gray-900);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-select:hover {
  border-color: var(--primary-color);
}

.filter-select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 1px var(--primary-color);
}

/* Template List */
.template-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1; /* 占用模板区域的剩余空间 */
  overflow-y: auto;
  padding-right: var(--space-2); /* 为滚动条留出空间 */
}

/* 美化滚动条 */
.template-list::-webkit-scrollbar {
  width: 6px;
}

.template-list::-webkit-scrollbar-track {
  background: var(--gray-100);
  border-radius: 3px;
}

.template-list::-webkit-scrollbar-thumb {
  background: var(--gray-400);
  border-radius: 3px;
}

.template-list::-webkit-scrollbar-thumb:hover {
  background: var(--gray-500);
}

.template-grid {
  display: grid;
  gap: var(--space-3);
}

.template-loading {
  text-align: center;
  padding: var(--space-8) 0;
  color: var(--gray-500);
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--gray-200);
  border-top: 2px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto var(--space-3);
}

/* Template List Item */
.template-item {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  cursor: pointer;
  transition: all var(--transition-fast);
  background: var(--white);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.template-item:hover {
  border-color: var(--primary-color);
  background: var(--gray-50);
  transform: translateX(4px);
}

.template-item.active {
  border-color: var(--primary-color);
  background: var(--primary-color);
  color: var(--white);
  box-shadow: var(--shadow-md);
  position: relative;
  animation: template-selected 0.3s ease-out;
}

@keyframes template-selected {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.02);
  }
  100% {
    transform: scale(1);
  }
}

.template-item.active .template-meta {
  color: rgba(255, 255, 255, 0.8);
}

.template-item.active .template-grade {
  background: rgba(255, 255, 255, 0.2);
  color: var(--white);
}

.template-content {
  flex: 1;
  min-width: 0;
}

.template-name {
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: var(--space-1);
  font-size: var(--text-base);
}

.template-item.active .template-name {
  color: var(--white);
}

.template-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--gray-500);
  flex-wrap: wrap;
}

.template-grade {
  background: var(--primary-color);
  color: var(--white);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 500;
}

.template-month {
  background: var(--gray-100);
  color: var(--gray-600);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
}

.template-item.active .template-month {
  background: rgba(255, 255, 255, 0.2);
  color: var(--white);
}

.template-sections {
  color: var(--gray-500);
  font-size: var(--text-xs);
}

.template-item.active .template-sections {
  color: rgba(255, 255, 255, 0.8);
}

/* Legacy template card styles for mobile/grid view */
.template-card {
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition-normal);
  background: var(--white);
}

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

.template-card.active {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 1px var(--primary-color);
}

.template-image {
  width: 100%;
  height: 160px;
  object-fit: cover;
  background: var(--gray-100);
}

.template-info {
  padding: var(--space-4);
}

.template-difficulty {
  color: var(--gray-500);
}

/* Configuration Section */
.config-section {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--gray-200);
  flex: 1; /* 占用剩余空间 */
  overflow: hidden; /* 外层隐藏溢出 */
  display: flex;
  flex-direction: column;
}

.config-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  overflow-y: auto; /* 启用垂直滚动 */
  flex: 1; /* 占用可用空间 */
  padding-right: var(--space-2); /* 为滚动条预留空间 */
}

/* 动态配置区域样式优化 */
.dynamic-config-section {
  /* 移除高度限制，由父容器config-form统一处理滚动 */
  margin: var(--space-2) 0;
}

/* 美化配置区域滚动条 */
.config-form::-webkit-scrollbar {
  width: 6px;
}

.config-form::-webkit-scrollbar-track {
  background: var(--gray-100);
  border-radius: 3px;
}

.config-form::-webkit-scrollbar-thumb {
  background: var(--gray-400);
  border-radius: 3px;
}

.config-form::-webkit-scrollbar-thumb:hover {
  background: var(--gray-500);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.form-label {
  font-weight: 500;
  color: var(--gray-700);
  font-size: var(--text-sm);
}

/* Slider Styles */
.slider-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.slider {
  width: 100%;
  height: 6px;
  border-radius: var(--radius-sm);
  background: var(--gray-200);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary-color);
  cursor: pointer;
  border: 2px solid var(--white);
  box-shadow: var(--shadow-md);
  transition: all var(--transition-fast);
}

.slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  box-shadow: var(--shadow-lg);
}

.slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary-color);
  cursor: pointer;
  border: 2px solid var(--white);
  box-shadow: var(--shadow-md);
}

.slider-value {
  text-align: right;
  font-weight: 600;
  color: var(--primary-color);
  font-size: var(--text-sm);
}


/* Advanced Settings */
.advanced-toggle {
  background: none;
  border: none;
  padding: var(--space-2) 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--gray-600);
  font-weight: 500;
  transition: color var(--transition-fast);
}

.advanced-toggle:hover {
  color: var(--primary-color);
}

.toggle-icon {
  width: 16px;
  height: 16px;
  transition: transform var(--transition-normal);
}

.advanced-toggle.expanded .toggle-icon {
  transform: rotate(90deg);
}

.advanced-options {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-normal);
}

.advanced-options.expanded {
  max-height: 300px;
}

/* Checkbox Group */
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  font-size: var(--text-sm);
}

.checkbox-item input[type="checkbox"] {
  display: none;
}

.checkmark {
  width: 20px;
  height: 20px;
  border: 2px solid var(--gray-300);
  border-radius: var(--radius-sm);
  position: relative;
  transition: all var(--transition-fast);
}

.checkbox-item input[type="checkbox"]:checked + .checkmark {
  background: var(--primary-color);
  border-color: var(--primary-color);
}

.checkbox-item input[type="checkbox"]:checked + .checkmark::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--white);
  font-size: 12px;
  font-weight: bold;
}

/* Generate Button */
.generate-btn {
  background: var(--primary-gradient);
  color: var(--white);
  border: none;
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-6);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-md);
}

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

.generate-btn:active {
  transform: translateY(0);
}

.generate-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-icon {
  width: 20px;
  height: 20px;
}

/* Preview Area */
.preview-area {
  background: var(--white);
  border-radius: var(--radius-xl);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  min-height: 85vh;
  overflow: hidden;
}

.preview-header {
  padding: var(--space-4); /* 从space-6减少到space-4，让头部更紧凑 */
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, var(--gray-50) 0%, var(--white) 100%);
  backdrop-filter: blur(10px);
}

.preview-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--gray-900);
}

.preview-actions {
  display: flex;
  gap: var(--space-3);
  align-items: center;
}

/* 旧的action-btn样式已移除，使用统一的新版本 */

/* Preview Container */
.preview-container {
  flex: 1;
  padding: var(--space-4);
  position: relative;
  background: var(--gray-50);
  border-radius: var(--radius-xl);
  margin: var(--space-4);
}

.preview-state {
  position: absolute;
  inset: var(--space-4);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  background: var(--white);
}

/* PDF Preview State - 让PDF容器占满整个预览区域 */
.pdf-state {
  padding: 0;
  background: var(--gray-50);
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}

/* Placeholder State */
.preview-placeholder {
  text-align: center;
  color: var(--gray-400);
}

.placeholder-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-4);
  opacity: 0.5;
}

.placeholder-text {
  font-size: var(--text-lg);
}

/* Loading State */
.loading-content {
  text-align: center;
  max-width: 400px;
  padding: var(--space-8);
}

.loading-spinner {
  width: 64px;
  height: 64px;
  border: 4px solid var(--gray-200);
  border-top: 4px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1.5s linear infinite;
  margin: 0 auto var(--space-6);
}

.loading-content h3 {
  color: var(--gray-900);
  margin-bottom: var(--space-3);
  font-size: var(--text-xl);
  font-weight: 600;
}

.loading-text {
  color: var(--gray-600);
  margin-bottom: var(--space-8);
  font-size: var(--text-base);
  line-height: 1.6;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--gray-200);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.progress-fill {
  height: 100%;
  background: var(--primary-gradient);
  width: 0%;
  transition: width var(--transition-normal);
  animation: progress-fill 3s ease-in-out;
  border-radius: var(--radius-lg);
}

/* Error State */
.error-content {
  text-align: center;
  max-width: 300px;
}

.error-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-4);
  color: var(--error);
}

.error-content h3 {
  color: var(--gray-900);
  margin-bottom: var(--space-2);
}

.error-message {
  color: var(--gray-500);
  margin-bottom: var(--space-6);
}

.retry-btn {
  background: var(--error);
  color: var(--white);
  border: none;
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-6);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 500;
  transition: all var(--transition-fast);
}

.retry-btn:hover {
  background: #dc2626;
}

/* PDF容器样式 - 优化的全屏体验 */
.pdf-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--white);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--gray-200);
}

.pdf-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background: linear-gradient(135deg, var(--gray-50) 0%, var(--white) 100%);
  border-bottom: 1px solid var(--gray-200);
  gap: var(--space-4);
  flex-wrap: wrap;
  min-height: 60px;
}

/* 移除不再需要的返回按钮样式 */

.pdf-status {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1;
  min-width: 0;
}

.pdf-title {
  font-size: var(--text-base);
  font-weight: 600;
  margin: 0;
  color: var(--gray-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (min-width: 768px) {
  .pdf-title {
    font-size: var(--text-lg);
  }
}

.pdf-actions {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
}

.pdf-description {
  padding: var(--space-2) var(--space-4);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  font-size: var(--text-sm);
  color: var(--gray-600);
  text-align: center;
}

.pdf-viewer-wrapper {
  flex: 1;
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2);
}

.pdf-viewer {
  width: 100%;
  height: 100%;
  min-height: 65vh;
  border: none;
  border-radius: var(--radius-md);
  background: var(--white);
  box-shadow: var(--shadow-md);
  transition: all var(--transition-normal);
}

/* 在PDF聚焦模式下，给PDF更多高度 */
@media (min-width: 1024px) {
  .container.pdf-focused .pdf-viewer {
    min-height: 75vh;
  }
}

.pdf-viewer:hover {
  box-shadow: var(--shadow-lg);
}

/* 按钮样式优化 */
.download-btn, .generate-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}

.download-btn {
  background: var(--primary-color);
  color: var(--white);
}

.download-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.generate-btn {
  background: var(--white);
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}

.generate-btn:hover {
  background: var(--gray-50);
  color: var(--gray-900);
  border-color: var(--gray-400);
}

.btn-text {
  display: none;
}

@media (min-width: 640px) {
  .btn-text {
    display: inline;
  }
  
  .download-btn, .generate-btn {
    padding: var(--space-2) var(--space-4);
  }
}

/* 状态徽章样式 */
.status-badge {
  display: inline-block;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.status-badge.sample {
  background: var(--success);
  color: var(--white);
}

.status-badge.generated {
  background: var(--primary-color);
  color: var(--white);
}

/* Mobile Progress Bar */
.mobile-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: var(--primary-gradient);
  z-index: 2000;
  display: none;
  box-shadow: 0 0 10px rgba(102, 126, 234, 0.5);
}

/* Mobile Styles */
@media (max-width: 1023px) {
  .container {
    grid-template-columns: 1fr; /* 单列布局，不限制宽度 */
    padding: 0 var(--space-4); /* 统一的页面边距 */
  }
  
  .sidebar {
    order: 2;
    max-width: none; /* 移除320px宽度限制 */
  }
  
  .preview-area {
    order: 1;
    min-height: 70vh;
  }
  
  .template-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  /* 移动端保持正常布局，不做特殊处理 */
  .container.pdf-focused {
    grid-template-columns: 1fr;
  }
  
  .pdf-viewer {
    min-height: 60vh;
  }
  
  .pdf-toolbar {
    padding: var(--space-2) var(--space-3);
  }
}

@media (max-width: 767px) {
  .container {
    gap: var(--space-6);
  }
  
  .template-section,
  .contact-section {
    padding: var(--space-4);
  }
  
  /* 模板列表和动态配置区域的高度由新的响应式布局统一管理 */
  
  .preview-area {
    min-height: 500px;
  }
  
  .preview-header {
    padding: var(--space-4);
    flex-wrap: wrap;
    gap: var(--space-3);
  }
  
  .preview-actions {
    justify-content: center;
  }
  
  .action-btn {
    flex: 1;
    justify-content: center;
    padding: var(--space-4);
  }
  
  .preview-container {
    padding: var(--space-4);
    margin: var(--space-3);
  }
  
  .pdf-viewer {
    border-radius: var(--radius-lg);
  }
  
  .template-grid {
    grid-template-columns: 1fr;
  }
  
  .header-content {
    padding: 0 var(--space-4);
  }
  
  .logo-text {
    font-size: var(--text-lg);
  }
}

/* Mobile Template Selector */
.mobile-template-selector {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--white);
  z-index: 1000;
  display: none;
  flex-direction: column;
}

.mobile-template-selector.active {
  display: flex;
}

.mobile-template-header {
  padding: var(--space-4);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.close-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-2);
  color: var(--gray-500);
}

.mobile-template-grid {
  flex: 1;
  padding: var(--space-4);
  overflow-y: auto;
}

.mobile-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  display: none;
}

.mobile-overlay.active {
  display: block;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: var(--space-6);
  right: var(--space-6);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.toast {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  max-width: 400px;
  transform: translateX(100%);
  animation: toast-slide-in var(--transition-normal) forwards;
}

.toast.success {
  border-left: 4px solid var(--success);
}

.toast.error {
  border-left: 4px solid var(--error);
}

.toast.warning {
  border-left: 4px solid var(--warning);
}

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

@keyframes progress-fill {
  0% { width: 0%; }
  50% { width: 60%; }
  100% { width: 100%; }
}

@keyframes toast-slide-in {
  to {
    transform: translateX(0);
  }
}

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

@keyframes progress-sweep {
  from {
    width: 0%;
  }
  to {
    width: 100%;
  }
}

/* Utility Classes */
.fade-in {
  animation: fade-in var(--transition-normal) ease-out;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* 新的PDF容器样式 - 覆盖旧版本 */
.pdf-header-compact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  min-height: 50px;
}

.pdf-info {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  flex: 1;
  min-width: 0;
  flex-direction: column;
}

@media (min-width: 768px) {
  .pdf-info {
    flex-direction: row;
    align-items: center;
  }
  
  .pdf-subtitle {
    margin-top: 0;
    margin-left: var(--space-2);
  }
}

.pdf-title-compact {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--gray-900);
  line-height: 1.3;
  flex: 1;
  min-width: 0;
}

.pdf-subtitle {
  font-size: var(--text-xs);
  color: var(--gray-500);
  line-height: 1.2;
  margin-top: var(--space-1);
}

.pdf-actions-compact {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
}

.btn-text-compact {
  display: none;
}

@media (min-width: 360px) {
  .btn-text-compact {
    display: inline;
  }
  
  .action-btn {
    padding: var(--space-2) var(--space-4);
  }
}

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: var(--text-sm) !important;
  font-weight: 500;
  white-space: nowrap;
}

/* 确保按钮内的SVG图标大小合适 */
.action-btn svg {
  width: 1.2em;
  height: 1.2em;
  flex-shrink: 0;
}

.action-btn.primary {
  background: var(--primary-color);
  color: var(--white);
}

.action-btn.primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.action-btn.secondary {
  background: var(--white);
  color: var(--gray-600);
  border: 1px solid var(--gray-300);
}

.action-btn.secondary:hover {
  background: var(--gray-50);
  color: var(--gray-900);
  border-color: var(--gray-400);
}

.pdf-viewer-full {
  flex: 1;
  width: 100%;
  height: 100%;
  border: none;
  background: var(--white);
}

@media (min-width: 1024px) {
  .pdf-viewer-full {
    min-height: 78vh;
  }

  .pdf-title-compact {
    font-size: var(--text-base);
  }

  .pdf-subtitle {
    font-size: var(--text-sm);
  }
}

@media (max-width: 1023px) {
  .pdf-viewer-full {
    flex: 1; /* 占用剩余空间 */
    min-height: 200px; /* 减少最小高度 */
    max-height: calc(100vh - 300px); /* 为header和其他内容预留更多空间 */
  }
  
  .pdf-container {
    max-height: calc(100vh - 120px); /* 限制整个容器高度 */
  }
}

/* 覆盖原有PDF容器样式 */
.pdf-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  background: var(--white);
  border-radius: var(--radius-lg);
  overflow: hidden;
  flex: 1;
}

/* PDF.js渲染容器样式 */
.pdf-viewer-container {
  flex: 1;
  overflow: auto;
  padding: var(--space-4);
  background: var(--gray-50);
  display: flex;
  flex-direction: column;
}

.pdf-pages-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
}

.pdf-canvas {
  display: block;
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-md);
  background: white;
  border: 1px solid var(--gray-200);
}

.pdf-page-indicator {
  background: var(--gray-100);
  color: var(--gray-700);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  text-align: center;
  border: 1px solid var(--gray-200);
}

.pdf-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  text-align: center;
  color: var(--gray-600);
  min-height: 200px;
}

.pdf-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  text-align: center;
  color: var(--gray-600);
  min-height: 200px;
}

.pdf-error .error-icon {
  color: var(--error);
  margin-bottom: var(--space-4);
}

.pdf-error h3 {
  margin: var(--space-2) 0;
  color: var(--gray-900);
}

.pdf-error .error-detail {
  margin: var(--space-2) 0 var(--space-4);
  font-size: var(--text-sm);
  color: var(--gray-500);
}

/* 新的PDF头部布局 - 覆盖旧样式 */
.pdf-header-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  gap: var(--space-4);
  min-height: 60px;
}

.pdf-status-line {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1;
  min-width: 0;
}

.pdf-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--gray-900);
  margin: 0;
  line-height: 1.3;
}

@media (min-width: 768px) {
  .pdf-title {
    font-size: var(--text-base);
  }
}

.pdf-actions {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
}

.pdf-description-line {
  padding: var(--space-2) var(--space-4);
  background: #fafafa;
  border-bottom: 1px solid var(--gray-200);
}

.pdf-description {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--gray-600);
  line-height: 1.4;
}

/* 移动端响应式设计 */
@media (max-width: 767px) {
  .pdf-header-main {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-3);
    min-height: 100px; /* 垂直布局需要更多高度 */
  }
  
  .pdf-actions {
    justify-content: center;
  }
  
  .pdf-viewer-full {
    min-height: 150px; /* 小屏幕进一步减少iframe高度 */
    max-height: calc(100vh - 350px); /* 为垂直header预留更多空间 */
  }
}
  
  .action-btn {
    flex: 1;
    justify-content: center;
  }
}

/* 更新按钮样式 */
@media (min-width: 360px) {
  .btn-text-compact {
    display: inline;
  }
  
  .action-btn {
    padding: var(--space-2) var(--space-4);
  }
}

/* 标签输入行样式（抽屉中使用） - 改为3行垂直布局 */
.labels-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
  margin-top: var(--space-2);
}

.label-input {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  transition: all var(--transition-fast);
  background: var(--white);
  text-align: left; /* 改为左对齐，更适合垂直布局 */
}

.label-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 1px var(--primary-color);
}

.label-input::placeholder {
  color: var(--gray-400);
}

/* 学生信息栏组的显示/隐藏逻辑 */
.student-labels {
  transition: opacity var(--transition-normal);
}

.student-labels.hidden {
  opacity: 0.5;
  pointer-events: none;
}

/* 抽屉式高级设置样式 */
.settings-drawer {
  position: fixed;
  top: 0;
  right: -420px; /* 默认隐藏在右侧外 */
  width: 420px;
  height: 100vh;
  z-index: 1000;
  transition: right var(--transition-normal) ease;
}

.settings-drawer.open {
  right: 0; /* 滑入可视区域 */
}

.drawer-overlay {
  position: absolute;
  top: 0;
  left: -100vw;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity var(--transition-normal);
  pointer-events: none;
}

.settings-drawer.open .drawer-overlay {
  opacity: 1;
  pointer-events: auto;
}

.drawer-content {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--white);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
}

.drawer-header {
  padding: var(--space-6);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--gray-50);
}


.drawer-title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--gray-900);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.drawer-icon {
  width: 20px;
  height: 20px;
  color: var(--primary-color);
}

.drawer-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-2);
  color: var(--gray-500);
  transition: color var(--transition-fast);
  border-radius: var(--radius-md);
}

.drawer-close:hover {
  color: var(--gray-700);
  background: var(--gray-100);
}

.drawer-body {
  flex: 1;
  padding: var(--space-6);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

/* 高级设置触发按钮 */
.advanced-trigger {
  width: 100%;
  background: var(--white);
  color: var(--primary-color);
  border: 1px solid var(--primary-color);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-weight: 500;
}

.advanced-trigger:hover {
  background: var(--primary-color);
  color: var(--white);
}

.advanced-trigger .btn-icon {
  width: 16px;
  height: 16px;
}

/* 设置按钮 */
.settings-trigger-btn {
  background: var(--white);
  border: 1px solid var(--gray-300);
  cursor: pointer;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--gray-700);
  transition: all var(--transition-fast);
  font-weight: 500;
  margin-left: auto; /* 让按钮靠右 */
}

.settings-trigger-btn:hover {
  background: var(--gray-50);
  color: var(--primary-color);
  border-color: var(--primary-color);
}

.settings-trigger-btn .settings-icon {
  width: 18px;
  height: 18px;
}

.settings-trigger-btn .settings-text {
  font-size: var(--text-sm);
}

/* 联系信息区域 */
.contact-section {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--gray-200);
  flex-shrink: 0;
}

/* PC端让contact-section自适应高度，不设置固定值 */

.contact-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* 微信二维码容器样式 */
.wechat-qrcode-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--gray-50);
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  text-align: center;
}

.qrcode-label {
  font-size: var(--text-sm);
  color: var(--gray-700);
  font-weight: 600;
  margin: 0;
}

.qrcode-image-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: var(--space-2);
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
}

.wechat-qrcode {
  width: 140px;
  height: 140px;
  border-radius: var(--radius-md);
  display: block;
}

.qrcode-desc {
  font-size: var(--text-sm);
  color: var(--gray-500);
  line-height: 1.4;
  margin: 0;
}

/* 预览区域生成按钮 */
.generate-btn-header {
  background: var(--primary-gradient);
  color: var(--white);
  border: none;
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-5);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-md);
}

.generate-btn-header:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.generate-btn-header:active {
  transform: translateY(0);
}

.generate-btn-header:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.generate-btn-header .btn-icon {
  width: 18px;
  height: 18px;
}

/* 设置分组样式 */
.settings-groups {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.settings-group {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--white);
}

.settings-group-header {
  padding: var(--space-4);
  background: linear-gradient(135deg, var(--gray-50) 0%, var(--white) 100%);
  border-bottom: 1px solid var(--gray-200);
}

.settings-group-title {
  margin: 0;
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--gray-900);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.settings-group-title .group-icon {
  width: 18px;
  height: 18px;
  color: var(--primary-color);
}

.settings-group-content {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* 滚动区域响应式优化 */
@media (max-height: 900px) {
  .sidebar {
    height: calc(100vh - 100px); /* 小屏幕减少顶部边距 */
  }
  
  .template-section {
    height: 380px; /* 中等屏幕减少模板区域高度 */
  }
}

@media (max-height: 700px) {
  .sidebar {
    height: calc(100vh - 80px); /* 更小屏幕进一步减少边距 */
  }
  
  .template-section {
    height: 300px; /* 小屏幕显著减少模板区域高度 */
  }
}

@media (max-width: 768px) {
  .sidebar {
    height: auto; /* 移动端取消固定高度 */
  }
  
  .template-section {
    height: auto; /* 移动端取消固定高度 */
    max-height: 300px; /* 设置最大高度 */
  }
  
  .contact-section {
    flex: none; /* 移动端取消flex伸缩 */
  }
  
  /* Header 设置按钮移动端优化 */
  .settings-trigger-btn .settings-text {
    display: none; /* 移动端隐藏文字 */
  }
  
  .generate-btn-header .btn-text {
    display: none; /* 移动端只显示图标 */
  }
  
  .generate-btn-header {
    padding: var(--space-3); /* 移动端缩小内边距 */
  }
  
  .wechat-qrcode-container {
    gap: var(--space-2);
    padding: var(--space-3);
  }
  
  .wechat-qrcode {
    width: 80px;
    height: 80px;
  }
  
  .labels-row {
    grid-template-columns: 1fr;
    gap: var(--space-2);
  }
  
  .label-input {
    text-align: left;
  }
  
  .settings-group-title {
    font-size: var(--text-sm);
  }
  
  /* 移动端抽屉优化 */
  .settings-drawer {
    right: -100%; /* 移动端从屏幕外滑入 */
    width: 90%; /* 移动端占用90%宽度 */
    max-width: 400px;
  }
  
  .drawer-header,
  .drawer-body,
  .drawer-footer {
    padding: var(--space-4);
  }
  
  .drawer-title {
    font-size: var(--text-base);
  }
  
  
  .labels-row {
    grid-template-columns: 1fr; /* 移动端标签输入框竖直排列 */
    gap: var(--space-3);
  }
}

/* Print Styles - 打印专用样式优化 */
@media print {
  /* 隐藏所有不必要的界面元素 */
  .header,
  .sidebar,
  .preview-header,
  .pdf-actions,
  .pdf-header-main,
  .pdf-description-line,
  .toast-container,
  .settings-drawer,
  .mobile-overlay,
  .mobile-template-selector {
    display: none !important;
  }
  
  /* 确保PDF内容占据整个打印页面 */
  body {
    margin: 0 !important;
    padding: 0 !important;
    background: white !important;
  }
  
  .preview-area,
  .preview-container,
  .pdf-state,
  .pdf-container {
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    background: white !important;
    width: 100% !important;
    height: 100% !important;
    min-height: auto !important;
    max-height: none !important;
  }
  
  /* 优化PDF查看器在打印时的显示 */
  .pdf-viewer-container {
    padding: 0 !important;
    background: white !important;
    height: 100vh !important;
    overflow: visible !important;
  }
  
  .pdf-pages-container {
    gap: 0 !important;
  }
  
  .pdf-canvas {
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    page-break-after: always;
    max-width: 100% !important;
    height: auto !important;
  }
  
  /* 隐藏页面指示器等界面元素 */
  .pdf-page-indicator,
  .pdf-loading,
  .pdf-error {
    display: none !important;
  }
  
  /* 确保iframe内容可以正常打印 */
  .pdf-viewer-full {
    width: 100% !important;
    height: 100vh !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  
  /* 分页控制 */
  @page {
    margin: 0;
    size: A4;
  }
}

/* 打印按钮动画效果 */
.action-btn[title*="打印"] {
  position: relative;
  overflow: hidden;
}

.action-btn[title*="打印"]:active {
  animation: print-pulse 0.3s ease-out;
}

@keyframes print-pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(0.95);
  }
  100% {
    transform: scale(1);
  }
}

/* 打印准备状态指示器 */
.print-preparing {
  position: relative;
}

.print-preparing::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid transparent;
  border-top: 2px solid var(--white);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

