/* Custom styles for Quiz Platform */

/* Primary Color Definitions - HIJAU (Teal/Green) */
:root {
  --primary-50: #f0fdfa;
  --primary-100: #ccfbf1;
  --primary-200: #99f6e4;
  --primary-300: #5eead4;
  --primary-400: #2dd4bf;
  --primary-500: #14b8a6;
  --primary-600: #1e5f4f;
  --primary-700: #165043;
  --primary-800: #134e3c;
  --primary-900: #0f4034;
}

.bg-primary {
  background-color: var(--primary-600) !important;
}
.bg-primary-dark {
  background-color: var(--primary-700) !important;
}
.hover\:bg-primary-dark:hover {
  background-color: var(--primary-700) !important;
}
.text-primary {
  color: var(--primary-600) !important;
}
.text-primary-dark {
  color: var(--primary-700) !important;
}
.hover\:text-primary-dark:hover {
  color: var(--primary-700) !important;
}
.text-primary-300 {
  color: var(--primary-300) !important;
}
.text-primary-400 {
  color: var(--primary-400) !important;
}
.group-hover\:text-primary-400:hover {
  color: var(--primary-400) !important;
}
.border-primary {
  border-color: var(--primary-600) !important;
}
.focus\:ring-primary:focus {
  --tw-ring-color: var(--primary-600) !important;
}

/* Optimized Animation for Fast Loading */
.fade-in {
  animation: fadeInFast 0.3s ease-out;
}

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

/* Fast Navigation Transitions - removed unused .nav-link styles */

/* Optimized Skeleton Loading */
.skeleton {
  will-change: opacity, transform;
}

/* User Menu Dropdown Styles */
#user-menu-dropdown {
  z-index: 9999 !important;
  box-shadow: 0 10px 25px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05) !important;
  border: 1px solid rgba(0, 0, 0, 0.05) !important;
}

#user-menu-dropdown.hidden {
  display: none !important;
}

#user-menu-dropdown:not(.hidden) {
  display: block !important;
}

/* Question Navigation Styles */
.question-nav-btn {
  transition: all 0.2s ease;
  min-width: 2rem;
  min-height: 2rem;
  font-weight: 600;
}

.question-nav-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

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

.question-nav-btn.current {
  background-color: #0f766e !important;
  color: white !important;
  border-color: #0f766e !important;
}

.question-nav-btn.answered {
  background-color: #dcfce7 !important;
  color: #166534 !important;
  border-color: #bbf7d0 !important;
}

.question-nav-btn.unanswered {
  background-color: white;
  color: #374151;
  border-color: #d1d5db;
}

.question-nav-btn.unanswered:hover {
  border-color: #14b8a6;
  background-color: #f0fdfa;
}

/* Mobile Sidebar */
#mobile-sidebar.show {
  transform: translateX(0) !important;
}

#mobile-sidebar-overlay.show {
  display: block !important;
}

/* Enhanced Sidebar Styles */
#desktop-sidebar {
  border-right: 1px solid #e5e7eb;
  transition: width 0.3s ease;
}

/* Removed unused #mobile-nav-toggle styles */

/* Mobile Sidebar Animation */
#mobile-sidebar {
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

#mobile-sidebar-overlay {
  backdrop-filter: blur(4px);
}

/* Removed unused .sidebar-collapsed styles */

/* Removed unused mobile nav content/icon styles */

/* Navigation Pagination Styles */
.navigation-pagination {
  padding: 0.5rem;
}

.navigation-scroll-area {
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  padding: 0.5rem;
  background-color: #f9fafb;
  max-height: 12rem; /* ~192px */
}

.navigation-scroll-area::-webkit-scrollbar {
  width: 4px;
}

.navigation-scroll-area::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 2px;
}

.navigation-scroll-area::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 2px;
}

.navigation-scroll-area::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Responsive adjustments for large question counts */
@media (max-width: 640px) {
  .navigation-scroll-area {
    max-height: 10rem; /* Smaller on mobile */
  }

  .question-nav-btn {
    min-width: 1.75rem;
    min-height: 1.75rem;
    font-size: 0.75rem;
  }
}

@media (min-width: 1024px) {
  .navigation-scroll-area {
    max-height: 16rem; /* Larger on desktop */
  }
}

/* Responsive grid adjustments */
@media (max-width: 640px) {
  #mobile-question-navigation {
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
  }

  .question-nav-btn {
    width: 2rem;
    height: 2rem;
    font-size: 0.75rem;
  }
}

