/* 全局样式表 - 基于TailwindCSS的自传小说生成器样式 */

/* 引入TailwindCSS基础样式 */
@import url('https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.2.19/tailwind.min.css');
@import url('https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css');
@import url('https://fonts.loli.net/css2?family=Noto+Serif+SC:wght@300;400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;600;700&display=swap');

/* 全局变量定义 */
:root {
  --primary-color: #ec4899; /* 优雅玫红 */
  --primary-hover: #db2777;
  --secondary-color: #10b981; /* 绿色 */
  --background-gradient: linear-gradient(135deg, #fdf2f8 0%, #ecfdf5 50%, #ffffff 100%);
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --border-color: #e5e7eb;
  --shadow-light: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-medium: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-large: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --border-radius: 0.5rem;
  --transition: all 0.3s ease;
}

/* 全局重置和基础样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

body {
  font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--background-gradient);
  min-height: 100vh;
  overflow-x: hidden;
}

/* 中文字体优化 */
.font-serif {
  font-family: 'Noto Serif SC', serif;
}

.font-sans {
  font-family: 'Noto Sans SC', sans-serif;
}

/* 主容器样式 */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* 页面布局 */
.page-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--background-gradient);
}

.main-content {
  flex: 1;
  padding: 2rem 0;
}

/* 导航栏样式 */
.navbar {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 40;
  transition: var(--transition);
}

.navbar-brand {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
  text-decoration: none;
  transition: var(--transition);
}

.navbar-brand:hover {
  color: var(--primary-hover);
  transform: scale(1.05);
}

.navbar-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius);
  transition: var(--transition);
  position: relative;
}

.nav-link:hover {
  color: var(--primary-color);
  background: rgba(236, 72, 153, 0.1);
}

.nav-link.active {
  color: var(--primary-color);
  background: rgba(236, 72, 153, 0.15);
}

/* 卡片样式 */
.card {
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-light);
  transition: var(--transition);
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--shadow-medium);
  transform: translateY(-2px);
}

.card-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(135deg, #fdf2f8 0%, #ffffff 100%);
}

.card-body {
  padding: 1.5rem;
}

.card-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background: #f9fafb;
}

/* 表单样式 */
.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: block;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 1rem;
  transition: var(--transition);
  background: white;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(236, 72, 153, 0.1);
}

.form-control:invalid {
  border-color: #ef4444;
}

.form-control:valid {
  border-color: var(--secondary-color);
}

.form-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: 2.5rem;
}

/* 按钮样式 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: var(--transition);
  gap: 0.5rem;
  min-height: 2.75rem;
}

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

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

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

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

.btn-secondary:hover:not(:disabled) {
  background: #059669;
  transform: translateY(-1px);
  box-shadow: var(--shadow-medium);
}

.btn-outline {
  background: transparent;
  color: var(--primary-color);
  border: 2px solid var(--primary-color);
}

.btn-outline:hover:not(:disabled) {
  background: var(--primary-color);
  color: white;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 2px solid var(--border-color);
}

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

.btn-lg {
  padding: 1rem 2rem;
  font-size: 1.125rem;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

/* 进度条样式 */
.progress {
  width: 100%;
  height: 0.75rem;
  background: #e5e7eb;
  border-radius: 9999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  border-radius: 9999px;
  transition: width 0.5s ease;
  position: relative;
}

.progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.3) 50%, transparent 100%);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* 加载动画 */
.loading-spinner {
  width: 2rem;
  height: 2rem;
  border: 3px solid #e5e7eb;
  border-top: 3px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* 消息提示样式 */
.toast {
  position: fixed;
  top: 1rem;
  right: 1rem;
  max-width: 24rem;
  padding: 1rem 1.5rem;
  border-radius: var(--border-radius);
  color: white;
  font-weight: 500;
  z-index: 50;
  box-shadow: var(--shadow-large);
}

.toast-success {
  background: var(--secondary-color);
}

.toast-error {
  background: #ef4444;
}

.toast-warning {
  background: #f59e0b;
}

.toast-info {
  background: #3b82f6;
}

/* 模态框样式 */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
}

.modal-content {
  background: white;
  border-radius: var(--border-radius);
  max-width: 32rem;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-large);
}

/* 小说阅读器样式 */
.reader-container {
  max-width: 48rem;
  margin: 0 auto;
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-medium);
  overflow: hidden;
}

