@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,300&family=DM+Serif+Display:ital@0;1&display=swap');

/* ── Design Tokens ── */
:root {
  --blue-50:  #EFF6FF;
  --blue-100: #DBEAFE;
  --blue-200: #BFDBFE;
  --blue-400: #60A5FA;
  --blue-500: #3B82F6;
  --blue-600: #2563EB;
  --blue-700: #1D4ED8;
  --blue-800: #1E40AF;
  --blue-900: #1E3A8A;

  --gray-50:  #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;

  --red-50:   #FEF2F2;
  --red-500:  #EF4444;
  --red-600:  #DC2626;

  --green-50:  #F0FDF4;
  --green-500: #22C55E;
  --green-600: #16A34A;

  --amber-50:  #FFFBEB;
  --amber-500: #F59E0B;

  /* Semantic */
  --bg:           #FFFFFF;
  --bg-surface:   #F9FAFB;
  --bg-subtle:    #F3F4F6;
  --border:       #E5E7EB;
  --border-focus: #2563EB;
  --text-primary: #111827;
  --text-secondary: #4B5563;
  --text-muted:   #9CA3AF;
  --accent:       #2563EB;
  --accent-hover: #1D4ED8;
  --accent-light: #EFF6FF;

  /* Sidebar */
  --sidebar-width: 240px;
  --sidebar-bg:    #0F172A;
  --sidebar-text:  #CBD5E1;
  --sidebar-active:#2563EB;
  --sidebar-hover: rgba(255,255,255,0.06);

  /* Typography */
  --font-sans:    'DM Sans', sans-serif;
  --font-display: 'DM Serif Display', serif;

  /* Spacing */
  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:    0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.1), 0 4px 8px rgba(0,0,0,0.06);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-surface);
  line-height: 1.6;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button { font-family: var(--font-sans); cursor: pointer; }
input, select, textarea { font-family: var(--font-sans); }

/* ── Utility ── */
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
.hidden { display: none !important; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  border: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-secondary {
  background: var(--bg);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-subtle); }
.btn-danger {
  background: var(--red-600);
  color: #fff;
}
.btn-danger:hover { background: #B91C1C; }
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: none;
}
.btn-ghost:hover { background: var(--bg-subtle); color: var(--text-primary); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ── Form Elements ── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}
.form-input {
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.form-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.form-input::placeholder { color: var(--text-muted); }
.form-input.error { border-color: var(--red-500); }
.form-error { font-size: 12px; color: var(--red-600); margin-top: 2px; }
.form-hint  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
select.form-input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
textarea.form-input { resize: vertical; min-height: 100px; }

/* ── Cards ── */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.card-body { padding: 24px; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.badge-blue   { background: var(--blue-50);  color: var(--blue-700); }
.badge-green  { background: var(--green-50); color: var(--green-600); }
.badge-amber  { background: var(--amber-50); color: #92400E; }
.badge-red    { background: var(--red-50);   color: var(--red-600); }
.badge-gray   { background: var(--gray-100); color: var(--gray-600); }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left;
  padding: 11px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg-subtle); }

/* ── Alerts ── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  border: 1px solid transparent;
}
.alert-error   { background: var(--red-50);   color: var(--red-600);   border-color: #FECACA; }
.alert-success { background: var(--green-50); color: var(--green-600); border-color: #BBF7D0; }
.alert-info    { background: var(--blue-50);  color: var(--blue-700);  border-color: var(--blue-200); }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.5);
  backdrop-filter: blur(2px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(12px);
  transition: transform 0.2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-body  { padding: 24px; display: flex; flex-direction: column; gap: 18px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.modal-close {
  background: none; border: none;
  color: var(--text-muted);
  font-size: 20px; line-height: 1;
  cursor: pointer; padding: 4px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.modal-close:hover { background: var(--bg-subtle); color: var(--text-primary); }

/* ── Spinner ── */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}
.spinner-blue {
  border-color: var(--blue-200);
  border-top-color: var(--accent);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast notifications ── */
#toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: var(--gray-900);
  color: #fff;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s ease;
  min-width: 260px;
  max-width: 380px;
}
.toast.toast-success { background: var(--green-600); }
.toast.toast-error   { background: var(--red-600); }
.toast.toast-info    { background: var(--blue-600); }
@keyframes slideUp {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-title { font-size: 22px; font-weight: 600; color: var(--text-primary); }
.page-subtitle { font-size: 14px; color: var(--text-secondary); margin-top: 2px; }

/* ── Stat cards ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.stat-value { font-size: 28px; font-weight: 600; color: var(--text-primary); line-height: 1.2; }
.stat-delta { font-size: 12px; color: var(--text-muted); }
.stat-icon  {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  margin-bottom: 4px;
}
.stat-icon-blue   { background: var(--blue-50);  color: var(--blue-600); }
.stat-icon-green  { background: var(--green-50); color: var(--green-600); }
.stat-icon-amber  { background: var(--amber-50); color: #D97706; }
.stat-icon-purple { background: #F5F3FF; color: #7C3AED; }

/* ── Sidebar layout ── */
.app-layout {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.25s ease;
}
.sidebar-logo {
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo-mark {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 16px;
  color: #fff;
  flex-shrink: 0;
}
.sidebar-logo-text {
  font-family: var(--font-display);
  font-size: 18px;
  color: #fff;
  letter-spacing: 0.01em;
}
.sidebar-logo-sub {
  font-family: var(--font-sans);
  font-size: 10px;
  color: rgba(255,255,255,0.35);
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: block;
  margin-top: -2px;
}
.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.25);
  padding: 14px 10px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 14px;
  font-weight: 400;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav-item.active {
  background: rgba(37,99,235,0.18);
  color: #fff;
  font-weight: 500;
}
.nav-item.active .nav-icon { color: var(--blue-400); }
.nav-icon { font-size: 16px; width: 20px; text-align: center; opacity: 0.8; flex-shrink: 0; }
.nav-item.active .nav-icon { opacity: 1; }

.sidebar-footer {
  padding: 12px 10px 16px;
  border-top: 1px solid rgba(255,255,255,0.07);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
  cursor: pointer;
}
.sidebar-user:hover { background: var(--sidebar-hover); }
.sidebar-avatar {
  width: 32px; height: 32px;
  background: var(--blue-700);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}
.sidebar-user-name { font-size: 13px; font-weight: 500; color: #fff; line-height: 1.3; }
.sidebar-user-role { font-size: 11px; color: rgba(255,255,255,0.4); text-transform: capitalize; }

/* ── Main content area ── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-breadcrumb {
  font-size: 14px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.topbar-breadcrumb span { color: var(--text-primary); font-weight: 500; }
.page-content { padding: 28px; flex: 1; max-width: 1200px; }

/* ── Role badge on topbar ── */
.role-pill {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.role-super_admin { background: #F5F3FF; color: #6D28D9; }
.role-admin       { background: var(--blue-50); color: var(--blue-700); }
.role-instructor  { background: var(--green-50); color: var(--green-600); }
.role-student     { background: var(--gray-100); color: var(--gray-600); }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.4; }
.empty-state-title { font-size: 16px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state-text  { font-size: 14px; }

/* ── Divider ── */
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .page-content { padding: 16px; }
}
