/* ============================================================
   Mock Up Exam — Student Score Page
   ============================================================ */

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

:root {
  --navy:       #1e3a5f;
  --navy-dark:  #152c48;
  --blue:       #2563eb;
  --blue-light: #dbeafe;
  --amber:      #f59e0b;
  --green:      #059669;
  --green-light:#d1fae5;
  --red:        #dc2626;
  --red-light:  #fee2e2;
  --text:       #1e293b;
  --text-muted: #64748b;
  --bg:         #f1f5f9;
  --card:       #ffffff;
  --border:     #e2e8f0;
  --shadow:     0 2px 8px rgba(0,0,0,0.08);
  --shadow-md:  0 4px 20px rgba(0,0,0,0.12);
  --radius:     12px;
  --radius-sm:  8px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Sarabun', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--blue); text-decoration: none; }

/* ── Header ── */
.site-header {
  background: linear-gradient(135deg, var(--navy-dark), var(--blue));
  color: white;
  padding: 1.5rem 1rem;
  position: relative;
}
.header-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.back-link {
  color: rgba(255,255,255,0.7);
  font-size: 0.85rem;
  transition: color 0.2s;
  align-self: flex-start;
}
.back-link:hover { color: white; }
.header-badge {
  display: inline-block;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 20px;
  padding: 0.15rem 0.75rem;
  font-size: 0.78rem;
  margin-bottom: 0.25rem;
}
.site-header h1 { font-size: 1.6rem; font-weight: 700; }
.header-sub { font-size: 0.875rem; opacity: 0.8; }

/* ── Container ── */
.container { max-width: 720px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }

/* ── Login Card ── */
.screen-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}
.login-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-md);
  text-align: center;
}
.login-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.login-card h2 { font-size: 1.3rem; font-weight: 700; color: var(--navy); margin-bottom: 0.3rem; }
.login-sub { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 1.5rem; }

/* ── Alerts ── */
.alert {
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  text-align: left;
}
.alert-error { background: var(--red-light); color: var(--red); border-left: 3px solid var(--red); }
.alert-success { background: var(--green-light); color: var(--green); border-left: 3px solid var(--green); }

/* ── Forms ── */
.form-group { margin-bottom: 1rem; text-align: left; }
.form-label { display: block; font-size: 0.875rem; font-weight: 600; margin-bottom: 0.35rem; }
.form-input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Sarabun', sans-serif;
  font-size: 0.9rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}
