/* ===== Base Styles & Variables ===== */
:root {
  /* Colors */
  --primary: #4361ee;
  --secondary: #3f37c9;
  --success: #4cc9f0;
  --danger: #f72585;
  --warning: #f8961e;
  --light: #f8f9fa;
  --dark: #212529;
  --gray: #6c757d;
  
  /* Semantic Colors */
  --correct: #28a745;
  --incorrect: #dc3545;
  --flagged: #ffc107;
  --text-light: #f8f9fa;
  --text-dark: #212529;
}

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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  background-color: #f5f7fa;
  color: var(--dark);
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* ===== Layout ===== */
.container {
  padding-bottom: 200px; /* Fix: prevent mobile keyboard from hiding feedback */
  max-width: 800px;
  margin: 0 auto;
  padding: 1rem;
}

/* ===== Navbar ===== */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background-color: white;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  transition: background-color 0.3s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand .logo {
  height: 40px;
  transition: filter 0.3s ease;
}

.brand span {
  font-weight: 600;
  font-size: 1.2rem;
  transition: color 0.3s ease;
}

.subtitle {
  font-size: 0.9rem;
  color: var(--gray);
  display: block;
}

.nav-actions {
  display: flex;
  gap: 0.5rem;
}

/* ===== Training Card ===== */
.training-card {
  background-color: white;
  border-radius: 12px;
  padding: 2rem;
  margin-top: 1rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.card-title {
  text-align: center;
  margin-bottom: 1.5rem;
  color: var(--primary);
  font-weight: 700;
}

/* ===== Mode Selector ===== */
.mode-selector {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.btn-mode {
  flex: 1;
  padding: 0.75rem;
  border: none;
  border-radius: 8px;
  background-color: #e9ecef;
  color: var(--gray);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

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

/* ===== Accent Picker ===== */
.accent-picker {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.accent-picker button {
  flex: 1;
  padding: 0.75rem;
  border: 2px solid #dee2e6;
  border-radius: 8px;
  background: white;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.accent-picker button.active {
  border-color: var(--primary);
  background-color: #f0f7ff;
}

.flag-icon {
  font-size: 1.2rem;
}

/* ===== Custom Words Section ===== */
.custom-words-section {
  margin-bottom: 1.5rem;
}

.section-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--gray);
}

textarea {
  width: 100%;
  padding: 1rem;
  border: 2px solid #dee2e6;
  border-radius: 8px;
  resize: vertical;
  min-height: 100px;
  margin-bottom: 0.75rem;
  font-family: inherit;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.file-upload {
  margin-bottom: 0.75rem;
  position: relative;
}

.btn-upload {
  display: inline-block;
  padding: 0.5rem 1rem;
  background-color: #e9ecef;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background-color 0.2s ease;
}

#file-input {
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

/* ===== Buttons ===== */
.btn-primary {
  background-color: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0.75rem 1.5rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

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

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background-color: var(--gray);
}

.btn-start {
  background-color: var(--success);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 1rem;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
  margin-top: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-start:hover {
  background-color: #3aa8d8;
}

.btn-secondary {
  background-color: white;
  color: var(--primary);
  border: 2px solid var(--primary);
  border-radius: 8px;
  padding: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background-color: #f0f7ff;
}

.btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background-color: #f8f9fa;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--gray);
  font-size: 1.2rem;
  cursor: pointer;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background-color: #f8f9fa;
}

.btn-icon.active {
  color: var(--flagged);
  background-color: rgba(255, 193, 7, 0.1);
}

/* ===== Trainer Area ===== */
.trainer-area {
  margin-bottom: 5rem; /* Fix: extra space above mobile keyboard */
  margin-top: 2rem;
}

.trainer-area.hidden {
  display: none;
}

.word-progress {
  font-size: 0.9rem;
  color: var(--gray);
  text-align: center;
  margin-bottom: 1rem;
}

.input-group {
  margin: 1.5rem 0;
}

.form-control {
  width: 100%;
  padding: 1rem;
  border: 2px solid #dee2e6;
  border-radius: 8px;
  font-size: 1.1rem;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
}

.correct-answer {
  border-color: var(--correct) !important;
  background-color: rgba(40, 167, 69, 0.05);
}

.incorrect-answer {
  border-color: var(--incorrect) !important;
  background-color: rgba(220, 53, 69, 0.05);
}

.button-group {
  display: flex;
  gap: 0.75rem;
  margin: 1.5rem 0;
}

.button-group button {
  flex: 1;
}

/* ===== Feedback ===== */
.feedback {
  padding: 1rem;
  border-radius: 8px;
  margin: 1rem 0;
  font-weight: 500;
}

.feedback.correct {
  background-color: #e6f7ee;
  color: var(--correct);
}

.feedback.incorrect {
  background-color: #fce8e8;
  color: var(--incorrect);
}

/* ===== Results Summary ===== */
.summary-area {
  margin-top: 2rem;
}

.summary-area.hidden {
  display: none;
}

.summary-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.score-display {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  margin-top: 0.5rem;
}

.score-percent {
  font-size: 1.2rem;
  color: var(--gray);
}

.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.results-card {
  padding: 1.5rem;
  border-radius: 8px;
}

.results-card.correct {
  background-color: #e8f5e9;
  border: 1px solid #a5d6a7;
}

.results-card.incorrect {
  background-color: #ffebee;
  border: 1px solid #ef9a9a;
}

.results-card h3 {
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.score-number {
  font-size: 2rem;
  font-weight: bold;
  text-align: center;
  margin: 0.5rem 0;
}

.word-list {
  max-height: 200px;
  overflow-y: auto;
  margin-top: 0.5rem;
  padding-right: 0.5rem;
}

.word-list::-webkit-scrollbar {
  width: 6px;
}

.word-list::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 3px;
}

.word-item {
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(0,0,0,0.1);
}

.summary-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

/* ===== Animations ===== */
@keyframes pulseGreen {
  0% { background: white; }
  50% { background: var(--correct); }
  100% { background: white; }
}

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

.fade-in {
  animation: fadeIn 0.3s ease-in;
}

/* ===== Dark Mode ===== */
.dark-mode {
  background-color: #1a1a1a;
  color: var(--text-light);
}

.dark-mode .training-card,
.dark-mode .navbar {
  background-color: #2d2d2d;
  color: var(--text-light);
}

.dark-mode textarea,
.dark-mode .form-control {
  background-color: #3d3d3d;
  border-color: #4d4d4d;
  color: var(--text-light);
}

.dark-mode .btn-secondary {
  background-color: #3d3d3d;
  border-color: #555;
  color: var(--text-light);
}

.dark-mode .btn-secondary:hover {
  background-color: #4d4d4d;
}

.dark-mode .results-card.correct {
  background-color: #1b3a1f;
  border-color: #2e7d32;
}

.dark-mode .results-card.incorrect {
  background-color: #3a1b1b;
  border-color: #7d2e2e;
}

.dark-mode .word-item {
  border-bottom-color: rgba(255,255,255,0.1);
}

.dark-mode .word-list::-webkit-scrollbar-thumb {
  background: #555;
}

.dark-mode .feedback.correct {
  background-color: rgba(40, 167, 69, 0.2);
}

.dark-mode .feedback.incorrect {
  background-color: rgba(220, 53, 69, 0.2);
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
  .container {
  padding-bottom: 200px; /* Fix: prevent mobile keyboard from hiding feedback */
    padding: 0.5rem;
  }

  .training-card {
    padding: 1.5rem;
  }

  .summary-grid,
  .results-grid {
    grid-template-columns: 1fr;
  }

  .button-group {
    flex-wrap: wrap;
  }

  .button-group button {
    min-width: calc(50% - 0.375rem);
  }
}

@media (max-width: 480px) {
  .brand span {
    font-size: 1rem;
  }

  .training-card {
    padding: 1rem;
  }

  .button-group button {
    min-width: 100%;
  }

  .summary-actions {
    flex-direction: column;
  }

  /* ======================
   Mobile Responsiveness
   ====================== */
@media (max-width: 768px) {
  /* Global mobile adjustments */
  .container {
    padding: 0 15px;
  }

  /* Pricing grid (if used on multiple pages) */
  .pricing-grid {
    flex-direction: column;
    align-items: center;
    gap: 15px;
  }

  .pricing-card {
    width: 100%;
    max-width: none;
    padding: 20px;
  }

  /* Navbar adjustments */
  .navbar {
    flex-direction: column;
    padding: 10px 0;
  }

  .nav-actions {
    margin-top: 10px;
  }
}
