.qbank-main-container, .selection-container, .bookmarks-container, .questions-container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 2rem;
}


.back-button {
  position: absolute;
  top: 0.5rem;    /* Add this to set the distance from the top */
  left: 0.5rem; 
  padding: 0.5rem;
  margin-bottom: 1rem;
  background: #2c5282;
  border: 2px solid #2c5282;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.back-button:hover {
  background: #2c5282;
  color: white;
  transform: scale(1.1);
  box-shadow: 0 4px 15px rgba(44, 82, 130, 0.3);
}

.back-button i {
  font-size: 1.2rem;
  color: rgba(255, 255, 255, 0.9);
  transition: color 0.3s ease;
}

.back-button:hover i {
  color: white;
}

/* Header adjustments */
header .header-content {
  position: relative;
  padding-left: 4rem;
}

/* Quiz Container */
.quiz-container {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding: 1rem;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.quiz-progress {
  font-size: 1.2rem;
  font-weight: 600;
  color: #2c5282;
}

.quiz-actions {
  display: flex;
  gap: 1rem;
}

.bookmark-question-btn, .exit-btn {
  background: white;
  border: 2px solid #2c5282;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

.bookmark-question-btn:hover, .exit-btn:hover {
  background: #2c5282;
  color: white;
}

.bookmark-question-btn i.fas {
  color: #f59e0b;
}

.question-container {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  position: relative;
  min-height: auto;
  max-width: 1000px;   /* <-- add or adjust this line */
  width: 100%;         /* <-- ensure it uses all available width up to max-width */
  margin-left: auto;   /* <-- center the container */
  margin-right: auto;
}

/* Bookmark button positioned at top-right of question container */
.question-container .bookmark-question-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: white;
  border: 2px solid #f59e0b;
  padding: 0.5rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  color: #2c5282;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  z-index: 10;
}

.question-container .bookmark-question-btn:hover {
  background: #fef3c7;
  transform: scale(1.05);
  border-color: #d97706;
}

.question-container .bookmark-question-btn i {
  color: #f59e0b;
  font-size: 1.2rem;
}

/* Quiz progress at top-left of question container */
.question-container .quiz-progress {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  background: #f8fafc;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #2c5282;
  border: 1px solid #e2e8f0;
  z-index: 10;
}

.question-text {
  font-size: 1.05rem;
  line-height: 1.6;
  color: #374151;
  margin-bottom: 1.25rem;
  padding: 2.5rem 2.5rem 0 0; /* Top padding for progress, right padding for bookmark */
  font-weight: 500;
}

.question-image {
  text-align: center;
  margin: 1.5rem 0;
}

.question-image img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.options-container {
  display: grid;
  gap: 0.5rem;
  margin: 1rem 0;
}

.option-btn {
  background: white;
  border: 2px solid #e5e7eb;
  padding: 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 48px;
  font-size: 0.95rem;
}

.option-btn:hover {
  border-color: #2c5282;
  background: #f8fafc;
}

.option-btn.correct {
  background: #dcfce7;
  border-color: #16a34a;
  color: #166534;
}

.option-btn.incorrect {
  background: #fee2e2;
  border-color: #ef4444;
  color: #991b1b;
}

.option-label {
  background: #2c5282;
  color: white;
  padding: 0.4rem;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  flex-shrink: 0;
}

.option-btn.correct .option-label {
  background: #16a34a;
}

.option-btn.incorrect .option-label {
  background: #ef4444;
}

.explanation-container {
  background: #f8fafc;
  border-radius: 12px;
  padding: 2rem;
  margin-top: 2rem;
  border-left: 4px solid #2c5282;
}

.explanation-container h3 {
  color: #2c5282;
  margin-bottom: 1rem;
  font-size: 1.2rem;
  font-weight: 600;
}

.explanation-image {
  text-align: center;
  margin: 1.5rem 0;
}

.explanation-image img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ── HTML content inside question / explanation ──────────────────── */
.question-html-content {
  color: #2d3748;
  overflow-x: hidden;
  word-break: break-word;
}

/* Images: never wider than their container */
.question-html-content img {
  max-width: 100% !important;
  height: auto !important;
  display: block;
  border-radius: 6px;
  margin: 0.5rem auto;
}

/* Tables: horizontal scroll so they never overflow the card */
.question-html-content table {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.question-html-content table td,
.question-html-content table th {
  padding: 0.4rem 0.6rem;
  border: 1px solid #cbd5e0;
  vertical-align: top;
}
.question-html-content table th { font-weight: 600; }

/* ── Light-mode: force dark text in case JSON injects white/light colours ── */
html[data-theme="light"] .question-html-content {
  color: #2d3748;
}
html[data-theme="light"] .question-html-content * {
  color: inherit !important;
  background-color: transparent !important;
  background: transparent !important;
}
html[data-theme="light"] .question-html-content img {
  border-color: transparent !important;
}

/* ── Dark-mode overrides ─────────────────────────────────────────── */
html:not([data-theme="light"]) .question-html-content {
  color: #d1d5db;
}
/* Strip any hardcoded white/black text + white backgrounds injected by JSON content */
html:not([data-theme="light"]) .question-html-content * {
  color: inherit !important;
  background-color: transparent !important;
  background: transparent !important;
  border-color: #374151 !important;
}
/* Keep images and code blocks readable */
html:not([data-theme="light"]) .question-html-content img {
  opacity: 0.9;
  border-color: transparent !important;
}
html:not([data-theme="light"]) .question-html-content table td,
html:not([data-theme="light"]) .question-html-content table th {
  border-color: #374151 !important;
}
/* Scrollbar inside tables — subtle dark-mode style */
html:not([data-theme="light"]) .question-html-content table::-webkit-scrollbar {
  height: 5px;
}
html:not([data-theme="light"]) .question-html-content table::-webkit-scrollbar-track {
  background: #1e2235;
}
html:not([data-theme="light"]) .question-html-content table::-webkit-scrollbar-thumb {
  background: #374151; border-radius: 3px;
}

.next-btn, .finish-btn {
  background: #16a34a;
  color: white;
  border: none;
  padding: 1rem 2rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.next-btn:hover, .finish-btn:hover {
  background: #15803d;
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(22, 163, 74, 0.3);
}

/* Loading and Error States */
.loading-container, .error-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  text-align: center;
}

.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.loading-spinner i {
  font-size: 3rem;
  color: #2c5282;
}

.error-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.error-content i {
  font-size: 4rem;
  color: #ef4444;
}

.error-content h3 {
  font-size: 1.5rem;
  color: #374151;
  margin: 0;
}

.error-content p {
  color: #6b7280;
  margin: 0;
  max-width: 400px;
}

.action-btn {
  background: linear-gradient(135deg, #2c5282, #1a365d);
  color: white;
  border: none;
  padding: 1rem 2rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(44, 82, 130, 0.3);
}

/* Responsive Design */
@media (max-width: 768px) {
  /* Reduce main container padding */
  .qbank-main-container, .selection-container, 
  .bookmarks-container, .questions-container {
    padding: 0.5rem; /* Reduced from 1rem */
  }

  /* Expand quiz container to full width */
  .quiz-container {
    padding: 0.25rem; /* Reduced from 0.5rem */
    max-width: 100%;  /* Full width instead of 99% */
  }

  /* Question container adjustments */
  .question-container {
    padding: 0.75rem; /* Reduced from 1rem */
    border-radius: 8px;
    max-width: 100%;  /* Remove max-width restriction */
    margin: 0 0 1rem; /* Remove auto margins */
  }

  /* Header padding reduction */
  header .header-content {
    padding-left: 2.5rem; /* Reduced from 3rem */
  }

  /* Progress indicator adjustment */
  .question-container .quiz-progress {
    top: 0.25rem; /* Reduced from 0.5rem */
    left: 0.25rem; /* Reduced from 0.5rem */
  }

  /* Question text padding optimization */
  .question-text {
    padding: 1.75rem 1.25rem 0 0; /* Reduced top/right padding */
    font-size: 1rem;
  }

  /* Explanation container padding */
  .explanation-container {
    padding: 1rem; /* Reduced from 1rem */
  }

  .back-button {
    left: 0.5rem;
    padding: 0.4rem;
    width: 40px;
    height: 40px;
  }

  .back-button i {
    font-size: 1rem;
  }

  .quiz-header {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
    padding: 0.75rem;
  }

  .quiz-actions {
    justify-content: center;
  }
 
  .question-container .bookmark-question-btn {
    top: 0.5rem;
    right: 0.5rem;
    width: 32px;
    height: 32px;
    padding: 0.3rem;
  }

  .question-container .bookmark-question-btn i {
    font-size: 0.9rem;
  }

  .option-btn {
    padding: 0.6rem;
    gap: 0.6rem;
    min-height: 44px;
    font-size: 0.9rem;
  }

  .option-label {
    width: 28px;
    height: 28px;
    font-size: 0.8rem;
    padding: 0.3rem;
  }

  .options-container {
    gap: 0.6rem;
}
}

/* Question Navigation Popup Styles */
.question-nav-popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.popup-content {
  position: relative;
  background: white;
  border-radius: 16px;
  padding: 2rem;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}

.popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid #f3f4f6;
}

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

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #6b7280;
  padding: 0.5rem;
  border-radius: 8px;
  transition: all 0.2s ease;
}

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

.question-nav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap: 0.75rem;
}

