/* IELTS Buddy Web - PRD侧边栏布局样式
   基于 ielts-web-prd.html PRD设计稿
*/

:root {
  --primary-color: #0f766e;
  --accent-color: #0d9488;
  --accent-light: rgba(15, 118, 110, 0.08);
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --text-main: #111827;
  --text-muted: #6b7280;
  --text-soft: #9ca3af;
  --border-color: #e5e7eb;
  --font-mono: 'SF Mono', 'Fira Code', Consolas, monospace;
  --font-size-md: 14px;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
               "Microsoft YaHei", "Helvetica Neue", sans-serif;
  color: var(--text-main);
  background: var(--bg-primary);
  line-height: 1.6;
  font-size: var(--font-size-md);
  height: 100%;
}

a { color: var(--primary-color); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === App Shell（PRD左右布局） === */
.app-shell {
  display: flex;
  height: calc(100vh - 48px);
}

/* === 侧边栏（PRD设计） === */
.app-sidebar {
  width: 220px;
  background: #1f2937;
  color: #d1d5db;
  padding: 16px 0;
  overflow-y: auto;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
.app-sidebar .brand-block {
  padding: 0 20px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 12px;
}
.app-sidebar .brand-block .logo {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--accent-color), var(--primary-color));
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  font-family: var(--font-mono);
  margin-right: 8px;
  vertical-align: middle;
}
.app-sidebar .brand-block .name {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
}
.app-sidebar .nav-group {
  margin-bottom: 8px;
}
.app-sidebar .nav-group-title {
  padding: 8px 20px 4px;
  font-size: 11px;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.app-sidebar .nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  font-size: 13px;
  color: #d1d5db;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  text-decoration: none;
  transition: all var(--transition-fast);
}
.app-sidebar .nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  text-decoration: none;
}
.app-sidebar .nav-item.active {
  background: rgba(15, 118, 110, 0.20);
  color: #fff;
  border-left: 3px solid var(--accent-color);
}
.app-sidebar .nav-item .icon {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
.sidebar-user {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-user .user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.sidebar-user .user-email {
  font-size: 12px;
  color: #9ca3af;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-user .logout-btn {
  width: 100%;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: #d1d5db;
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.sidebar-user .logout-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* === 主内容区 === */
.app-main {
  flex: 1;
  overflow-y: auto;
  padding: 20px 28px;
  background: var(--bg-secondary);
}
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.app-header .title-block h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}
.user-block {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  font-size: 13px;
}
.avatar {
  width: 28px;
  height: 28px;
  background: var(--primary-color);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}
.main-content {
  /* 内容区域 */
}

/* === Footer === */
.footer {
  border-top: 1px solid var(--border-color);
  padding: 12px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  display: flex;
  justify-content: center;
  gap: 8px;
  height: 48px;
  align-items: center;
}

/* === 认证页面（居中卡片） === */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 48px);
  background: var(--bg-secondary);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 32px 28px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}
