/* ========================================
   RESET & BASE STYLES
   ======================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #1a5276;
  --primary-light: #2980b9;
  --primary-dark: #0e3450;
  --success: #27ae60;
  --success-light: #d4efdf;
  --danger: #c0392b;
  --danger-light: #f5b7b1;
  --warning: #f39c12;
  --warning-light: #fdebd0;
  --text: #2c3e50;
  --text-light: #7f8c8d;
  --bg: #f5f7fa;
  --card-bg: #ffffff;
  --border: #dce1e8;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
  --transition: 0.2s ease;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ========================================
   SCREEN MANAGEMENT
   ======================================== */
.screen {
  display: none;
}

.screen.active {
  display: block;
}

/* ========================================
   HOME SCREEN
   ======================================== */
.home-container {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 20px 60px;
}

.home-header {
  text-align: center;
  margin-bottom: 32px;
}

.home-header h1 {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.5px;
}

.subtitle {
  font-size: 1.1rem;
  color: var(--text-light);
  margin-top: 4px;
}

.info-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.info-card h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 12px;
}

.info-card p {
  color: var(--text);
  font-size: 0.95rem;
}

.info-card ul {
  list-style: none;
  padding: 0;
}

.info-card ul li {
  padding: 8px 0;
  padding-left: 20px;
  position: relative;
  font-size: 0.95rem;
  color: var(--text);
  border-bottom: 1px solid var(--bg);
}

.info-card ul li:last-child {
  border-bottom: none;
}

