@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600;700&display=swap');

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: 'Open Sans', Arial, sans-serif;
  background-color: #f4f6f9;
  color: #222;
  overflow: hidden;
  user-select: none;
}

/* Enable instantaneous taps and remove touch delay across all interactive elements */
button,
.nta-btn,
.q-btn,
.sub-tab-btn,
.option-item,
.btn-submit-exam {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

/* =========================================================
   TOP HEADER BANNER
========================================================= */
.nta-header {
  height: 52px;
  background: #173b6c;
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  border-bottom: 2px solid #0f2647;
}

.nta-exam-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.nta-header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.nta-timer-badge {
  background: #fff;
  color: #d9534f;
  font-size: 14px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 4px;
  border: 1px solid #c9302c;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* =========================================================
   SUBJECT NAVIGATION TABS
========================================================= */
.subject-nav-bar {
  height: 38px;
  background: #e9edf2;
  border-bottom: 1px solid #ccd4de;
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 4px;
}

.sub-tab-btn {
  height: 30px;
  padding: 0 16px;
  font-size: 12px;
  font-weight: 700;
  background: #dfe4ea;
  border: 1px solid #b8c4d1;
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  cursor: pointer;
  color: #333;
}

.sub-tab-btn.active {
  background: #173b6c;
  color: #fff;
  border-color: #173b6c;
}

/* =========================================================
   LAYOUT SPLIT (MAIN QUESTION AREA VS PALETTE)
========================================================= */
.nta-main-layout {
  display: flex;
  height: calc(100vh - 90px);
}

.nta-question-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-right: 1px solid #ccd4de;
}

.question-meta-bar {
  height: 36px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 600;
}

.question-marking-scheme {
  font-size: 12px;
  color: #475569;
}

.question-marking-scheme span {
  font-weight: 700;
  color: #16a34a;
}

.question-marking-scheme span.negative {
  color: #dc2626;
}

.question-content-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

.question-text-area {
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 20px;
  color: #111;
}

.question-figure {
  max-width: 100%;
  margin: 12px 0;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
}

/* Options */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.option-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s ease;
}

.option-item:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.option-item input[type="radio"] {
  margin-top: 4px;
  cursor: pointer;
}

/* =========================================================
   BOTTOM ACTIONS BAR
========================================================= */
.nta-bottom-actions {
  height: 54px;
  background: #f8fafc;
  border-top: 1px solid #ccd4de;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
}

.action-btn-group {
  display: flex;
  gap: 8px;
}

.nta-btn {
  height: 34px;
  padding: 0 14px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
}

