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

:root {
  --primary: #4f46e5;
  --primary-light: #eef2ff;
  --primary-dark: #3730a3;
  --secondary: #0ea5e9;
  --secondary-light: #f0f9ff;
  --bg-app: #f3f4f6;
  --bg-card: #ffffff;
  --border-color: #e5e7eb;
  --text-main: #1f2937;
  --text-muted: #6b7280;
  --success: #10b981;
  --success-light: #ecfdf5;
  --success-dark: #065f46;
  --error: #ef4444;
  --error-light: #fef2f2;
  --error-dark: #991b1b;
  --accent: #f59e0b;
  --accent-light: #fef3c7;
  --radius: 16px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Sarabun', 'Inter', sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* 16:9 Viewport Box (For PC/Screens) */
.viewport-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  padding: 15px;
}

.quiz-container {
  width: 100%;
  height: 100%;
  aspect-ratio: 16 / 9;
  max-width: calc((100vh - 30px) * 16 / 9);
  max-height: calc((100vw - 30px) * 9 / 16);
  
  background-color: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: var(--transition);
}

/* Header */
.quiz-header {
  height: 65px;
  min-height: 65px;
  border-bottom: 1px solid var(--border-color);
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, #ffffff 0%, #fafafa 100%);
}

.quiz-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60%;
}

.student-info-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  background-color: var(--primary-light);
  color: var(--primary-dark);
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 500;
}

.student-info-badge span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.student-info-badge .separator {
  color: var(--primary);
  opacity: 0.3;
}

/* Main Viewport Grid */
.quiz-main {
  flex: 1;
  display: flex;
  overflow: hidden; /* prevents layout breakage */
}

/* Left Panel: Scenario + Explanation */
.panel-left {
  width: 50%;
  height: 100%;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-color);
  background-color: #fafafa;
}

.scenario-section {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.scenario-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.scenario-title::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 16px;
  background-color: var(--primary);
  border-radius: 2px;
}

.scenario-content {
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--text-main);
  text-align: justify;
}

.explanation-section {
  height: 42%;
  min-height: 150px;
  border-top: 1px solid var(--border-color);
  background-color: #ffffff;
  padding: 20px 24px;
  overflow-y: auto;
  transition: var(--transition);
  position: relative;
}

.explanation-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--success-dark);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.explanation-title::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 16px;
  background-color: var(--success);
  border-radius: 2px;
}

.explanation-content {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-main);
}

.explanation-placeholder {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  gap: 8px;
}

/* Right Panel: Question + Choices + Actions */
.panel-right {
  width: 50%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background-color: #ffffff;
}

.question-section {
  padding: 24px;
  border-bottom: 1px solid var(--border-color);
  overflow-y: auto;
  max-height: 35%;
}

.question-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.question-number {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  background-color: var(--primary-light);
  padding: 3px 10px;
  border-radius: 6px;
}

.question-text {
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.6;
  color: var(--text-main);
}

