/* ===== AI 打字通 - 全局样式 ===== */

:root {
  /* 主色 */
  --primary: #4FC3F7;
  --primary-dark: #29B6F6;
  --primary-light: #B3E5FC;
  --accent: #FFB74D;
  --accent-dark: #FFA726;
  /* 语义色 */
  --success: #66BB6A;
  --error: #EF5350;
  --warning: #FFEE58;
  --info: #42A5F5;
  /* 中性色 */
  --bg: #F0F4F8;
  --surface: #FFFFFF;
  --surface-alt: #F7F9FC;
  --text: #37474F;
  --text-secondary: #78909C;
  --text-light: #B0BEC5;
  --border: #E0E0E0;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  --radius: 12px;
  --radius-lg: 20px;
  --radius-sm: 8px;
  /* 尺寸 */
  --font-base: 18px;
  --font-lg: 24px;
  --font-xl: 32px;
  --font-sm: 14px;
  --font-xs: 12px;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --nav-height: 64px;
  --header-height: 80px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: var(--font-base);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  user-select: none;
  -webkit-user-select: none;
}

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

/* ===== 顶部栏 ===== */
.app-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  z-index: 100;
  flex-shrink: 0;
}

.app-header .logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--font-lg);
  font-weight: 700;
  color: var(--primary-dark);
}

.app-header .logo .icon {
  font-size: var(--font-xl);
}

.header-stats {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.stat-badge {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.stat-badge .stat-icon {
  font-size: var(--font-lg);
}

.stat-badge .stat-value {
  color: var(--primary-dark);
  font-size: var(--font-lg);
}

/* ===== 主内容区 ===== */
.app-main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
}

.page {
  display: none;
  min-height: 100%;
  padding: var(--space-lg);
}

.page.active {
  display: block;
}

/* ===== 底部导航 ===== */
.bottom-nav {
  height: var(--nav-height);
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: var(--surface);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--space-xs) var(--space-md);
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: var(--font-xs);
  font-weight: 500;
  transition: color 0.2s;
}

.nav-item:hover {
  color: var(--primary-dark);
}

.nav-item.active {
  color: var(--primary-dark);
}

.nav-item .nav-icon {
  font-size: var(--font-xl);
}

/* ===== 通用按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--font-base);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

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

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

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

.btn-secondary {
  background: var(--surface-alt);
  color: var(--text);
}

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

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

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

.btn-large {
  padding: var(--space-md) var(--space-xl);
  font-size: var(--font-lg);
  border-radius: var(--radius);
}

/* ===== 通用卡片 ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: var(--space-lg);
  box-shadow: var(--shadow);
}

/* ===== 弹窗 ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay.show {
  display: flex;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  max-width: 480px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: modalPop 0.3s ease;
}

@keyframes modalPop {
  0% { transform: scale(0.8); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.modal h2 {
  font-size: var(--font-xl);
  margin-bottom: var(--space-md);
}

.modal p {
  color: var(--text-secondary);
  margin-bottom: var(--space-lg);
}

.modal-buttons {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
}

/* ===== 星级 ===== */
.stars {
  display: flex;
  gap: var(--space-xs);
  justify-content: center;
}

.star {
  font-size: var(--font-xl);
  color: var(--border);
}

.star.filled {
  color: var(--warning);
  filter: drop-shadow(0 0 4px rgba(255, 238, 88, 0.6));
}

/* ===== 进度条 ===== */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar .fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* ===== 动画 ===== */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

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

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

@keyframes celebrate {
  0% { transform: scale(1) rotate(0deg); }
  25% { transform: scale(1.1) rotate(-5deg); }
  50% { transform: scale(1.2) rotate(5deg); }
  75% { transform: scale(1.1) rotate(-3deg); }
  100% { transform: scale(1) rotate(0deg); }
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(79, 195, 247, 0.4); }
  50% { box-shadow: 0 0 0 12px rgba(79, 195, 247, 0); }
}

/* ===== 工具类 ===== */
.text-center { text-align: center; }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-muted { color: var(--text-secondary); }
.hidden { display: none !important; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-md { margin-bottom: var(--space-md); }

/* ===== 滚动条 ===== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--text-light);
  border-radius: 3px;
}

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