.question-nav-btn {
  width: 60px;
  height: 60px;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  font-weight: bold;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  color: #374151;
}

.question-nav-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-color: #3b82f6;
}

.question-nav-btn.current {
  background: #3b82f6;
  color: white;
  border-color: #3b82f6;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.question-nav-btn.answered {
  background: #10b981;
  color: white;
  border-color: #10b981;
}

.question-nav-btn.answered.current {
  background: #3b82f6;
  border-color: #3b82f6;
}

/* Enhanced Quiz Progress Styles */
.question-container .quiz-progress {
  background: rgba(255, 255, 255, 0.9);
  padding: 0.5rem 0.75rem;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.9rem;
  color: #1f2937;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(59, 130, 246, 0.2);
  transition: all 0.3s ease;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.question-container .quiz-progress:hover {
  background: rgba(255, 255, 255, 1);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-color: #3b82f6;
}

/* Tablet specific adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
  .quiz-container {
    max-width: 100%; /* Full width instead of 99% */
    padding: 0.5rem;
  }
  
  .question-container {
    max-width: 100%; /* Remove max-width restriction */
  }

  .question-text {
    font-size: 1.02rem;
    padding: 2.75rem 3.5rem 0 0;
  }

  .option-btn {
    padding: 0.65rem;
    gap: 0.65rem;
    font-size: 0.97rem;
  }
  /* Mobile View Adjustments */