.btn-save-next {
  background: #22c55e;
  color: #fff;
  border-color: #16a34a;
}
.btn-save-next:hover { background: #16a34a; }

.btn-mark-review {
  background: #f59e0b;
  color: #fff;
  border-color: #d97706;
}
.btn-mark-review:hover { background: #d97706; }

.btn-clear {
  background: #fff;
  color: #334155;
  border-color: #cbd5e1;
}
.btn-clear:hover { background: #f1f5f9; }

/* =========================================================
   RIGHT SIDE: PALETTE & CANDIDATE DETAILS
========================================================= */
.nta-palette-container {
  width: 320px;
  background: #f1f4f8;
  display: flex;
  flex-direction: column;
}

.candidate-profile-box {
  background: #fff;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #dcdfe4;
}

.candidate-photo {
  width: 44px;
  height: 44px;
  background: #cbd5e1;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #475569;
  font-size: 16px;
}

.candidate-info-text {
  font-size: 12px;
  line-height: 1.4;
}

.candidate-info-text strong {
  font-size: 13px;
  color: #0f172a;
}

/* NTA Symbol / Legend Box */
.nta-legend-grid {
  padding: 10px 12px;
  background: #fff;
  border-bottom: 1px solid #dcdfe4;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  font-size: 11px;
  color: #333;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-badge {
  width: 22px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
}

/* NTA Traditional Shapes & Hex Colors */
.badge-not-visited {
  background: #e2e8f0;
  color: #334155;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
}

.badge-not-answered {
  background: #e11d48;
  clip-path: polygon(0 0, 100% 0, 100% 75%, 50% 100%, 0 75%);
}

.badge-answered {
  background: #16a34a;
  clip-path: polygon(50% 0%, 100% 25%, 100% 100%, 0 100%, 0 25%);
}

.badge-marked {
  background: #7c3aed;
  border-radius: 50%;
}

.badge-ans-marked {
  background: #7c3aed;
  border-radius: 50%;
  position: relative;
}
.badge-ans-marked::after {
  content: "";
  width: 6px;
  height: 6px;
  background: #22c55e;
  border-radius: 50%;
  position: absolute;
  bottom: 0;
  right: 0;
}

/* Palette Question Buttons */
.palette-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.palette-heading {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 8px;
  color: #334155;
}

.palette-buttons-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.q-btn {
  width: 100%;
  height: 34px;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  outline: none;
  transition: transform 0.1s;
}
.q-btn:hover { transform: scale(1.05); }

.q-btn.q-not-visited {
  background: #e2e8f0;
  color: #334155;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
}

.q-btn.q-not-answered {
  background: #e11d48;
  color: #fff;
  clip-path: polygon(0 0, 100% 0, 100% 75%, 50% 100%, 0 75%);
}

.q-btn.q-answered {
  background: #16a34a;
  color: #fff;
  clip-path: polygon(50% 0%, 100% 25%, 100% 100%, 0 100%, 0 25%);
}

.q-btn.q-marked {
  background: #7c3aed;
  color: #fff;
  border-radius: 50%;
}

.q-btn.q-answered-marked {
  background: #7c3aed;
  color: #fff;
  border-radius: 50%;
  position: relative;
}
.q-btn.q-answered-marked::after {
  content: "✔";
  font-size: 8px;
  color: #fff;
  position: absolute;
  bottom: 0px;
  right: 2px;
}

/* Palette Submit Button Area */
.palette-submit-bar {
  padding: 10px 14px;
  background: #fff;
  border-top: 1px solid #dcdfe4;
}

.btn-submit-exam {
  width: 100%;
  height: 38px;
  background: #0284c7;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
.btn-submit-exam:hover { background: #0369a1; }

/* =========================================================
   MOBILE-ONLY REDESIGN (≤768px) — laptop CSS above is untouched
========================================================= */
@media (max-width: 768px) {

  html, body {
    background: #eef2f7;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* ---- Top bar: keep it, just tighten it up ---- */
  .nta-header {
    height: 46px;
    padding: 0 12px;
  }
  .nta-exam-title { font-size: 12px; }
  .nta-timer-badge { font-size: 12px; padding: 3px 8px; }

  /* ---- Subject tabs -> bordered icon cards ---- */
  .subject-nav-bar {
    height: auto;
    background: transparent;
    border-bottom: none;
    padding: 10px 10px 0;
    gap: 8px;
  }

  .sub-tab-btn {
    flex: 1;
    height: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: #fff;
    color: #173b6c;
    border: 1px solid #dbe2ea;
    border-radius: 10px;
    font-size: 11px;
    touch-action: manipulation;
  }
  .sub-tab-btn::before {
    font-size: 18px;
  }

  .sub-tab-btn.active {
    background: #dbeafe;
    color: #1d4ed8;
    border-color: #93c5fd;
  }

  /* ---- Stack palette above question, both as cards ---- */
  .nta-main-layout {
    flex-direction: column;
    height: auto;
    gap: 10px;
    padding: 10px;
  }

  .nta-palette-container {
    order: -1;
    width: 100%;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    overflow: hidden;
  }

  .candidate-profile-box { border-bottom: 1px solid #eef1f5; }

  /* Legend counts aren't in the reference look — hide on mobile */
  .nta-legend-grid { display: none; }

  .palette-scroll-area {
    max-height: 210px;
  }

  .palette-buttons-grid {
    grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
    gap: 8px;
  }

  /* Palette buttons*/
  .q-btn {
    height: 42px;
    font-size: 12px;
    touch-action: manipulation;
    pointer-events: auto;
  }

  /* ---- Question card ---- */
  .nta-question-container {
    border-right: none;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    overflow: hidden;
  }

  .question-meta-bar { font-size: 12px; }
  .question-content-scroll { padding: 16px; }
  .question-text-area { font-size: 14px; }

  .option-item {
    padding: 12px 14px;
    font-size: 14px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  .option-item input[type="radio"] {
    width: 18px;
    height: 18px;
  }

  /* ---- Bottom action bar -> 4 equal icon buttons ---- */
  .nta-bottom-actions {
    height: auto;
    padding: 10px;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  }

  .action-btn-group {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .nta-bottom-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }
  .action-btn-group { display: contents; } /* let all 4 buttons share one grid */

  .nta-btn {
    height: 64px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 10px;
    border-radius: 10px;
    padding: 0 4px;
    text-align: center;
    touch-action: manipulation;
    pointer-events: auto;
  }
  .nta-btn::before { font-size: 16px; }

  #markBtn {
    background: #7c3aed;
    border-color: #6d28d9;
    color: #fff;
  }
  #clearBtn {
    background: #f6f5f5;
    border-color: #e6e3e3;
    color: #352e2e;
  }
  #prevBtn {
    background: #e2e8f0;
    border-color: #cbd5e1;
    color: #334155;
  }

  .palette-submit-bar { border-top: 1px solid #eef1f5; }
}