﻿/* Examaya — exam room */

/* ── Outer shell ─────────────────────────────────────── */
.examaya-exam-room {
  position: fixed !important;
  inset: 0 !important;
  background: #f0f2f5;
  z-index: 99999 !important;
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #1d2327;
}

/* ── Header ──────────────────────────────────────────── */
.examaya-exam-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  height: 56px;
  flex-shrink: 0;
  border-bottom: 1px solid #dcdfe3;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.examaya-exam-title {
  font-weight: 700;
  font-size: 15px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.examaya-exam-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: .04em;
  padding: 5px 14px;
  background: #f6f7f7;
  border-radius: 6px;
  border: 1px solid #dcdfe3;
  min-width: 74px;
  text-align: center;
}
.examaya-exam-timer.warn {
  background: #fdecee;
  color: #c0392b;
  border-color: #f5c6cb;
  animation: nano-timer-pulse 1s ease-in-out infinite;
}
@keyframes nano-timer-pulse {
  0%,100% { opacity: 1; }
  50%      { opacity: .6; }
}

/* ── Body: main + right sidebar ─────────────────────── */
.examaya-exam-body {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 280px;
  min-height: 0;
  overflow: hidden;
}

/* ── Question main area ──────────────────────────────── */
.examaya-exam-main {
  overflow-y: auto;
  background: #f0f2f5;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 36px 32px;
}
.examaya-exam-main-inner {
  background: #fff;
  border-radius: 12px;
  padding: 36px 40px 28px;
  box-shadow: 0 2px 10px rgba(0,0,0,.08);
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
}

/* Question number badge */
#examaya-question .q-number {
  display: inline-block;
  color: #2271b1;
  background: #eaf2fb;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: 3px 10px;
  border-radius: 99px;
  margin-bottom: 16px;
}

/* Question text */
#examaya-question .q-text {
  font-size: 17px;
  line-height: 1.7;
  margin: 0 0 24px;
  color: #1d2327;
  font-weight: 500;
}
#examaya-question img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 0 0 20px;
  display: block;
}

/* Answer options */
#examaya-question .opts {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#examaya-question .opts li {
  margin: 0;
}
#examaya-question .opts label {
  display: flex;
  gap: 14px;
  padding: 14px 18px;
  border: 1.5px solid #dcdfe3;
  border-radius: 9px;
  cursor: pointer;
  background: #fff;
  align-items: center;
  line-height: 1.5;
  font-size: 15px;
  transition: border-color .12s, background .12s, box-shadow .12s;
  user-select: none;
}
#examaya-question .opts label:hover {
  background: #f6f8fb;
  border-color: #93b4d4;
  box-shadow: 0 1px 4px rgba(34,113,177,.1);
}
#examaya-question .opts input[type=radio] {
  flex-shrink: 0;
  accent-color: #2271b1;
  width: 18px;
  height: 18px;
  cursor: pointer;
  margin: 0;
}
#examaya-question .opts label.checked {
  background: #eaf2fb;
  border-color: #2271b1;
  box-shadow: 0 0 0 3px rgba(34,113,177,.08);
}
#examaya-question .opts label.checked input[type=radio] {
  accent-color: #2271b1;
}

/* Essay textarea */
#examaya-essay {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid #dcdfe3;
  border-radius: 9px;
  font-size: 15px;
  line-height: 1.6;
  resize: vertical;
  transition: border-color .12s;
  font-family: inherit;
  box-sizing: border-box;
}
#examaya-essay:focus {
  outline: none;
  border-color: #2271b1;
  box-shadow: 0 0 0 3px rgba(34,113,177,.1);
}

/* Nav controls row */
.examaya-exam-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid #eef0f2;
}
.examaya-exam-controls .examaya-btn {
  padding: 9px 20px;
  font-size: 14px;
}
.examaya-exam-controls .examaya-btn-primary {
  padding: 9px 24px;
}

/* ── Right Sidebar / Nav Panel ───────────────────────── */
.examaya-exam-nav {
  border-left: 1px solid #dcdfe3;
  background: #fff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.examaya-nav-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid #eef0f2;
  flex-shrink: 0;
}
.examaya-nav-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: #8c939b;
  margin: 0 0 10px;
}
.examaya-progress {
  height: 6px;
  background: #eef0f2;
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 6px;
}
.examaya-progress-bar {
  height: 100%;
  background: #2271b1;
  width: 0;
  border-radius: 99px;
  transition: width .25s ease;
}
.examaya-progress-text {
  font-size: 11px;
  color: #646970;
}
.examaya-nav-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
}

