/* 打字练习工具样式 */

/* CSS变量定义 */
:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-tertiary: #e9ecef;
  --text-primary: #212529;
  --text-secondary: #6c757d;
  --border-color: #dee2e6;
  --primary-color: #667eea;
  --primary-rgb: 102, 126, 234;
  --success-color: #28a745;
  --success-rgb: 40, 167, 69;
  --danger-color: #dc3545;
  --danger-rgb: 220, 53, 69;
}

.main-grid {
  display: grid;
  grid-template-columns: 280px 1fr 280px;
  gap: 1.5rem;
  margin-bottom: 2rem;
  animation: fadeInUp 0.6s ease-out;
  width: 100%;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1200px) {
  .main-grid {
    grid-template-columns: 1fr;
    max-width: 800px;
    margin: 0 auto 2rem auto;
  }
  
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* 练习区域 */
.practice-area {
  min-height: 400px;
  position: relative;
  overflow: hidden;
}

.practice-area::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, 
    var(--primary-color) 0%, 
    var(--success-color) 50%, 
    var(--primary-color) 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.practice-area.active::before {
  opacity: 1;
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.practice-text {
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  padding: 2rem;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 1.3rem;
  line-height: 2;
  min-height: 140px;
  margin-bottom: 1.5rem;
  user-select: none;
  white-space: pre-wrap;
  word-wrap: break-word;
  position: relative;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.practice-text:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.practice-text .char {
  position: relative;
  border-radius: 3px;
  padding: 2px 1px;
  margin: 0 1px;
  transition: all 0.15s ease;
  display: inline-block;
}

.practice-text .char.correct {
  background: linear-gradient(135deg, var(--success-color), #22c55e);
  color: white;
  transform: scale(1.05);
  box-shadow: 0 2px 4px rgba(34, 197, 94, 0.3);
}

.practice-text .char.incorrect {
  background: linear-gradient(135deg, var(--danger-color), #f87171);
  color: white;
  transform: scale(1.05);
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
  animation: shake 0.3s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0) scale(1.05); }
  25% { transform: translateX(-2px) scale(1.05); }
  75% { transform: translateX(2px) scale(1.05); }
}

.practice-text .char.current {
  background: linear-gradient(135deg, var(--primary-color), #60a5fa);
  color: white;
  animation: pulse 1.5s infinite;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.5);
  transform: scale(1.1);
}

@keyframes pulse {
  0%, 100% { 
    opacity: 1; 
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.5);
  }
  50% { 
    opacity: 0.7; 
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.8);
  }
}

.translation-text {
  background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
  border: 1px solid #0ea5e9;
  border-radius: 12px;
  padding: 1.2rem 1.5rem;
  font-size: 1rem;
  color: #0c4a6e;
  margin-bottom: 1.5rem;
  font-weight: 500;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.1);
  transition: all 0.3s ease;
}

.translation-text:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(14, 165, 233, 0.15);
}

.translation-text::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #0ea5e9, #06b6d4);
}

.translation-text::after {
  content: '💡';
  position: absolute;
  top: 1rem;
  right: 1.2rem;
  font-size: 1.2rem;
  opacity: 0.7;
}

.input-area {
  margin-bottom: 1.5rem;
  position: relative;
}

.typing-input {
  width: 100%;
  padding: 1.2rem 1.5rem;
  border: 2px solid var(--border-color);
  border-radius: 12px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 1.2rem;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.typing-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.15), 0 4px 16px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

.typing-input:disabled {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: not-allowed;
  transform: none;
}

.typing-input.error {
  border-color: var(--danger-color);
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.15);
  animation: inputShake 0.3s ease-in-out;
}

@keyframes inputShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* 进度条 */
.progress-bar {
  width: 100%;
  height: 12px;
  background: var(--bg-secondary);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1.5rem;
  position: relative;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, 
    var(--primary-color) 0%, 
    #60a5fa 25%, 
    var(--success-color) 75%, 
    #22c55e 100%);
  width: 0%;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.progress-fill::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: progressShine 2s infinite;
}

@keyframes progressShine {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* 统计网格 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.stat-card {
  background: linear-gradient(135deg, var(--bg-secondary), rgba(var(--primary-rgb), 0.02));
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem 1rem;
  text-align: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary-color), var(--success-color));
  transform: translateX(-100%);
  transition: transform 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  border-color: var(--primary-color);
}

.stat-card:hover::before {
  transform: translateX(0);
}

.stat-value {
  font-size: 2.2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary-color), var(--success-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.5rem;
  transition: all 0.3s ease;
}

.stat-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

.stat-card.updated {
  animation: statPulse 0.6s ease-out;
}

@keyframes statPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.stat-card.updated .stat-value {
  animation: valueGlow 0.6s ease-out;
}

@keyframes valueGlow {
  0% { filter: brightness(1); }
  50% { filter: brightness(1.3) drop-shadow(0 0 8px rgba(var(--success-rgb), 0.6)); }
  100% { filter: brightness(1); }
}

/* 模态框 */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(8px);
  animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    backdrop-filter: blur(0px);
  }
  to {
    opacity: 1;
    backdrop-filter: blur(8px);
  }
}

.modal-content {
  background: var(--bg-primary);
  border-radius: 16px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
  max-width: 520px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2rem;
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(135deg, var(--bg-secondary), rgba(var(--primary-rgb), 0.05));
}

.modal-header h3 {
  margin: 0;
  color: var(--text-primary);
  font-size: 1.5rem;
  font-weight: 700;
}

.btn-close {
  background: none;
  border: none;
  font-size: 1.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.btn-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  transform: scale(1.1);
}

.modal-body {
  padding: 2rem;
}

