/* ============================================================================
   Features CSS: Recording, Quiz, Test Mode
   ============================================================================ */

/* Recording Controls */
.recording-controls {
  margin-top: 0; /* No margin when inside line-controls */
  padding: 4px 8px; /* Reduced vertical padding: 4px vertical, 8px horizontal */
  background: rgba(59, 130, 246, 0.1);
  border-radius: 6px; /* Reduced from 8px */
  border: 1px solid rgba(59, 130, 246, 0.2);
  pointer-events: auto; /* Ensure controls are clickable */
  flex-shrink: 0; /* Prevent shrinking in flex container */
  min-width: fit-content; /* Allow container to fit content */
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px; /* Small gap between status and buttons */
}

.recording-controls * {
  pointer-events: auto; /* All children are clickable */
}

.recording-status {
  font-size: 0.65rem; /* Smaller font */
  color: #3b82f6;
  margin-bottom: 0; /* No margin, use gap from parent */
  margin-top: 0;
  padding: 0;
  font-weight: 500;
  line-height: 1.1; /* Tighter line height */
}

.recording-buttons {
  display: flex;
  gap: 6px; /* Increased gap for better spacing */
  flex-wrap: nowrap;
  align-items: center;
  overflow-x: auto;
  min-width: fit-content; /* Allow buttons to fit properly */
}

.recording-controls .icon-btn {
  padding: 6px 12px; /* Match line-btn padding */
  font-size: 0.875rem; /* Match line-btn font-size */
  border-radius: 6px; /* Match line-btn border-radius */
  border: 1px solid rgba(59, 130, 246, 0.3);
  background: white;
  color: #3b82f6;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
  height: 32px; /* Match line-btn height */
  display: flex;
  align-items: center;
  justify-content: center;
}

.recording-controls .icon-btn:hover {
  background: #3b82f6;
  color: white;
  border-color: #3b82f6;
}

.recording-controls .btn-play-original,
.recording-controls .btn-play-user {
  min-width: 80px; /* Slightly wider for text content */
  width: auto; /* Allow width to fit content */
  padding: 6px 12px; /* Match line-btn padding */
  height: 32px; /* Match line-btn height */
  text-align: center;
}

.recording-controls .icon-btn.hidden {
  display: none;
}

.recording-controls .btn-record {
  background: #ef4444;
  color: white;
  border-color: #ef4444;
  height: 32px; /* Match line-btn height */
}

.recording-controls .btn-record:hover {
  background: #dc2626;
}

.recording-controls .btn-stop {
  background: #f59e0b;
  color: white;
  border-color: #f59e0b;
  height: 32px; /* Match line-btn height */
}

.recording-controls .btn-stop:hover {
  background: #d97706;
}


.line .vi.hidden-answer:hover {
  filter: blur(4px);
}

.btn-secondary {
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background: white;
  color: #374151;
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: #f9fafb;
  border-color: #9ca3af;
}

.btn-secondary.active {
  background: #3b82f6;
  color: white;
  border-color: #3b82f6;
}

/* Quiz Modal */
.quiz-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.quiz-modal-content {
  background: white;
  border-radius: 12px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid #e5e7eb;
}

.quiz-header h2 {
  margin: 0;
  font-size: 1.5rem;
  color: #1f2937;
}

.quiz-close {
  background: none;
  border: none;
  font-size: 2rem;
  color: #6b7280;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
}

.quiz-close:hover {
  background: #f3f4f6;
  color: #374151;
}

.quiz-body {
  padding: 20px;
}

.quiz-progress {
  margin-bottom: 24px;
}

.quiz-progress-text {
  display: block;
  font-size: 0.875rem;
  color: #6b7280;
  margin-bottom: 8px;
}

.quiz-progress-bar {
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
}

.quiz-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #8b5cf6);
  transition: width 0.3s;
}

.quiz-question {
  margin-bottom: 24px;
}

.quiz-question-text {
  margin-bottom: 16px;
}

.quiz-jp {
  font-size: 1.25rem;
  color: #1f2937;
  margin-bottom: 8px;
  font-weight: 500;
}

.quiz-vi {
  font-size: 1rem;
  color: #374151;
  margin-bottom: 8px;
}