@media (max-width: 768px) {
  /* Reduce main container padding */
  .qbank-main-container, .selection-container, 
  .bookmarks-container, .questions-container {
    padding: 0.5rem; /* Reduced from 1rem */
  }

  /* Expand quiz container to full width */
  .quiz-container {
    padding: 0.25rem; /* Reduced from 0.5rem */
    max-width: 100%;  /* Full width instead of 99% */
  }

  /* Question container adjustments */
  .question-container {
    padding: 0.75rem; /* Reduced from 1rem */
    border-radius: 8px;
    max-width: 100%;  /* Remove max-width restriction */
    margin: 0 0 1rem; /* Remove auto margins */
  }

  /* Header padding reduction */
  header .header-content {
    padding-left: 2.5rem; /* Reduced from 3rem */
  }

  /* Progress indicator adjustment */
  .question-container .quiz-progress {
    top: 0.25rem; /* Reduced from 0.5rem */
    left: 0.25rem; /* Reduced from 0.5rem */
  }

  /* Question text padding optimization */
  .question-text {
    padding: 1.75rem 1.25rem 0 0; /* Reduced top/right padding */
    font-size: 1rem;
  }

  /* Explanation container padding */
  .explanation-container {
    padding: 1rem; /* Reduced from 1rem */
  }
}

/* Tablet View Adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
  
}
}

/* ================================================================
   DARK MODE overrides for Quiz Styles
   ================================================================ */
html:not([data-theme="light"]) .quiz-header {
  background: #1a1d2e;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

html:not([data-theme="light"]) .bookmark-question-btn,
html:not([data-theme="light"]) .exit-btn {
  background: #1a1d2e;
  border-color: #3182ce;
  color: #63b3ed;
}
html:not([data-theme="light"]) .bookmark-question-btn:hover,
html:not([data-theme="light"]) .exit-btn:hover {
  background: #2c5282;
  color: #fff;
}

html:not([data-theme="light"]) .question-container {
  background: #1a1d2e;
  box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}

html:not([data-theme="light"]) .question-container .bookmark-question-btn {
  background: #252b3b;
  border-color: #d97706;
}
html:not([data-theme="light"]) .question-container .bookmark-question-btn:hover {
  background: #3a2f1a;
}

html:not([data-theme="light"]) .question-container .quiz-progress {
  background: rgba(26, 29, 46, 0.95);
  color: #e2e8f0;
  border-color: rgba(49, 130, 206, 0.35);
}

html:not([data-theme="light"]) .question-text { color: #d1d5db; }

html:not([data-theme="light"]) .option-btn {
  background: #1e2235;
  border-color: #2a3045;
  color: #e2e8f0;
}
html:not([data-theme="light"]) .option-btn:hover {
  border-color: #3182ce;
  background: #252b3b;
}
html:not([data-theme="light"]) .option-btn.correct {
  background: #14532d;
  border-color: #16a34a;
  color: #bbf7d0;
}
html:not([data-theme="light"]) .option-btn.incorrect {
  background: #450a0a;
  border-color: #ef4444;
  color: #fecaca;
}

html:not([data-theme="light"]) .explanation-container {
  background: #1e2235;
  border-left-color: #3182ce;
}

html:not([data-theme="light"]) .popup-content {
  background: #1a1d2e;
  box-shadow: 0 20px 50px rgba(0,0,0,0.6);
}
html:not([data-theme="light"]) .popup-header { border-bottom-color: #2a3045; }
html:not([data-theme="light"]) .popup-header h3 { color: #e2e8f0; }
html:not([data-theme="light"]) .close-btn { color: #8892a4; }
html:not([data-theme="light"]) .close-btn:hover { background: #252b3b; color: #e2e8f0; }

html:not([data-theme="light"]) .question-nav-btn {
  background: #1e2235;
  border-color: #2a3045;
  color: #e2e8f0;
}
html:not([data-theme="light"]) .question-nav-btn:hover {
  border-color: #3182ce;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

html:not([data-theme="light"]) .error-content h3 { color: #e2e8f0; }
html:not([data-theme="light"]) .error-content p { color: #8892a4; }