.choices-section {
  flex: 1;
  padding: 20px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Option Cards styling */
.choice-card {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  cursor: pointer;
  background-color: #ffffff;
  transition: var(--transition);
  position: relative;
  user-select: none;
}

.choice-card:hover:not(.disabled) {
  border-color: var(--primary);
  background-color: var(--primary-light);
  transform: translateY(-1px);
}

.choice-card.selected {
  border-color: var(--primary);
  background-color: var(--primary-light);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
}

.choice-prefix {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  background-color: var(--bg-app);
  color: var(--text-muted);
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: 700;
  font-size: 13px;
  margin-right: 14px;
  border: 1px solid var(--border-color);
  transition: var(--transition);
}

.choice-card:hover:not(.disabled) .choice-prefix {
  background-color: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.choice-card.selected .choice-prefix {
  background-color: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.choice-text {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-main);
}

/* Correct/Incorrect states */
.choice-card.correct {
  border-color: var(--success);
  background-color: var(--success-light);
}

.choice-card.correct .choice-prefix {
  background-color: var(--success);
  color: #ffffff;
  border-color: var(--success);
}

.choice-card.incorrect {
  border-color: var(--error);
  background-color: var(--error-light);
}

.choice-card.incorrect .choice-prefix {
  background-color: var(--error);
  color: #ffffff;
  border-color: var(--error);
}

.choice-card.disabled {
  cursor: not-allowed;
}

/* Status Indicator Icons */
.choice-status-icon {
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Actions Section */
.actions-section {
  height: 70px;
  min-height: 70px;
  padding: 0 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #fafafa;
}

/* Progress bar inside footer */
.progress-bar-container {
  width: 40%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-bar-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.progress-bar-track {
  height: 6px;
  background-color: var(--border-color);
  border-radius: 9999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background-color: var(--primary);
  width: 0%;
  transition: width 0.4s ease;
}

/* Buttons */
.btn {
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 10px 24px;
  border-radius: 9999px;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-dark);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  background-color: var(--text-muted);
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  background-color: #ffffff;
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

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

/* Welcome Page & Registration */
.welcome-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  padding: 40px;
  background: linear-gradient(135deg, #ffffff 0%, #f9fafb 100%);
  text-align: center;
}

.welcome-logo-container {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.welcome-logo {
  max-width: 140px;
  max-height: 140px;
  object-fit: contain;
}

.welcome-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 8px;
}

.welcome-subtitle {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 28px;
  max-width: 600px;
  line-height: 1.5;
}

.register-card {
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  padding: 28px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.form-input, .form-select {
  font-family: inherit;
  font-size: 14px;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  outline: none;
  background-color: #fafafa;
  transition: var(--transition);
}

.form-input:focus, .form-select:focus {
  border-color: var(--primary);
  background-color: #ffffff;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Summary and Results View */
.result-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  padding: 24px;
  background: #ffffff;
  overflow: hidden;
}

.result-header {
  text-align: center;
  margin-bottom: 20px;
}

.result-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 4px;
}

.result-card-grid {
  display: flex;
  gap: 20px;
  flex: 1;
  overflow: hidden;
  margin-bottom: 16px;
}

.score-summary-card {
  width: 35%;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: #fafafa;
  text-align: center;
}

.score-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: conic-gradient(var(--primary) calc(var(--percentage) * 1%), var(--border-color) 0);
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 16px;
  position: relative;
}

.score-circle::before {
  content: '';
  position: absolute;
  width: 102px;
  height: 102px;
  border-radius: 50%;
  background-color: #fafafa;
}

.score-circle-text {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.score-val {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1;
}

.score-total {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.badge-pass {
  background-color: var(--success-light);
  color: var(--success-dark);
  font-weight: 700;
  font-size: 14px;
  padding: 6px 16px;
  border-radius: 9999px;
  border: 1px solid var(--success);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.badge-fail {
  background-color: var(--error-light);
  color: var(--error-dark);
  font-weight: 700;
  font-size: 14px;
  padding: 6px 16px;
  border-radius: 9999px;
  border: 1px solid var(--error);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.details-review-card {
  width: 65%;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.review-list-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.review-scroll-container {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 4px;
}

.review-item {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background-color: #fafafa;
}

.review-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.review-item-q {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.4;
}

.review-ans-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  padding-left: 10px;
  border-left: 2px solid var(--border-color);
}

.review-ans-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.review-ans-correct {
  color: var(--success-dark);
  font-weight: 500;
}

.review-ans-user {
  color: var(--text-main);
}

.review-ans-user.wrong {
  color: var(--error-dark);
  text-decoration: line-through;
}

.review-explanation {
  font-size: 11.5px;
  color: var(--text-muted);
  background-color: #ffffff;
  padding: 6px 10px;
  border-radius: 4px;
  border-left: 2px solid var(--primary);
  margin-top: 4px;
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  height: 50px;
  align-items: center;
}

/* Loading Overlay */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.85);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 10;
  gap: 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--primary-dark);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--primary-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ADMIN PANEL STYLING */
.admin-wrapper {
  width: 100%;
  max-width: 1100px;
  height: calc(100vh - 40px);
  margin: 20px auto;
  background-color: #ffffff;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.admin-header {
  height: 70px;
  border-bottom: 1px solid var(--border-color);
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #fafafa;
}

.admin-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-badge {
  background-color: #fef3c7;
  color: #92400e;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 9999px;
  border: 1px solid #f59e0b;
}

.admin-main {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.admin-left {
  width: 38%;
  border-right: 1px solid var(--border-color);
  padding: 24px;
  overflow-y: auto;
  background-color: #fcfcfd;
}

.admin-right {
  width: 62%;
  padding: 24px;
  overflow-y: auto;
}

.panel-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 12.5px;
}

.admin-table th, .admin-table td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--border-color);
}

.admin-table th {
  font-weight: 600;
  background-color: #fafafa;
  color: var(--text-muted);
}

.admin-table tbody tr:hover {
  background-color: #f9fafb;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 22px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: .4s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--success);
}

input:checked + .slider:before {
  transform: translateX(22px);
}

.action-btn-group {
  display: flex;
  gap: 8px;
}

.btn-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background-color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.btn-icon:hover {
  background-color: var(--error-light);
  border-color: var(--error);
  color: var(--error);
}

.csv-format-help {
  margin-top: 24px;
  padding: 16px;
  background-color: var(--primary-light);
  border: 1px solid rgba(79, 70, 229, 0.15);
  border-radius: 8px;
}

.csv-format-help h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 8px;
}

.csv-format-help p, .csv-format-help li {
  font-size: 11.5px;
  color: var(--primary-dark);
  opacity: 0.85;
  line-height: 1.5;
}

.csv-format-help ul {
  margin-left: 16px;
  margin-top: 4px;
}

.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  width: 100vw;
  background-color: var(--bg-app);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background-color: #ffffff;
  padding: 32px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Scenario Images Gallery */
.scenario-images-container {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.scenario-img-thumb {
  height: 60px;
  width: auto;
  max-width: 90px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  cursor: pointer;
  background-color: #f1f5f9;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.scenario-img-thumb:hover {
  transform: scale(1.06) translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

/* Reusable Fullscreen Lightbox */
.lightbox-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(15, 23, 42, 0.85); /* Slate-900 with alpha */
  backdrop-filter: blur(8px);
  z-index: 99999;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.lightbox-modal.show {
  display: flex;
  opacity: 1;
}

.lightbox-content {
  max-width: 85%;
  max-height: 85%;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  border: 3px solid rgba(255, 255, 255, 0.1);
  transform: scale(0.92);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.lightbox-modal.show .lightbox-content {
  transform: scale(1);
}

.lightbox-close {
  position: absolute;
  top: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-size: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  border: none;
  transition: var(--transition);
}

.lightbox-close:hover {
  background-color: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  transform: rotate(90deg);
}

/* Admin Image Thumbnails preview */
.admin-images-wrapper {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.admin-img-preview {
  height: 32px;
  width: auto;
  max-width: 50px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: var(--transition);
}

.admin-img-preview:hover {
  transform: scale(1.1);
  border-color: var(--primary);
}

/* ==========================================================================
   REDESIGNED ADMIN PANEL LAYOUT & CSV EDITOR
   ========================================================================== */
.admin-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-color: #f8fafc;
}

.admin-sidebar {
  width: 260px;
  min-width: 260px;
  background-color: #1e1b4b; /* Deep Indigo */
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  height: 100%;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-sidebar-header {
  padding: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-sidebar-logo {
  font-size: 26px;
}

.admin-sidebar-logo-img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border-radius: 8px;
  background-color: #ffffff;
  padding: 3px;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.admin-sidebar-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.35;
}

.admin-menu-list {
  list-style: none;
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.admin-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  color: #cbd5e1;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition);
}

.admin-menu-item:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: #ffffff;
}

.admin-menu-item.active {
  background-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 12px -2px rgba(79, 70, 229, 0.25);
}

.admin-sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 11px;
  color: #94a3b8;
  text-align: center;
}

.admin-content-area {
  flex: 1;
  height: 100%;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
}

.admin-content-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.admin-content-title {
  font-size: 19px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-card {
  background-color: #ffffff;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  margin-bottom: 20px;
}

.admin-split-layout {
  display: flex;
  gap: 24px;
  flex: 1;
}

.admin-split-left {
  width: 38%;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.admin-split-right {
  width: 62%;
}

/* CSV Questions Editor Layouts */
.editor-question-row {
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  background-color: #ffffff;
  transition: var(--transition);
  position: relative;
}

.editor-question-row:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.editor-question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #f1f5f9;
}

.editor-question-title {
  font-weight: 700;
  color: var(--primary-dark);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.editor-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 12px;
}

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

.btn-danger {
  background-color: var(--error);
  color: #ffffff;
}

.btn-danger:hover {
  background-color: var(--error-dark);
}

.btn-success {
  background-color: var(--success);
  color: #ffffff;
}

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

/* Modal and Utility Styles */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 20px;
}

.admin-modal {
  background-color: #ffffff;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 480px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: auto;
}

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

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary-dark);
}

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
}

.modal-close:hover {
  color: var(--error);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--border-color);
  padding-top: 12px;
}