.info-card ul li::before {
  content: "\2022";
  color: var(--primary-light);
  font-weight: bold;
  position: absolute;
  left: 0;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.info-item {
  background: var(--bg);
  border-radius: 6px;
  padding: 14px;
  text-align: center;
}

.info-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.info-value {
  display: block;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
}

.category-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.category-tag {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.85rem;
  color: var(--text);
}

/* ========================================
   BUTTONS
   ======================================== */
.btn-primary {
  display: block;
  width: 100%;
  padding: 16px 24px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
  margin-top: 12px;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-primary:disabled {
  background: #b0bec5;
  cursor: not-allowed;
}

.btn-secondary {
  padding: 10px 20px;
  background: transparent;
  color: var(--text-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-secondary:hover {
  border-color: var(--primary-light);
  color: var(--primary);
}

.btn-secondary.flagged {
  border-color: var(--warning);
  color: var(--warning);
  background: var(--warning-light);
}

.btn-small {
  padding: 4px 10px;
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-small:hover {
  background: rgba(255,255,255,0.1);
}

/* ========================================
   EXAM HEADER
   ======================================== */
.exam-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--primary);
  color: #fff;
  padding: 12px 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.exam-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.header-center {
  display: flex;
  align-items: center;
  gap: 12px;
}

.question-counter {
  font-weight: 600;
  font-size: 1rem;
}

.difficulty-badge {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.difficulty-badge.easy {
  background: var(--success);
}

.difficulty-badge.medium {
  background: var(--warning);
  color: var(--text);
}

.difficulty-badge.hard {
  background: var(--danger);
}

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

.timer {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 1.1rem;
  font-weight: 600;
}

.timer.warning {
  color: #f1c40f;
}

.timer.danger {
  color: #e74c3c;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ========================================
   PROGRESS BAR
   ======================================== */
.exam-body {
  max-width: 800px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.progress-bar-container {
  background: var(--border);
  border-radius: 20px;
  height: 8px;
  margin-bottom: 8px;
  position: relative;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-light), var(--primary));
  border-radius: 20px;
  width: 0%;
  transition: width 0.4s ease;
}

.progress-text {
  display: block;
  text-align: right;
  font-size: 0.8rem;
  color: var(--text-light);
  margin-bottom: 20px;
}

/* ========================================
   QUESTION CONTAINER
   ======================================== */
.question-container {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  animation: fadeIn 0.3s ease;
}

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

.question-type-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  background: var(--bg);
  color: var(--text-light);
  border: 1px solid var(--border);
}

.question-type-badge.sata {
  background: #eaf2f8;
  color: var(--primary);
  border-color: var(--primary-light);
}

.question-category {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 16px;
}

.question-stem {
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 1.7;
  color: var(--text);
  margin-bottom: 24px;
}

/* ========================================
   OPTIONS
   ======================================== */
.options-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 0.95rem;
  line-height: 1.5;
}

.option:hover {
  border-color: var(--primary-light);
  background: #f0f7fc;
}

.option.selected {
  border-color: var(--primary);
  background: #e8f0fe;
}

.option-indicator {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
  transition: all var(--transition);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-light);
}

.option-indicator.checkbox {
  border-radius: 4px;
}

.option.selected .option-indicator {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.option-text {
  flex: 1;
}

/* ========================================
   EXAM ACTIONS
   ======================================== */
.exam-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.exam-actions .btn-primary {
  width: auto;
  min-width: 180px;
  margin-top: 0;
}

/* ========================================
   RESULTS SCREEN
   ======================================== */
.results-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 20px 60px;
}

.result-header {
  text-align: center;
  padding: 48px 24px;
  border-radius: 0 0 var(--radius) var(--radius);
  margin-bottom: 24px;
}

.result-header.pass {
  background: linear-gradient(135deg, #27ae60, #2ecc71);
  color: #fff;
}

.result-header.fail {
  background: linear-gradient(135deg, #c0392b, #e74c3c);
  color: #fff;
}

.result-header h1 {
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.result-header p {
  font-size: 1.1rem;
  opacity: 0.9;
}

.results-summary {
  margin-bottom: 24px;
}

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

.summary-item {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow);
}

.summary-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.summary-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

/* ========================================
   CATEGORY BREAKDOWN
   ======================================== */
.category-breakdown {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.category-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.category-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.category-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

.category-score {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-light);
}

.category-bar-bg {
  height: 10px;
  background: var(--bg);
  border-radius: 5px;
  overflow: hidden;
}

.category-bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.6s ease;
}

.category-bar-fill.high {
  background: var(--success);
}

.category-bar-fill.mid {
  background: var(--warning);
}

.category-bar-fill.low {
  background: var(--danger);
}

/* ========================================
   QUESTION REVIEW
   ======================================== */
.review-instructions {
  margin-bottom: 16px;
  font-size: 0.9rem;
  color: var(--text-light);
}

.question-review {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 600px;
  overflow-y: auto;
}

.review-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition);
  font-size: 0.9rem;
}

.review-item:hover {
  background: var(--bg);
}

.review-item.expanded {
  flex-direction: column;
  align-items: flex-start;
  background: var(--bg);
}

.review-item-header {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.review-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
}

.review-icon.correct {
  background: var(--success);
}

.review-icon.incorrect {
  background: var(--danger);
}

.review-number {
  font-weight: 600;
  color: var(--text);
  min-width: 30px;
}

.review-stem {
  flex: 1;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.review-flag {
  color: var(--warning);
  font-size: 1rem;
}

.review-detail {
  width: 100%;
  padding: 16px 0 4px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

.review-detail .question-stem {
  font-size: 0.95rem;
  margin-bottom: 16px;
}

.review-detail .review-option {
  padding: 8px 12px;
  margin-bottom: 6px;
  border-radius: 6px;
  font-size: 0.9rem;
}

.review-option.user-selected {
  border-left: 3px solid var(--primary);
  background: #e8f0fe;
}

.review-option.correct-answer {
  border-left: 3px solid var(--success);
  background: var(--success-light);
}

.review-option.wrong-selected {
  border-left: 3px solid var(--danger);
  background: var(--danger-light);
}

.rationale {
  margin-top: 12px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  line-height: 1.6;
}

.rationale-label {
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
  display: block;
}

/* ========================================
   RESULTS ACTIONS
   ======================================== */
.results-actions {
  text-align: center;
  margin-top: 32px;
}

.results-actions .btn-primary {
  max-width: 320px;
  margin: 0 auto;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
  .home-header h1 {
    font-size: 2rem;
  }

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

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

  .exam-header {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 16px;
  }

  .header-left {
    display: none;
  }

  .exam-body {
    padding: 16px 12px 48px;
  }

  .question-container {
    padding: 20px 16px;
  }

  .exam-actions {
    flex-direction: column;
  }

  .exam-actions .btn-primary {
    width: 100%;
  }

  .review-stem {
    max-width: 180px;
  }
}

@media (max-width: 480px) {
  .info-grid {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    grid-template-columns: 1fr 1fr;
  }

  .home-container {
    padding: 24px 12px 40px;
  }
}