/* ── Question Number Grid ────────────────────────────── */
.examaya-q-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
  margin-bottom: 16px;
}
.examaya-q-grid button {
  height: 40px;
  border: 1.5px solid #dcdfe3;
  background: #fff;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #1d2327;
  position: relative;
  transition: background .1s, border-color .1s, transform .08s;
  line-height: 1;
  padding: 0;
}
.examaya-q-grid button:hover {
  background: #f0f2f5;
  border-color: #b5bdc5;
  transform: scale(1.05);
}
.examaya-q-grid button.visited {
  background: #fef9ec;
  border-color: #f0c843;
  color: #7a5c00;
}
.examaya-q-grid button.answered {
  background: #eaf6ee;
  border-color: #5fa870;
  color: #1a5e30;
  font-weight: 600;
}
.examaya-q-grid button.current {
  background: #2271b1;
  border-color: #2271b1;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(34,113,177,.35);
  transform: none;
}
.examaya-q-grid button.flagged::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 4px;
  width: 7px;
  height: 7px;
  background: #e74c3c;
  border-radius: 50%;
  border: 1px solid #fff;
}
.examaya-q-grid button.answered.current {
  background: #1a5fa2;
  border-color: #1a5fa2;
  color: #fff;
}

/* ── Legend ──────────────────────────────────────────── */
.examaya-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid #eef0f2;
  font-size: 12px;
  color: #646970;
}
.examaya-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}
.legend-dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex-shrink: 0;
  border: 1.5px solid transparent;
}
.legend-dot.answered { background: #eaf6ee; border-color: #5fa870; }
.legend-dot.visited   { background: #fef9ec; border-color: #f0c843; }
.legend-dot.current   { background: #2271b1; border-color: #2271b1; }
.legend-dot.flagged   { background: #fff; border-color: #dcdfe3; position: relative; }
.legend-dot.flagged::after {
  content: "";
  position: absolute;
  top: 1px; right: 1px;
  width: 6px; height: 6px;
  background: #e74c3c;
  border-radius: 50%;
}

/* ── Short Answer Input ──────────────────────────────── */
.examaya-short-ans {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid #dcdfe3;
  border-radius: 9px;
  font-size: 15px;
  font-family: inherit;
  box-sizing: border-box;
  transition: border-color .12s;
}
.examaya-short-ans:focus {
  outline: none;
  border-color: #2271b1;
  box-shadow: 0 0 0 3px rgba(34,113,177,.1);
}

/* ── Mode Belajar Feedback ───────────────────────────── */
.examaya-learning-fb {
  margin-top: 20px;
  padding: 20px 22px;
  border-radius: 12px;
  border: 2px solid transparent;
}
.examaya-learning-fb.correct {
  background: #f0fdf4;
  border-color: #86efac;
  color: #14532d;
}
.examaya-learning-fb.incorrect {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #7f1d1d;
}
.examaya-learning-fb .lf-header {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 10px;
}
.examaya-learning-fb .lf-icon {
  font-size: 22px;
}
.examaya-learning-fb .lf-answer,
.examaya-learning-fb .lf-explanation {
  font-size: 14px;
  line-height: 1.6;
  margin: 6px 0 0;
}
.examaya-learning-fb .lf-next {
  margin-top: 14px;
}

/* ── Video/Audio Embeds ──────────────────────────────── */
.q-video,
.q-audio {
  margin: 10px 0 18px;
}
.q-video iframe {
  max-width: 640px;
  aspect-ratio: 16/9;
  border-radius: 8px;
  display: block;
}

/* ── Modal ───────────────────────────────────────────── */
.examaya-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100000;
}
.examaya-modal[hidden] { display: none; }
.examaya-modal-box {
  background: #fff;
  border-radius: 10px;
  padding: 28px 28px 22px;
  max-width: 460px;
  width: 90%;
  box-shadow: 0 16px 48px rgba(0,0,0,.22);
}
.examaya-modal-box h3 {
  margin: 0 0 12px;
  font-size: 16px;
}
.examaya-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* ── Security ────────────────────────────────────────── */
.examaya-noselect { user-select: none; -webkit-user-select: none; }

/* ── Responsive: mobile (≤ 640px) ────────────────────── */
@media (max-width: 640px) {

  /* --- Header --- */
  .examaya-exam-header {
    flex-wrap: wrap;
    height: auto;
    min-height: 52px;
    padding: 8px 12px;
    gap: 6px;
    column-gap: 10px;
    row-gap: 0;
  }
  .examaya-exam-title  { font-size: 14px; }
  .examaya-exam-timer  { font-size: 16px; padding: 4px 10px; min-width: 60px; }
  .examaya-q-timer     { font-size: 12px; padding: 3px 8px; }
  #examaya-finish-btn  { font-size: 13px; padding: 7px 12px; }
  /* Violations: push to own full-width row below title/timer/btn */
  .examaya-violation-wrap {
    order: 10;
    flex-basis: 100%;
    font-size: 12px;
    padding: 4px 0 2px;
    border-top: 1px solid #eef0f2;
  }

  /* --- Body: single full-height column --- */
  .examaya-exam-body {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    overflow-y: auto;
  }

  /* --- Main question area: full width --- */
  .examaya-exam-main {
    padding: 14px 12px 80px; /* bottom clears FAB */
    order: 1;
    align-items: stretch;
    overflow-y: auto;
  }
  .examaya-exam-main-inner {
    padding: 18px 14px 14px;
    border-radius: 10px;
    max-width: 100%;
  }

  /* --- Question content --- */
  #examaya-question .q-text  { font-size: 15px; line-height: 1.65; margin-bottom: 18px; }
  #examaya-question .opts label {
    padding: 13px 14px;
    font-size: 14px;
    min-height: 48px;
    align-items: center;
  }
  #examaya-question .opts input[type=radio] { width: 20px; height: 20px; }
  #examaya-essay { font-size: 14px; }

  /* --- Navigation controls --- */
  .examaya-exam-controls { margin-top: 20px; padding-top: 14px; gap: 8px; }
  .examaya-exam-controls .examaya-btn,
  .examaya-exam-controls .examaya-btn-primary {
    flex: 1;
    min-height: 44px;
    padding: 10px 6px;
    font-size: 13px;
    text-align: center;
    justify-content: center;
  }
  /* Save-and-continue: full width */
  .examaya-save-wrap .examaya-btn-ghost { width: 100%; min-height: 44px; font-size: 13px; }

  /* --- Nav sidebar → slide-up bottom drawer --- */
  .examaya-exam-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10001;
    background: #fff;
    border-top: 1px solid #dcdfe3;
    border-left: 0;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 24px rgba(0,0,0,.15);
    display: flex;
    flex-direction: column;
    max-height: 0;
    overflow: hidden;
    transition: max-height .28s cubic-bezier(.4,0,.2,1);
  }
  .examaya-exam-nav.is-open {
    max-height: 65vh;
    overflow-y: auto;
  }
  .examaya-nav-header {
    position: relative;
    padding: 14px 44px 12px 16px; /* right pad clears close btn */
    border-bottom: 1px solid #eef0f2;
    flex-shrink: 0;
  }
  .examaya-nav-scroll { overflow-y: auto; overflow-x: hidden; padding: 14px 16px 20px; }
  .examaya-q-grid {
    grid-template-columns: repeat(7, 1fr);
    gap: 7px;
    margin-bottom: 14px;
  }
  .examaya-q-grid button { height: 42px; font-size: 13px; }
  .examaya-legend { flex-direction: row; flex-wrap: wrap; gap: 6px 14px; padding-top: 10px; border-top: 1px solid #eef0f2; }

  /* --- Close button (inside nav drawer header) --- */
  .examaya-nav-close {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f2f5;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    color: #646970;
    padding: 0;
  }

  /* --- Backdrop overlay --- */
  .examaya-nav-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 10000;
    display: none;
  }
  .examaya-nav-overlay.is-open { display: block; }

  /* --- FAB: floating nav toggle button --- */
  .examaya-nav-fab {
    position: fixed;
    bottom: 18px;
    right: 14px;
    z-index: 9999;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: var(--exam-primary, #2271b1);
    color: #fff;
    border: none;
    border-radius: 50px;
    padding: 11px 16px 11px 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,.28);
    transition: transform .12s, box-shadow .12s;
    font-family: inherit;
    letter-spacing: .01em;
  }
  .examaya-nav-fab:active { transform: scale(.96); box-shadow: 0 2px 8px rgba(0,0,0,.22); }
  .examaya-nav-fab svg { width: 16px; height: 16px; flex-shrink: 0; }
  .examaya-nav-fab .fab-progress {
    background: rgba(255,255,255,.22);
    border-radius: 20px;
    padding: 1px 8px;
    font-size: 12px;
    font-weight: 500;
  }
}

/* Desktop: hide mobile-only elements */
@media (min-width: 641px) {
  .examaya-nav-fab,
  .examaya-nav-close,
  .examaya-nav-overlay { display: none !important; }
}

/* ---- Toast notification ---- */
.examaya-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1a1a2e;
  color: #fff;
  padding: 12px 24px;
  border-radius: 6px;
  font-size: 14px;
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
  pointer-events: none;
}