@media (min-width: 1024px) {
  #desktop-question-navigation {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* Loading animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideIn {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Animation classes */
.animate-fade-in {
  animation: fadeIn 0.5s ease-out;
}

.animate-slide-in {
  animation: slideIn 0.3s ease-out;
}

.animate-pulse {
  animation: pulse 2s infinite;
}

/* Custom radio button styles */
.quiz-option {
  transition: all 0.2s ease;
}

.quiz-option:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.quiz-option input:checked + span {
  background-color: #4f46e5;
  color: white;
  border-radius: 0.5rem;
  padding: 0.5rem;
  margin: -0.5rem;
}

/* Progress bar animation */
.progress-bar {
  transition: width 0.5s ease-in-out;
}

/* Notification styles */
.notification {
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Score circle animation */
.score-circle circle {
  transition: stroke-dashoffset 1s ease-in-out;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  .sidebar-mobile {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  .sidebar-mobile.open {
    transform: translateX(0);
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #1f2937;
    --text-primary: #f3f4f6;
  }
}

/* Print styles */
@media print {
  .no-print {
    display: none;
  }

  .print-break {
    page-break-before: always;
  }
}

/* Loading spinner */
.loading-spinner {
  border: 2px solid #f3f3f3;
  border-top: 2px solid #4f46e5;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Focus styles for accessibility */
.focus-visible:focus {
  outline: 2px solid #4f46e5;
  outline-offset: 2px;
}

/* Utility classes */
.text-shadow {
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.box-shadow-soft {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.gradient-bg {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Quiz specific styles */
.question-card {
  transition: all 0.3s ease;
  border-left: 4px solid transparent;
}

.question-card.answered {
  border-left-color: #10b981;
  background-color: #f0fdf4;
}

.question-card.current {
  border-left-color: #4f46e5;
  background-color: #eef2ff;
}

/* Timer styles */
.timer-warning {
  animation: pulse 1s infinite;
  color: #ef4444;
}

/* Results page styles */
.result-card {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
}

.result-card.failed {
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
}

/* Responsive grid */
.auto-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
}

/* Smooth scroll */
html {
  scroll-behavior: smooth;
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* Perfect circle for icons */
.perfect-circle {
  border-radius: 50% !important;
  aspect-ratio: 1 / 1;
  min-width: fit-content;
  min-height: fit-content;
}

/* Multimedia Quiz Styles */
.question-image img {
  transition: transform 0.3s ease;
}

.question-image img:hover {
  transform: scale(1.05);
}

.image-option {
  transition: all 0.2s ease;
  border: 2px solid transparent;
}

.image-option:hover {
  border-color: #4f46e5;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.image-option input:checked + div {
  border-color: #10b981;
  background-color: #f0fdf4;
}

/* Audio Player Styles */
.audio-player {
  background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
  border: 1px solid #d1d5db;
}

.audio-player button {
  transition: all 0.2s ease;
}

.audio-player button:hover {
  transform: scale(1.1);
}

.audio-player button:active {
  transform: scale(0.95);
}

/* Long Text Handling */
.question-text {
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  line-height: 1.6;
}

/* Question text with conversation format support */
#question-text {
  white-space: pre-wrap; /* Preserve whitespace and line breaks */
  line-height: 1.8;
}

.question-text-long {
  max-height: 200px;
  overflow-y: auto;
  padding-right: 10px;
}

.question-text-long::-webkit-scrollbar {
  width: 4px;
}

.question-text-long::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 2px;
}

/* Image Selection Styles */
.image-selection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

@media (max-width: 640px) {
  .image-selection-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }
}

.image-selection-item {
  position: relative;
  overflow: hidden;
  border-radius: 0.5rem;
}

.image-selection-item img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.image-selection-item:hover img {
  transform: scale(1.1);
}

.image-selection-item .description {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
  color: white;
  padding: 0.5rem;
  font-size: 0.75rem;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.image-selection-item:hover .description {
  opacity: 1;
}

/* Responsive improvements */
@media (max-width: 640px) {
  .question-image img {
    max-height: 200px;
  }

  .image-selection-item img {
    height: 120px;
  }
}

/* Removed global body padding-bottom as it conflicts with fixed footer navigation */
/* Each page now handles its own spacing with specific classes */

/* Fixed Footer Navigation Styles */
.fixed-bottom-nav {
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  z-index: 9999 !important;
  background-color: white !important;
  border-top: 1px solid #e5e7eb !important;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1) !important;
}

/* Mobile Navigation Spacing */
.mobile-nav-spacing {
  height: 64px; /* Space for mobile navigation */
}

/* Ensure main content doesn't overlap with fixed footer */
.content-with-fixed-footer {
  padding-bottom: 120px !important; /* Increased to 120px for better spacing on mobile, especially for longer content */
}

/* User Menu Dropdown hover (align with #user-menu-dropdown usage) */
#user-menu-dropdown a:hover {
  background-color: #f8fafc;
}

@media (min-width: 768px) {
  .mobile-nav-spacing {
    display: none;
  }
  .content-with-fixed-footer {
    padding-bottom: 0 !important;
  }
}

/* Results transition styles */
#quiz-results {
  transition: opacity 0.5s ease-in-out;
}

#results-main-content {
  transition: opacity 0.4s ease-in;
}

#results-loading-skeleton {
  transition: opacity 0.3s ease-out;
}

/* Perfect circle utility defined earlier; duplicate removed */

/* Results animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in-up {
  animation: fadeInUp 0.6s ease-out;
}

/* Results button styles */
#quiz-results button {
  transition: all 0.2s ease;
}

