
/* Global box sizing for better layout control */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Quiz app wrapper - now responsive and scrollable if needed */
.quiz-app-wrapper {
  display: flex;
  justify-content: center;
  align-items: flex-start; /* Modal-friendly positioning */
  min-height: calc(100vh - 70px); /* Accounts for navbar (60px) + footer (50px) */
  background: linear-gradient(to top, #cdffd8, #94b9ff);
  width: 100%;
  padding: 15px 0;
  overflow-y: auto; /* Allows scroll if content is tall */
}

/* Main app container - clean, compact, and responsive */
#app {
  width: 90% !important;
  max-width: 1024px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  padding: 25px;
  position: relative;
  margin: 20px auto 10px auto; /* Top margin adjusted */
}

/* Responsive typography and padding for very small screens */
@media (max-width: 360px) {
  #app {
    padding: 15px;
    font-size: 14px;
  }
}

.speak-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1em;
  margin-right: 8px;
  color: #007bff;
}

.speak-btn:hover {
  color: #0056b3;
}


/* Responsive title */
h1 {
  text-align: center;
  margin: 5px 0 10px; /* Reduced margins */
  font-size: clamp(18px, 4vw, 22px);
  padding: 5px; /* Reduced padding */
}

/* Compact tracker and timer */
.tracker, .timer {
  position: absolute;
  top: 10px;
  font-size: clamp(14px, 3vw, 18px);
  font-weight: bold;
  color: #555;
}

.tracker {
  left: 15px;
}

.timer {
  right: 15px;
}

/* Question with reduced spacing */
.question {
  font-size: clamp(16px, 4vw, 20px);
  margin: 20px 0 20px; /* Reduced top margin */
  text-align: left;
  padding: 0 10px;
  line-height: 1.5; /* Adjust this value as needed */
}

/* Options container - now flex row with wrapping */
.options {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap; /* Allow items to wrap */
  gap: 12px;        /* Space between items */
  justify-content: flex-start;
  align-items: flex-start;
}

/* Each option item - auto width and responsive */
.options li {
  background: #f9f9f9;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid #ddd;
  cursor: pointer;
  transition: background-color 0.3s ease, border-color 0.3s ease;
  font-size: clamp(15px, 2.5vw, 16px);
  text-align: left;
  white-space: normal;
  word-break: break-word;

  /* Flex item behavior */
  flex: 0 1 auto; /* Don't grow, allow shrink, auto width */
  max-width: 100%; /* Avoid overflowing container */
}

/* Option hover */
.options li:hover {
  background-color: #eef4ff;
  border-color: #004aad;
}

/* Submit button - left aligned, auto width */
.quiz-btn {
  display: inline-block;
  padding: 12px 20px;
  font-size: clamp(16px, 2.5vw, 18px);
  background: #004aad;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  margin-top: 20px;
  transition: background 0.3s ease;
  align-self: flex-start;
  white-space: nowrap;
}
.quiz-btn:hover {
  background: #00378f;
}


/* Extra small devices specific adjustments */
@media (max-width: 480px) {
  .quiz-app-wrapper {
    padding: 10px 0;
  }
  
  #app {
    width: 90%;
    padding: 15px;
  }
  
  .question {
    margin: 25px 0 12px; /* Even more compact on small devices */
  }
  
  .options li {
    padding: 7px;
    min-height: 15px;
    margin-bottom: 6px;
  }
  
  .quiz-btn {
    padding: 8px;
    margin: 12px 0 5px;
  }
  
  /* Modal adjustments for very small screens */
  .modal {
    width: 90%;
    top: 15%;
    padding: 12px;
    max-height: 55vh;
  }
  
  .modal h2 {
    margin: 5px 0;
    font-size: 20px;
  }
  .modal p {
    font-size: 16px;
  }
  h1 {
    text-align: center;
    padding: 8px; /* Reduced padding */
  }
  .question {
    margin: 10px;
    text-align: center;
  }
}


/* ===== MODAL STYLES ===== */
.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  border-radius: 10px;
  z-index: 1000;
  width: 90%;
  max-width: 700px;
  display: none;
  flex-direction: column;
  padding: 25px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  max-height: 90vh; /* Prevent from overflowing screen */
  overflow-y: auto; /* Allows scrolling if content is too tall */
}

#modal-title {
  font-size: 1.6rem;
  font-weight: bold;
  margin-bottom: 20px;
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}
#modal-title .icon {
  margin-left: 8px;
  font-size: 1.4rem;
}

/* Title Colors */
.title-correct {
  color: #2e7d32; /* Green */
}

.title-incorrect {
  color: #d32f2f; /* Red */
}

.title-complete {
  color: #004aad; /* Blue */
}

#modal-text {
  display: flex;
  flex-direction: column;
  gap: 15px;
  font-size: 1rem;
  line-height: 1.5;
  color: #333;
}

/* Answer sections */
.answer-section {
  display: block;
  padding: 10px;
  border-radius: 5px;
}

.your-answer {
  background-color: #ffebee; /* Light red */
  border-left: 4px solid #d32f2f;
}

.correct-answer {
  background-color: #e8f5e9; /* Light green */
  border-left: 4px solid #2e7d32;
}

.explanation {
  background-color: #e3f2fd; /* Light blue */
  border-left: 4px solid #1565c0;
}

