/* Typingram Two-Box Engine & Exam Simulator Stylesheet */

.exam-simulator-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 1.5rem;
  margin: 1.5rem 0;
}

/* Exam Header Controls */
.exam-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1.25rem;
}

.exam-info-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.exam-badge {
  background: #2563eb;
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 4px 10px;
  border-radius: 4px;
  text-transform: uppercase;
}

.timer-box {
  background: var(--bg-main);
  border: 2px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-family: monospace;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.timer-box.warning {
  border-color: var(--warning);
  color: var(--warning);
}

.timer-box.danger {
  border-color: var(--danger);
  color: var(--danger);
  animation: pulse-danger 1s infinite alternate;
}

@keyframes pulse-danger {
  from { opacity: 1; }
  to { opacity: 0.6; }
}

.timer-select-control {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  outline: none;
}

.timer-select-control:focus {
  border-color: var(--primary);
}

.engine-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.font-btn {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 34px;
  height: 34px;
  border-radius: 4px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

/* Lesson Switcher Grid */
.lesson-navigation-bar {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1.25rem;
}

.lesson-nav-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 0.75rem;
}

.lesson-pagination-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-lesson-nav {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 4px 12px;
  border-radius: 4px;
  font-weight: 800;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: all 0.15s ease;
}

.btn-lesson-nav:hover:not(:disabled) {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.simulator-submit-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.lesson-nav-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.lesson-chips-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 140px;
  overflow-y: auto;
  padding: 4px;
}

.lesson-chip-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 5px 11px;
  border-radius: 4px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.lesson-chip-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.lesson-chip-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 4px rgba(37,99,235,0.3);
}

/* Two-Box Display */
.two-box-layout {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.box-wrapper {
  display: flex;
  flex-direction: column;
}

.box-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.master-box {
  height: 200px;
  overflow-y: scroll;
  padding: 1.25rem;
  background: var(--bg-main);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--text-main);
  user-select: none;
  font-family: inherit;
  white-space: pre-wrap;
  scrollbar-width: thin;
}

.master-box::-webkit-scrollbar {
  width: 8px;
}

.master-box::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.user-typing-area {
  width: 100%;
  height: 200px;
  padding: 1.25rem;
  background: var(--bg-card);
  border: 2px solid var(--primary);
  border-radius: var(--radius-sm);
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--text-main);
  font-family: inherit;
  outline: none;
  resize: vertical;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.04);
}

.user-typing-area:focus {
  border-color: var(--primary-hover);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.2);
}

/* Live Stats Bar */
.live-stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-top: 1rem;
}

.stat-item {
  display: flex;
  flex-direction: column;
}

.stat-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
}

.stat-val {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
}

/* Exam Action Buttons */
.exam-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 1.25rem;
}

/* Modal Scorecard */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 1.5rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 780px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  padding: 2rem;
  animation: modal-pop 0.25s ease-out;
}

@keyframes modal-pop {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
}

.scorecard-banner {
  padding: 1.25rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  text-align: center;
}

.scorecard-banner.pass {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid #10b981;
  color: #065f46;
}

.scorecard-banner.fail {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid #ef4444;
  color: #991b1b;
}

.scorecard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.score-box {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1rem;
  text-align: center;
}

.score-box-num {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--primary);
  margin-top: 4px;
}

.error-breakdown-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.9rem;
}

.error-breakdown-table th, .error-breakdown-table td {
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  text-align: left;
}

.error-breakdown-table th {
  background: var(--bg-main);
  font-weight: 700;
}

/* Advertising Placeholders & Split Layout */
.typing-page-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  margin: 1.5rem 0;
}

.typing-main-column {
  flex: 1;
  min-width: 0;
}

.typing-ad-sidebar {
  width: 300px;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 90px;
}

.ad-slot {
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 10px rgba(0,0,0,0.02);
}

.ad-slot .ad-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #94a3b8;
  margin-bottom: 6px;
}

.ad-slot .ad-subtext {
  font-size: 0.82rem;
  color: #cbd5e1;
}

.ad-leaderboard {
  width: 100%;
  height: 90px;
  margin: 1.5rem 0;
}

.ad-skyscraper {
  width: 100%;
  height: 600px;
}

.ad-rectangle-mid {
  width: 100%;
  height: 120px;
  margin: 2rem 0;
}

.ad-banner-bottom {
  width: 100%;
  height: 90px;
  margin: 2rem 0 1rem;
}

/* Overlap Mode Styling */
.overlap-toggle-btn {
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.overlap-toggle-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.overlap-toggle-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* In Overlap Mode, candidate types directly on visual characters */
.overlap-box-active .user-typing-area {
  display: none !important;
}

.overlap-display-stage {
  display: none;
  height: 280px;
  overflow-y: auto;
  padding: 1.25rem;
  background: var(--bg-card);
  border: 2px solid var(--primary);
  border-radius: var(--radius-sm);
  font-size: 1.2rem;
  line-height: 2.2;
  font-family: inherit;
  outline: none;
  cursor: text;
}

.overlap-box-active .master-box {
  display: none !important;
}

.overlap-box-active .overlap-display-stage {
  display: block !important;
}

.char-span {
  position: relative;
  transition: color 0.05s;
}

.char-span.correct {
  color: #10b981;
  font-weight: 700;
}

.char-span.incorrect {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.2);
  border-radius: 2px;
}

.char-span.current {
  color: var(--primary);
  border-bottom: 3px solid var(--primary);
  background: rgba(37, 99, 235, 0.1);
  padding-bottom: 2px;
}

@media (max-width: 992px) {
  .typing-page-layout {
    flex-direction: column;
  }
  .typing-ad-sidebar {
    width: 100%;
    position: static;
  }
  .ad-skyscraper {
    height: 180px;
  }
}