.auth-card h1 {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 600;
}
.auth-card .lede {
  color: var(--text-muted);
  margin-bottom: 24px;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-label {
  font-size: 13px;
  color: var(--text-muted);
}
.field-hint {
  font-size: 12px;
  color: var(--text-muted);
}
.field input {
  padding: 10px 12px;
  font-size: 15px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-primary);
  outline: none;
  transition: border-color 0.15s;
}
.field input:focus {
  border-color: var(--primary-color);
}
.btn-primary {
  padding: 12px 16px;
  background: var(--primary-color);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  text-align: center;
  text-decoration: none;
  display: inline-block;
}
.btn-primary:hover {
  opacity: 0.9;
  text-decoration: none;
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.auth-error {
  background: rgba(220, 38, 38, 0.08);
  color: #dc2626;
  border: 1px solid rgba(220, 38, 38, 0.2);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
}
.auth-success {
  background: rgba(15, 118, 110, 0.08);
  color: var(--primary-color, #0f766e);
  border: 1px solid rgba(15, 118, 110, 0.2);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
}
.auth-foot {
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  color: var(--text-muted);
}

/* === 密码可见切换 === */
.input-with-toggle {
  position: relative;
  display: flex;
  align-items: center;
}
.input-with-toggle input {
  flex: 1;
  /* 右侧预留 40px 给眼睛按钮 */
  padding-right: 40px !important;
  width: 100%;
}
.input-with-toggle .pwd-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  color: var(--text-muted, #6b7280);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.12s ease, color 0.12s ease;
}
.input-with-toggle .pwd-toggle:hover {
  background: var(--bg-secondary, #f9fafb);
  color: var(--text-main, #1f2937);
}
.input-with-toggle .pwd-toggle:focus-visible {
  outline: 2px solid var(--primary-color, #0f766e);
  outline-offset: 1px;
}

/* === 忘记密码：默认密码展示框 === */
.default-pwd {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 1.05em;
  background: rgba(15, 118, 110, 0.08);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--primary-color, #0f766e);
  font-weight: 600;
  letter-spacing: 0.5px;
}
.forgot-pwd-result {
  margin-top: 16px;
  padding: 16px 18px;
  background: linear-gradient(135deg,
    rgba(15, 118, 110, 0.04) 0%,
    rgba(13, 148, 136, 0.08) 100%);
  border: 1px solid rgba(15, 118, 110, 0.25);
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.7;
}
.forgot-pwd-result .result-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--primary-color, #0f766e);
  margin-bottom: 12px;
}
.forgot-pwd-result .result-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 6px 0;
}
.forgot-pwd-result .result-label {
  flex: 0 0 80px;
  color: var(--text-muted, #6b7280);
  font-size: 13px;
}
.forgot-pwd-result .result-value {
  color: var(--text-main, #1f2937);
  word-break: break-all;
}
.forgot-pwd-result .result-value.default-pwd {
  font-size: 1.15em;
  padding: 4px 10px;
  background: #fff;
  border: 1px dashed rgba(15, 118, 110, 0.4);
}
.forgot-pwd-result .result-tip {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(15, 118, 110, 0.15);
  color: var(--text-muted, #6b7280);
  font-size: 13px;
}
.forgot-pwd-result .result-tip a {
  color: var(--primary-color, #0f766e);
  font-weight: 600;
}

/* === 统计卡片（PRD风格） === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}
.stat-card .label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.stat-card .value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-main);
}
.stat-card .delta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
.stat-card.accent {
  border-left: 4px solid var(--accent-color);
}
.stat-card.warn {
  border-left: 4px solid #f59e0b;
}

/* === 面板（PRD风格） === */
.panel {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}
.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  font-size: 15px;
  font-weight: 600;
}
.panel-title .actions {
  display: flex;
  gap: 8px;
}
.btn {
  padding: 8px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.btn:hover {
  background: var(--bg-primary);
  border-color: var(--text-muted);
}
.btn.primary {
  background: var(--primary-color);
  color: #fff;
  border-color: var(--primary-color);
}
.btn.primary:hover {
  opacity: 0.9;
}

/* === 学习/复习页 === */
.study-page {
  max-width: 640px;
  margin: 0 auto;
}
.study-page h1 {
  font-size: 22px;
  margin: 0 0 8px;
  font-weight: 700;
}
.lede {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 20px;
}
.word-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}
.word-info {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 16px;
}
.word-info .word {
  font-size: 32px;
  font-weight: 600;
  color: var(--text-main);
}
.word-info .phonetic {
  font-size: 14px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.word-meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 16px;
  margin: 0 0 20px;
}
.word-meta dt {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  align-self: center;
}
.word-meta dd {
  margin: 0;
  font-size: 14px;
}
.word-meta dd.answer {
  font-weight: 500;
}
.word-meta dd.placeholder {
  color: var(--text-soft);
  font-style: italic;
}
.word-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.btn-secondary {
  padding: 10px 14px;
  background: var(--bg-secondary);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.btn-secondary:hover {
  background: var(--bg-primary);
  border-color: var(--text-muted);
}
.btn-good {
  background: #16a34a;
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-right: 8px;
}
.btn-bad {
  background: #dc2626;
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-good:hover, .btn-bad:hover {
  opacity: 0.9;
}

/* === 提示消息 === */
.hint {
  font-size: 14px;
  color: var(--text-muted);
  background: var(--bg-primary);
  border: 1px dashed var(--border-color);
  border-radius: 8px;
  padding: 16px 20px;
  text-align: center;
}

/* === 数据表格 === */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
}
.data-table th, .data-table td {
  padding: 10px 14px;
  text-align: left;
  font-size: 14px;
  border-bottom: 1px solid var(--border-color);
}
.data-table th {
  background: var(--bg-secondary);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.data-table tr:last-child td {
  border-bottom: none;
}

/* === 进度条 === */
.progress-bar {
  height: 6px;
  background: var(--border-color);
  border-radius: 3px;
  overflow: hidden;
  margin: 8px 0;
}
.progress-bar .fill {
  height: 100%;
  background: var(--primary-color);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* === 标签 === */
.tag {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-muted);
  margin-right: 6px;
}
.tag.accent {
  background: var(--accent-light);
  border-color: var(--accent-color);
  color: var(--primary-color);
}

/* === 响应式 === */
@media (max-width: 900px) {
  .app-shell {
    flex-direction: column;
  }
  .app-sidebar {
    width: 100%;
    height: auto;
    flex-direction: row;
    overflow-x: auto;
    padding: 8px 16px;
  }
  .brand-block {
    display: none;
  }
  .nav-group {
    display: flex;
    gap: 4px;
    margin-bottom: 0;
  }
  .nav-group-title {
    display: none;
  }
  .nav-item {
    padding: 8px 12px;
    white-space: nowrap;
  }
  .sidebar-user {
    margin-top: 0;
    margin-left: auto;
    padding: 0 8px;
    border-top: none;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
  }
  .user-info {
    display: none;
  }
  .logout-btn {
    width: auto;
  }
}

/* ============================================================
 * 错词本 (mistakes.html) — v3.6
 * ============================================================ */

.mistakes-page {
  padding: 1.5rem 2rem 3rem;
}

.mistakes-page .lede {
  color: var(--text-muted, #6b7280);
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.mistakes-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 960px) {
  .mistakes-layout { grid-template-columns: 1fr; }
}

.mistakes-main { min-width: 0; }

.mistakes-toolbar {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
  background: var(--bg-card, #fff);
  padding: 0.85rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border-color, #e5e7eb);
  margin-bottom: 1rem;
}

.mistakes-toolbar .filter-group {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  font-size: 0.9rem;
}

.mistakes-toolbar .filter-group select {
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border-color, #d1d5db);
  border-radius: 6px;
  background: var(--bg-primary, #fff);
  color: inherit;
  font-size: 0.9rem;
}

.mistakes-list-card {
  background: var(--bg-card, #fff);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 10px;
  overflow: hidden;
}

.mistakes-list-meta {
  display: flex;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  font-size: 0.85rem;
  color: var(--text-muted, #6b7280);
  background: var(--bg-soft, #f9fafb);
  border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.mistakes-list {
  display: flex;
  flex-direction: column;
}

.mistake-card {
  border-bottom: 1px solid var(--border-color, #f1f5f9);
  padding: 1.1rem 1rem;
}

.mistake-card:last-child { border-bottom: none; }

.mistake-card .mistake-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.6rem;
}

.mistake-word-block { min-width: 0; }

.mistake-word {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-main, #111);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.mistake-phonetic {
  color: var(--text-muted, #6b7280);
  font-size: 0.85rem;
  margin-top: 2px;
}

.mistake-wrong-block {
  text-align: center;
  background: #fef2f2;
  color: #dc2626;
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
  min-width: 60px;
}

.mistake-wrong-count {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
}

.mistake-wrong-label {
  font-size: 0.7rem;
  color: #b91c1c;
  margin-top: 2px;
}

.mistake-meaning {
  color: var(--text-main, #374151);
  font-size: 0.95rem;
  margin: 0.4rem 0;
  line-height: 1.5;
}

.mistake-example {
  background: var(--bg-soft, #f8fafc);
  border-left: 3px solid var(--primary-color, #2563eb);
  padding: 0.4rem 0.7rem;
  margin-top: 0.4rem;
  font-style: italic;
  color: var(--text-main, #334155);
  border-radius: 0 4px 4px 0;
  font-size: 0.85rem;
}

.mistake-example-cn {
  margin-top: 0.3rem;
  font-size: 0.8rem;
  color: var(--text-muted, #6b7280);
  padding-left: 0.95rem;
}

.mistake-meta {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.7rem;
}

.meta-chip {
  background: var(--bg-soft, #f3f4f6);
  border: 1px solid var(--border-color, #e5e7eb);
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  font-size: 0.78rem;
  color: var(--text-main, #475569);
}

.badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-weight: 500;
}

.badge.difficult {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.badge.star {
  background: #fef9c3;
  color: #a16207;
}

.mistake-actions {
  margin-top: 0.7rem;
  display: flex;
  gap: 0.4rem;
  justify-content: flex-end;
}

.mistake-actions .btn-secondary.small {
  font-size: 0.8rem;
  padding: 0.35rem 0.7rem;
}

.mistakes-list .empty-state {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--text-muted, #6b7280);
  font-size: 1rem;
}

.mistakes-list .loading-hint {
  padding: 1.5rem;
  text-align: center;
  color: var(--text-muted, #6b7280);
}

.mistakes-side { display: flex; flex-direction: column; gap: 1rem; }

.stat-card {
  background: var(--bg-card, #fff);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 10px;
  padding: 1rem;
}

.stat-card.accent {
  background: linear-gradient(135deg, #ef4444 0%, #f59e0b 100%);
  color: #fff;
  border: none;
}

.stat-card.accent .stat-label,
.stat-card.accent .stat-sub {
  color: rgba(255, 255, 255, 0.85);
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted, #6b7280);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text-main, #111);
}

.stat-card.accent .stat-value { color: #fff; }

.stat-value-small {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main, #111);
  margin-bottom: 0.4rem;
}

.stat-sub {
  font-size: 0.75rem;
  color: var(--text-muted, #6b7280);
  margin-top: 0.3rem;
}

.top-offenders {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.top-offenders li {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.85rem;
}

.top-offenders .top-rank {
  display: inline-block;
  width: 22px;
  font-weight: 600;
  color: var(--text-muted, #9ca3af);
  font-size: 0.78rem;
}

.top-offenders .top-word {
  flex: 1;
  color: var(--text-main, #374151);
  font-weight: 500;
}

.top-offenders .top-count {
  color: #dc2626;
  font-weight: 600;
  font-size: 0.82rem;
}

.top-offenders .top-empty {
  color: var(--text-muted, #9ca3af);
  font-size: 0.85rem;
}
