/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

:root {
  --bg: #ffffff;
  --bg-sidebar: #fafbfc;
  --bg-code: #f6f8fa;
  --text: #374151;
  --text-muted: #6b7280;
  --accent: #005ea0;
  --accent-hover: #004a7f;
  --accent-light: #e6f0f8;
  --border: #e5e7eb;
  --heading: #111827;
  --sidebar-width: 280px;
  --table-stripe: #f9fafb;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --card-shadow-hover: 0 10px 25px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.04);
  --tag-bg: #e6f0f8;
  --tag-text: #005ea0;
  --gradient: linear-gradient(135deg, #005ea0 0%, #0077c8 100%);
  --radius: 10px;
  --info-bg: #e6f0f8;
  --info-border: #005ea0;
  --success: #10b981;
  --warning: #f59e0b;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --bg-sidebar: #0c1222;
  --bg-code: #1e293b;
  --text: #cbd5e1;
  --text-muted: #64748b;
  --accent: #5ba8d8;
  --accent-hover: #7dc0ea;
  --accent-light: #0d2a42;
  --border: #1e293b;
  --heading: #f1f5f9;
  --table-stripe: #131c31;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --card-shadow-hover: 0 10px 25px rgba(0,0,0,0.4);
  --tag-bg: #0d2a42;
  --tag-text: #5ba8d8;
  --gradient: linear-gradient(135deg, #005ea0 0%, #0077c8 100%);
  --info-bg: #0d2a42;
  --info-border: #5ba8d8;
}

html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  display: flex;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--accent-hover); }

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 1.5rem 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-logo {
  display: block;
  max-width: 220px;
  margin-bottom: 0.75rem;
}

.sidebar-header {
  padding: 0 1.25rem 1.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.sidebar-header .course-id {
  font-size: 0.7rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}

.sidebar-header h2 {
  font-size: 0.95rem;
  color: var(--heading);
  line-height: 1.4;
  margin-top: 0.25rem;
  font-weight: 700;
}

.sidebar-header .semester {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.sidebar nav { padding: 0 0.75rem; }

.sidebar .nav-section {
  margin-bottom: 0.5rem;
}

.sidebar .nav-section-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 0.5rem 0.5rem 0.25rem;
  font-weight: 600;
}

.sidebar .nav-section a {
  display: block;
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  font-size: 0.83rem;
  color: var(--text);
  transition: all 0.15s ease;
}

.sidebar .nav-section a:hover {
  background: var(--border);
  text-decoration: none;
  transform: translateX(2px);
}

.sidebar .nav-section a.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

/* ===== Main Content ===== */
.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0.75rem 2rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 50;
  gap: 0.75rem;
  backdrop-filter: blur(8px);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
}

.theme-toggle, .menu-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.65rem;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text);
  transition: all 0.2s ease;
}

.theme-toggle:hover, .menu-toggle:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

.menu-toggle {
  display: none;
}

.content {
  max-width: 860px;
  margin: 0 auto;
  padding: 2.5rem 2.5rem 4rem;
}

/* ===== Hero Section ===== */
.hero {
  background: var(--gradient);
  border-radius: var(--radius);
  padding: 2.5rem;
  margin-bottom: 2rem;
  color: white;
}

.hero h1 {
  font-size: 1.8rem;
  color: white;
  margin-bottom: 0.5rem;
  font-weight: 700;
}

.hero .subtitle {
  color: rgba(255,255,255,0.85);
  margin-bottom: 0;
  font-size: 1rem;
}

/* ===== Typography ===== */
h1 {
  font-size: 2rem;
  color: var(--heading);
  margin-bottom: 0.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.35rem;
  color: var(--heading);
  margin: 2.5rem 0 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--border);
  font-weight: 700;
  letter-spacing: -0.01em;
}

h3 {
  font-size: 1.1rem;
  color: var(--heading);
  margin: 1.5rem 0 0.5rem;
  font-weight: 600;
}

p { margin-bottom: 1rem; }
ul, ol { margin: 0.5rem 0 1rem 1.5rem; }
li { margin-bottom: 0.35rem; }

.subtitle {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

/* ===== Tables ===== */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 1.5rem;
  font-size: 0.88rem;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--card-shadow);
}

th, td {
  padding: 0.65rem 0.85rem;
  text-align: left;
}

