/* ===== CSS Variables & Reset ===== */
:root {
  --primary: #6C63FF;
  --primary-dark: #5A52D5;
  --primary-light: #8B85FF;
  --secondary: #FF6584;
  --success: #28C76F;
  --warning: #FF9F43;
  --danger: #EA5455;
  --info: #00CFE8;
  --dark: #1E1E2D;
  --dark-2: #2D2D3F;
  --dark-3: #3B3B4F;
  --text: #E0E0E0;
  --text-muted: #8A8A9A;
  --bg: #12121A;
  --bg-card: #1A1A2E;
  --bg-input: #16213E;
  --border: #2A2A3C;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0,0,0,0.3);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

a { color: var(--primary-light); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--dark-3); border-radius: 3px; }

/* ===== Login Page ===== */
.login-container {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0F0C29 0%, #302B63 50%, #24243E 100%);
  padding: 20px;
}

.login-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 48px 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow);
}

.login-box .logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-box .logo h1 {
  font-size: 28px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 800;
}

.login-box .logo p {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}

.tab-switcher {
  display: flex;
  background: var(--dark);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 28px;
}

.tab-switcher button {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: var(--transition);
}

.tab-switcher button.active {
  background: var(--primary);
  color: #fff;
}

/* ===== Forms ===== */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  transition: var(--transition);
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.15);
}

.form-group textarea {
  resize: vertical;
  min-height: 100px;
}

.form-group input::placeholder { color: var(--text-muted); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  width: 100%;
}

.btn-primary:hover { box-shadow: 0 4px 15px rgba(108, 99, 255, 0.4); }

.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-info { background: var(--info); color: #fff; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.btn-sm { padding: 8px 16px; font-size: 13px; border-radius: 8px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }

.btn-icon {
  width: 36px; height: 36px; padding: 0;
  border-radius: 8px; font-size: 16px;
}

/* ===== Dashboard Layout ===== */
.dashboard {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: var(--transition);
}

.sidebar .brand {
  font-size: 22px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  padding: 0 8px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.sidebar-nav { flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  color: var(--text-muted);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 4px;
  border: none;
  background: none;
  width: 100%;
  font-size: 14px;
  text-align: left;
}

.nav-item:hover { background: var(--dark); color: var(--text); }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item .icon { font-size: 18px; width: 24px; text-align: center; }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
}

.user-details { flex: 1; }
.user-details .name { font-weight: 600; font-size: 14px; }
.user-details .role { font-size: 12px; color: var(--text-muted); text-transform: capitalize; }

.main-content {
  flex: 1;
  margin-left: 260px;
  padding: 32px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
}

.page-header h2 {
  font-size: 24px;
  font-weight: 700;
}

.page-header .subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 2px;
}

/* ===== Stats Cards ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: var(--transition);
}

.stat-card:hover { border-color: var(--primary); transform: translateY(-2px); }

.stat-card .stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 16px;
}

.stat-card .stat-icon.purple { background: rgba(108,99,255,0.15); color: var(--primary); }
.stat-card .stat-icon.green { background: rgba(40,199,111,0.15); color: var(--success); }
.stat-card .stat-icon.orange { background: rgba(255,159,67,0.15); color: var(--warning); }
.stat-card .stat-icon.red { background: rgba(234,84,85,0.15); color: var(--danger); }
.stat-card .stat-icon.blue { background: rgba(0,207,232,0.15); color: var(--info); }

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 4px;
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ===== Cards & Panels ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

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

.card-header h3 { font-size: 18px; font-weight: 700; }

/* ===== Tables ===== */
.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  text-align: left;
  padding: 12px 16px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 14px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

tbody tr:hover { background: rgba(108,99,255,0.05); }

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}

.badge-live { background: rgba(234,84,85,0.15); color: var(--danger); }
.badge-scheduled { background: rgba(255,159,67,0.15); color: var(--warning); }
.badge-completed { background: rgba(40,199,111,0.15); color: var(--success); }
.badge-draft { background: rgba(138,138,154,0.15); color: var(--text-muted); }
.badge-pass { background: rgba(40,199,111,0.15); color: var(--success); }
.badge-fail { background: rgba(234,84,85,0.15); color: var(--danger); }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
}

.modal-overlay.active { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: var(--transition);
}

