/* ─────────────────────────────────────────────
   STUDENT-FACING STYLES  (Coderbyte-inspired)
   Light theme · Inter font · Blue accent
───────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f0f2f5;
  color: #111827;
  min-height: calc(100vh - 57px);
  -webkit-font-smoothing: antialiased;
}

a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── PAGE WRAPPER ── */
.page-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: #f0f2f5;
}

/* ── CARD (two-column like Coderbyte) ── */
.cb-card {
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 2px 12px rgba(0,0,0,.10), 0 0 0 1px rgba(0,0,0,.04);
  display: flex;
  width: 100%;
  max-width: 680px;
  overflow: hidden;
  min-height: 380px;
}

.cb-card-left {
  width: 280px;
  flex-shrink: 0;
  padding: 2.5rem 2rem;
  border-right: 1px solid #f0f2f5;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.cb-card-right {
  flex: 1;
  padding: 2.5rem 2rem;
}

/* Logo */
.cb-logo {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin-bottom: 2rem;
  text-decoration: none;
}

.cb-logo .logo-icon {
  width: 36px; height: 36px;
  background: #111827;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -.05em;
  flex-shrink: 0;
}

.cb-logo .logo-text {
  font-size: 1.1rem;
  font-weight: 700;
  color: #111827;
  letter-spacing: -.02em;
}

.cb-card-left h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #111827;
  line-height: 1.4;
  margin-bottom: .65rem;
  letter-spacing: -.01em;
}

.cb-card-left p {
  font-size: .85rem;
  color: #6b7280;
  line-height: 1.6;
}

.cb-card-left .note {
  font-size: .82rem;
  color: #6b7280;
  margin-top: 1rem;
  line-height: 1.6;
}