/* Print Styles */
@media print {
  html, body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 12pt;
    height: auto !important;
    width: auto !important;
    overflow: visible !important; /* Allow document scrolling for printing */
  }
  
  .viewport-wrapper {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .quiz-container {
    display: block !important;
    border: none !important;
    box-shadow: none !important;
    max-width: none !important;
    max-height: none !important;
    width: 100% !important;
    height: auto !important;
    background: transparent !important;
    overflow: visible !important; /* Crucial: allow container to expand vertically */
    aspect-ratio: auto !important; /* Crucial: remove aspect ratio limit on print */
    padding: 0 !important;
    margin: 0 !important;
  }

  /* Hide everything except the result view */
  .quiz-header, .quiz-main, .loading-overlay, .print-hide {
    display: none !important;
  }

  /* Ensure result view fills the page and flows naturally */
  #result-view {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
  }

  .result-card-grid {
    display: block !important; /* Stack vertically for print to prevent column clipping */
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .score-summary-card {
    width: 100% !important;
    max-width: 500px !important;
    margin: 0 auto 30px auto !important; /* Center the scorecard at the top */
    border: 1px solid #ccc !important;
    background: #fafafa !important;
    padding: 24px 15px !important;
    height: auto !important;
    display: block !important; 
    text-align: center !important;
  }

  .score-circle {
    margin: 0 auto 16px auto !important;
    display: flex !important; /* Keep flex inside circle as it has fixed dimensions */
  }

  #status-badge {
    display: inline-block !important;
    margin: 10px auto !important;
  }

  .details-review-card {
    width: 100% !important; /* Full width for high readability */
    border: none !important;
    padding: 0 !important;
    margin-top: 20px !important;
    height: auto !important;
    overflow: visible !important;
  }

  /* If print-no-review class is applied, hide detailed review */
  #result-view.print-no-review .details-review-card {
    display: none !important;
  }
  
  #result-view.print-no-review .score-summary-card {
    margin: 40px auto !important;
  }

  /* Crucial: Expand scroll container to print all items */
  .review-scroll-container {
    overflow: visible !important;
    max-height: none !important;
    height: auto !important;
  }

  .review-item {
    page-break-inside: avoid !important;
    border: 1px solid #ddd !important;
    background: #fafafa !important;
  }
}