.form-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  font-family: 'Sarabun', sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: white; }
.btn-primary:hover:not(:disabled) { background: #1d4ed8; }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-full { width: 100%; padding: 0.7rem; font-size: 0.95rem; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.82rem; }

/* ── Score Dashboard ── */
.student-bar {
  background: var(--card);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
  border: 1px solid var(--border);
  gap: 1rem;
}
.student-info { display: flex; align-items: center; gap: 0.75rem; }
.student-avatar {
  width: 2.5rem;
  height: 2.5rem;
  background: var(--blue-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.student-name { font-weight: 700; font-size: 1rem; color: var(--navy); }
.student-code { font-size: 0.82rem; color: var(--text-muted); }

/* ── Loading / Empty ── */
.loading-box, .empty-box {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.spinner {
  width: 1.75rem; height: 1.75rem;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 0.75rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }

/* ── Blueprint Score Card ── */
.blueprint-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 1.25rem;
}

.bp-card-header {
  background: linear-gradient(135deg, var(--navy-dark), var(--navy));
  color: white;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.bp-card-title { font-size: 1rem; font-weight: 700; }
.bp-total-badge {
  background: var(--amber);
  color: var(--navy-dark);
  border-radius: 20px;
  padding: 0.25rem 0.85rem;
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
}

.bp-score-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--border);
}
.bp-summary-item {
  text-align: center;
  padding: 0.9rem 0.5rem;
  border-right: 1px solid var(--border);
}
.bp-summary-item:last-child { border-right: none; }
.bp-summary-label { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.25rem; }
.bp-summary-score { font-size: 1.35rem; font-weight: 700; color: var(--navy); }
.bp-summary-max { font-size: 0.78rem; color: var(--text-muted); }

/* ── Score Sections ── */
.score-section { border-bottom: 1px solid var(--border); }
.score-section:last-child { border-bottom: none; }

.score-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}
.score-section-header:hover { background: var(--bg); }
.section-title {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.section-pts {
  font-size: 0.88rem;
  color: var(--text-muted);
  font-weight: 500;
}
.section-chevron { font-size: 0.82rem; color: var(--text-muted); transition: transform 0.2s; }
.score-section.open .section-chevron { transform: rotate(180deg); }

.score-section-body { display: none; padding: 0 1.25rem 1rem; }
.score-section.open .score-section-body { display: block; }

/* MC items */
.mc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.mc-item {
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  border: 1px solid;
}
.mc-item.correct {
  background: var(--green-light);
  border-color: #6ee7b7;
  color: #065f46;
}
.mc-item.incorrect {
  background: var(--red-light);
  border-color: #fca5a5;
  color: #991b1b;
}
.mc-item.unanswered {
  background: #f1f5f9;
  border-color: var(--border);
  color: var(--text-muted);
}
.mc-q-num { font-weight: 700; }
.mc-ans { font-size: 0.78rem; opacity: 0.8; }
.mc-pts { font-weight: 700; flex-shrink: 0; }

/* SA / LA question blocks */
.q-block { margin-top: 0.75rem; }
.q-block-header {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--navy);
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.q-block-total {
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.15rem 0.6rem;
  border-radius: 20px;
  background: var(--blue-light);
  color: var(--blue);
}
.criteria-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.criteria-table th {
  text-align: left;
  padding: 0.45rem 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}
.criteria-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.criteria-table tr:last-child td { border-bottom: none; }
.score-bar { display: flex; align-items: center; gap: 0.5rem; }
.score-fill-track {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.score-fill-bar {
  height: 100%;
  border-radius: 3px;
  background: var(--blue);
  transition: width 0.4s ease;
}
.score-fill-bar.full { background: var(--green); }
.score-fill-bar.zero { background: #e2e8f0; }
.score-val { font-weight: 700; font-size: 0.82rem; white-space: nowrap; color: var(--navy); min-width: 3rem; text-align: right; }

/* Case badge */
.case-badge {
  display: inline-block;
  background: #ede9fe;
  color: #6d28d9;
  border-radius: 20px;
  padding: 0.15rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

/* Admin comment below criteria name */
.score-comment {
  font-size: 0.78rem;
  color: var(--navy);
  background: #f0f9ff;
  border-left: 3px solid #38bdf8;
  padding: 0.3rem 0.5rem;
  border-radius: 0 4px 4px 0;
  margin-top: 0.3rem;
  line-height: 1.5;
  font-style: italic;
}

/* ── Footer ── */
.site-footer {
  background: var(--navy-dark);
  color: rgba(255,255,255,0.5);
  text-align: center;
  padding: 1rem;
  font-size: 0.8rem;
  margin-top: auto;
}

/* ── Case Sub-Criteria Breakdown (Student View) ── */
.case-subcrit-breakdown {
  margin-top: 0.35rem;
  padding: 0.3rem 0.5rem;
  background: #faf5ff;
  border-radius: 4px;
  border-left: 2px solid #c4b5fd;
}
.subcrit-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  padding: 0.1rem 0;
  color: var(--text-muted);
  border-bottom: 1px solid #f3e8ff;
}
.subcrit-item:last-child { border-bottom: none; }
.subcrit-name { flex: 1; }
.subcrit-score { font-weight: 600; color: var(--navy); margin-left: 0.5rem; }

/* ── KaTeX MathML fallback hide (in case CDN CSS is unavailable) ── */
.katex-mathml {
  position: absolute !important;
  overflow: hidden !important;
  clip: rect(1px, 1px, 1px, 1px) !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  border: 0 !important;
}

/* ── Responsive ── */
@media (max-width: 500px) {
  .site-header h1 { font-size: 1.3rem; }
  .login-card { padding: 1.75rem 1.25rem; }
  .bp-score-summary { grid-template-columns: 1fr 1fr 1fr; }
  .bp-summary-score { font-size: 1.15rem; }
  .mc-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .student-bar { flex-direction: column; align-items: flex-start; }
}
