/* ==========================================================================
   School Testing Portal - Very Light & Minimal Professional CSS Design System
   ========================================================================== */

:root {
  --bg-main: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --border-color: #e2e8f0;
  --border-hover: #cbd5e1;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eeeffe;
  
  --success: #059669;
  --success-bg: #ecfdf5;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --info: #0284c7;
  --info-bg: #f0f9ff;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
  
  --font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --transition: all 0.2s ease-in-out;
}

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

svg {
  max-width: 100%;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 0.95rem;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Layout Elements */
.app-header {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text-main);
}

.brand-logo svg {
  color: var(--primary);
  width: 28px !important;
  height: 28px !important;
  min-width: 28px !important;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  list-style: none;
}

.nav-link {
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.9rem;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.nav-link:hover, .nav-link.active {
  color: var(--primary);
  background-color: var(--primary-light);
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
}

.role-tag {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background-color: var(--primary);
  color: #ffffff;
}

.role-tag.admin { background-color: #0f172a; }
.role-tag.teacher { background-color: #4f46e5; }
.role-tag.student { background-color: #059669; }

.main-content {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
}

.page-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* Cards & Panels */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

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

.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-main);
}

/* Form Controls */
.form-group {
  margin-bottom: 1.2rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.form-control, .form-select {
  width: 100%;
  padding: 0.6rem 0.85rem;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text-main);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.form-control:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition);
  white-space: nowrap;
}

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

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

.btn-secondary {
  background-color: var(--bg-subtle);
  color: var(--text-main);
  border-color: var(--border-color);
}

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

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

.btn-success:hover {
  background-color: #047857;
}

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

.btn-danger:hover {
  background-color: #b91c1c;
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

.table th {
  background-color: var(--bg-subtle);
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
  color: var(--text-main);
}

.table tbody tr:hover {
  background-color: var(--bg-subtle);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success { background-color: var(--success-bg); color: var(--success); }
.badge-warning { background-color: var(--warning-bg); color: var(--warning); }
.badge-danger { background-color: var(--danger-bg); color: var(--danger); }
.badge-info { background-color: var(--info-bg); color: var(--info); }
.badge-secondary { background-color: var(--bg-subtle); color: var(--text-muted); }

/* Catchy Alert Messages */
.alert {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid transparent;
  box-shadow: var(--shadow-sm);
  animation: slideDownAlert 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes slideDownAlert {
  from { transform: translateY(-10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.alert-success {
  background-color: var(--success-bg);
  color: #065f46;
  border-color: #a7f3d0;
  border-left: 4px solid var(--success);
}

.alert-danger {
  background-color: var(--danger-bg);
  color: #991b1b;
  border-color: #fecaca;
  border-left: 4px solid var(--danger);
}

.alert-info {
  background-color: var(--info-bg);
  color: #075985;
  border-color: #bae6fd;
  border-left: 4px solid var(--info);
}

/* ==========================================================================
   CATCHY CUSTOM CONFIRMATION & ALERT MODAL
   ========================================================================== */
.catchy-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  z-index: 100000;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.catchy-modal-overlay.active {
  display: flex;
  opacity: 1;
}

.catchy-modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  max-width: 420px;
  width: 90%;
  text-align: center;
  animation: modalScaleUp 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalScaleUp {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.catchy-modal-icon-box {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--danger-bg);
  color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem auto;
  box-shadow: 0 0 0 6px #fef2f2;
}

.catchy-modal-icon-box svg {
  width: 32px !important;
  height: 32px !important;
}

.catchy-modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.catchy-modal-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.catchy-modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.catchy-modal-actions .btn {
  flex: 1;
  padding: 0.65rem 1rem;
}

/* Grid Dashboard Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.1;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 0.25rem;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background-color: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* MCQ Interactive Builder & Exam View */
.mcq-option-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  background-color: var(--bg-subtle);
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.mcq-option-radio {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

.mcq-student-option {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.9rem 1.1rem;
  background-color: var(--bg-surface);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 0.75rem;
  cursor: pointer;
  transition: var(--transition);
}

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

.mcq-student-option.selected {
  border-color: var(--primary);
  background-color: var(--primary-light);
}

.mcq-option-letter {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background-color: var(--bg-subtle);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mcq-student-option.selected .mcq-option-letter {
  background-color: var(--primary);
  color: #ffffff;
}

/* Question Navigator Palette */
.q-palette {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
  gap: 0.5rem;
  margin-top: 1rem;
}

.q-palette-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  color: var(--text-main);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.q-palette-btn.answered {
  background-color: var(--success-bg);
  border-color: var(--success);
  color: var(--success);
}

.q-palette-btn.current {
  border-color: var(--primary);
  background-color: var(--primary-light);
  color: var(--primary);
  font-weight: 800;
  box-shadow: 0 0 0 2px var(--primary);
}

/* Countdown Timer */
.exam-timer-box {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  color: var(--danger);
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   TESTING-THEMED ANIMATED SCREEN LOADER
   ========================================================================== */
.app-loader-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(248, 250, 252, 0.92);
  backdrop-filter: blur(5px);
  z-index: 99999;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.app-loader-overlay.active {
  display: flex;
  opacity: 1;
}

.loader-content-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2.25rem 2.5rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 380px;
  width: 90%;
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.testing-loader-icon-box {
  position: relative;
  width: 80px;
  height: 80px;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.testing-loader-ring {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 3.5px dashed var(--primary);
  border-radius: 50%;
  animation: spinRing 3s linear infinite;
}

@keyframes spinRing {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.testing-loader-paper {
  width: 50px;
  height: 50px;
  background: var(--primary-light);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.15);
  animation: pulseIcon 1.5s ease-in-out infinite alternate;
}

.testing-loader-paper svg {
  width: 28px !important;
  height: 28px !important;
  max-width: 28px !important;
  max-height: 28px !important;
}

@keyframes pulseIcon {
  0% { transform: scale(0.95); }
  100% { transform: scale(1.05); }
}

.pencil-write-anim {
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 26px;
  height: 26px;
  background: var(--success);
  color: #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  animation: checkBounce 1.2s ease-in-out infinite;
}

.pencil-write-anim svg {
  width: 14px !important;
  height: 14px !important;
  max-width: 14px !important;
  max-height: 14px !important;
}

@keyframes checkBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-4px) scale(1.15); }
}

.loader-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.loader-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.loader-progress-bar {
  width: 100%;
  height: 4px;
  background: var(--bg-subtle);
  border-radius: 4px;
  margin-top: 1.2rem;
  overflow: hidden;
  position: relative;
}

.loader-progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 40%;
  background: linear-gradient(90deg, var(--primary), #818cf8);
  border-radius: 4px;
  animation: progressAnim 1.4s ease-in-out infinite;
}

@keyframes progressAnim {
  0% { left: -40%; width: 30%; }
  50% { width: 60%; }
  100% { left: 100%; width: 30%; }
}

/* Footer */
.app-footer {
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  padding: 1rem 1.25rem;
  text-align: center;
  font-size: 0.825rem;
  color: var(--text-muted);
  margin-top: auto;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .nav-container {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  .nav-links {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 0.25rem;
  }
  .page-title-bar {
    flex-direction: column;
    align-items: flex-start;
  }
  .main-content {
    padding: 1rem 0.75rem;
  }
}
