/* ======================= MODAL STYLES ======================= */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
  background-color: #fff;
  margin: 5% auto;
  padding: 0;
  border-radius: 10px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  position: relative;
}

.modal .close {
  position: absolute;
  top: 15px;
  right: 20px;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  color: #aaa;
  z-index: 10;
}

.modal .close:hover {
  color: #000;
}

/* ======================= LOGIN MODAL SPECIFIC STYLES ======================= */
.auth-container {
  padding: 30px;
}

.auth-tabs {
  display: flex;
  margin-bottom: 20px;
  border-bottom: 1px solid #ddd;
}

.tab-btn {
  flex: 1;
  padding: 12px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  color: #666;
  transition: all 0.3s;
}

.tab-btn.active {
  color: #007bff;
  border-bottom: 3px solid #007bff;
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
}

.auth-form h3 {
  text-align: center;
  margin-bottom: 20px;
  color: #333;
}

.form-group {
  margin-bottom: 15px;
}

.form-group input {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-size: 16px;
  box-sizing: border-box;
}

.form-group label.terms-inline-label {
  display: block;
  width: 100%;
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.5;
  color: #334155;
  cursor: pointer;
}

.form-group label.terms-inline-label span {
  min-width: 0;
}

.form-group label.terms-inline-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  padding: 0;
  margin: 0 2px;
  vertical-align: middle;
  position: relative;
  top: -1px;
}

.form-group input:focus {
  border-color: #007bff;
  outline: none;
}

.auth-btn {
  width: 100%;
  padding: 12px;
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 5px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.3s;
}

.auth-btn:hover {
  background-color: #0056b3;
}

.auth-links {
  text-align: center;
  margin-top: 15px;
}

.forgot-password {
  color: #007bff;
  text-decoration: none;
}

.forgot-password:hover {
  text-decoration: underline;
}

/* ======================= EXAM HELP MODAL STYLES ======================= */
.help-container {
  padding: 20px;
}

.help-tabs {
  display: flex;
  margin-bottom: 20px;
  border-bottom: 1px solid #ddd;
}

.help-content {
  display: none;
}

.help-content.active {
  display: block;
}

.instruction-content h4 {
  color: #007bff;
  margin-bottom: 10px;
  border-bottom: 2px solid #007bff;
  padding-bottom: 5px;
  font-size: 1.1em;
}

.instruction-content ul {
  padding-left: 20px;
  margin-bottom: 15px;
}

.instruction-content li {
  margin-bottom: 8px;
  line-height: 1.5;
}

.instruction-content ul ul {
  margin-top: 5px;
  margin-bottom: 5px;
}

/* ======================= COMING SOON MESSAGE ======================= */
.coming-soon-message {
  text-align: center;
  margin-top: 20px;
  padding: 15px;
  background-color: #e7f3ff;
  border-radius: 8px;
  border-left: 4px solid #007bff;
  font-size: 14px;
  line-height: 1.5;
  color: #333;
}

.coming-soon-message strong {
  color: #007bff;
  display: block;
  margin-bottom: 5px;
  font-size: 15px;
}

/* ======================= LOGIN MODAL FIXES ======================= */
#loginModal.modal {
  display: none;
  position: fixed;
  z-index: 1001;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  overflow: auto;
  justify-content: center;
  align-items: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  overscroll-behavior: contain;
}

#loginModal.modal.login-modal--open {
  display: flex;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

#loginModal .modal-content {
  background-color: #fff;
  margin: 0 auto;
  padding: 0;
  border-radius: 10px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  position: relative;
  top: 0;
  transform: none;
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* ======================= EXAM HELP MODAL FIXES ======================= */
#examHelpModal.modal {
  display: none;
  position: fixed;
  z-index: 1002; /* Higher than exam popup */
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  overflow: auto;
}

#examHelpModal .modal-content {
  background-color: #fff;
  margin: 5% auto;
  padding: 0;
  border-radius: 10px;
  width: 90%;
  max-width: 600px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  position: relative;
}

/* ======================= EXIT EXAM MODAL ======================= */
#exitExamModal.modal {
  display: none;
  position: fixed;
  z-index: 1003;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.65);
  justify-content: center;
  align-items: center;
}

#exitExamModal.modal.active {
  display: flex;
}

#exitExamModal .modal-content {
  width: 90%;
  max-width: 460px;
  margin: 0 auto;
}

.exit-exam-body {
  padding: 28px 24px 24px;
}

.exit-exam-body h3 {
  margin: 0 0 12px;
  color: #111827;
  font-size: 22px;
}

.exit-exam-body p {
  margin: 0 0 10px;
  color: #374151;
  line-height: 1.5;
}

.exit-exam-body .exit-warning {
  color: #b91c1c;
  font-weight: 700;
}

.exit-exam-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.exit-exam-actions .auth-btn {
  width: 50%;
}

/* ======================= EXAM SUBMIT CONFIRMATION ======================= */
#examSubmitConfirmation.modal {
  display: none;
  position: fixed;
  z-index: 1004;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  justify-content: center;
  align-items: center;
  padding: 16px;
}

#examSubmitConfirmation.modal.active {
  display: flex;
}

#examSubmitConfirmation .exam-submit-confirmation__content {
  width: 90%;
  max-width: 460px;
  margin: 0 auto;
}

.exam-submit-confirmation__body {
  padding: 28px 24px 24px;
}