.cb-card-left .note strong { color: #111827; }

/* ── FORM ── */
.form-group { margin-bottom: 1.15rem; }

.form-group label {
  display: block;
  font-size: .82rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: .4rem;
}

.form-group label .req { color: #ef4444; margin-left: 2px; }

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: .62rem .85rem;
  border: 1.5px solid #d1d5db;
  border-radius: 6px;
  font-size: .9rem;
  font-family: inherit;
  color: #111827;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
  -webkit-appearance: none;
}

.form-group input::placeholder { color: #9ca3af; }

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .85rem center;
  padding-right: 2.5rem;
  cursor: pointer;
}

/* ── BUTTONS ── */
.btn-cb {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  padding: .65rem 1.6rem;
  border-radius: 6px;
  font-family: inherit;
  font-size: .9rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background .15s, transform .12s, box-shadow .15s;
  text-decoration: none;
}

.btn-cb-primary {
  background: #2563eb;
  color: #fff;
}
.btn-cb-primary:hover {
  background: #1d4ed8;
  box-shadow: 0 4px 14px rgba(37,99,235,.35);
  transform: translateY(-1px);
  text-decoration: none;
  color: #fff;
}

.btn-cb-outline {
  background: #fff;
  color: #374151;
  border: 1.5px solid #d1d5db;
}
.btn-cb-outline:hover {
  border-color: #9ca3af;
  background: #f9fafb;
  text-decoration: none;
}

.btn-cb-green {
  background: #059669;
  color: #fff;
}
.btn-cb-green:hover {
  background: #047857;
  box-shadow: 0 4px 14px rgba(5,150,105,.3);
  transform: translateY(-1px);
  text-decoration: none;
  color: #fff;
}

.btn-cb-block { width: 100%; }
.btn-cb:active { transform: scale(.97); }

/* ── ALERTS ── */
.alert {
  padding: .75rem 1rem;
  border-radius: 6px;
  font-size: .85rem;
  margin-bottom: 1rem;
  border: 1px solid;
}
.alert-error   { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.alert-info    { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.alert-success { background: #f0fdf4; color: #065f46; border-color: #a7f3d0; }

/* ── STEP INDICATOR ── */
.steps {
  display: flex;
  gap: .4rem;
  margin-bottom: 1.8rem;
}

.step-bar {
  flex: 1;
  height: 3px;
  border-radius: 99px;
  background: #e5e7eb;
}
.step-bar.done   { background: #059669; }
.step-bar.active { background: #2563eb; }

/* ── PASSCODE INPUT ── */
.passcode-input {
  font-size: 1.5rem !important;
  font-weight: 700 !important;
  letter-spacing: .25em !important;
  text-align: center !important;
  font-family: 'SF Mono','Fira Code',monospace !important;
  text-transform: uppercase !important;
}

/* ── ASSESSMENT TOPBAR ── */
.assess-topbar {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  padding: .85rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.assess-topbar .brand {
  display: flex;
  align-items: center;
  gap: .55rem;
}

.assess-topbar .brand .live-dot {
  width: 7px; height: 7px;
  background: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(16,185,129,.2);
  animation: livePulse 2s infinite;
}

@keyframes livePulse {
  0%,100% { box-shadow: 0 0 0 3px rgba(16,185,129,.2); }
  50%      { box-shadow: 0 0 0 6px rgba(16,185,129,.05); }
}

.assess-topbar h2  { font-size: .95rem; font-weight: 700; color: #111827; }
.assess-topbar .meta { font-size: .75rem; color: #6b7280; }

/* Timer */
#timer {
  background: #f3f4f6;
  border: 1.5px solid #e5e7eb;
  color: #111827;
  padding: .5rem 1.2rem;
  border-radius: 6px;
  font-size: 1.2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: .06em;
  min-width: 90px;
  text-align: center;
  transition: all .3s;
  font-family: 'SF Mono','Fira Code',monospace;
}

#timer.warning { background: #fffbeb; border-color: #fcd34d; color: #b45309; }
#timer.danger  { background: #fef2f2; border-color: #fca5a5; color: #b91c1c; animation: timerPulse 1s infinite; }

@keyframes timerPulse {
  0%,100% { opacity: 1; }
  50%      { opacity: .6; }
}

/* ── ASSESSMENT BODY ── */
.assess-body {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.8rem 1.5rem;
  display: grid;
  grid-template-columns: 1fr 250px;
  gap: 1.4rem;
}

/* Progress */
.progress-wrap { margin-bottom: 1.2rem; }
.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: .75rem;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: .4rem;
}
.progress-track {
  height: 5px;
  background: #e5e7eb;
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: #2563eb;
  border-radius: 99px;
  transition: width .4s ease;
}

/* Question card */
.q-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 2rem;
  display: none;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
  animation: fadeUp .2s ease;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.q-badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: .28rem .7rem;
  border-radius: 99px;
  margin-bottom: 1.1rem;
}

.q-text {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.7;
  color: #111827;
  margin-bottom: 1.5rem;
}

/* Options */
.options-list { list-style: none; display: flex; flex-direction: column; gap: .5rem; }

.option-label {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .85rem 1rem;
  border: 1.5px solid #e5e7eb;
  border-radius: 7px;
  cursor: pointer;
  transition: all .12s;
  background: #fff;
}

.option-label:hover { border-color: #2563eb; background: #eff6ff; }

.option-label.selected {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 0 0 1px #2563eb;
}

.option-letter {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: #f3f4f6;
  border: 1.5px solid #e5e7eb;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  color: #6b7280;
  flex-shrink: 0;
  font-family: 'SF Mono','Fira Code',monospace;
  transition: all .12s;
}

.option-label.selected .option-letter { background: #2563eb; border-color: #2563eb; color: #fff; }
.option-label:hover .option-letter    { border-color: #2563eb; color: #2563eb; background: #dbeafe; }

.option-label input[type="radio"] { display: none; }
.option-text { font-size: .9rem; color: #374151; font-weight: 500; line-height: 1.5; }
.option-label.selected .option-text { color: #1d4ed8; font-weight: 600; }

/* Nav controls */
.q-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.5rem;
  padding-top: 1.2rem;
  border-top: 1px solid #f3f4f6;
}

/* ── SIDEBAR PANEL ── */
.assess-sidebar { display: flex; flex-direction: column; gap: 1rem; }

.panel {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 1.1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}

.panel h4 {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: #9ca3af;
  padding-bottom: .7rem;
  border-bottom: 1px solid #f3f4f6;
  margin-bottom: .85rem;
}

/* Question number grid */
.q-nav-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: .32rem;
}

.nav-q-btn {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 5px;
  border: 1.5px solid #e5e7eb;
  background: #f9fafb;
  font-size: .74rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .12s;
  color: #9ca3af;
  font-family: 'SF Mono',monospace;
}

.nav-q-btn:hover { border-color: #2563eb; color: #2563eb; background: #eff6ff; }
.nav-q-btn.answered { background: #dcfce7; border-color: #86efac; color: #15803d; }
.nav-q-btn.current  { border-color: #2563eb; color: #2563eb; background: #eff6ff; }
.nav-q-btn.answered.current { background: #dbeafe; border-color: #2563eb; color: #1d4ed8; }

.q-legend {
  margin-top: .75rem;
  display: flex;
  flex-direction: column;
  gap: .3rem;
}
.q-legend-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .72rem;
  color: #9ca3af;
}
.legend-dot {
  width: 10px; height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}
.legend-dot.answered { background: #86efac; border: 1.5px solid #4ade80; }
.legend-dot.current  { background: #bfdbfe; border: 1.5px solid #2563eb; }
.legend-dot.pending  { background: #f3f4f6; border: 1.5px solid #d1d5db; }

/* Panel info rows */
.info-row-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .8rem;
  padding: .35rem 0;
  border-bottom: 1px solid #f3f4f6;
}
.info-row-item:last-child { border-bottom: none; }
.info-row-item .ikey { color: #6b7280; }
.info-row-item .ival { font-weight: 600; color: #111827; }

/* ── TAB WARNING TOAST ── */
#tab-warning {
  display: none;
  position: fixed;
  top: 1rem; right: 1rem;
  background: #fff;
  border: 1px solid #fca5a5;
  color: #b91c1c;
  padding: .75rem 1.1rem;
  border-radius: 8px;
  font-size: .85rem;
  font-weight: 600;
  z-index: 9999;
  box-shadow: 0 4px 20px rgba(0,0,0,.12);
  animation: slideIn .25s ease;
}

@keyframes slideIn {
  from { transform: translateX(60px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── SUBMIT MODAL ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.open { display: flex; }

.modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 2rem;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  animation: popIn .2s cubic-bezier(.34,1.56,.64,1);
}

@keyframes popIn {
  from { opacity: 0; transform: scale(.92); }
  to   { opacity: 1; transform: scale(1); }
}

.modal-icon {
  width: 54px; height: 54px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  margin: 0 auto 1rem;
}

.modal-box h3 { font-size: 1.05rem; font-weight: 700; color: #111827; margin-bottom: .5rem; }
.modal-box p  { font-size: .875rem; color: #6b7280; margin-bottom: 1.4rem; line-height: 1.6; }
.modal-buttons { display: flex; gap: .6rem; justify-content: center; }

/* ── RESULT PAGE ── */
.result-page {
  min-height: 100vh;
  background: #f0f2f5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.result-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 16px rgba(0,0,0,.1);
  max-width: 520px;
  width: 100%;
  overflow: hidden;
  border: 1px solid #e5e7eb;
}

.result-banner {
  padding: 2.2rem 2rem;
  text-align: center;
  border-bottom: 1px solid #f3f4f6;
}

.result-banner .check-circle {
  width: 64px; height: 64px;
  background: #f0fdf4;
  border: 2px solid #86efac;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem;
  margin: 0 auto .9rem;
  color: #16a34a;
}

.result-banner h2 { font-size: 1.3rem; font-weight: 800; color: #111827; letter-spacing: -.02em; }
.result-banner p  { font-size: .875rem; color: #6b7280; margin-top: .4rem; line-height: 1.6; }
.result-banner .auto-note { font-size: .78rem; color: #9ca3af; margin-top: .5rem; }

.result-body { padding: 1.6rem; }

.result-box {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 1.2rem;
  text-align: center;
  margin-bottom: 1.2rem;
}

.result-box p { font-size: .875rem; color: #6b7280; line-height: 1.7; }
.result-box strong { color: #111827; }

.result-footer {
  text-align: center;
  padding-top: 1rem;
  border-top: 1px solid #f3f4f6;
  font-size: .78rem;
  color: #9ca3af;
}

/* ── UNANSWERED WARNING ── */
#unanswered-warning {
  display: none;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #991b1b;
  padding: .75rem 1rem;
  border-radius: 6px;
  font-size: .85rem;
  font-weight: 500;
  margin-bottom: 1rem;
}

/* ── UTILS ── */
.text-center { text-align: center; }
.text-sm     { font-size: .825rem; }
.text-muted  { color: #6b7280; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

/* ── RESPONSIVE ── */
@media (max-width: 640px) {
  .cb-card { flex-direction: column; }
  .cb-card-left { width: 100%; border-right: none; border-bottom: 1px solid #f0f2f5; padding: 1.8rem 1.5rem; }
  .assess-body { grid-template-columns: 1fr; }
  .assess-sidebar { order: -1; }
  .q-nav-grid { grid-template-columns: repeat(7, 1fr); }
}

/* ── STUDENT TOPNAV ── */
.student-topnav {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  padding: 12px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}

.student-topnav .s-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
}

.student-topnav .s-logo-mark {
  width: 32px; height: 32px;
  border-radius: 7px;
  overflow: hidden;
  background: #fff;
  border: 1px solid #e5e7eb;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  padding: 2px;
}

.student-topnav .s-logo-mark img {
  width: 100%; height: 100%;
  object-fit: contain; display: block;
}

.student-topnav .s-logo-name {
  font-size: 15px;
  font-weight: 800;
  color: #0d1117;
  letter-spacing: -.02em;
}

.student-topnav .s-logo-name span { color: #2563eb; }

.student-topnav .s-back {
  font-size: 13px;
  font-weight: 500;
  color: #6b7280;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: color .15s;
}

.student-topnav .s-back:hover { color: #0d1117; }