/* ── Theme Presets (v1.1.1) ─────────────────────────── */
.examaya-exam-room {
  --exam-primary: #5865f2;
  --exam-bg:      #f0f2f5;
  --exam-text:    #1d2327;
}
.examaya-theme-ocean    { --exam-primary: #0077b6; --exam-bg: #f0f8ff; }
.examaya-theme-forest   { --exam-primary: #2d6a4f; --exam-bg: #f0faf4; }
.examaya-theme-sunset   { --exam-primary: #e07020; --exam-bg: #fff8f0; }
.examaya-theme-midnight { --exam-primary: #7c3aed; --exam-bg: #1e1e2e; --exam-text: #e2e8f0; }
.examaya-theme-rose     { --exam-primary: #e11d48; --exam-bg: #fff0f5; }

/* Apply CSS variables to exam room elements */
.examaya-exam-room                { background: var(--exam-bg); color: var(--exam-text); }
.examaya-theme-midnight .examaya-exam-header  { background: #2a2a3e; border-color: #3a3a5c; }
.examaya-theme-midnight .examaya-exam-content { background: #252535; }
.examaya-exam-room .examaya-option-btn.selected { background: var(--exam-primary); border-color: var(--exam-primary); }

/* ── Per-question timer (v1.1.1) ─────────────────────── */
.examaya-q-timer {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffc107;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 12px;
}
.examaya-q-timer.warn {
  background: #fdecee;
  color: #c0392b;
  border-color: #f5c6cb;
  animation: nano-timer-pulse 1s ease-in-out infinite;
}

/* ── Page navigation (v1.1.1) ────────────────────────── */
.examaya-page-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 0;
  font-size: 13px;
  color: #6b7280;
}
.examaya-page-nav button {
  padding: 6px 14px;
  border: 1px solid #dcdfe3;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}
.examaya-page-nav button:disabled {
  opacity: .4;
  cursor: default;
}

/* ── Practice mode badge (v1.1.1) ────────────────────── */
.examaya-badge-practice {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  background: #d1fae5;
  color: #065f46;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  border: 1px solid #6ee7b7;
  vertical-align: middle;
}

/* ── Ghost button (v1.1.1) ───────────────────────────── */
.examaya-btn-ghost {
  padding: 7px 16px;
  border: 1px solid #dcdfe3;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  transition: background .15s, border-color .15s;
}
.examaya-btn-ghost:hover { background: #f3f4f6; border-color: #9ca3af; }

/* ── Social share row (v1.1.1) ───────────────────────── */
.examaya-share-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.examaya-share-row a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  transition: opacity .15s;
}
.examaya-share-row a:hover { opacity: .85; }
.examaya-share-twitter   { background: #1d9bf0; }
.examaya-share-facebook  { background: #1877f2; }
.examaya-share-whatsapp  { background: #25d366; }

/* ── Matching question table (v1.1.1) ────────────────── */
.examaya-matching-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}
.examaya-matching-table th,
.examaya-matching-table td {
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  font-size: 14px;
}
.examaya-matching-table th {
  background: #f9fafb;
  font-weight: 600;
  text-align: left;
}
.examaya-matching-sel {
  width: 100%;
  padding: 6px;
  border: 1px solid #dcdfe3;
  border-radius: 4px;
  font-size: 14px;
}
.examaya-matching-sel.correct { border-color: #10b981; background: #f0fdf4; }
.examaya-matching-sel.wrong   { border-color: #ef4444; background: #fef2f2; }

/* ── Fill-blank input (v1.1.1) ───────────────────────── */
.examaya-fill-blank {
  width: 100%;
  max-width: 400px;
  padding: 10px 14px;
  border: 2px solid #dcdfe3;
  border-radius: 6px;
  font-size: 15px;
  margin-top: 8px;
  transition: border-color .15s;
}
.examaya-fill-blank:focus { outline: none; border-color: var(--exam-primary, #5865f2); }
.examaya-fill-blank.correct { border-color: #10b981; background: #f0fdf4; }
.examaya-fill-blank.wrong   { border-color: #ef4444; background: #fef2f2; }

/* ── Result message (v1.1.1) ─────────────────────────── */
.examaya-result-message {
  margin: 16px 0;
  padding: 16px 20px;
  background: #eff6ff;
  border-left: 4px solid #3b82f6;
  border-radius: 6px;
  font-size: 15px;
  line-height: 1.6;
}

.examaya-toast.warning { background: #b26a00; }
.examaya-toast.danger  { background: #d63638; }

/* ---- Section header bar ---- */
.examaya-section-hdr {
  background: #f0f6ff;
  border-left: 4px solid #2271b1;
  padding: 8px 16px;
  margin-bottom: 16px;
  border-radius: 0 4px 4px 0;
  font-weight: 600;
  font-size: 15px;
}

/* ---- Locked grid button ---- */
#examaya-q-grid button.locked {
  opacity: 0.35;
  cursor: not-allowed;
  background: #e5e5e5;
  color: #888;
}
