/* ===== 高中日语在线刷题 - 主样式 ===== */

/* ===== 微信浏览器核心适配 ===== */
:root {
  --primary: #d32f2f;
  --primary-dark: #b71c1c;
  --primary-light: #ef5350;
  --accent: #ffc107;
  --accent-dark: #ff8f00;
  --bg: #faf8f5;
  --card: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px 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);
  /* 微信安全区域 */
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-left: env(safe-area-inset-left, 0px);
  --safe-area-right: env(safe-area-inset-right, 0px);
}

* { 
  box-sizing: border-box;
  /* 防止微信字体自动缩放 */
  -webkit-text-size-adjust: 100% !important;
  text-size-adjust: 100% !important;
  -webkit-tap-highlight-color: rgba(0,0,0,0);
}

/* 微信浏览器字体优化 - 修复flex布局下的滚动问题 */
html {
  overflow-y: auto !important;
  overflow-x: hidden !important;
  height: auto !important;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg) !important;
  color: var(--text) !important;
  line-height: 1.6;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  min-height: 100vh !important;
  -webkit-overflow-scrolling: touch;
}

/* 禁止选择复制（可选，按需启用） */
/*.no-select {
  -webkit-user-select: none;
  user-select: none;
}*/

/* 微信环境隐藏顶部地址栏 */
body.wechat-ready {
  padding-top: env(safe-area-inset-top);
}

/* iPhone X+ 安全区域适配 */
@supports (padding: env(safe-area-inset-top)) {
  .navbar {
    padding-top: env(safe-area-inset-top);
  }
  .fixed-bottom-bar {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* 触摸目标尺寸优化 - 微信推荐 48px+ */
.btn {
  min-height: 48px;
  min-width: 48px;
}

.option-item {
  min-height: 52px;
  padding: 14px 16px;
}

/* 移动端表单输入优化 */
.form-input {
  font-size: 16px !important; /* 微信必须16px否则会缩放 */
  -webkit-appearance: none;
  appearance: none;
  border-radius: 8px;
  padding: 12px 14px;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(211,47,47,0.1);
}

/* 移动端按钮点击效果 */
.btn:active {
  opacity: 0.85;
  transform: scale(0.98);
}

/* 选项卡触摸反馈 */
.option-item:active {
  transform: scale(0.98);
}

/* 分享引导遮罩 */
.share-guide-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.85);
  z-index: 9999;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 20px;
  color: white;
  text-align: center;
}

.share-guide-overlay.show {
  display: flex;
}

.share-guide-overlay .guide-icon {
  width: 80px;
  height: 80px;
  margin-top: 60px;
  margin-bottom: 20px;
  animation: bounce 1s infinite;
}

.share-guide-overlay h3 {
  font-size: 20px;
  margin-bottom: 12px;
  color: #fff;
}

.share-guide-overlay p {
  font-size: 15px;
  line-height: 1.6;
  color: rgba(255,255,255,0.8);
  max-width: 300px;
}

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

/* 微信分享按钮样式 */
.wechat-share-btn {
  position: relative;
}

/* 微信禁止分享时的提示 */
.wechat-forbidden-tip {
  background: rgba(0,0,0,0.8);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10000;
  display: none;
}

/* 移动端安全区域间距 */
.safe-area-top {
  padding-top: var(--safe-area-top);
}

.safe-area-bottom {
  padding-bottom: var(--safe-area-bottom);
}

/* ===== 导航栏 ===== */
.navbar {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  padding: 0 1.5rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(211,47,47,0.3);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: white;
  text-decoration: none;
}

.navbar-brand span { font-size: 1.5rem; }

.navbar-menu {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.navbar-menu a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  padding: 0.5rem 0.875rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s;
}

.navbar-menu a:hover,
.navbar-menu a.active {
  color: white;
  background: rgba(255,255,255,0.15);
}

/* ===== Hero 区域 ===== */
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, #7b1fa2 50%, #1565c0 100%);
  color: white;
  padding: 4rem 1.5rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 30px 30px;
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
  position: relative;
}

.hero p {
  font-size: 1.125rem;
  opacity: 0.9;
  max-width: 600px;
  margin: 0 auto 2rem;
  position: relative;
}

