/* ============================================================
   CBT PRO - Professional Responsive Design System
   Pure CSS - No Bootstrap
   Mobile-first, hamburger navigation, all screen sizes
   ============================================================ */

:root {
  --primary: #1a56db;
  --primary-dark: #1e429f;
  --primary-light: #3b82f6;
  --secondary: #0e9f6e;
  --danger: #e02424;
  --warning: #ff5a1f;
  --success: #057a55;
  --dark: #1f2a37;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1);
  --font: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --sidebar-width: 260px;
  --header-height: 60px;
  --transition: .25s ease;
}

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

html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--gray-100);
  color: var(--gray-900);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }

/* ---------- Utilities ---------- */
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 1rem; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-sm { font-size: .875rem; }
.text-xs { font-size: .75rem; }
.font-bold { font-weight: 700; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 1rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }
.w-full { width: 100%; }
.rounded { border-radius: var(--radius); }
.shadow { box-shadow: var(--shadow); }
.shadow-md { box-shadow: var(--shadow-md); }
.bg-white { background: #fff; }
.bg-primary { background: var(--primary); color: #fff; }
.bg-success { background: var(--success); color: #fff; }
.bg-danger { background: var(--danger); color: #fff; }
.text-muted { color: var(--gray-500); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  font-size: .9rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition), transform .1s;
  text-decoration: none;
  line-height: 1.2;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; }
.btn-secondary { background: var(--gray-200); color: var(--gray-900); }
.btn-secondary:hover { background: var(--gray-300); text-decoration: none; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--primary);
  color: var(--primary);
}
.btn-outline:hover { background: var(--primary); color: #fff; text-decoration: none; }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 1.1rem; }
.form-label {
  display: block;
  font-size: .875rem;
  font-weight: 600;
  margin-bottom: .35rem;
  color: var(--gray-700);
}
.form-control {
  width: 100%;
  padding: .6rem .85rem;
  font-size: .95rem;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius);
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, .15);
}
.form-control.is-invalid { border-color: var(--danger); }
.form-error { color: var(--danger); font-size: .8rem; margin-top: .25rem; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .8rem center; padding-right: 2rem; }
textarea.form-control { min-height: 100px; resize: vertical; }

/* ---------- Cards ---------- */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--gray-200);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-body { padding: 1.25rem; }
.card-footer {
  padding: .85rem 1.25rem;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
}

/* ---------- Tables ---------- */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
.table th, .table td {
  padding: .75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
}
.table th {
  background: var(--gray-50);
  font-weight: 600;
  color: var(--gray-700);
  white-space: nowrap;
}
.table tr:hover td { background: var(--gray-50); }
.table .badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-success { background: #def7ec; color: #03543f; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fde8e8; color: #9b1c1c; }
.badge-info { background: #e1effe; color: #1e429f; }

/* ---------- Layout: Auth ---------- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a56db 0%, #0e9f6e 100%);
  padding: 1.5rem;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 2rem;
}
.auth-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}
.auth-logo h1 {
  font-size: 1.75rem;
  color: var(--primary);
  margin-bottom: .25rem;
}
.auth-logo p { color: var(--gray-500); font-size: .9rem; }

/* ---------- App Shell (Dashboard) ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--dark);
  color: #fff;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1000;
  transform: translateX(-100%);
  transition: transform var(--transition);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.sidebar.open { transform: translateX(0); }
.sidebar-header {
  padding: 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
}
.sidebar-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  display: none;
  line-height: 1;
}
.sidebar-nav { padding: 1rem 0; flex: 1; }
.nav-section {
  padding: .5rem 1.25rem;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: rgba(255,255,255,.4);
  margin-top: .5rem;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .7rem 1.25rem;
  color: rgba(255,255,255,.75);
  text-decoration: none;
  font-size: .9rem;
  transition: background var(--transition), color var(--transition);
}
.nav-link:hover, .nav-link.active {
  background: rgba(255,255,255,.08);
  color: #fff;
  text-decoration: none;
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }

/* Main content */
.main-content {
  flex: 1;
  margin-left: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition);
}

/* Top header */
.top-header {
  height: var(--header-height);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.hamburger {
  background: none;
  border: none;
  cursor: pointer;
  padding: .4rem;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.hamburger span {
  display: block;
  width: 22px;
  height: 2.5px;
  background: var(--gray-700);
  border-radius: 2px;
  transition: var(--transition);
}
.header-title { font-weight: 700; font-size: 1.05rem; }
.header-actions { display: flex; align-items: center; gap: .75rem; }
.user-chip {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .875rem;
  font-weight: 600;
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .85rem;
}

/* Page content */
.page-content {
  flex: 1;
  padding: 1.25rem;
}

/* Stats cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.15rem;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
}
.stat-card.green { border-left-color: var(--success); }
.stat-card.orange { border-left-color: var(--warning); }
.stat-card.red { border-left-color: var(--danger); }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: .8rem; color: var(--gray-500); margin-top: .2rem; }

/* Overlay for mobile sidebar */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition), visibility var(--transition);
}
.sidebar-overlay.show { opacity: 1; visibility: visible; }

/* Exam taking interface */
.exam-header {
  background: var(--dark);
  color: #fff;
  padding: .85rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  position: sticky;
  top: 0;
  z-index: 50;
}
.exam-timer {
  font-size: 1.25rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: rgba(255,255,255,.12);
  padding: .35rem .85rem;
  border-radius: var(--radius);
}
.question-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.question-number {
  font-size: .8rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: .5rem;
}
.question-text { font-size: 1.05rem; margin-bottom: 1rem; line-height: 1.6; }
.options-list { list-style: none; }
.option-item {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .75rem 1rem;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  margin-bottom: .5rem;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.option-item:hover { border-color: var(--primary-light); background: #f0f5ff; }
.option-item.selected { border-color: var(--primary); background: #e1effe; }
.option-item input { margin-top: .2rem; }

/* Fill gap & essay */
.fill-gap-input, .essay-area {
  width: 100%;
  padding: .75rem;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
}
.essay-area { min-height: 180px; resize: vertical; }

/* Alerts */
.alert {
  padding: .85rem 1.1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .9rem;
}
.alert-success { background: #def7ec; color: #03543f; border: 1px solid #bcf0da; }
.alert-danger { background: #fde8e8; color: #9b1c1c; border: 1px solid #fbd5d5; }
.alert-info { background: #e1effe; color: #1e429f; border: 1px solid #c3ddfd; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

/* ---------- Desktop breakpoints ---------- */
@media (min-width: 768px) {
  .sidebar {
    transform: translateX(0);
  }
  .sidebar-close { display: none !important; }
  .hamburger { display: none; }
  .main-content { margin-left: var(--sidebar-width); }
  .page-content { padding: 1.5rem 2rem; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 1024px) {
  .page-content { padding: 2rem 2.5rem; }
}

/* Mobile sidebar open state already handled by .sidebar.open */
@media (max-width: 767px) {
  .sidebar-close { display: block; }
  .header-title { font-size: .95rem; }
  .user-chip span { display: none; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Print */
@media print {
  .sidebar, .top-header, .hamburger, .btn { display: none !important; }
  .main-content { margin-left: 0 !important; }
}