.chapter-title {
  text-align: center;
  padding: 2rem;
  background: linear-gradient(135deg, #fdf2f8 0%, #ffffff 100%);
  border-bottom: 1px solid var(--border-color);
}

.chapter-poem {
  font-family: 'Noto Serif SC', serif;
  font-size: 1.25rem;
  color: var(--text-secondary);
  font-style: italic;
  line-height: 1.8;
}

.chapter-content {
  padding: 2rem;
  font-family: 'Noto Serif SC', serif;
  font-size: 1.125rem;
  line-height: 1.8;
  color: var(--text-primary);
}

.chapter-content p {
  margin-bottom: 1.5rem;
  text-indent: 2em;
}

.reader-navigation {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  background: #f9fafb;
  border-top: 1px solid var(--border-color);
}

.chapter-select {
  min-width: 8rem;
}

/* 人格测试样式 */
.personality-option {
  padding: 1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: var(--transition);
  background: white;
}

.personality-option:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow-light);
}

.personality-option.selected {
  border-color: var(--primary-color);
  background: rgba(236, 72, 153, 0.05);
}

.personality-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  background: rgba(236, 72, 153, 0.1);
  color: var(--primary-color);
  font-weight: 700;
  border-radius: 50%;
  margin-right: 1rem;
}

/* 错误样式 */
.error-message {
  color: #ef4444;
  font-size: 0.875rem;
  margin-top: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.error-message::before {
  content: '⚠️';
}

/* 成功样式 */
.success-message {
  color: var(--secondary-color);
  font-size: 0.875rem;
  margin-top: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.success-message::before {
  content: '✅';
}

/* 响应式设计 */
@media (max-width: 768px) {
  .container {
    padding: 0 0.75rem;
  }
  
  .main-content {
    padding: 1rem 0;
  }
  
  .card-body {
    padding: 1rem;
  }
  
  .chapter-content {
    padding: 1.5rem 1rem;
    font-size: 1rem;
  }
  
  .reader-navigation {
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
  }
  
  .navbar-nav {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .btn {
    width: 100%;
    justify-content: center;
  }
  
  .modal-content {
    margin: 1rem;
    max-width: calc(100vw - 2rem);
  }
}

@media (max-width: 480px) {
  html {
    font-size: 14px;
  }
  
  .chapter-title {
    padding: 1.5rem 1rem;
  }
  
  .chapter-poem {
    font-size: 1.125rem;
  }
  
  .chapter-content {
    padding: 1rem;
    font-size: 0.95rem;
  }
}

/* 打印样式 */
@media print {
  .navbar,
  .reader-navigation,
  .btn,
  .toast {
    display: none !important;
  }
  
  .page-wrapper {
    background: white;
  }
  
  .chapter-content {
    font-size: 12pt;
    line-height: 1.6;
  }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
  :root {
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --border-color: #374151;
    --background-gradient: linear-gradient(135deg, #1f2937 0%, #111827 50%, #0f172a 100%);
  }
  
  body {
    background: var(--background-gradient);
    color: var(--text-primary);
  }
  
  .card {
    background: #1f2937;
    border: 1px solid var(--border-color);
  }
  
  .form-control {
    background: #374151;
    border-color: var(--border-color);
    color: var(--text-primary);
  }
  
  .navbar {
    background: rgba(31, 41, 55, 0.95);
    border-bottom-color: var(--border-color);
  }
}

/* 无障碍支持 */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* 高对比度模式 */
@media (prefers-contrast: high) {
  :root {
    --primary-color: #000;
    --text-primary: #000;
    --text-secondary: #333;
    --border-color: #000;
  }
  
  .btn-primary {
    background: #000;
    border: 2px solid #000;
  }
  
  .form-control {
    border: 2px solid #000;
  }
}

/* 工具类 */
.text-gradient {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.glass-effect {
  background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.hover-lift {
  transition: var(--transition);
}

.hover-lift:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-large);
}

.fade-in {
  animation: fadeIn 0.6s ease-out;
}

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

.slide-in-right {
  animation: slideInRight 0.6s ease-out;
}

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

/* 滚动条样式 */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-hover);
}

/* 选择文本样式 */
::selection {
  background: rgba(236, 72, 153, 0.3);
  color: var(--text-primary);
}

::-moz-selection {
  background: rgba(236, 72, 153, 0.3);
  color: var(--text-primary);
}