:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --secondary: #0ea5e9;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg: #0f172a;
  --bg2: #1e293b;
  --bg3: #334155;
  --text: #f1f5f9;
  --text2: #94a3b8;
  --border: #334155;
  --radius: 10px;
}

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

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

/* Landing */
.landing {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
}

.landing-card {
  text-align: center;
  padding: 60px 40px;
  background: var(--bg2);
  border-radius: 20px;
  border: 1px solid var(--border);
  max-width: 420px;
  width: 90%;
  box-shadow: 0 25px 50px rgba(0,0,0,0.5);
}

.logo-icon { font-size: 3rem; }
.logo h1 { font-size: 2rem; color: var(--primary); margin: 10px 0 5px; }
.logo p { color: var(--text2); margin-bottom: 40px; }

.landing-buttons { display: flex; flex-direction: column; gap: 12px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s;
}
.btn-lg { padding: 14px 24px; font-size: 16px; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--secondary); color: white; }
.btn-secondary:hover { background: #0284c7; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #16a34a; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-warning { background: var(--warning); color: white; }
.btn-outline { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn-outline:hover { background: var(--primary); color: white; }
.btn-ghost { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg3); color: var(--text); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Forms */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
}

.auth-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 90%;
  max-width: 420px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}

.auth-card h2 { font-size: 1.5rem; margin-bottom: 6px; }
.auth-card .subtitle { color: var(--text2); font-size: 14px; margin-bottom: 28px; }

.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; color: var(--text2); margin-bottom: 6px; font-weight: 500; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--primary);
}
.form-group textarea { resize: vertical; min-height: 80px; font-family: inherit; }

.error-msg { color: var(--danger); font-size: 13px; margin-top: 10px; }
.success-msg { color: var(--success); font-size: 13px; margin-top: 10px; }

.auth-footer { text-align: center; margin-top: 20px; font-size: 13px; color: var(--text2); }
.auth-footer a { color: var(--primary); text-decoration: none; }

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

.sidebar {
  width: 240px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}
.sidebar-logo h2 { font-size: 1.1rem; color: var(--primary); }
.sidebar-logo p { font-size: 12px; color: var(--text2); }

.sidebar-nav { flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  color: var(--text2);
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-item:hover, .nav-item.active {
  background: rgba(99,102,241,0.1);
  color: var(--primary);
}
.nav-item .icon { font-size: 16px; width: 20px; }

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

.main-content {
  flex: 1;
  margin-left: 240px;
  padding: 30px;
  overflow-y: auto;
}

/* Cards */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-header h3 { font-size: 1rem; }

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}
.stat-card .stat-value { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-card .stat-label { font-size: 13px; color: var(--text2); margin-top: 4px; }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; padding: 10px 14px; color: var(--text2); font-weight: 500; border-bottom: 1px solid var(--border); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
td { padding: 12px 14px; border-bottom: 1px solid rgba(51,65,85,0.5); }
tr:hover td { background: rgba(99,102,241,0.05); }

/* Badge */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}
.badge-success { background: rgba(34,197,94,0.15); color: var(--success); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-danger { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-info { background: rgba(14,165,233,0.15); color: var(--secondary); }

/* Page header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-header h2 { font-size: 1.4rem; }
.page-header p { color: var(--text2); font-size: 14px; margin-top: 2px; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 30px;
  width: 100%;
  max-width: 700px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h3 { font-size: 1.2rem; margin-bottom: 20px; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* Test cards for student */
.test-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.test-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.2s;
}
.test-card:hover { border-color: var(--primary); }
.test-card h3 { font-size: 1rem; margin-bottom: 8px; }
.test-card .meta { display: flex; gap: 16px; font-size: 13px; color: var(--text2); margin: 10px 0 16px; }
.test-card .meta span { display: flex; align-items: center; gap: 4px; }

/* Instructions page */
.instructions-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
}
.instructions-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  max-width: 700px;
  width: 100%;
}
.instructions-card h2 { font-size: 1.5rem; margin-bottom: 6px; }
.instructions-card .test-meta { display: flex; gap: 20px; color: var(--text2); font-size: 14px; margin: 10px 0 24px; }
.instructions-list { list-style: none; margin-bottom: 24px; }
.instructions-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.instructions-list li::before { content: '→'; color: var(--primary); flex-shrink: 0; }