th {
  background: var(--bg-sidebar);
  font-weight: 600;
  color: var(--heading);
  border-bottom: 2px solid var(--border);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

td {
  border-bottom: 1px solid var(--border);
}

tr:nth-child(even) { background: var(--table-stripe); }
tr:hover { background: var(--accent-light); }
tr.exam-row { background: var(--tag-bg); }
tr.exam-row td { font-weight: 600; color: var(--accent); }

/* ===== Code ===== */
code {
  background: var(--bg-code);
  padding: 0.15rem 0.45rem;
  border-radius: 5px;
  font-size: 0.84em;
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  color: var(--accent);
}

pre {
  background: var(--bg-code);
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 1rem 0 1.5rem;
  border: 1px solid var(--border);
  position: relative;
}

pre code {
  background: none;
  padding: 0;
  font-size: 0.84rem;
  line-height: 1.65;
  color: var(--text);
}

/* ===== Cards ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  margin: 1rem 0 1.5rem;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  background: var(--bg);
  box-shadow: var(--card-shadow);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
  box-shadow: var(--card-shadow-hover);
  transform: translateY(-3px);
  border-color: var(--accent);
}

.card h4 {
  font-size: 0.93rem;
  color: var(--heading);
  margin-bottom: 0.4rem;
  font-weight: 600;
}

.card p {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.tag {
  display: inline-block;
  font-size: 0.68rem;
  padding: 0.2rem 0.55rem;
  border-radius: 99px;
  background: var(--tag-bg);
  color: var(--tag-text);
  font-weight: 600;
  margin-right: 0.3rem;
  margin-bottom: 0.3rem;
  letter-spacing: 0.02em;
}

/* ===== Info Box ===== */
.info-box {
  border-left: 4px solid var(--info-border);
  background: var(--info-bg);
  padding: 1rem 1.25rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 1rem 0 1.5rem;
}

.info-box p:last-child { margin-bottom: 0; }

/* ===== Badge ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  padding: 0.25rem 0.7rem;
  border-radius: 99px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-exam {
  background: #fef2f2;
  color: #dc2626;
}

[data-theme="dark"] .badge-exam {
  background: #450a0a;
  color: #fca5a5;
}

.badge-new {
  background: #ecfdf5;
  color: #059669;
}

[data-theme="dark"] .badge-new {
  background: #022c22;
  color: #6ee7b7;
}

/* ===== Section Header with Icon ===== */
.section-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 1rem;
  margin-right: 0.5rem;
  vertical-align: middle;
}

/* ===== Topic List ===== */
.topic-list {
  list-style: none;
  margin-left: 0;
  padding: 0;
}

.topic-list li {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  border-radius: 6px;
  transition: background 0.15s;
}

.topic-list li:hover {
  background: var(--accent-light);
}

.topic-list li:last-child { border-bottom: none; }

/* ===== Grading Bar ===== */
.grading-bar {
  display: flex;
  height: 12px;
  border-radius: 99px;
  overflow: hidden;
  margin: 0.75rem 0 1rem;
  box-shadow: var(--card-shadow);
}

.grading-bar > div {
  transition: width 0.5s ease;
}

.grading-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.grading-legend span::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 0.4rem;
  vertical-align: middle;
}

/* ===== Assignment Box ===== */
.assignment-box {
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin: 1rem 0 1.5rem;
  background: var(--accent-light);
}

.assignment-box h3 {
  margin-top: 0;
  color: var(--accent);
}

/* ===== Footer ===== */
.footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ===== Animations ===== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.content > * {
  animation: fadeInUp 0.4s ease both;
}

.content > *:nth-child(2) { animation-delay: 0.05s; }
.content > *:nth-child(3) { animation-delay: 0.1s; }
.content > *:nth-child(4) { animation-delay: 0.15s; }
.content > *:nth-child(5) { animation-delay: 0.2s; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main {
    margin-left: 0;
  }
  .menu-toggle {
    display: block;
  }
  .content {
    padding: 1.5rem 1rem 3rem;
  }
  .card-grid {
    grid-template-columns: 1fr;
  }
  .hero {
    padding: 1.75rem;
  }
  .hero h1 {
    font-size: 1.4rem;
  }
}

/* ===== Backdrop for mobile sidebar ===== */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
  backdrop-filter: blur(2px);
}

.sidebar-backdrop.show {
  display: block;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
