/* 日语单词记忆卡片 - 样式 */

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;

  --bg: #f8fafc;
  --bg-card: #ffffff;
  --bg-secondary: #f1f5f9;
  --text: #1e293b;
  --text-secondary: #64748b;
  --border: #e2e8f0;

  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);

  --radius: 12px;
  --radius-lg: 20px;
}

.dark-mode {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-secondary: #334155;
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --border: #475569;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 1rem;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header h1 {
  font-size: 1.25rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.header h1::before {
  content: "🇯🇵";
}

/* Navigation */
.nav {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

.nav-btn {
  padding: 0.5rem 1.5rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

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

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

/* Main Content */
.main {
  flex: 1;
  padding: 1.5rem;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

/* Pages */
.page {
  display: none;
}

.page.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

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

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Home Page */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-card .icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.stat-card .number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}

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

.progress-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.progress-section h3 {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.progress-bar {
  height: 8px;
  background: var(--bg-secondary);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

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

.progress-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: right;
}

.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.btn {
  padding: 1rem 1.5rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

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

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

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}

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

/* Study Page */
.study-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.study-header .btn-back {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
}

.study-progress {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Flashcard */
.flashcard-container {
  perspective: 1000px;
  margin-bottom: 1.5rem;
}

.flashcard {
  position: relative;
  width: 100%;
  height: 280px;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.flashcard.flipped {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.card-front {
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-secondary) 100%);
}

.card-back {
  transform: rotateY(180deg);
  background: linear-gradient(135deg, var(--primary) 0%, var(--info) 100%);
  color: white;
}

.card-word {
  font-size: 3rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.card-reading {
  font-size: 1.25rem;
  color: var(--text-secondary);
}

.card-back .card-reading {
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 0.5rem;
}

.card-info {
  display: flex;
  gap: 1rem;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 1rem;
}

.card-meaning {
  font-size: 1.75rem;
  font-weight: 600;
  text-align: center;
}

.card-lesson {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.2);
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
}

.flip-hint {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

/* Rating Buttons */
.rating-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

.rating-buttons.hidden {
  display: none;
}

.rating-btn {
  padding: 0.75rem 0.5rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.rating-btn:hover {
  transform: translateY(-2px);
}

.rating-btn.again {
  background: var(--danger);
  color: white;
}

.rating-btn.hard {
  background: var(--warning);
  color: white;
}

.rating-btn.good {
  background: var(--success);
  color: white;
}

.rating-btn.easy {
  background: var(--info);
  color: white;
}

.rating-btn .key {
  font-size: 0.7rem;
  opacity: 0.7;
}

/* Stats Page */
.stats-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.stats-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stats-row {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.stats-row:last-child {
  border-bottom: none;
}

.stats-row .label {
  color: var(--text-secondary);
}

.stats-row .value {
  font-weight: 600;
}

.lesson-stat-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  font-size: 0.9rem;
}

.lesson-stat-item span:first-child {
  width: 60px;
}

.mini-progress {
  flex: 1;
  height: 6px;
  background: var(--bg-secondary);
  border-radius: 999px;
  overflow: hidden;
}

.mini-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
}

/* Settings Page */
.setting-item {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
}

.setting-item .label {
  font-weight: 500;
}

.setting-item .description {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.setting-item input[type="number"] {
  width: 80px;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  text-align: center;
  background: var(--bg);
  color: var(--text);
}

/* Toggle Switch */
.toggle {
  position: relative;
  width: 50px;
  height: 28px;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-secondary);
  border-radius: 999px;
  cursor: pointer;
  transition: 0.3s;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}

.toggle input:checked+.toggle-slider {
  background: var(--primary);
}

.toggle input:checked+.toggle-slider::before {
  transform: translateX(22px);
}

/* Lesson Grid */
.lesson-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.lesson-checkbox-label {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  background: var(--bg-secondary);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.lesson-checkbox-label:has(input:checked) {
  background: var(--primary);
  color: white;
}

.lesson-checkbox-label input {
  display: none;
}

/* Action Buttons */
.settings-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

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

.btn-danger:hover {
  background: #dc2626;
}

/* Responsive */
@media (max-width: 480px) {
  .card-word {
    font-size: 2.5rem;
  }

  .card-meaning {
    font-size: 1.5rem;
  }

  .flashcard {
    height: 250px;
  }

  .rating-btn {
    padding: 0.6rem 0.25rem;
    font-size: 0.75rem;
  }

  .lesson-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Hidden utility */
.hidden {
  display: none !important;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: modalFadeIn 0.3s ease;
}

.modal.hidden {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 320px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: modalSlideIn 0.3s ease;
}

.modal-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text);
}

.modal-body {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.modal-btn {
  width: 100%;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes modalSlideIn {
  from {
    transform: scale(0.9) translateY(-20px);
    opacity: 0;
  }

  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}