/* ==========================================================================
   Simulador de Exámenes & Seguimiento (Exam Runner & Scorecard)
   ========================================================================== */

/* Top bar during exam */
.exam-header {
  border-bottom: 1px solid var(--line);
  background: #111612;
  padding: 14px 4%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
}
.exam-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: Space, sans-serif;
  font-weight: 700;
  font-size: 18px;
}
.exam-brand span { color: var(--accent); }
.exam-meta-bar {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.exam-timer-box {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #182019;
  border: 1px solid var(--line);
  padding: 6px 14px;
  border-radius: 20px;
  font-family: ui-monospace, monospace;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 1px;
}
.exam-timer-box.warning {
  border-color: #ff9900;
  color: #ffb84d;
  background: #2a1c0d;
  animation: pulseWarning 1.5s infinite;
}
.exam-timer-box.danger {
  border-color: #ff5555;
  color: #ff7777;
  background: #2d1111;
  animation: pulseDanger 1s infinite;
}
@keyframes pulseWarning {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}
@keyframes pulseDanger {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.8; transform: scale(1.03); }
}

/* Exam Layout */
.exam-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 4% 80px;
}

/* Lobby / Setup Screen */
.lobby-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 36px;
  margin: 24px 0 40px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.3);
}
.lobby-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.lobby-title h1 {
  margin: 6px 0 12px;
  font-size: clamp(26px, 3.2vw, 38px);
}
.lobby-title p {
  margin: 0;
  max-width: 720px;
  font-size: 14px;
}
.exam-badge-tag {
  background: #ccff6615;
  border: 1px solid #ccff6640;
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.lobby-specs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin: 28px 0;
}
.spec-box {
  background: #121813;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 18px;
}
.spec-box small {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 1px;
  margin-bottom: 6px;
}
.spec-box strong {
  display: block;
  font-size: 18px;
  font-family: Space, sans-serif;
  color: var(--text);
}

.mode-selector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
  margin: 28px 0;
}
.mode-card {
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 22px;
  background: #141b15;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}
.mode-card:hover {
  border-color: #556c4d;
  transform: translateY(-2px);
}
.mode-card.selected {
  border-color: var(--accent);
  background: #182419;
  box-shadow: 0 0 0 1px var(--accent);
}
.mode-card input[type="radio"] {
  position: absolute;
  top: 20px;
  right: 20px;
  accent-color: var(--accent);
}
.mode-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.mode-card p {
  font-size: 12px;
  line-height: 1.6;
  margin: 0;
  color: var(--muted);
}

/* History in Lobby */
.history-section {
  margin-top: 48px;
}
.history-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #121813;
  margin-top: 16px;
}
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  text-align: left;
  min-width: 600px;
}
.history-table th {
  background: #182219;
  padding: 12px 16px;
  color: var(--accent);
  font-weight: 600;
  border-bottom: 1px solid var(--line);
}
.history-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #233022;
  color: #d0dcd0;
}
.badge-status {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-status.passed {
  background: #19381e;
  color: #79f26b;
  border: 1px solid #336b3b;
}
.badge-status.failed {
  background: #381e19;
  color: #ff9179;
  border: 1px solid #6b332b;
}

/* ==========================================================================
   Exam Active Runner (Room)
   ========================================================================== */
.exam-runner-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 28px;
  align-items: start;
}
.question-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 32px;
  box-shadow: 0 12px 36px rgba(0,0,0,0.3);
}
.question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.question-count {
  font-family: Space, sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.question-module-badge {
  font-size: 11px;
  color: var(--muted);
  background: #111712;
  border: 1px solid var(--line);
  padding: 4px 10px;
  border-radius: 4px;
}
.flag-btn {
  background: transparent;
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}
.flag-btn:hover {
  border-color: #ffb84d;
}
.flag-btn.flagged {
  background: #33240e;
  border-color: #ff9900;
  color: #ffc977;
}

.question-text {
  font-size: 16px;
  line-height: 1.8;
  color: #f0f4ec;
  margin: 0 0 28px;
  font-weight: 500;
}

.options-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.option-label {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #141c15;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 13px;
  line-height: 1.7;
}
.option-label:hover {
  background: #182319;
  border-color: #4b6245;
}
.option-label.selected {
  background: #18261a;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.option-label input[type="radio"] {
  accent-color: var(--accent);
  margin-top: 4px;
  flex-shrink: 0;
}
.option-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: #202b21;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  color: var(--accent);
}