.exam-submit-confirmation__body h2 {
  margin: 0 0 12px;
  color: #111827;
  font-size: 22px;
}

.exam-submit-confirmation__body p {
  margin: 0;
  color: #374151;
  line-height: 1.5;
}

.exam-submit-confirmation__actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.exam-submit-confirmation__actions .auth-btn {
  width: 50%;
}

/* Help button in exam popup */
.help-btn {
  position: absolute;
  top: 10px;
  right: 50px;
  width: 24px;
  height: 24px;
  background: #000000;
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  z-index: 10;
}

.help-btn:hover {
  background: #0056b3;
}

/* Ensure exam popup has lower z-index than help modal */
.exam-popup {
  z-index: 1001; /* Lower than exam help modal (1002) */
}

/* Keep the practice modal below the filter popup when both are open */
.practice-modal {
  z-index: 1000;
}

/* The practice filter popup must sit above the full-screen practice modal */
#subtopicFilterPopup,
.exam-popup.filter-modal {
  position: fixed;
  z-index: 2000;
}

/* Ensure close button in exam popup has consistent styling */
#examCloseBtn.close-btn {
  position: absolute;
  top: 10px;
  right: 20px;
  width: 24px;
  height: 24px;
  background: #000000;
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  z-index: 10;
  line-height: 1;
  padding: 0;
  text-decoration: none;
}

#examCloseBtn.close-btn:hover {
  background: #0056b3;
}

/* Social Login Styles */
.social-login {
  margin-top: 20px;
  text-align: center;
}

.divider {
  display: flex;
  align-items: center;
  margin: 20px 0;
  color: #666;
  font-size: 14px;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid #ddd;
}

.divider::before {
  margin-right: 10px;
}

.divider::after {
  margin-left: 10px;
}

.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 12px;
  background: white;
  color: #333;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
}

.google-btn:hover {
  background: #f8f9fa;
  border-color: #ccc;
}

.google-btn img {
  width: 18px;
  height: 18px;
  margin-right: 10px;
}

/* User Section Styles */
.user-section {
  text-align: center;
}

.logout-btn {
  transition: background 0.3s;
}

.logout-btn:hover {
  background: #c82333 !important;
}

.coming-soon-message {
  display: none; /* Hide the coming soon message since we're implementing now */
}

/* =====================================================================
   REFRESH / LEAVE WARNING MODAL  —  5-second countdown abandon warning
   ===================================================================== */
#refreshWarningModal.modal {
  display: none;
  position: fixed;
  z-index: 10020;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  justify-content: center;
  align-items: center;
  padding: 16px;
}
#refreshWarningModal.modal.active { display: flex; }

.refresh-warning-content {
  width: 90%;
  max-width: 420px;
  border-radius: 16px;
  overflow: hidden;
  animation: refreshWarnIn .22s cubic-bezier(.34,1.56,.64,1);
}
@keyframes refreshWarnIn {
  from { opacity: 0; transform: scale(.9) translateY(-16px); }
  to   { opacity: 1; transform: scale(1)  translateY(0);     }
}
.refresh-warning-body {
  padding: 32px 28px 26px;
  text-align: center;
}
.refresh-warning-icon {
  font-size: 40px;
  line-height: 1;
  margin-bottom: 12px;
}
.refresh-warning-body h3 {
  margin: 0 0 10px;
  color: #111827;
  font-size: 20px;
  font-weight: 700;
}
.refresh-warning-body > p {
  margin: 0 0 20px;
  color: #374151;
  font-size: 14px;
  line-height: 1.55;
}

/* ── Countdown ring ── */
.refresh-countdown-ring {
  position: relative;
  width: 80px;
  height: 80px;
  margin: 0 auto 14px;
}
.countdown-svg {
  width: 80px;
  height: 80px;
  transform: rotate(-90deg);        /* start arc at top */
}
.countdown-track {
  fill: none;
  stroke: #e5e7eb;
  stroke-width: 5;
}
.countdown-progress {
  fill: none;
  stroke: #dc3545;
  stroke-width: 5;
  stroke-linecap: round;
  /* circumference of r=26 circle = 2π×26 ≈ 163.4 */
  stroke-dasharray: 163.4;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear, stroke .4s;
}
/* turns green when user stays */
.countdown-progress.safe { stroke: #22c55e; }

.countdown-number {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 800;
  color: #dc3545;
  transition: color .4s;
}
.countdown-number.safe { color: #22c55e; }

.refresh-warning-sub {
  color: #6b7280;
  font-size: 13px;
  margin: 0 0 20px;
}

/* ── Buttons ── */
.refresh-warning-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#refreshWarnStayBtn {
  background: #22c55e;
  font-size: 15px;
  font-weight: 700;
}
#refreshWarnStayBtn:hover { background: #16a34a; }

.refresh-warn-leave {
  background: #fff !important;
  color: #dc3545 !important;
  border: 1.5px solid #dc3545 !important;
  font-size: 14px !important;
}
.refresh-warn-leave:hover { background: #fff5f5 !important; }
.refresh-warn-leave:disabled {
  opacity: .45 !important;
  cursor: not-allowed !important;
}

@media (min-width: 400px) {
  .refresh-warning-actions { flex-direction: row; }
  #refreshWarnStayBtn,
  .refresh-warn-leave { width: 50%; }
}
