/* Custom styles for ProgMaster */

/* Prose styling for markdown content */
.prose {
  max-width: none;
}

.prose pre {
  margin: 1.5em 0;
  border-radius: 0.5rem;
  background-color: #1e1e1e;
}

.prose code {
  font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
  font-size: 0.875em;
}

.prose :not(pre) > code {
  background-color: #f3f4f6;
  padding: 0.2em 0.4em;
  border-radius: 0.25rem;
  font-weight: 500;
}

.dark .prose :not(pre) > code {
  background-color: #374151;
}

/* Table styling */
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
}

.prose th,
.prose td {
  border: 1px solid #e5e7eb;
  padding: 0.75rem 1rem;
  text-align: left;
}

.dark .prose th,
.dark .prose td {
  border-color: #374151;
}

.prose th {
  background-color: #f9fafb;
  font-weight: 600;
}

.dark .prose th {
  background-color: #1f2937;
}

/* Heading anchors */
.prose h1 .header-anchor,
.prose h2 .header-anchor,
.prose h3 .header-anchor,
.prose h4 .header-anchor,
.prose h5 .header-anchor,
.prose h6 .header-anchor {
  opacity: 0;
  margin-left: 0.5rem;
  color: #6b7280;
  text-decoration: none;
  transition: opacity 0.2s;
}

.prose h1:hover .header-anchor,
.prose h2:hover .header-anchor,
.prose h3:hover .header-anchor,
.prose h4:hover .header-anchor,
.prose h5:hover .header-anchor,
.prose h6:hover .header-anchor {
  opacity: 1;
}

/* Syntax highlighting (highlight.js github-dark theme adjustments) */
.hljs {
  background: #0d1117 !important;
  color: #c9d1d9;
  padding: 1.5rem;
  border-radius: 0.5rem;
  overflow-x: auto;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}

.dark ::-webkit-scrollbar-track {
  background: #1e293b;
}

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

::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

/* Line clamp utility */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Dark mode background adjustment */
.dark .bg-gray-750 {
  background-color: #1a2332;
}

/* Image zoom effect */
img.cursor-zoom-in {
  cursor: zoom-in;
  transition: transform 0.3s ease;
}

img.max-w-none {
  cursor: zoom-out;
}

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

/* Active TOC item */
nav a.active {
  color: #3b82f6;
  font-weight: 500;
}

/* File type badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 9999px;
}

/* Loading spinner */
.spinner {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Transition utilities */
.transition-all {
  transition: all 0.2s ease;
}

/* Focus visible styling */
:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Gradient background utility */
.gradient-bg {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
}

/* Card hover effect */
.card-hover {
  transition: all 0.3s ease;
}

.card-hover:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

/* Print styles */
@media print {
  nav,
  aside,
  footer,
  .no-print {
    display: none !important;
  }

  .prose {
    max-width: 100% !important;
  }

  body {
    background: white !important;
    color: black !important;
  }
}

/* Language Switcher - CSS-only dropdown */
.lang-switcher {
  padding-bottom: 0.5rem; /* Extend hover zone below button */
  margin-bottom: -0.5rem; /* Compensate for visual alignment */
}

.lang-switcher .lang-dropdown {
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  pointer-events: none;
}

/* Bridge the gap between button and dropdown to prevent hover loss */
.lang-switcher .lang-dropdown::before {
  content: '';
  position: absolute;
  top: -1rem; /* Extend above the mt-2 gap for more forgiving hover */
  left: -1rem; /* Extend left for diagonal mouse movement */
  right: -1rem; /* Extend right for diagonal mouse movement */
  height: 1.5rem; /* Cover more vertical area */
}

.lang-switcher:hover .lang-dropdown,
.lang-switcher:focus-within .lang-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

/* Rotate chevron icon when dropdown is open */
.lang-switcher:hover svg,
.lang-switcher:focus-within svg {
  transform: rotate(180deg);
}

/* ================================================
   Quiz Modal Styles
   ================================================ */

.modal-backdrop {
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(2rem);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-content::-webkit-scrollbar {
  width: 8px;
}

.modal-content::-webkit-scrollbar-track {
  background: rgb(15 23 42);
}

.modal-content::-webkit-scrollbar-thumb {
  background: rgb(51 65 85);
  border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
  background: rgb(71 85 105);
}

/* ================================================
   Collapsible Animations
   ================================================ */

.module-content,
#practice-test-content {
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chevron-icon {
  transition: transform 0.2s ease-in-out;
}

/* ================================================
   Range Slider Styling
   ================================================ */

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  background: #3b82f6;
  cursor: pointer;
  border-radius: 50%;
  border: 2px solid #1e293b;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

input[type="range"]::-webkit-slider-thumb:hover {
  background: #2563eb;
  box-shadow: 0 4px 8px rgba(0,0,0,0.4);
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: #3b82f6;
  cursor: pointer;
  border-radius: 50%;
  border: 2px solid #1e293b;
}

input[type="range"]:focus {
  outline: none;
}

/* ================================================
   Mobile Responsive
   ================================================ */

@media (max-width: 768px) {
  .modal-content {
    max-height: 95vh;
    border-radius: 1rem;
  }

  .quiz-modal-body {
    padding: 1rem;
  }

  .quiz-question {
    padding: 1rem;
  }
}

/* ================================================
   Loading Animation
   ================================================ */

.animate-spin {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