.quiz-prompt {
  font-size: 0.875rem;
  color: #6b7280;
  margin: 0;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.quiz-option {
  padding: 12px 16px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  background: white;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9375rem;
  color: #374151;
}

.quiz-option:hover {
  border-color: #3b82f6;
  background: #eff6ff;
}

.quiz-option.selected {
  border-color: #3b82f6;
  background: #dbeafe;
  color: #1e40af;
}

/* Fill in the blank */
.quiz-blank {
  font-size: 1.1rem;
  padding: 12px;
  background: #f9fafb;
  border-radius: 8px;
  border: 2px dashed #d1d5db;
}

/* Ordering question */
.quiz-word-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
  padding: 12px;
  background: #f9fafb;
  border-radius: 8px;
  min-height: 60px;
}

.quiz-word-item {
  padding: 8px 16px;
  border: 2px solid #e5e7eb;
  border-radius: 6px;
  background: white;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9375rem;
  color: #374151;
}

.quiz-word-item:hover {
  border-color: #3b82f6;
  background: #eff6ff;
  transform: translateY(-2px);
}

.quiz-word-item.quiz-ordered-item {
  background: #dbeafe;
  border-color: #3b82f6;
  color: #1e40af;
}

.quiz-answer-area {
  margin-top: 16px;
  padding: 16px;
  background: #f0f9ff;
  border-radius: 8px;
  border: 2px solid #bae6fd;
}

.quiz-ordered-words {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
  min-height: 50px;
  padding: 8px;
  background: white;
  border-radius: 6px;
}

.quiz-prompt-small {
  font-size: 0.8125rem;
  color: #6b7280;
  margin: 0 0 8px 0;
}

.quiz-clear-order {
  padding: 6px 12px;
  font-size: 0.875rem;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background: white;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.2s;
}

.quiz-clear-order:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
}

/* True/False question */
.quiz-tf-options {
  flex-direction: row;
  gap: 16px;
}

.quiz-tf-btn {
  flex: 1;
  padding: 16px;
  font-size: 1.1rem;
  font-weight: 600;
}

.quiz-tf-btn[data-option="true"]:hover {
  background: #dcfce7;
  border-color: #22c55e;
  color: #15803d;
}

.quiz-tf-btn[data-option="false"]:hover {
  background: #fee2e2;
  border-color: #ef4444;
  color: #dc2626;
}

.quiz-tf-btn[data-option="true"].selected {
  background: #22c55e;
  border-color: #22c55e;
  color: white;
}

.quiz-tf-btn[data-option="false"].selected {
  background: #ef4444;
  border-color: #ef4444;
  color: white;
}

.quiz-context {
  font-size: 1rem;
  color: #6b7280;
  font-style: italic;
  margin: 8px 0;
  padding: 8px;
  background: #f9fafb;
  border-radius: 6px;
}

.quiz-statement {
  font-size: 1.1rem;
  color: #1f2937;
  font-weight: 500;
  margin: 12px 0;
  padding: 12px;
  background: #fef3c7;
  border-left: 4px solid #f59e0b;
  border-radius: 4px;
}

/* Furigana matching */
.quiz-kanji {
  font-size: 2rem;
  text-align: center;
  padding: 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 12px;
  margin: 16px 0;
  font-weight: 600;
}

/* Multiple select */
.quiz-multiple-select {
  gap: 10px;
}

.quiz-checkbox-option {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}

.quiz-checkbox {
  font-size: 1.2rem;
  min-width: 24px;
  display: inline-block;
}

.quiz-option-text {
  flex: 1;
}

.quiz-checkbox-option.selected {
  background: #dbeafe;
  border-color: #3b82f6;
}

.quiz-checkbox-option.selected .quiz-checkbox {
  color: #3b82f6;
}

.quiz-audio-btn {
  padding: 10px 20px;
  font-size: 1rem;
  border-radius: 8px;
  border: 2px solid #3b82f6;
  background: white;
  color: #3b82f6;
  cursor: pointer;
  transition: all 0.2s;
  margin: 10px 0;
  font-weight: 500;
}

.quiz-audio-btn:hover {
  background: #3b82f6;
  color: white;
}

.quiz-button-container {
  border: none !important;
  background: transparent !important;
  padding: 0 !important;
  margin: 20px 0 !important;
}

.quiz-button-container:hover {
  background: transparent !important;
}