/* Responsive Styles for Mobile / Portrait Screens */
@media screen and (max-width: 1024px), screen and (max-height: 620px), screen and (orientation: portrait) {
  body {
    height: auto !important;
    min-height: 100vh !important;
    overflow-y: auto !important; /* Allow scrolling on body for mobile */
    align-items: flex-start !important;
  }

  .viewport-wrapper {
    padding: 0 !important;
    height: auto !important;
    min-height: 100vh !important;
    display: block !important;
    width: 100% !important;
  }

  .quiz-container {
    aspect-ratio: auto !important; /* Disable 16:9 box */
    max-width: none !important;
    max-height: none !important;
    height: auto !important;
    min-height: 100vh !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
  }

  /* Stack panels vertically on mobile screen */
  .quiz-main {
    flex-direction: column !important;
    overflow: visible !important;
    height: auto !important;
  }

  .panel-left, .panel-right {
    width: 100% !important;
    height: auto !important;
  }

  .panel-left {
    border-right: none !important;
    border-bottom: 1px solid var(--border-color) !important;
  }

  .scenario-section {
    max-height: 350px !important; /* Limit height and scroll scenario description */
    overflow-y: auto !important;
    padding: 20px 16px !important;
  }

  .explanation-section {
    height: auto !important;
    min-height: unset !important;
    padding: 16px !important;
  }

  .question-section {
    max-height: none !important;
    padding: 20px 16px !important;
  }

  .choices-section {
    overflow-y: visible !important;
    padding: 16px !important;
  }

  .actions-section {
    position: sticky !important;
    bottom: 0 !important;
    z-index: 100 !important;
    background-color: #fafafa !important;
    border-top: 1px solid var(--border-color) !important;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.05) !important;
    padding: 0 16px !important;
  }

  /* Registration page on mobile */
  .welcome-container {
    padding: 32px 16px !important;
    height: auto !important;
    min-height: 100vh !important;
    justify-content: flex-start !important;
  }
  
  .welcome-title {
    font-size: 18px !important;
    margin-top: 12px !important;
  }
  
  .welcome-subtitle {
    font-size: 13px !important;
    margin-bottom: 24px !important;
  }

  .register-card {
    padding: 20px 16px !important;
    width: 100% !important;
    box-shadow: none !important;
    border: none !important;
    background: transparent !important;
  }

  /* Results page on mobile */
  .result-container {
    padding: 20px 16px !important;
    height: auto !important;
    min-height: 100vh !important;
  }

  .result-card-grid {
    flex-direction: column !important;
    height: auto !important;
    overflow: visible !important;
  }

  .score-summary-card {
    width: 100% !important;
    margin-bottom: 16px !important;
    padding: 24px 16px !important;
  }

  .details-review-card {
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
    padding: 16px !important;
  }
  
  .review-scroll-container {
    max-height: none !important;
    overflow: visible !important;
  }

  .result-actions {
    flex-direction: column !important;
    height: auto !important;
    gap: 12px !important;
    margin-top: 24px !important;
    padding-bottom: 24px !important;
  }

  .result-actions .btn, .result-actions div {
    width: 100% !important;
    justify-content: center !important;
  }
}

