/* =====================================================
   test.css – ESP for SPORTS Test System Styles
   ===================================================== */

/* ── Overlay ───────────────────────────────────────── */
.tm-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: #f0f4f8;
  display: none;
  flex-direction: column;
  font-family: 'Open Sans', sans-serif;
  overflow: hidden;
}

body.tm-open {
  overflow: hidden;
}

/* ── Header ────────────────────────────────────────── */
.tm-header {
  background: linear-gradient(135deg, #003366 0%, #0055a4 100%);
  color: #fff;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.tm-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.tm-close-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  transition: background 0.2s;
}
.tm-close-btn:hover { background: rgba(255,255,255,0.3); }

.tm-title-block {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.tm-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.75;
}
.tm-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
  font-family: 'Montserrat', sans-serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tm-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.tm-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.15);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 0.85rem;
  font-weight: 600;
}
.tm-stat i { font-size: 0.9rem; color: #2ecc71; }
.tm-stat.tm-wrong i { color: #e74c3c; }
.tm-stat.tm-remain i { color: #f39c12; }

/* ── Progress Bar ──────────────────────────────────── */
.tm-progress-wrap {
  background: #fff;
  padding: 6px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  border-bottom: 1px solid #e2e8f0;
}

.tm-progress-bar {
  flex: 1;
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}

.tm-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #0055a4, #2ecc71);
  border-radius: 4px;
  transition: width 0.4s ease;
}

.tm-progress-label {
  font-size: 0.8rem;
  color: #64748b;
  white-space: nowrap;
  font-weight: 600;
}

/* ── Main Body ─────────────────────────────────────── */
.tm-body {
  flex: 1;
  display: flex;
  gap: 0;
  overflow: hidden;
  min-height: 0;
}

/* ── Question Panel ────────────────────────────────── */
.tm-question-panel {
  flex: 1;
  padding: 30px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
  box-sizing: border-box;
}

.tm-q-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tm-q-num {
  font-size: 0.85rem;
  color: #64748b;
  font-weight: 600;
}

.tm-difficulty {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.tm-diff-easy { background: #d1fae5; color: #065f46; }
.tm-diff-med  { background: #fef3c7; color: #92400e; }
.tm-diff-hard { background: #fee2e2; color: #991b1b; }

.tm-question-text {
  font-size: 1.15rem;
  line-height: 1.65;
  color: #1e293b;
  font-weight: 500;
  margin: 0;
}

/* ── Options ───────────────────────────────────────── */
.tm-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tm-option {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: #fff;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px 18px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  font-family: inherit;
}
.tm-option:hover:not(:disabled) {
  border-color: #0055a4;
  background: #f0f7ff;
  transform: translateX(3px);
}
.tm-option.tm-selected {
  border-color: #0055a4;
  background: #e8f1ff;
}
.tm-option.tm-correct {
  border-color: #2ecc71;
  background: #d1fae5;
}
.tm-option.tm-incorrect {
  border-color: #e74c3c;
  background: #fee2e2;
}
.tm-option:disabled { cursor: not-allowed; }

.tm-opt-key {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f1f5f9;
  font-weight: 700;
  font-size: 0.9rem;
  color: #003366;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.tm-selected .tm-opt-key { background: #0055a4; color: #fff; }
.tm-correct  .tm-opt-key { background: #2ecc71; color: #fff; }
.tm-incorrect .tm-opt-key { background: #e74c3c; color: #fff; }

.tm-opt-text {
  font-size: 0.95rem;
  color: #334155;
  line-height: 1.5;
  padding-top: 4px;
}

/* ── Feedback ──────────────────────────────────────── */
.tm-feedback {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 10px;
  font-size: 0.92rem;
  line-height: 1.6;
}
.tm-feedback i { font-size: 1.3rem; flex-shrink: 0; margin-top: 1px; }
.tm-feedback div { display: flex; flex-direction: column; gap: 4px; }
.tm-feedback strong { font-size: 1rem; }
.tm-feedback span, .tm-feedback p { margin: 0; color: inherit; }

.tm-fb-correct  { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.tm-fb-incorrect { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.tm-fb-correct i { color: #059669; }
.tm-fb-incorrect i { color: #dc2626; }

/* ── Side Panel ────────────────────────────────────── */
.tm-side-panel {
  width: 220px;
  min-width: 220px;
  flex-shrink: 0;
  background: #fff;
  border-left: 1px solid #e2e8f0;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  overflow-y: auto;
  box-sizing: border-box;
}

.tm-passing-info {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.88rem;
  color: #475569;
  width: 100%;
}
.tm-passing-info i { color: #0055a4; }

.tm-score-circle {
  position: relative;
  width: 130px;
  height: 130px;
}
.tm-score-circle svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.tm-circle-bg { fill: none; stroke: #e2e8f0; stroke-width: 8; }
.tm-circle-fg {
  fill: none;
  stroke: #e74c3c;
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s ease, stroke 0.3s ease;
}
.tm-score-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
#tm-score-pct {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1e293b;
  font-family: 'Montserrat', sans-serif;
}
.tm-score-text small {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
}

.tm-section-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #0055a4;
  font-weight: 700;
  text-align: center;
}

/* ── Footer ────────────────────────────────────────── */
.tm-footer {
  background: #fff;
  border-top: 1px solid #e2e8f0;
  padding: 14px 20px;
  display: flex;
  justify-content: flex-end;
  flex-shrink: 0;
  box-sizing: border-box;
}

/* ── Buttons ───────────────────────────────────────── */
.tm-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s;
  font-family: inherit;
  white-space: nowrap;
}
.tm-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.tm-btn-primary {
  background: #0055a4;
  color: #fff;
  border-color: #0055a4;
}
.tm-btn-primary:hover:not(:disabled) { background: #003d7a; border-color: #003d7a; }

.tm-btn-secondary {
  background: #f1f5f9;
  color: #334155;
  border-color: #e2e8f0;
}
.tm-btn-secondary:hover { background: #e2e8f0; }

.tm-btn-outline {
  background: transparent;
  color: #0055a4;
  border-color: #0055a4;
}
.tm-btn-outline:hover { background: #f0f7ff; }

/* ── Results Screen ────────────────────────────────── */
.tm-results {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow-y: auto;
}

.tm-results-header {
  padding: 40px 30px;
  text-align: center;
  color: #fff;
}
.tm-results-pass { background: linear-gradient(135deg, #1a7a4a 0%, #2ecc71 100%); }
.tm-results-fail { background: linear-gradient(135deg, #7f1d1d 0%, #e74c3c 100%); }

.tm-results-icon { font-size: 3rem; margin-bottom: 12px; }
.tm-results-header h2 {
  font-size: 1.8rem;
  font-weight: 700;
  margin: 0 0 10px;
  font-family: 'Montserrat', sans-serif;
}
.tm-results-header p { margin: 0; opacity: 0.9; font-size: 1rem; }

.tm-results-body {
  flex: 1;
  padding: 30px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.tm-score-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.tm-result-stat {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  border: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tm-rs-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: #1e293b;
  font-family: 'Montserrat', sans-serif;
}
.tm-rs-value.pass { color: #059669; }
.tm-rs-value.fail { color: #dc2626; }
.tm-rs-label { font-size: 0.8rem; color: #64748b; text-transform: uppercase; letter-spacing: 0.05em; }

.tm-breakdown {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  border: 1px solid #e2e8f0;
}
.tm-breakdown h3 {
  font-size: 1rem;
  margin: 0 0 14px;
  color: #1e293b;
  font-family: 'Montserrat', sans-serif;
}
.tm-breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.9rem;
  color: #475569;
}
.tm-breakdown-row:last-child { border-bottom: none; }

.tm-early-stop-msg {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 10px;
  padding: 16px;
  color: #9a3412;
  font-size: 0.9rem;
}
.tm-early-stop-msg i { font-size: 1.2rem; flex-shrink: 0; }

.tm-review-toggle { display: flex; justify-content: center; }

.tm-review-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tm-review-item {
  background: #fff;
  border-radius: 10px;
  padding: 16px;
  border-left: 4px solid #e2e8f0;
}
.tm-rv-correct  { border-left-color: #2ecc71; }
.tm-rv-incorrect { border-left-color: #e74c3c; }

.tm-rv-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.tm-rv-num { font-weight: 700; color: #0055a4; font-size: 0.85rem; }
.tm-rv-header i { color: inherit; }
.tm-rv-correct   .tm-rv-header i { color: #059669; }
.tm-rv-incorrect .tm-rv-header i { color: #dc2626; }

.tm-rv-question { font-size: 0.92rem; color: #1e293b; margin: 0 0 8px; font-weight: 500; }
.tm-rv-answer   { font-size: 0.88rem; color: #475569; margin: 0 0 6px; }
.tm-rv-exp      { font-size: 0.85rem; color: #0055a4; background: #f0f7ff; border-radius: 6px; padding: 8px 12px; margin: 6px 0 0; display: flex; gap: 8px; }
.tm-rv-exp i    { flex-shrink: 0; margin-top: 1px; }

.tm-results-footer {
  background: #fff;
  border-top: 1px solid #e2e8f0;
  padding: 16px 30px;
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-shrink: 0;
}

/* ── Error State ───────────────────────────────────── */
.tm-error-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: #64748b;
  text-align: center;
  padding: 40px;
}
.tm-error-state i { font-size: 3rem; color: #f59e0b; }
.tm-error-state h3 { font-size: 1.4rem; color: #1e293b; margin: 0; }
.tm-error-state p  { max-width: 400px; margin: 0; line-height: 1.6; }

/* ── Test Launch Buttons (unit cards in index.html) ── */
.test-btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.start-test-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: #003366;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  font-family: inherit;
}
.start-test-btn:hover {
  background: #0055a4;
  transform: translateY(-1px);
}
.start-test-btn i { font-size: 0.8rem; }
.start-test-btn.test-b {
  background: #1a7a4a;
}
.start-test-btn.test-b:hover { background: #14563a; }

/* Progress Test — purple/indigo */
.start-test-btn.test-progress {
  background: #6d28d9;
}
.start-test-btn.test-progress:hover { background: #5b21b6; }

/* Final Test — gold/amber */
.start-test-btn.test-final {
  background: #b45309;
}
.start-test-btn.test-final:hover { background: #92400e; }

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 768px) {
  .tm-header { padding: 10px 14px; flex-wrap: wrap; }
  .tm-header-right { display: none; }

  .tm-body { flex-direction: column; }

  .tm-side-panel {
    width: 100%;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    border-left: none;
    border-top: 1px solid #e2e8f0;
    padding: 12px 16px;
    order: -1;
  }

  .tm-score-circle { width: 70px; height: 70px; }
  #tm-score-pct { font-size: 1rem; }
  .tm-section-label { display: none; }
  .tm-passing-info { width: auto; }

  .tm-question-panel { padding: 16px; }
  .tm-question-text { font-size: 1rem; }

  .tm-footer { padding: 12px 16px; }
  .tm-btn { padding: 10px 18px; font-size: 0.88rem; }

  .tm-score-summary { grid-template-columns: repeat(2, 1fr); }

  .tm-results-header { padding: 30px 20px; }
  .tm-results-body { padding: 20px; }
  .tm-results-footer { flex-direction: column; padding: 14px 20px; }
  .tm-results-footer .tm-btn { width: 100%; justify-content: center; }

  .tm-stat { font-size: 0.75rem; padding: 4px 8px; }
}

@media (max-width: 480px) {
  .tm-title { font-size: 0.88rem; }
  .tm-score-summary { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .tm-result-stat { padding: 14px 10px; }
  .tm-rs-value { font-size: 1.3rem; }
}