@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap');

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

:root {
  --bg: #fdf8f3;
  --bg2: #f5f0ea;
  --purple: #442fff;
  --purple-dark: #3320cc;
  --purple-light: #ede8ff;
  --text: #1c1c1c;
  --text-muted: #6b7a99;
  --text-heading: #2a4365;
  --border: #e2d9f3;
  --white: #ffffff;
  --danger: #e53e3e;
  --success: #38a169;
  --warning: #d69e2e;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(68,47,255,0.08);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
}

body {
  font-family: 'Montserrat', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
}

/* ===== HEADER ===== */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 64px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 32px;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 700;
  font-size: 18px;
  color: var(--purple);
  letter-spacing: -0.5px;
}
.header-logo span { color: var(--text-heading); }
.header-nav { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}
.header-user strong { color: var(--text-heading); }

/* ===== SIDEBAR ===== */
.layout { display: flex; padding-top: 64px; min-height: 100vh; }
.sidebar {
  width: 240px;
  min-height: calc(100vh - 64px);
  background: var(--white);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  position: fixed;
  top: 64px;
  left: 0;
  bottom: 0;
  overflow-y: auto;
}
.sidebar-section { padding: 0 16px; margin-bottom: 8px; }
.sidebar-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 12px 12px 6px;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  font-weight: 500;
  font-size: 13px;
  transition: all 0.15s;
}
.sidebar-link:hover { background: var(--purple-light); color: var(--purple); }
.sidebar-link.active { background: var(--purple); color: var(--white); }
.sidebar-link .icon { font-size: 16px; width: 20px; text-align: center; }

/* ===== MAIN CONTENT ===== */
.main { margin-left: 240px; padding: 32px; flex: 1; }
.page-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 8px;
}
.page-subtitle { color: var(--text-muted); font-size: 13px; margin-bottom: 28px; }

/* ===== CARDS ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 32px; }
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.stat-card .stat-num { font-size: 32px; font-weight: 700; color: var(--purple); }
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; font-weight: 500; }

.card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
}
.card-title { font-weight: 700; font-size: 14px; color: var(--text-heading); }
.card-body { padding: 20px; }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
th { font-weight: 700; color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; background: var(--bg); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #faf7ff; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary { background: var(--purple); color: var(--white); }
.btn-primary:hover { background: var(--purple-dark); }
.btn-outline { background: transparent; color: var(--purple); border: 1.5px solid var(--purple); }
.btn-outline:hover { background: var(--purple-light); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #c53030; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--danger); background: #fff5f5; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-group { display: flex; gap: 6px; align-items: center; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--text-heading); margin-bottom: 6px; }
input[type=text], input[type=password], select, textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--white);
  outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--purple); }
textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ===== MODAL ===== */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--white);
  border-radius: var(--radius);
  width: 480px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-weight: 700; font-size: 16px; color: var(--text-heading); }
.modal-close { background: none; border: none; cursor: pointer; font-size: 20px; color: var(--text-muted); line-height: 1; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ===== ALERTS ===== */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert-error { background: #fff5f5; border: 1px solid #fed7d7; color: var(--danger); }
.alert-success { background: #f0fff4; border: 1px solid #c6f6d5; color: var(--success); }
.alert-info { background: var(--purple-light); border: 1px solid var(--border); color: var(--purple); }

/* ===== BADGES ===== */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge-purple { background: var(--purple-light); color: var(--purple); }
.badge-green { background: #f0fff4; color: var(--success); }
.badge-red { background: #fff5f5; color: var(--danger); }
.badge-gray { background: #f7fafc; color: var(--text-muted); }

/* ===== PROGRESS ===== */
.progress-bar { background: var(--bg2); border-radius: 99px; height: 6px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--purple); border-radius: 99px; transition: width 0.3s; }

/* ===== COURSE CARD (student view) ===== */
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.course-card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  color: inherit;
  display: block;
}
.course-card:hover { border-color: var(--purple); box-shadow: var(--shadow); transform: translateY(-2px); }
.course-card-dir { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--purple); margin-bottom: 8px; }
.course-card-title { font-weight: 700; font-size: 15px; color: var(--text-heading); margin-bottom: 8px; }
.course-card-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }

/* ===== MATERIAL LIST ===== */
.material-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  background: var(--white);
  transition: all 0.15s;
}
.material-item:hover { border-color: var(--purple); background: #faf9ff; }
.material-item.viewed { opacity: 0.7; }
.material-icon { font-size: 22px; flex-shrink: 0; }
.material-info { flex: 1; min-width: 0; }
.material-title { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.material-type { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ===== LOGIN PAGE ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
}
.login-box {
  background: var(--white);
  border-radius: 16px;
  padding: 40px;
  width: 380px;
  max-width: 100%;
  box-shadow: 0 8px 40px rgba(68,47,255,0.12);
  border: 1px solid var(--border);
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo-text {
  font-size: 22px;
  font-weight: 700;
  color: var(--purple);
  line-height: 1.2;
}
.login-logo-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.login-title { font-size: 18px; font-weight: 700; color: var(--text-heading); margin-bottom: 20px; }
.login-btn {
  width: 100%;
  padding: 12px;
  background: var(--purple);
  color: var(--white);
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  letter-spacing: 0.3px;
}
.login-btn:hover { background: var(--purple-dark); }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ===== UTILITIES ===== */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-muted { color: var(--text-muted); }
.text-purple { color: var(--purple); }
.fw-bold { font-weight: 700; }
.hidden { display: none; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 16px; }
  .header { padding: 0 16px; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