.modal-overlay.active .modal { transform: translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.modal-header h3 { font-size: 20px; font-weight: 700; }

.modal-close {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ===== Test Page ===== */
.test-container {
  min-height: 100vh;
  background: var(--bg);
}

.test-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.test-header .test-title { font-size: 18px; font-weight: 700; }

.timer {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

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

@keyframes pulse { 50% { opacity: 0.5; } }

.test-body {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px;
}

.question-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  margin-bottom: 24px;
}

.question-number {
  font-size: 13px;
  color: var(--primary);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.question-text {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 24px;
  line-height: 1.5;
}

.options-list { list-style: none; }

.option-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: var(--transition);
}

.option-item:hover { border-color: var(--primary); background: rgba(108,99,255,0.05); }
.option-item.selected { border-color: var(--primary); background: rgba(108,99,255,0.1); }

.option-radio {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
}

.option-item.selected .option-radio {
  border-color: var(--primary);
  background: var(--primary);
}

.option-item.selected .option-radio::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
}

.option-label { font-size: 15px; }

.question-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.q-dot {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--dark);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.q-dot.answered { background: var(--success); color: #fff; border-color: var(--success); }
.q-dot.current { border-color: var(--primary); color: var(--primary); }
.q-dot.flagged { background: var(--warning); color: #fff; border-color: var(--warning); }

.test-actions {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
}

/* ===== Proctor Warning ===== */
.proctor-warning {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--danger);
  color: #fff;
  padding: 16px 24px;
  border-radius: 12px;
  font-weight: 600;
  z-index: 9999;
  display: none;
  animation: slideIn 0.3s ease;
  box-shadow: 0 8px 32px rgba(234,84,85,0.4);
}

.proctor-warning.show { display: block; }

@keyframes slideIn {
  from { transform: translateX(100px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===== Fullscreen Prompt ===== */
.fullscreen-prompt {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  text-align: center;
}

.fullscreen-prompt h2 { font-size: 28px; margin-bottom: 12px; }
.fullscreen-prompt p { color: var(--text-muted); margin-bottom: 24px; }

/* ===== Question Upload ===== */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 20px;
}

.upload-zone:hover { border-color: var(--primary); background: rgba(108,99,255,0.05); }
.upload-zone .upload-icon { font-size: 48px; margin-bottom: 12px; color: var(--text-muted); }
.upload-zone p { color: var(--text-muted); }
.upload-zone input { display: none; }

/* ===== Toast Notification ===== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 14px 20px;
  border-radius: 10px;
  font-weight: 500;
  font-size: 14px;
  animation: slideIn 0.3s ease;
  min-width: 300px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }
.toast-warning { background: var(--warning); color: #fff; }
.toast-info { background: var(--info); color: #fff; }

/* ===== Proximity Alert ===== */
.proximity-alert {
  background: rgba(234,84,85,0.1);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.proximity-alert .alert-icon { font-size: 24px; }

/* ===== Attendance Grid ===== */
.attendance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 6px;
}

.att-day {
  aspect-ratio: 1;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
}

.att-day.present { background: rgba(40,199,111,0.2); color: var(--success); }
.att-day.absent { background: rgba(234,84,85,0.2); color: var(--danger); }
.att-day.none { background: var(--dark); color: var(--text-muted); }

/* ===== Score Chart ===== */
.score-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.score-bar .label { width: 120px; font-size: 13px; color: var(--text-muted); text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.score-bar .bar-bg { flex: 1; height: 8px; background: var(--dark); border-radius: 4px; overflow: hidden; }
.score-bar .bar-fill { height: 100%; border-radius: 4px; transition: width 1s ease; }
.score-bar .value { font-size: 13px; font-weight: 600; width: 50px; text-align: right; }

/* ===== Live Indicator ===== */
.live-dot {
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
  animation: pulse 1.5s infinite;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 20px; }
  .login-box { padding: 32px 24px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .test-body { padding: 16px; }
  .question-card { padding: 20px; }

  .mobile-toggle {
    display: flex !important;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 101;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text);
    font-size: 20px;
  }
}

.mobile-toggle { display: none; }

/* ===== Chips ===== */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: var(--dark);
  color: var(--text-muted);
}

.chip-remove {
  cursor: pointer;
  font-size: 14px;
  color: var(--text-muted);
  background: none;
  border: none;
}

/* ===== Switch ===== */
.switch {
  position: relative;
  width: 44px;
  height: 24px;
}

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

.switch .slider {
  position: absolute;
  inset: 0;
  background: var(--dark-3);
  border-radius: 12px;
  cursor: pointer;
  transition: var(--transition);
}

.switch .slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
  transition: var(--transition);
}

.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h4 { font-size: 18px; color: var(--text); margin-bottom: 8px; }

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--dark);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 24px;
  overflow-x: auto;
}

.tab-btn {
  padding: 10px 20px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: var(--transition);
  white-space: nowrap;
}

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

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== Grid Layout ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }

@media (max-width: 768px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ===== OTP Input ===== */
.otp-inputs {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 20px 0;
}

.otp-inputs input {
  width: 48px;
  height: 56px;
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  outline: none;
}

.otp-inputs input:focus { border-color: var(--primary); }

/* ===== Progress Ring ===== */
.progress-ring {
  width: 120px;
  height: 120px;
  margin: 0 auto 16px;
}

/* ===== Proctoring cam box ===== */
.cam-preview {
  width: 160px;
  height: 120px;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid var(--border);
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 50;
}

.cam-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ===== Print Styles ===== */
@media print {
  .sidebar, .test-header, .btn { display: none !important; }
  .main-content { margin: 0; padding: 20px; }
  body { background: #fff; color: #000; }
}