/* Section labels */
.answer-section::before {
  display: block;
  font-weight: bold;
  margin-bottom: 5px;
}

.your-answer::before {
  content: "Your answer:";
  color: #d32f2f;
}

.correct-answer::before {
  content: "Correct answer:";
  color: #2e7d32;
}

.explanation::before {
  content: "Explanation:";
  color: #1565c0;
}

/* Next button */
#modal-close {
  display: block;
  width: 100%;
  padding: 12px;
  background: #004aad;
  color: white;
  border: none;
  border-radius: 5px;
  font-size: 1rem;
  cursor: pointer;
  margin-top: 20px;
  transition: background 0.3s;
}

#modal-close:hover {
  background: #003b8e;
}

/* Overlay */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
}

/* ===== RESPONSIVE ADJUSTMENTS ===== */
@media (max-width: 600px) {
  .modal {
    width: 95%;
    padding: 20px;
  }
  
  #modal-title {
    font-size: 1.2rem;
    margin-bottom: 15px;
  }
  
  .answer-section {
    padding: 8px;
  }
  
  #modal-close {
    padding: 10px;
  }
}

@media (max-width: 480px) {
  .modal {
    width: 90%;
    padding: 15px;
  }
  
  #modal-title {
    font-size: 1.1rem;
  }
  
  #modal-text {
    font-size: 0.9rem;
    gap: 10px;
  }
  
  .answer-section::before {
    font-size: 0.9rem;
  }
}
.final-summary {
  text-align: center;
  font-size: 1.1rem;
  line-height: 1.6;
  margin-top: 10px;
  padding: 15px;
  background-color: #f1f8e9; /* soft green background */
  border-left: 4px solid #689f38; /* professional green accent */
  border-radius: 8px;
  color: #2e7d32;
}

.final-summary div {
  margin: 5px 0;
}

.options li:hover {
  background: #f1f1f1;
  border-color: #ccc;
}

.options li.selected {
  background: #dbeeff;
  border-color: #3399ff;
}

.options li.correct {
  background: #d4edda;
  border-color: #28a745;
  color: #155724;
}

.options li.wrong {
  background: #f8d7da;
  border-color: #dc3545;
  color: #721c24;
}

.quiz-btn:disabled {
  background: #c0c0c0;
  cursor: not-allowed;
}

#loader {
  text-align: center;
  font-size: clamp(16px, 4vw, 20px);
}

.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.2);
  z-index: 15;
  display: none;
}

.disabled {
  pointer-events: none;
  opacity: 1;
}

/* Social media buttons styling */
.social-buttons {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
}

.social-buttons a {
  display: inline-block;
  /*padding: 10px 20px;*/
  padding: 7.5px 7.5px;
  border-radius: 5px;
  color: white;
  text-decoration: none;
  font-size: 16px;
  text-align: center;
}

.social-buttons .home-btn {
  background-color: #3b5998;
}

.social-buttons .dashboard-btn {
  background-color: #1da1f2;
}

.social-buttons .back-btn {
  background-color: #25d366;
}


/* Sorting question styles */
.sorting-section {
  margin-bottom: 20px;
  padding: 15px;
  border-radius: 8px;
  background: #f8f9fa;
}

.sorting-section h4 {
  margin-top: 0;
  margin-bottom: 10px;
  color: #495057;
}

.tangled {
  border: 2px dashed #adb5bd;
}

.sorted {
  border: 2px solid #dee2e6;
}

.draggable-item {
  display: inline-block;
  padding: 8px 12px;
  margin: 5px;
  background: #e9ecef;
  border-radius: 4px;
  cursor: move;
  user-select: none;
  border: 1px solid #ced4da;
}

.draggable-item.dragging {
  opacity: 0.5;
  background: #dee2e6;
}

.drop-slot {
  display: inline-block;
  min-width: 100px;
  min-height: 40px;
  margin: 5px;
  padding: 8px 12px;
  background: white;
  border-radius: 4px;
  border: 2px dashed #adb5bd;
}

.drop-slot.drag-over {
  background: #e9ecef;
  border-color: #495057;
}

.drop-slot .dropped-item {
  background: #d1e7dd;
  border-color: #a3cfbb;
  cursor: default;
}

/* Input question styles */
.input-container {
  width: 100%;
  margin-top: 15px;
}

.answer-input {
  width: 100%;
  padding: 10px 15px;
  border: 2px solid #dee2e6;
  border-radius: 8px;
  font-size: 16px;
  transition: border-color 0.3s;
}

.answer-input:focus {
  outline: none;
  border-color: #86b7fe;
  box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.1);
}

/* Sorting improvements */
.draggable-item.used {
  opacity: 0.5;
  background: #e9ecef;
  text-decoration: line-through;
}

.draggable-item.dropped {
  background: #d1e7dd;
  border-color: #a3cfbb;
  cursor: default;
}

/* Error state for submit button */
button:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.emoji {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  margin: 15px;
  width: min(30vw, 10rem);       /* Responsive width: 12% of screen, max 3rem */
  aspect-ratio: 1 / 1;          /* Keeps it square */

  font-size: min(15vw, 5rem);  /* Emoji scales with screen size */
  border: 2px solid #ccc;
  border-radius: 0.4em;
  background-color: #f9f9f9;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}