/* Practice mode instant explanation */
.practice-feedback {
  margin-top: 24px;
  padding: 18px 20px;
  border-radius: 8px;
  background: #121913;
  border: 1px solid var(--line);
}
.practice-feedback.correct {
  border-color: #4da659;
  background: #132417;
}
.practice-feedback.wrong {
  border-color: #b35940;
  background: #261715;
}
.practice-feedback h4 {
  margin: 0 0 8px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.practice-feedback p {
  font-size: 12px;
  line-height: 1.7;
  margin: 0;
  color: #cfdbcb;
}

/* Question bottom navigation */
.question-actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.question-actions-bar .nav-group {
  display: flex;
  gap: 10px;
}

/* Question Drawer / Grid Aside */
.exam-aside {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px;
  position: sticky;
  top: 86px;
}
.exam-aside h3 {
  font-size: 13px;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin: 0 0 16px;
  color: var(--muted);
}
.question-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 22px;
}
.grid-item {
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #141b15;
  color: #bdc8b6;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all 0.15s ease;
}
.grid-item:hover {
  border-color: var(--accent);
}
.grid-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}
.grid-item.answered {
  background: #1e3321;
  color: #8ce975;
  border-color: #3b6b3e;
}
.grid-item.flagged::after {
  content: '🚩';
  position: absolute;
  top: -4px;
  right: -4px;
  font-size: 8px;
}

.grid-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 16px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}
.legend-box {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid var(--line);
}
.legend-box.ans { background: #1e3321; border-color: #3b6b3e; }
.legend-box.flag { background: #141b15; position: relative; }
.legend-box.flag::after { content: '🚩'; font-size: 8px; position: absolute; top: 1px; left: 2px; }

/* ==========================================================================
   Scorecard / Results Screen
   ========================================================================== */
.scorecard-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 38px;
  margin: 24px 0 40px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.35);
}
.scorecard-banner {
  text-align: center;
  padding: 32px 20px;
  border-radius: 10px;
  margin-bottom: 32px;
}
.scorecard-banner.passed {
  background: radial-gradient(circle at center, #1b3820 0%, #122215 100%);
  border: 2px solid #4eb559;
}
.scorecard-banner.failed {
  background: radial-gradient(circle at center, #381e19 0%, #201311 100%);
  border: 2px solid #b34a36;
}
.scorecard-status-title {
  font-size: clamp(28px, 4vw, 42px);
  font-family: Space, sans-serif;
  font-weight: 700;
  margin: 8px 0;
}
.scorecard-banner.passed .scorecard-status-title { color: #82f573; }
.scorecard-banner.failed .scorecard-status-title { color: #ff9179; }

.score-display {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  margin: 16px 0;
}
.score-number {
  font-size: clamp(48px, 7vw, 72px);
  font-family: Space, sans-serif;
  font-weight: 700;
  line-height: 1;
  color: #ffffff;
}
.score-scale {
  font-size: 20px;
  color: var(--muted);
}
.score-percentage {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin: 28px 0;
}
.stat-card {
  background: #121813;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 20px;
  text-align: center;
}
.stat-card small {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 1px;
  margin-bottom: 6px;
}
.stat-card strong {
  font-size: 24px;
  font-family: Space, sans-serif;
  color: var(--text);
}

/* Domain / Module breakdown */
.breakdown-section {
  margin: 36px 0;
}
.breakdown-row {
  margin: 16px 0;
  background: #141b15;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 20px;
}
.breakdown-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 12px;
}
.breakdown-bar-bg {
  width: 100%;
  height: 8px;
  background: #253325;
  border-radius: 4px;
  overflow: hidden;
}
.breakdown-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.6s ease;
}
.breakdown-bar-fill.warn { background: #ff9900; }
.breakdown-bar-fill.danger { background: #ff5555; }

/* Questions Review Accordion */
.review-section {
  margin-top: 42px;
}
.review-filters {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.review-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 14px;
  background: #141b15;
  overflow: hidden;
}
.review-card-head {
  padding: 16px 20px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.review-card-head:hover {
  background: #182219;
}
.review-body {
  padding: 20px;
  background: #111712;
  border-top: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.7;
}

/* Hub view (when no curso parameter is specified) */
.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  margin-top: 28px;
}
.hub-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.2s, border-color 0.2s;
}
.hub-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
}
.hub-card-icon {
  width: 38px;
  height: 38px;
  margin-bottom: 14px;
}
.hub-card h3 {
  margin: 0 0 6px;
  font-size: 17px;
}
.hub-card p {
  font-size: 12px;
  line-height: 1.6;
  margin: 0 0 16px;
  color: var(--muted);
  flex-grow: 1;
}

/* Modal confirm finish */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-content {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}
.modal-content h3 {
  margin: 0 0 12px;
  font-size: 20px;
}
.modal-content p {
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 22px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

@media (max-width: 860px) {
  .exam-runner-layout {
    grid-template-columns: 1fr;
  }
  .exam-aside {
    position: static;
    margin-top: 24px;
  }
  .question-panel {
    padding: 20px;
  }
  .scorecard-card {
    padding: 22px;
  }
}