.countdown-box {
  text-align: center;
  padding: 20px;
  background: var(--bg3);
  border-radius: var(--radius);
  margin-bottom: 20px;
}
.countdown-box .count { font-size: 3rem; font-weight: 700; color: var(--primary); }
.countdown-box p { color: var(--text2); font-size: 14px; }

/* Test environment */
.test-env {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.test-header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.test-header .test-title { font-size: 15px; font-weight: 600; }
.test-header .timer {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--success);
  font-family: monospace;
  padding: 6px 16px;
  background: rgba(34,197,94,0.1);
  border-radius: var(--radius);
  border: 1px solid rgba(34,197,94,0.3);
}
.test-header .timer.warning { color: var(--warning); background: rgba(245,158,11,0.1); border-color: rgba(245,158,11,0.3); }
.test-header .timer.danger { color: var(--danger); background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.3); animation: pulse 1s infinite; }

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

.test-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.problem-panel {
  width: 45%;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px;
  background: var(--bg);
}

.editor-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-toolbar {
  padding: 10px 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.editor-toolbar select {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
}

#code-editor {
  flex: 1;
  background: #1a1a2e;
  color: #e2e8f0;
  border: none;
  outline: none;
  padding: 16px;
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 14px;
  line-height: 1.6;
  resize: none;
  tab-size: 2;
}

.output-panel {
  height: 200px;
  border-top: 1px solid var(--border);
  background: var(--bg2);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.output-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
}
.output-tab {
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text2);
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.output-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.output-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  font-family: monospace;
  font-size: 13px;
}

/* Question nav */
.question-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}
.q-btn {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
}
.q-btn.active { background: var(--primary); border-color: var(--primary); color: white; }
.q-btn.answered { background: rgba(34,197,94,0.2); border-color: var(--success); color: var(--success); }

/* Problem statement */
.problem-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 6px; }
.problem-marks { font-size: 13px; color: var(--warning); margin-bottom: 16px; }
.problem-section { margin-bottom: 16px; }
.problem-section h4 { font-size: 13px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.problem-section p, .problem-section pre { font-size: 14px; line-height: 1.7; color: var(--text); }
.problem-section pre { background: var(--bg3); padding: 12px; border-radius: 6px; overflow-x: auto; }

.sample-case {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
  font-size: 13px;
}
.sample-case .label {
  color: #8b949e;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  font-weight: 600;
  margin-bottom: 5px;
}
.sample-case pre {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 5px;
  padding: 8px 12px;
  font-family: 'Cascadia Code','Fira Code','Consolas',monospace;
  font-size: 12px;
  color: #e6edf3;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.5;
}

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 16px;
}
.alert-warning { background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.3); color: var(--warning); }
.alert-danger { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: var(--danger); }
.alert-success { background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.3); color: var(--success); }
.alert-info { background: rgba(14,165,233,0.1); border: 1px solid rgba(14,165,233,0.3); color: var(--secondary); }

/* Result page */
.result-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
}
.result-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  max-width: 500px;
  width: 100%;
  text-align: center;
}
.result-score { font-size: 4rem; font-weight: 700; color: var(--primary); margin: 20px 0; }
.result-details { display: flex; justify-content: center; gap: 30px; margin: 20px 0; color: var(--text2); font-size: 14px; }

/* Loader */
.loader {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Utility */
.flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mb-3 { margin-bottom: 12px; }
.text-sm { font-size: 13px; }
.text-muted { color: var(--text2); }
.text-center { text-align: center; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--bg3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 16px; }
  .test-body { flex-direction: column; }
  .problem-panel { width: 100%; height: 40vh; border-right: none; border-bottom: 1px solid var(--border); }
}