.result-stats {
  margin-bottom: 2rem;
}

.result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.result-item:hover {
  background: rgba(var(--primary-rgb), 0.02);
  margin: 0 -1rem;
  padding: 1rem;
  border-radius: 8px;
}

.result-item:last-child {
  border-bottom: none;
}

.result-label {
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.result-label::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary-color);
}

.result-value {
  font-weight: 800;
  font-size: 1.3rem;
  background: linear-gradient(135deg, var(--primary-color), var(--success-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.result-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.result-actions .btn {
  min-width: 120px;
  padding: 0.8rem 1.5rem;
  font-weight: 600;
  border-radius: 8px;
  transition: all 0.3s ease;
}

.result-actions .btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

/* 练习状态样式 */
.practice-active .practice-text {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.practice-completed .practice-text {
  border-color: var(--success-color);
  background: rgba(var(--success-rgb), 0.05);
}

.practice-error .typing-input {
  border-color: var(--danger-color);
  box-shadow: 0 0 0 3px rgba(var(--danger-rgb), 0.1);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .practice-text {
    font-size: 1rem;
    padding: 1rem;
  }
  
  .typing-input {
    font-size: 1rem;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .result-actions {
    flex-direction: column;
  }
  
  .modal-content {
    margin: 1rem;
    width: calc(100% - 2rem);
  }
}

/* 深色主题适配 */
@media (prefers-color-scheme: dark) {
  .practice-text .char.correct {
    background-color: #22c55e;
  }
  
  .practice-text .char.incorrect {
    background-color: #ef4444;
  }
  
  .practice-text .char.current {
    background-color: #3b82f6;
  }
}

/* 深色主题类 */
.dark-theme {
  --bg-primary: #1a1a1a;
  --bg-secondary: #2d2d2d;
  --bg-tertiary: #404040;
  --text-primary: #ffffff;
  --text-secondary: #b3b3b3;
  --border-color: #404040;
  --primary-color: #60a5fa;
  --primary-rgb: 96, 165, 250;
  --success-color: #22c55e;
  --success-rgb: 34, 197, 94;
  --danger-color: #ef4444;
  --danger-rgb: 239, 68, 68;
}

/* 修复模态框样式 */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(8px);
  animation: modalFadeIn 0.3s ease-out;
}

.modal-content {
  background: var(--bg-primary);
  border-radius: 16px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
  max-width: 520px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--border-color);
  position: relative;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  border-radius: 16px 16px 0 0;
}

.modal-body {
  padding: 2rem;
  background: var(--bg-primary);
  border-radius: 0 0 16px 16px;
}

.result-stats {
  margin-bottom: 2rem;
}

.result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.result-item:last-child {
  border-bottom: none;
}

.result-label {
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.result-value {
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--primary-color);
}

.result-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.result-actions .btn {
  min-width: 120px;
  padding: 0.8rem 1.5rem;
  font-weight: 600;
  border-radius: 8px;
  transition: all 0.3s ease;
}

.dark-theme .practice-text .char.correct {
  background: linear-gradient(135deg, #22c55e, #16a34a);
}

.dark-theme .practice-text .char.incorrect {
  background: linear-gradient(135deg, #ef4444, #dc2626);
}

.dark-theme .practice-text .char.current {
  background: linear-gradient(135deg, #60a5fa, #3b82f6);
}

.dark-theme .translation-text {
  background: linear-gradient(135deg, #1e293b, #334155);
  border-color: #60a5fa;
  color: #e2e8f0;
}

.dark-theme .translation-text::before {
  background: linear-gradient(90deg, #60a5fa, #06b6d4);
}

.dark-theme .toast {
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

/* 动画效果 */
.stat-card .stat-value {
  transition: all 0.3s ease;
}

.stat-card.updated .stat-value {
  transform: scale(1.1);
  color: var(--success-color);
}

.practice-text .char {
  transition: all 0.1s ease;
}

/* 键盘快捷键提示 */
.keyboard-shortcuts {
  position: fixed;
  bottom: 20px;
  left: 20px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 1000;
}

.keyboard-shortcuts.show {
  opacity: 1;
}

.keyboard-shortcuts .shortcut {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.keyboard-shortcuts .shortcut:last-child {
  margin-bottom: 0;
}

.keyboard-shortcuts .key {
  background: rgba(255, 255, 255, 0.2);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: monospace;
}

/* 性能指标 */
.performance-indicator {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  gap: 0.5rem;
}

.performance-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-secondary);
  transition: all 0.3s ease;
}

.performance-dot.excellent {
  background: var(--success-color);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}

.performance-dot.good {
  background: #f59e0b;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
}

.performance-dot.poor {
  background: var(--danger-color);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}

/* 练习历史记录 */
.history-panel {
  position: fixed;
  top: 0;
  right: -300px;
  width: 300px;
  height: 100vh;
  background: var(--bg-primary);
  border-left: 1px solid var(--border-color);
  box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
  transition: right 0.3s ease;
  z-index: 999;
  overflow-y: auto;
}

.history-panel.open {
  right: 0;
}

.history-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.history-content {
  padding: 1rem;
}

.history-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  transition: transform 0.2s ease;
}

.history-item:hover {
  transform: translateX(-5px);
  box-shadow: 5px 0 15px rgba(0, 0, 0, 0.1);
}

/* 响应式改进 */
@media (max-width: 768px) {
  .toast {
    top: 10px;
    right: 10px;
    left: 10px;
    right: 10px;
    min-width: auto;
  }
  
  .keyboard-shortcuts {
    bottom: 10px;
    left: 10px;
    right: 10px;
  }
  
  .history-panel {
    width: 100%;
    right: -100%;
  }
}