.quiz-footer {
  padding: 20px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.btn-primary {
  padding: 10px 20px;
  border-radius: 6px;
  border: none;
  background: #3b82f6;
  color: white;
  cursor: pointer;
  font-size: 0.9375rem;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-primary:hover {
  background: #2563eb;
}

.btn-primary.hidden {
  display: none;
}

/* Quiz Results */
.quiz-results {
  padding: 20px;
}

.quiz-score {
  text-align: center;
  padding: 32px;
  border-radius: 12px;
  margin-bottom: 24px;
}

.quiz-score.passed {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
}

.quiz-score.failed {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
}

.quiz-score-number {
  font-size: 3rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.quiz-score-label {
  font-size: 1rem;
  opacity: 0.9;
  margin-bottom: 12px;
}

.quiz-badge {
  display: inline-block;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 500;
}

.quiz-details {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.quiz-result-item {
  display: flex;
  gap: 12px;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

.quiz-result-item.correct {
  background: #f0fdf4;
  border-color: #86efac;
}

.quiz-result-item.incorrect {
  background: #fef2f2;
  border-color: #fca5a5;
}

.quiz-result-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.quiz-result-content {
  flex: 1;
}

.quiz-result-question {
  font-size: 0.9375rem;
  color: #374151;
  margin: 0 0 8px 0;
  font-weight: 500;
}

.quiz-result-answer {
  font-size: 0.875rem;
  color: #6b7280;
  margin: 4px 0;
}

.quiz-result-user {
  font-size: 0.875rem;
  color: #dc2626;
  margin: 4px 0 0 0;
}

/* Quiz Container (at end of lesson) */
.quiz-container {
  padding: 24px;
  text-align: center;
  margin-top: 32px;
  border-top: 2px dashed #e5e7eb;
}

.btn-quiz {
  padding: 14px 28px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: white;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.btn-quiz:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px -2px rgba(0, 0, 0, 0.15);
}

/* Dark mode support */
body.theme-dark .quiz-modal-content {
  background: #1f2937;
  color: #f9fafb;
}

body.theme-dark .quiz-header {
  border-color: #374151;
}

body.theme-dark .quiz-header h2 {
  color: #f9fafb;
}

body.theme-dark .quiz-option {
  background: #374151;
  border-color: #4b5563;
  color: #f9fafb;
}

body.theme-dark .quiz-option:hover {
  background: #4b5563;
  border-color: #3b82f6;
}

body.theme-dark .quiz-result-item {
  background: #374151;
  border-color: #4b5563;
}

body.theme-dark .quiz-result-question {
  color: #f9fafb;
}

body.theme-dark .recording-controls {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.3);
}

body.theme-dark .recording-controls .icon-btn {
  background: #374151;
  color: #93c5fd;
  border-color: #4b5563;
}

body.theme-dark .recording-controls .icon-btn:hover {
  background: #3b82f6;
  color: white;
}

/* Mobile responsive for quiz */
@media (max-width: 768px) {
  .quiz-modal {
    padding: 10px;
  }

  .quiz-modal-content {
    max-height: 95vh;
  }

  .quiz-header {
    padding: 16px;
  }

  .quiz-header h2 {
    font-size: 1.25rem;
  }

  .quiz-close {
    font-size: 1.5rem;
    width: 28px;
    height: 28px;
  }

  .quiz-body {
    padding: 16px;
  }

  .quiz-progress-text {
    font-size: 0.8125rem;
  }

  .quiz-jp {
    font-size: 1.1rem;
  }

  .quiz-vi {
    font-size: 0.9375rem;
  }

  .quiz-prompt {
    font-size: 0.8125rem;
  }

  .quiz-option {
    padding: 10px 14px;
    font-size: 0.875rem;
  }

  .quiz-audio-btn {
    padding: 8px 16px;
    font-size: 0.875rem;
  }

  .quiz-footer {
    padding: 16px;
  }

  .btn-primary {
    padding: 8px 16px;
    font-size: 0.875rem;
  }

  .quiz-results {
    padding: 16px;
  }

  .quiz-score {
    padding: 24px;
  }

  .quiz-score-number {
    font-size: 2.5rem;
  }

  .quiz-score-label {
    font-size: 0.9375rem;
  }

  .quiz-badge {
    font-size: 0.8125rem;
    padding: 5px 10px;
  }

  .quiz-result-item {
    padding: 12px;
    gap: 10px;
  }

  .quiz-result-icon {
    font-size: 1.25rem;
  }

  .quiz-result-question {
    font-size: 0.875rem;
  }

  .quiz-result-answer {
    font-size: 0.8125rem;
  }

  .quiz-result-user {
    font-size: 0.8125rem;
  }
}

