/* Base styles */
body {
  font-family: 'Segoe UI', sans-serif;
  background-color: var(--bg);
  margin: 80px 20px 40px;
  color: var(--text);
}

:root {
  --bg: #f2f4f8;
  --text: #333;
  --card: #fff;
  --highlight: #18398A;
}

body.dark-mode {
  --bg: #121212;
  --text: #e0e0e0;
  --card: #1e1e1e;
  --highlight: #90caf9;
}

h1 {
  color: var(--highlight);
  text-align: center;
  margin-bottom: 40px;
}

form {
  background: var(--card);
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  margin-bottom: 30px;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
  overflow: visible;
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: bold;
  color: var(--text);
}

input[type="number"] {
  width: 80px;
  padding: 5px;
  margin-top: 5px;
}

button {
  background-color: #18398A;
  color: white;
  padding: 10px 18px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  margin-top: 10px;
}

button:hover {
  background-color: #2c4da5;
}

.question-block {
  background: var(--card);
  padding: 20px;
  border-radius: 10px;
  margin: 20px 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.situation-container {
  background-color: #f1f1f1;
  padding: 18px 24px;
  border-radius: 12px;
  margin-bottom: 30px;
  scroll-margin-top: 120px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

body.dark-mode .situation-container {
  background-color: #2c2c2c;
}

.situation-container h3 {
  background-color: var(--card);
  display: inline-block;
  padding: 4px 10px;
  border: 2px solid #444;
  border-radius: 6px;
  font-size: 1.1rem;
  margin-bottom: 12px;
  color: var(--text);
}

.choice-box {
  display: block;
  padding: 12px;
  margin: 8px 0;
  border-radius: 8px;
  border: 2px solid #ccc;
  cursor: pointer;
  transition: background 0.3s, border-color 0.3s;
  background-color: #f9f9f9;
  color: var(--text);
}

body.dark-mode .choice-box {
  background-color: #2a2a2a;
  border-color: #555;
}

.choice-box:hover {
  background-color: #f0f0f0;
  border-color: #18398A;
}

.choice-box.selected {
  background-color: #dcefff;
  border-color: #18398A;
}

.correct {
  background-color: #c8f7c5 !important;
  border-color: #27ae60 !important;
}

.incorrect {
  background-color: #fdd !important;
  border-color: #e74c3c !important;
}

.correct-answer {
  font-style: italic;
  margin-top: 10px;
  color: #555;
}

/* Main layout */
#exam-layout {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: flex-start;
  gap: 30px;
  max-width: 1400px;
  margin: auto;
  padding-bottom: 200px;
}

#exam-form {
  flex: 3;
  padding-right: 10px;
}

#sidebar-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 260px;
  width: 240px;
  background: var(--card);
  padding: 10px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Toggle button */
#toggle-sidebar {
  display: block;
  text-align: center;
  width: 100%;
  font-size: 0.9rem;
  background-color: #eee;
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 6px;
  cursor: pointer;
  font-weight: bold;
  color: #333;
}

/* Sidebar collapse behavior */
#sidebar-controls.collapsed #sidebar-content {
  display: none;
}

#sidebar-controls #toggle-sidebar {
  background: #ccc;
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: bold;
  margin-bottom: 10px;
}

/* Tracker */
#situation-tracker-bar {
  background: var(--card);
  padding: 12px;
  border-radius: 12px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-height: 180px;
  overflow-y: auto;
}

.tracker-dot {
  padding: 4px 10px;
  border-radius: 10px;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.3s, background-color 0.3s, border-color 0.3s;
  color: white;
}

.tracker-dot:hover {
  transform: scale(1.1);
}

.tracker-dot.incomplete {
  background-color: #e74c3c;
  border: 2px solid #e74c3c;
}

.tracker-dot.complete {
  background-color: #4caf50;
  border: 2px solid #4caf50;
}

.tracker-dot.partial {
  background-color: #3498db;
  border: 2px solid #3498db;
}

.tracker-dot.pulsing {
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(229, 57, 53, 0.7);
  }
  70% {
    transform: scale(1.08);
    box-shadow: 0 0 0 10px rgba(229, 57, 53, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(229, 57, 53, 0);
  }
}

/* Submit & score */
#fixed-submit {
  background: var(--card);
  padding: 10px 15px;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  text-align: center;
  width: 100%;
}

#floating-score {
  font-size: 1.2rem;
  font-weight: bold;
  margin-bottom: 8px;
  color: var(--highlight);
}

#submit-btn {
  background-color: #18398A;
  color: white;
  font-weight: bold;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  width: 100%;
}

#submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Scroll margin for anchor offset */
#exam-form > div {
  scroll-margin-top: 120px;
}

/* Desktop: floating sidebar bottom-right */
@media (min-width: 769px) {
  #sidebar-controls {
    position: fixed;
    bottom: 20px;
    right: 20px;
    top: auto;
  }
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  #exam-layout {
    flex-direction: column;
    padding: 0 10px 200px;
  }

  #sidebar-controls {
    position: fixed;
    bottom: 10px;
    top: auto;
    left: 50%;
    transform: translateX(-50%);
    max-width: 90vw;
    width: 90vw;
    background: var(--card);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 10px;
    border-radius: 12px;
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }

  #situation-tracker-bar {
    max-height: 140px;
    overflow-y: auto;
    padding: 8px;
    justify-content: center;
  }

  .tracker-dot {
    font-size: 0.8rem;
    padding: 3px 6px;
  }

  #submit-btn {
    font-size: 0.9rem;
    padding: 6px 10px;
  }
}

/* Smooth scroll when tracker dot is clicked */
html {
  scroll-behavior: smooth;
}

.highlight-answer {
  color: red;
  background-color: yellow;
  display: inline;
  padding: 0 2px; /* left/right padding */
  border-radius: 3px; /* optional, softer edges */
}

.answer-correct {
  background-color: #d1fad1;
  font-weight: bold;
}

#toggleTrackerBtn {
  background-color: #18398A;
  color: white;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: bold;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  width: 100%;
  margin-bottom: 8px;
}

.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 20px;
  margin-top: 8px;
}

.choice-box {
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  transition: background-color 0.2s ease-in-out;
  background-color: #f9f9f9;
}

.choice-box:hover {
  background-color: #e0f3ff;
}

.choice-box.selected {
  background-color: #c7f0d9;
  border: 2px solid #4CAF50;
}

.choice-box.correct {
  background-color: #d4edda !important;
  border-color: #28a745;
}

.choice-box.incorrect {
  background-color: #f8d7da !important;
  border-color: #dc3545;
}

/* Tag control buttons */
.tag-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 4px;
}

.tag-btn {
  padding: 6px 12px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid #ccc;
  background-color: #f0f0f0;
  color: #000; /* visible text color */
  cursor: pointer;
}

.tag-btn:hover {
  background-color: #e0e0e0;
}

