/* Path: frontend/features/kidtype-english/style.css */
/* Enhanced left-right split layout for desktop typing practice */

:root {
  --bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --card: #ffffff;
  --card-glass: rgba(255, 255, 255, 0.95);
  --accent: #6b8afd;
  --accent-2: #9ad0ff;
  --ok: #22c55e;
  --bad: #ef4444;
  --text: #1f2937;
  --text-light: #6b7280;
  --muted: #9ca3af;
  --kbd: #f0f3ff;
  --kbd-key: #ffffff;
  --kbd-border: #e5e9ff;
  --highlight: #ffe9a9;
  
  /* 新增颜色 */
  --border-light: rgba(255, 255, 255, 0.3);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.15);
  
  /* 布局变量 */
  --header-height: 60px;
  --left-panel-width: 70%;
  --right-panel-width: 30%;
  --panel-gap: 20px;
}

/* 全局重置 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* 背景渐变动画 */
body {
  background: var(--bg);
  background-size: 400% 400%;
  animation: gradientShift 10s ease infinite;
  height: 100vh;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* 顶部导航栏 */
.top-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: linear-gradient(135deg, rgba(255,255,255,0.98) 0%, rgba(255,255,255,0.95) 100%);
  backdrop-filter: blur(20px);
  border-bottom: 2px solid rgba(107, 138, 253, 0.2);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
  z-index: 1000;
}