#quiz-results button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#quiz-results button:active {
  transform: translateY(0);
}

/* Quiz results layout */
#quiz-results {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem 1rem;
  min-height: 100vh;
  background: #f9fafb;
}

@media (min-width: 640px) {
  #quiz-results {
    padding: 3rem 2rem;
  }
}

@media (min-width: 1024px) {
  #quiz-results {
    padding: 4rem 2rem;
  }
}

/* Highlight effect for answer review section */
.highlight-section {
  animation: highlightPulse 2s ease-in-out;
  border: 2px solid #0f766e !important;
  border-radius: 0.75rem !important;
}

@keyframes highlightPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(15, 118, 110, 0.7);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(15, 118, 110, 0.3);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(15, 118, 110, 0);
  }
}

/* ========================================
   Furigana (Ruby Annotation) Support
   ======================================== */

/* Ruby (furigana container) styling */
ruby {
  position: relative;
  display: ruby;
  ruby-position: over;
  line-height: 2.2;
}

/* RT (ruby text - furigana hiragana) styling */
rt {
  font-size: 0.5em;
  line-height: 1.2;
  text-align: center;
  color: #4b5563; /* gray-600 */
  font-weight: 400;
}

/* RP (ruby parentheses - fallback untuk browser lama) */
rp {
  display: none; /* Hide parentheses di browser modern */
}

/* Furigana untuk pertanyaan quiz */
#question-text ruby {
  line-height: 2.4;
}

#question-text rt {
  font-size: 0.45em;
  color: #6b7280; /* gray-500 */
}

/* Furigana untuk pilihan jawaban */
.answer-option ruby {
  line-height: 2.2;
}

.answer-option rt {
  font-size: 0.5em;
  color: #6b7280;
}

/* Responsive furigana size */
@media (max-width: 640px) {
  ruby {
    line-height: 2;
  }

  rt {
    font-size: 0.45em;
  }

  #question-text ruby {
    line-height: 2.2;
  }

  #question-text rt {
    font-size: 0.4em;
  }
}

/* Furigana untuk conversation mode */
.conversation-text ruby {
  line-height: 2.3;
}

.conversation-text rt {
  font-size: 0.48em;
  color: #9ca3af; /* gray-400 */
}

/* Ensure proper spacing dengan furigana */
.has-furigana {
  padding-top: 0.5rem;
  padding-bottom: 0.25rem;
}

/* SweetAlert2 Custom Styles */
.swal2-small-popup {
  width: 420px !important;
  max-width: 90vw !important;
  font-size: 0.9rem !important;
}

.swal2-small-popup .swal2-title {
  font-size: 1.25rem !important;
  padding: 0.5rem 1rem !important;
}

.swal2-small-popup .swal2-html-container {
  padding: 0.5rem 1rem !important;
  margin: 0 !important;
}

.swal2-small-popup .swal2-actions {
  padding: 0.5rem 1rem 1rem !important;
}

@media (max-width: 640px) {
  .swal2-small-popup {
    width: 95vw !important;
    font-size: 0.85rem !important;
  }

  .swal2-small-popup .swal2-title {
    font-size: 1.1rem !important;
  }
}