/* ===== 卡片 ===== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 1.5rem;
  transition: transform 0.2s, box-shadow 0.2s;
}

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

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.5rem;
}

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  line-height: 1.4;
}

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

.btn-primary:hover { background: var(--primary-dark); }

.btn-accent {
  background: var(--accent);
  color: var(--text);
}

.btn-accent:hover { background: var(--accent-dark); }

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

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

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

.btn-ghost:hover { background: var(--border); }

.btn-sm { padding: 0.375rem 1rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.875rem 2rem; font-size: 1rem; }

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

.btn-white:hover {
  background: #f5f5f5;
}

/* ===== 表单 ===== */
.form-group {
  margin-bottom: 1.25rem;
}

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

.form-input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.875rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: white;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(211,47,47,0.1);
}

/* ===== 答题界面 ===== */
.question-card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 2rem;
  margin-bottom: 1.5rem;
}

.question-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.question-type-badge {
  padding: 0.25rem 0.625rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-vocab { background: #e3f2fd; color: #1565c0; }
.badge-grammar { background: #fce4ec; color: #c62828; }
.badge-reading { background: #e8f5e9; color: #2e7d32; }
.badge-listening { background: #fff3e0; color: #e65100; }
.badge-easy { background: #e8f5e9; color: #2e7d32; }
.badge-medium { background: #fff3e0; color: #e65100; }
.badge-hard { background: #fce4ec; color: #c62828; }

.question-content {
  font-size: 1.125rem;
  line-height: 1.8;
  margin-bottom: 1.5rem;
  color: var(--text);
}

.question-passage {
  background: #f8f9fa;
  border-left: 4px solid var(--primary);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  border-radius: 0 8px 8px 0;
  line-height: 1.8;
  font-size: 0.9375rem;
}
.question-passage b, .question-passage strong { color: #1a1a2e; }
.question-passage u { text-decoration: underline; }
.question-passage em, .question-passage i { font-style: italic; }

/* 富文本passage样式（清理Word粘贴的HTML） */
.passage-content {
  font-size: 0.9375rem;
  line-height: 1.8;
  word-break: break-word;
}
.passage-content p { margin: 0.5em 0; }
.passage-content span { font-family: inherit !important; font-size: inherit !important; color: inherit !important; }
.passage-content .MsoNormal { margin: 0.25em 0; font-family: inherit !important; }
.passage-content b, .passage-content strong { color: #1a1a2e; font-weight: 600; }
.passage-content u { text-decoration: underline; }
.passage-content em, .passage-content i { font-style: italic; }
.passage-content ul, .passage-content ol { margin: 0.5em 0; padding-left: 1.5em; }

/* 选项 */
.options-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.option-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  margin-bottom: 0.5rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.option-item:hover {
  border-color: var(--primary-light);
  background: #fff5f5;
}

.option-item.selected {
  border-color: var(--primary);
  background: #ffebee;
}

.option-item.correct {
  border-color: var(--success);
  background: #ecfdf5;
}

.option-item.wrong {
  border-color: var(--danger);
  background: #fef2f2;
}

.option-letter {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8125rem;
  background: #f3f4f6;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.option-item.selected .option-letter {
  background: var(--primary);
  color: white;
}

.option-item.correct .option-letter {
  background: var(--success);
  color: white;
}

.option-item.wrong .option-letter {
  background: var(--danger);
  color: white;
}

/* 解析 */
.explanation-box {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-top: 1rem;
  font-size: 0.875rem;
  line-height: 1.6;
}

.explanation-box .label {
  color: #0369a1;
  font-weight: 700;
  margin-right: 0.5rem;
}

/* ===== 考试计时器 ===== */
.exam-timer {
  position: fixed;
  top: 64px;
  right: 1rem;
  z-index: 90;
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  border: 2px solid var(--primary);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.exam-timer .time {
  font-size: 1.5rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.exam-timer.warning .time { color: var(--danger); }

.exam-timer .label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ===== 进度条 ===== */
.progress-bar {
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
}

.progress-bar-fill.green {
  background: linear-gradient(90deg, #10b981, #34d399);
}

/* ===== 统计卡片 ===== */
.stat-card {
  text-align: center;
  padding: 1.5rem;
}

.stat-card .value {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}

.stat-card .label {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 0.375rem;
}

/* ===== 排名 ===== */
.rank-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border);
}

.rank-item:last-child { border-bottom: none; }

.rank-number {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.rank-1 { background: #fef3c7; color: #92400e; }
.rank-2 { background: #e5e7eb; color: #374151; }
.rank-3 { background: #fde8d8; color: #9a3412; }
.rank-default { background: #f3f4f6; color: #6b7280; }

/* ===== 页脚 ===== */
.footer {
  background: #1a1a2e;
  color: rgba(255,255,255,0.6);
  text-align: center;
  padding: 2rem 1.5rem;
  margin-top: 4rem;
  font-size: 0.8125rem;
}

.footer a { color: rgba(255,255,255,0.8); text-decoration: none; }
.footer a:hover { color: white; }

/* ===== Toast 通知 ===== */
.toast-container {
  position: fixed;
  top: 80px;
  right: 1rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
  max-width: 360px;
}

.toast-success { background: #065f46; color: white; }
.toast-error { background: #991b1b; color: white; }
.toast-warning { background: #92400e; color: white; }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}

/* ===== VIP 标识 ===== */
.vip-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  border-radius: 20px;
  font-size: 0.6875rem;
  font-weight: 700;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #78350f;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .hero h1 { font-size: 1.75rem; }
  .hero p { font-size: 1rem; }
  .navbar-menu { display: none; }
  .mobile-menu-btn { display: block; }
  .card-grid { grid-template-columns: 1fr; }
  .question-card { padding: 1.25rem; }
  .exam-timer { top: auto; bottom: 1rem; right: 1rem; left: 1rem; justify-content: center; }
  /* 微信/移动端触摸优化 */
  body { -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; }
  .option-item { min-height: 48px; padding: 1rem; }
  .btn { min-height: 44px; }
  a, button { touch-action: manipulation; }
  /* 移动端表格优化 */
  table { font-size: 0.8125rem; }
  td, th { padding: 0.5rem !important; }
  /* 移动端底部安全区域 */
  .safe-bottom { padding-bottom: env(safe-area-inset-bottom, 20px); }
}

@media (max-width: 480px) {
  .hero { padding: 2.5rem 1rem; }
  .hero h1 { font-size: 1.5rem; }
  .stat-card .value { font-size: 1.75rem; }
}

/* ===== 微信内置浏览器适配 ===== */
/* 微信中input获取焦点时页面放大问题 */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
  input[type="text"], input[type="email"], input[type="password"], input[type="search"],
  input[type="tel"], input[type="url"], textarea, select {
    font-size: 16px !important;
  }
}

/* 微信中禁止长按弹出菜单 */
.no-select {
  -webkit-user-select: none;
  user-select: none;
}

/* ===== 移动端菜单 ===== */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
}

.mobile-nav {
  display: none;
  background: var(--primary-dark);
  padding: 1rem;
}

.mobile-nav.open { display: block; }

.mobile-nav a {
  display: block;
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
}

.mobile-nav a:hover,
.mobile-nav a.active {
  background: rgba(255,255,255,0.1);
  color: white;
}

@media (max-width: 768px) {
  .mobile-menu-btn { display: block; }
}

/* ===== 错题标记 ===== */
.mistake-icon { color: var(--danger); }
.correct-icon { color: var(--success); }

/* ===== 空状态 ===== */
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-secondary);
}

.empty-state .icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: 0.3;
}

.empty-state p {
  font-size: 1rem;
  margin-bottom: 1.5rem;
}

/* ===== 分类图标 ===== */
.category-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.cat-vocab { background: #e3f2fd; }
.cat-grammar { background: #fce4ec; }
.cat-reading { background: #e8f5e9; }
.cat-listening { background: #fff3e0; }

/* ===== 标签 ===== */
.tag {
  display: inline-block;
  padding: 0.25rem 0.625rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  background: #f3f4f6;
  color: var(--text-secondary);
}

/* ===== 加载动画 ===== */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

/* ===== 答题进度指示器 ===== */
.progress-indicator {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 1.5rem;
}

.progress-dot {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: white;
  color: var(--text-secondary);
  transition: all 0.15s;
}

.progress-dot:hover { border-color: var(--primary-light); }
.progress-dot.current { border-color: var(--primary); background: var(--primary); color: white; }
.progress-dot.answered { border-color: var(--success); background: #ecfdf5; color: var(--success); }
.progress-dot.flagged { border-color: var(--warning); }