.top-header h1 {
  background: linear-gradient(45deg, #667eea, #764ba2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 700;
  font-size: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.title-emoji {
  display: inline-block;
  animation: rotate 2s ease-in-out infinite;
}

@keyframes rotate {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(10deg); }
}

.back-btn {
  padding: 8px 16px;
  background: rgba(107, 138, 253, 0.1);
  color: #667eea;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 500;
  transition: all 0.3s ease;
}

.back-btn:hover {
  background: #667eea;
  color: white;
  transform: translateX(-3px);
}

/* 主容器 - 左右分屏布局 */
.main-container {
  display: flex;
  gap: var(--panel-gap);
  height: calc(100vh - var(--header-height));
  margin-top: var(--header-height);
  padding: 20px;
}

/* 左侧面板 - 练习文本区 */
.left-panel {
  width: var(--left-panel-width);
  display: flex;
  flex-direction: column;
  gap: 15px;
}

/* 统计信息栏 */
.stats-bar {
  background: var(--card-glass);
  backdrop-filter: blur(10px);
  border: 2px solid var(--border-light);
  border-radius: 16px;
  padding: 15px 20px;
  box-shadow: var(--shadow-md);
}

.progress-wrapper {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 15px;
}

.progress {
  flex: 1;
  height: 12px;
  background: linear-gradient(90deg, #e0e7ff, #f0f4ff);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.bar {
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #10b981, #059669);
  transition: width 0.3s ease;
  position: relative;
  overflow: hidden;
}

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

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

.progress-text {
  font-weight: 600;
  color: var(--text);
  min-width: 50px;
}

.stats-group {
  display: flex;
  gap: 20px;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: linear-gradient(145deg, #f9fafb, #ffffff);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  flex: 1;
}

.stat-item.score-item {
  background: linear-gradient(135deg, #ffd93d, #ffb347);
  color: #333;
  font-weight: 700;
}

.stat-icon {
  font-size: 18px;
}

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

.stat-value {
  font-weight: 600;
  color: var(--text);
  margin-left: auto;
}

.score-item .stat-label,
.score-item .stat-value {
  color: #333;
}

/* 鼓励语区域 */
.encouragement {
  text-align: center;
  font-size: 18px;
  color: #667eea;
  font-weight: bold;
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, rgba(255,255,255,0.9), rgba(255,255,255,0.95));
  border-radius: 12px;
  padding: 8px;
  box-shadow: var(--shadow-sm);
}

/* 练习文本显示区 */
.text-display-wrapper {
  flex: 1;
  background: var(--card-glass);
  backdrop-filter: blur(10px);
  border: 2px solid var(--border-light);
  border-radius: 20px;
  padding: 25px;
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
}

.text-display {
  font-size: 26px;
  line-height: 2.2;
  letter-spacing: 1.2px;
  color: var(--text);
  min-height: 200px;
  position: relative;
}

/* 文本字符样式 */
.text-display span {
  transition: all 0.2s ease;
  position: relative;
  display: inline-block;
}

.text-display span.current {
  background: linear-gradient(135deg, #ffd93d, #ffb347);
  color: #333;
  padding: 3px 6px;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(255, 193, 7, 0.4);
  animation: bounce 0.5s ease infinite;
  transform: scale(1.2);
  font-weight: bold;
  margin: 0 2px;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0) scale(1.2); }
  50% { transform: translateY(-5px) scale(1.2); }
}

.text-display span.typed {
  color: #22c55e;
  background: linear-gradient(145deg, #e8f5e9, #f1f8e9);
  border-radius: 6px;
  padding: 2px 4px;
}

.text-display span.error {
  background: linear-gradient(135deg, #ff6b6b, #ff8787);
  color: white;
  padding: 3px 6px;
  border-radius: 6px;
  animation: shake 0.3s;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* 对话格式优化 */
.dialogue-line {
  margin: 12px 0;
  padding-left: 20px;
}

.speaker-name {
  color: #667eea !important;
  font-weight: bold !important;
  margin-right: 12px;
}

/* 当前字符提示 */
.current-char-hint {
  background: var(--card-glass);
  backdrop-filter: blur(10px);
  border: 2px solid var(--border-light);
  border-radius: 16px;
  padding: 15px 20px;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 20px;
}

.hint-label {
  font-size: 16px;
  color: var(--text-light);
  font-weight: 500;
}

.hint-value {
  font-size: 24px;
  font-weight: bold;
  color: #667eea;
  background: linear-gradient(135deg, #667eea, #764ba2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  min-width: 40px;
  text-align: center;
}

.finger-hint {
  flex: 1;
  font-size: 15px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.finger-hint .dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  animation: dotPulse 1.5s ease infinite;
}

@keyframes dotPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* 右侧面板 - 控制区 */
.right-panel {
  width: var(--right-panel-width);
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height) - 40px);
}

/* 设置区域 */
.settings-section {
  background: var(--card-glass);
  backdrop-filter: blur(10px);
  border: 2px solid var(--border-light);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--shadow-md);
  max-height: 45%;
  overflow-y: auto;
}

.settings-section h3 {
  margin-bottom: 15px;
  color: var(--text);
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.setting-group {
  margin-bottom: 12px;
}

.setting-group.compact {
  margin-bottom: 8px;
}

.setting-group label {
  display: block;
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 5px;
  font-weight: 500;
}

.grade-selector {
  background: linear-gradient(90deg, #ff6b6b, #ffd93d, #6bcf7f, #4ecdc4, #95afc0, #c56cf0);
  padding: 2px;
  border-radius: 10px;
}

.grade-selector select {
  width: 100%;
  background: white;
}

select {
  width: 100%;
  background: white;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
}

select:hover {
  border-color: #667eea;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

select:focus {
  outline: none;
  border-color: #764ba2;
  box-shadow: 0 0 0 3px rgba(118, 75, 162, 0.1);
}

/* 操作按钮组 */
.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 15px 0;
}

.btn {
  width: 100%;
  padding: 10px 16px;
  border: none;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  font-size: 14px;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.btn-speak {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}

.btn:before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

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

.btn:hover:before {
  width: 300px;
  height: 300px;
}

.btn:disabled {
  background: linear-gradient(135deg, #9ca3af, #6b7280);
  cursor: not-allowed;
  box-shadow: none;
}

/* 复选框样式 */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #667eea;
}

/* 滑块样式 */
input[type="range"] {
  width: 100%;
  accent-color: #667eea;
  cursor: pointer;
  margin-top: 5px;
}

/* 键盘显示区 */
.keyboard-section {
  flex: 1;
  background: var(--card-glass);
  backdrop-filter: blur(10px);
  border: 2px solid var(--border-light);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.keyboard-section h3 {
  margin-bottom: 15px;
  color: var(--text);
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.keyboard-container {
  flex: 1;
  background: linear-gradient(145deg, #fafbfc, #ffffff);
  padding: 15px;
  border-radius: 16px;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.05);
  overflow-y: auto;
  overflow-x: hidden;
}

.keyboard-container .row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
  justify-content: center;
}

/* 键盘按键样式 */
.keyboard-container .key {
  background: linear-gradient(145deg, #ffffff, #f8f9fa);
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  min-height: 40px;
  min-width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  color: #4b5563;
  position: relative;
  transition: all 0.2s ease;
  box-shadow: 
    0 3px 6px rgba(0, 0, 0, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  cursor: pointer;
  user-select: none;
}

.keyboard-container .key:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
}

/* 特殊按键宽度 */
.keyboard-container .key.wide { min-width: 75px; }
.keyboard-container .key.xwide { min-width: 100px; }
.keyboard-container .key.space { min-width: 280px; }

/* 当前应按的键 */
.keyboard-container .key.active {
  background: linear-gradient(135deg, #ffd93d, #ffb347) !important;
  border-color: #ffc107 !important;
  color: #333 !important;
  transform: scale(1.1) translateY(-3px);
  box-shadow: 
    0 0 25px rgba(255, 193, 7, 0.6),
    0 8px 16px rgba(255, 193, 7, 0.4),
    inset 0 0 10px rgba(255, 255, 255, 0.5) !important;
  animation: keyPulse 0.6s ease infinite;
  z-index: 10;
  font-weight: 700;
}

@keyframes keyPulse {
  0%, 100% {
    transform: scale(1.1) translateY(-3px);
    box-shadow: 
      0 0 25px rgba(255, 193, 7, 0.6),
      0 8px 16px rgba(255, 193, 7, 0.4);
  }
  50% {
    transform: scale(1.15) translateY(-5px);
    box-shadow: 
      0 0 35px rgba(255, 193, 7, 0.8),
      0 12px 20px rgba(255, 193, 7, 0.5);
  }
}

/* Shift键提示 */
.keyboard-container .key.shift-hint {
  background: linear-gradient(135deg, #c084fc, #a855f7) !important;
  border-color: #9333ea !important;
  color: white !important;
  animation: shiftBlink 0.5s ease infinite;
}

@keyframes shiftBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.keyboard-tip {
  margin-top: 10px;
  text-align: center;
  font-size: 13px;
  color: var(--text-light);
}

/* 手指颜色 */
.pinky { 
  background: linear-gradient(135deg, #ff6b6b, #ff5252); 
}
.ring { 
  background: linear-gradient(135deg, #ffd93d, #ffc107); 
}
.middle { 
  background: linear-gradient(135deg, #6bcf7f, #4caf50); 
}
.index { 
  background: linear-gradient(135deg, #4ecdc4, #26a69a); 
}
.thumb { 
  background: linear-gradient(135deg, #c56cf0, #9c27b0); 
}

/* 成就徽章 */
.achievement {
  position: fixed;
  top: 80px;
  right: -300px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  padding: 15px 20px;
  border-radius: 15px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  font-weight: bold;
  transition: right 0.5s ease;
  z-index: 1001;
}

.achievement.show {
  right: 20px;
}

.achievement .emoji {
  font-size: 24px;
  margin-right: 10px;
}

/* 星星动画背景 */
.stars {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.star {
  position: absolute;
  width: 2px;
  height: 2px;
  background: white;
  border-radius: 50%;
  animation: twinkle 3s infinite;
}

@keyframes twinkle {
  0%, 100% { opacity: 0; }
  50% { opacity: 1; }
}

/* 隐藏输入框 */
#hiddenInput {
  position: absolute;
  top: -9999px;
  left: -9999px;
}

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

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: rgba(107, 138, 253, 0.3);
  border-radius: 10px;
  transition: background 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(107, 138, 253, 0.5);
}

/* 响应式调整（仅考虑大屏幕） */
@media (min-width: 1920px) {
  .text-display {
    font-size: 28px;
    line-height: 2.4;
  }
  
  .keyboard-container .key {
    min-height: 45px;
    min-width: 45px;
    font-size: 15px;
  }
}

@media (max-width: 1366px) {
  :root {
    --left-panel-width: 65%;
    --right-panel-width: 35%;
  }
  
  .text-display {
    font-size: 24px;
  }
}

/* 加载动画 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.left-panel, .right-panel {
  animation: fadeIn 0.5s ease;
}

.settings-section {
  animation: fadeIn 0.6s ease;
}

.keyboard-section {
  animation: fadeIn 0.7s ease;
}