/* ============================================
   ClassWiki - Main Stylesheet
   Wikipedia-inspired modern design
   ============================================ */

/* ---- Google Fonts ---- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Noto+Sans:wght@400;500;600;700&display=swap');

/* ============================================
   CSS Custom Properties (Design Tokens)
   ============================================ */
:root {
  /* Colors - Light theme (Monochrome) */
  --color-bg: #ffffff;
  --color-surface: #f9f9f9;
  --color-surface-hover: #f1f1f1;
  --color-border: #e0e0e0;
  --color-border-light: #f0f0f0;
  --color-text: #111111;
  --color-text-secondary: #444444;
  --color-text-muted: #888888;
  --color-link: #222222;
  --color-link-hover: #000000;
  --color-link-visited: #444444;
  --color-primary: #222222;
  --color-primary-light: #e8e8e8;
  --color-primary-dark: #000000;

  --color-success: #10b981;
  --color-success-light: #d1fae5;
  --color-warning: #f59e0b;
  --color-warning-light: #fef3c7;
  --color-danger: #ef4444;
  --color-danger-light: #fee2e2;
  --color-info: #0ea5e9;

  /* Wikipedia-style accents */
  --color-infobox-bg: #f8fafc;
  --color-infobox-header: #e2e8f0;
  --color-infobox-border: #cbd5e1;
  --color-toc-bg: #f8fafc;
  --color-toc-border: #cbd5e1;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  /* Typography */
  --font-primary: 'Inter', 'Noto Sans', system-ui, -apple-system, sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 2rem;
  --font-size-4xl: 2.5rem;

  /* Border radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 50%;

  /* Shadows (Softer & Deeper) */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.05);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

  /* Layout */
  --header-height: 64px;
  --sidebar-width: 280px;
  --content-max-width: 1200px;
  --article-max-width: 900px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   Dark Theme
   ============================================ */
[data-theme="dark"] {
  --color-bg: #121212;
  --color-surface: #1e1e1e;
  --color-surface-hover: #2c2c2c;
  --color-border: #333333;
  --color-border-light: #222222;
  --color-text: #f5f5f5;
  --color-text-secondary: #cccccc;
  --color-text-muted: #999999;
  --color-link: #d4d4d4;
  --color-link-hover: #ffffff;
  --color-link-visited: #aaaaaa;
  --color-primary: #eeeeee;
  --color-primary-light: #333333;
  --color-primary-dark: #ffffff;

  --color-success-light: #064e3b;
  --color-warning-light: #78350f;
  --color-danger-light: #7f1d1d;

  --color-infobox-bg: #1e293b;
  --color-infobox-header: #0f172a;
  --color-infobox-border: #334155;
  --color-toc-bg: #1e293b;
  --color-toc-border: #334155;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.6);
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-primary);
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--color-link);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-link-hover);
  text-decoration: underline;
}

a:visited {
  color: var(--color-link-visited);
}

img {
  max-width: 100%;
  height: auto;
}

/* ============================================
   Layout
   ============================================ */
.app-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---- Header ---- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  padding: 0 var(--space-lg);
  gap: var(--space-md);
  backdrop-filter: blur(12px);
  background: rgba(255, 255, 255, 0.92);
}

[data-theme="dark"] .header {
  background: rgba(22, 27, 34, 0.92);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 700;
  font-size: var(--font-size-xl);
  color: var(--color-text);
  text-decoration: none !important;
}

.logo:hover {
  color: var(--color-primary);
  text-decoration: none;
}

.logo-emoji {
  font-size: 1.5rem;
}

.logo-text {
  background: linear-gradient(135deg, var(--color-primary), #666666);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#sidebar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-text);
  padding: var(--space-xs);
}

.header-center {
  flex: 1;
  display: flex;
  justify-content: center;
  max-width: 500px;
  margin: 0 auto;
}

.search-wrapper {
  position: relative;
  width: 100%;
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 0 var(--space-md);
  transition: all var(--transition-fast);
}

.search-input-wrapper:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.search-icon {
  color: var(--color-text-muted);
  flex-shrink: 0;
}

#search-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px var(--space-sm);
  font-size: var(--font-size-sm);
  color: var(--color-text);
  outline: none;
  font-family: var(--font-primary);
}

#search-input::placeholder {
  color: var(--color-text-muted);
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: none;
  max-height: 300px;
  overflow-y: auto;
  z-index: 200;
}

.search-results.show {
  display: block;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  color: var(--color-text);
  transition: background var(--transition-fast);
  text-decoration: none !important;
}

.search-result-item:hover {
  background: var(--color-surface-hover);
  text-decoration: none;
}

.search-result-type {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  min-width: 80px;
}

.search-empty {
  padding: var(--space-lg);
  text-align: center;
  color: var(--color-text-muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
}

/* Dark mode toggle */
#dark-mode-toggle {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
  color: var(--color-text);
}

#dark-mode-toggle:hover {
  background: var(--color-surface-hover);
}

/* ---- Auth Section ---- */
.btn-login {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 6px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text);
  transition: all var(--transition-fast);
  font-family: var(--font-primary);
  white-space: nowrap;
}

.btn-login:hover {
  background: var(--color-surface-hover);
  box-shadow: var(--shadow-sm);
}

.user-menu {
  position: relative;
}

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: none;
  border: 1px solid transparent;
  padding: 4px 12px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  font-size: var(--font-size-sm);
  color: var(--color-text);
  transition: all var(--transition-fast);
  font-family: var(--font-primary);
}

.user-menu-trigger:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-border);
}

.user-avatar-small {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  object-fit: cover;
}

.user-name {
  font-weight: 500;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  display: none;
  z-index: 200;
  overflow: hidden;
}

.user-dropdown.show {
  display: block;
}

.dropdown-item {
  display: block;
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: none;
  border: none;
  text-align: left;
  font-size: var(--font-size-sm);
  color: var(--color-text);
  cursor: pointer;
  transition: background var(--transition-fast);
  font-family: var(--font-primary);
  text-decoration: none !important;
}

.dropdown-item:hover {
  background: var(--color-surface-hover);
  text-decoration: none;
  color: var(--color-text);
}

.ban-badge {
  display: block;
  padding: var(--space-sm) var(--space-md);
  background: var(--color-danger-light);
  color: var(--color-danger);
  font-size: var(--font-size-xs);
  font-weight: 500;
}

/* ---- Breadcrumb ---- */
.breadcrumb {
  padding: var(--space-sm) var(--space-lg);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border-light);
  font-size: var(--font-size-sm);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex-wrap: wrap;
}

.breadcrumb-link {
  color: var(--color-link);
}

.breadcrumb-sep {
  color: var(--color-text-muted);
  margin: 0 2px;
}

.breadcrumb-current {
  color: var(--color-text-secondary);
  font-weight: 500;
}

/* ---- Main Content ---- */
.main-content {
  flex: 1;
  max-width: var(--content-max-width);
  width: 100%;
  margin: 0 auto;
  padding: var(--space-xl) var(--space-lg);
}

/* ---- Footer ---- */
.footer {
  border-top: 1px solid var(--color-border);
  padding: var(--space-xl) var(--space-lg);
  text-align: center;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  background: var(--color-surface);
}

.footer a {
  color: var(--color-link);
}

/* ============================================
   Page Transitions
   ============================================ */
.page-exit {
  opacity: 0;
  transform: translateY(8px);
  transition: all 150ms ease;
}

.page-enter {
  animation: pageEnter 300ms ease forwards;
}

@keyframes pageEnter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   Loading Spinner
   ============================================ */
.loading-spinner {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: var(--space-2xl);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-primary);
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none !important;
  white-space: nowrap;
}

.btn:hover {
  text-decoration: none;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--color-primary-dark);
  box-shadow: var(--shadow-md);
  color: #fff;
}

.btn-secondary {
  background: var(--color-surface-hover);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-border-light);
}

.btn-outline {
  background: transparent;
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
}

.btn-outline:hover {
  background: var(--color-primary-light);
}

.btn-danger {
  background: var(--color-danger);
  color: #fff;
}

.btn-danger:hover {
  background: #c82333;
}

.btn-warning {
  background: var(--color-warning);
  color: #333;
}

.btn-success {
  background: var(--color-success);
  color: #fff;
}

.btn-sm {
  padding: 4px 10px;
  font-size: var(--font-size-xs);
}

.btn-xs {
  padding: 2px 8px;
  font-size: var(--font-size-xs);
}

/* ============================================
   Forms
   ============================================ */
.input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: var(--font-primary);
  font-size: var(--font-size-sm);
  color: var(--color-text);
  background: var(--color-surface);
  transition: all var(--transition-fast);
  outline: none;
}

.input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.textarea {
  resize: vertical;
  min-height: 80px;
}

select.input {
  cursor: pointer;
}

.form-group {
  margin-bottom: var(--space-md);
}

.form-group label {
  display: block;
  margin-bottom: var(--space-xs);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.form-hint {
  display: block;
  margin-top: var(--space-xs);
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.required {
  color: var(--color-danger);
}

.text-muted {
  color: var(--color-text-muted);
}

/* File Upload */
.file-upload {
  position: relative;
}

.file-upload-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xl);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

.file-upload-area:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.file-upload-icon {
  font-size: 2rem;
}

.file-preview {
  max-width: 200px;
  max-height: 200px;
  border-radius: var(--radius-md);
  margin-top: var(--space-sm);
  object-fit: cover;
}

/* ============================================
   Modal
   ============================================ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--space-md);
  opacity: 0;
  animation: fadeIn 200ms ease forwards;
}

@keyframes fadeIn {
  to {
    opacity: 1;
  }
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 250ms ease;
}

.modal-lg {
  max-width: 600px;
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg);
  border-bottom: 1px solid var(--color-border-light);
}

.modal-header h3 {
  font-size: var(--font-size-lg);
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: var(--space-xs);
  line-height: 1;
}

.modal-body {
  padding: var(--space-lg);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--color-border-light);
}

/* ============================================
   Toast
   ============================================ */
.toast-container {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-xl);
  z-index: 2000;
  transform: translateY(20px);
  opacity: 0;
  transition: all var(--transition-normal);
}

.toast-container.toast-show {
  transform: translateY(0);
  opacity: 1;
}

.toast-content {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 12px 20px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-size: var(--font-size-sm);
}

.toast-success .toast-content {
  border-left: 4px solid var(--color-success);
}

.toast-error .toast-content {
  border-left: 4px solid var(--color-danger);
}

.toast-info .toast-content {
  border-left: 4px solid var(--color-primary);
}

.toast-icon {
  font-size: 1.1rem;
}

/* ============================================
   Hero Section
   ============================================ */
.hero {
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
  background: linear-gradient(135deg, var(--color-primary-light), var(--color-surface));
  border-radius: var(--radius-xl);
  margin-bottom: var(--space-2xl);
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -30%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(51, 102, 204, 0.08) 0%, transparent 70%);
  border-radius: var(--radius-full);
}

.hero-title {
  font-size: var(--font-size-4xl);
  font-weight: 700;
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
}

.hero-icon {
  font-size: 3rem;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-8px);
  }
}

.hero-subtitle {
  font-size: var(--font-size-xl);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-sm);
}

.hero-description {
  font-size: var(--font-size-base);
  color: var(--color-text-muted);
  max-width: 600px;
  margin: 0 auto var(--space-xl);
  line-height: 1.8;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: var(--space-xl);
  flex-wrap: wrap;
}

.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-md) var(--space-xl);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  min-width: 120px;
  transition: transform var(--transition-fast);
}

.stat-card:hover {
  transform: translateY(-2px);
}

.stat-number {
  font-size: var(--font-size-3xl);
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1;
}

.stat-label {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-xs);
}

/* ============================================
   Section Headers
   ============================================ */
.section {
  margin-bottom: var(--space-2xl);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.section-header h2 {
  font-size: var(--font-size-2xl);
  font-weight: 600;
}

/* ============================================
   School Cards
   ============================================ */
.schools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-lg);
}

.school-card {
  display: block;
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition-normal);
  text-decoration: none !important;
  color: var(--color-text);
}

.school-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--color-primary);
  text-decoration: none;
  color: var(--color-text);
}

.school-card-header {
  height: 120px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.school-logo {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-lg);
  object-fit: cover;
  background: white;
  padding: 4px;
}

.school-logo-placeholder {
  font-size: 3rem;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.school-card-body {
  padding: var(--space-md) var(--space-lg);
}

.school-name {
  font-size: var(--font-size-lg);
  font-weight: 600;
  margin-bottom: var(--space-xs);
}

.school-address {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

/* ============================================
   Class Cards
   ============================================ */
.classes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: var(--space-lg);
}

.class-card {
  display: block;
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition-normal);
  text-decoration: none !important;
  color: var(--color-text);
}

.class-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--color-primary);
  text-decoration: none;
  color: var(--color-text);
}

.class-card-cover {
  height: 100px;
  background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.class-card-emoji {
  font-size: 2.5rem;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

.lock-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  font-size: var(--font-size-xs);
}

.class-card-body {
  padding: var(--space-md);
}

.class-card-body h3 {
  font-size: var(--font-size-base);
  font-weight: 600;
  margin-bottom: var(--space-xs);
}

.class-card-meta {
  display: flex;
  gap: var(--space-md);
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

/* ============================================
   How It Works
   ============================================ */
.how-it-works h2 {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.steps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-lg);
}

.step-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  text-align: center;
  transition: all var(--transition-normal);
}

.step-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.step-number {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: white;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-md);
  font-size: var(--font-size-lg);
}

.step-card h3 {
  margin-bottom: var(--space-sm);
  font-size: var(--font-size-base);
}

.step-card p {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

/* ============================================
   Wikipedia-style Article
   ============================================ */
.wiki-article {
  max-width: var(--article-max-width);
  margin: 0 auto;
}

.article-cover {
  height: 200px;
  background-size: cover;
  background-position: center;
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-lg);
}

.article-layout {
  display: flex;
  gap: var(--space-xl);
}

.article-main {
  flex: 1;
  min-width: 0;
}

.article-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 2px solid var(--color-border);
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.article-header-content {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  flex: 1;
}

.school-page-logo {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-lg);
  object-fit: cover;
}

.article-title {
  font-size: var(--font-size-3xl);
  font-weight: 400;
  line-height: 1.2;
  font-family: 'Linux Libertine', 'Georgia', 'Times', serif;
}

.article-meta {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.article-actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.article-section {
  margin-bottom: var(--space-xl);
}

.article-section h2 {
  font-size: var(--font-size-2xl);
  font-weight: 400;
  padding-bottom: var(--space-xs);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-md);
  font-family: 'Linux Libertine', 'Georgia', 'Times', serif;
}

.article-section h3 {
  font-size: var(--font-size-xl);
  font-weight: 500;
  margin: var(--space-lg) 0 var(--space-md);
}

.article-content {
  line-height: 1.8;
  font-size: var(--font-size-base);
}

.article-content p {
  margin-bottom: var(--space-md);
}

.article-meta-section {
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border-light);
}

/* ============================================
   Table of Contents (TOC)
   ============================================ */
.toc {
  position: sticky;
  top: calc(var(--header-height) + var(--space-xl));
  width: 200px;
  flex-shrink: 0;
  max-height: calc(100vh - var(--header-height) - var(--space-2xl));
  overflow-y: auto;
}

.toc-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-toc-bg);
  border: 1px solid var(--color-toc-border);
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.toc-nav {
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border: 1px solid var(--color-toc-border);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  padding: var(--space-sm) 0;
}

.toc-link {
  display: block;
  padding: var(--space-xs) var(--space-md);
  font-size: var(--font-size-sm);
  color: var(--color-link);
  transition: background var(--transition-fast);
  text-decoration: none !important;
}

.toc-link:hover {
  background: var(--color-primary-light);
  text-decoration: none;
}

.toc-link.toc-sub {
  padding-left: var(--space-xl);
  font-size: var(--font-size-xs);
}

/* ============================================
   Infobox (Wikipedia-style)
   ============================================ */
.infobox {
  float: right;
  width: 280px;
  margin: 0 0 var(--space-lg) var(--space-lg);
  border: 1px solid var(--color-infobox-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--color-infobox-bg);
}

.infobox-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.infobox-header {
  background: var(--color-infobox-header);
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-size-base);
  font-weight: 600;
  text-align: center;
  color: var(--color-text);
}

[data-theme="dark"] .infobox-header {
  color: #e6edf3;
}

.infobox-image {
  text-align: center;
  padding: var(--space-sm);
}

.infobox-image img {
  max-width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.infobox-label {
  font-weight: 500;
  color: var(--color-text-secondary);
  padding: var(--space-xs) var(--space-md);
  border-top: 1px solid var(--color-border-light);
  vertical-align: top;
  width: 40%;
}

.infobox-table td:last-child {
  padding: var(--space-xs) var(--space-md);
  border-top: 1px solid var(--color-border-light);
}

/* ============================================
   Members
   ============================================ */
.members-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.member-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  text-decoration: none !important;
  color: var(--color-text);
  transition: all var(--transition-fast);
}

.member-card:hover {
  background: var(--color-surface-hover);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: var(--color-text);
}

.member-card-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  object-fit: cover;
  flex-shrink: 0;
}

.member-card-info h4 {
  font-size: var(--font-size-sm);
  font-weight: 600;
  margin-bottom: 2px;
}

.member-role-badge {
  display: inline-block;
  font-size: var(--font-size-xs);
  padding: 1px 8px;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

.role-teacher {
  background: #e0e0e0;
  color: #111111;
}

.role-monitor {
  background: #cccccc;
  color: #111111;
}

.role-student {
  background: #f0f0f0;
  color: #333333;
}

[data-theme="dark"] .role-teacher {
  background: #333333;
  color: #ffffff;
}

[data-theme="dark"] .role-monitor {
  background: #444444;
  color: #ffffff;
}

[data-theme="dark"] .role-student {
  background: #222222;
  color: #dddddd;
}

/* Members table */
.members-table-wrapper {
  overflow-x: auto;
}

.wiki-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
  background: var(--color-surface);
}

.wiki-table th {
  background: var(--color-infobox-bg);
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  font-weight: 600;
  border: 1px solid var(--color-border);
}

.wiki-table td {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border-light);
  vertical-align: middle;
}

.wiki-table tbody tr:hover {
  background: var(--color-surface-hover);
}

.member-avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  object-fit: cover;
}

.member-link {
  font-weight: 500;
}

.member-profile-avatar {
  width: 180px;
  height: 180px;
  border-radius: var(--radius-md);
  object-fit: cover;
}

.member-infobox {
  float: right;
  width: 260px;
}

/* ============================================
   Wiki Pages List
   ============================================ */
.wiki-pages-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.wiki-page-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
  text-decoration: none !important;
  color: var(--color-text);
}

.wiki-page-item:hover {
  background: var(--color-surface-hover);
  text-decoration: none;
  color: var(--color-text);
}

.wiki-page-title {
  flex: 1;
  color: var(--color-link);
}

.wiki-page-date {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

/* ============================================
   Empty State
   ============================================ */
.empty-state {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--color-text-muted);
}

.empty-state.small {
  padding: var(--space-xl);
}

.empty-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: var(--space-md);
}

/* ============================================
   Error Page
   ============================================ */
.error-page {
  text-align: center;
  padding: var(--space-2xl);
}

.error-page h1 {
  font-size: var(--font-size-4xl);
  margin-bottom: var(--space-md);
}

.error-page p {
  color: var(--color-text-muted);
  margin-bottom: var(--space-lg);
}

/* ============================================
   Edit Page
   ============================================ */
.edit-page {
  max-width: var(--article-max-width);
  margin: 0 auto;
}

.edit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}

.edit-header h1 {
  font-size: var(--font-size-2xl);
  font-weight: 600;
}

.edit-info {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.edit-author {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.editor-toolbar-info {
  margin-bottom: var(--space-sm);
}

.quill-container {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  min-height: 300px;
}

.quill-container .ql-editor {
  min-height: 300px;
  font-family: var(--font-primary);
  font-size: var(--font-size-base);
  line-height: 1.8;
  color: var(--color-text);
}

.quill-container .ql-toolbar {
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  border-color: var(--color-border);
}

.quill-container .ql-container {
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  border-color: var(--color-border);
}

.edit-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
  flex-wrap: wrap;
}

.preview-panel {
  margin-top: var(--space-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  background: var(--color-infobox-bg);
  border-bottom: 1px solid var(--color-border);
}

.preview-content {
  padding: var(--space-lg);
}

/* ============================================
   History / Revision Timeline
   ============================================ */
.history-page {
  max-width: var(--article-max-width);
  margin: 0 auto;
}

.revision-timeline {
  position: relative;
  padding-left: var(--space-xl);
}

.revision-timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--color-border);
}

.revision-item {
  position: relative;
  margin-bottom: var(--space-lg);
}

.revision-marker {
  position: absolute;
  left: calc(-1 * var(--space-xl) + 4px);
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  background: var(--color-border);
  border: 2px solid var(--color-surface);
}

.revision-latest .revision-marker {
  background: var(--color-primary);
  width: 12px;
  height: 12px;
  left: calc(-1 * var(--space-xl) + 3px);
}

.revision-content {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  padding: var(--space-md);
}

.revision-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-xs);
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.revision-author {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--font-size-sm);
}

.revision-time {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.revision-summary {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.revision-snapshot {
  margin-top: var(--space-sm);
}

.revision-snapshot summary {
  font-size: var(--font-size-sm);
  color: var(--color-link);
  cursor: pointer;
  padding: var(--space-xs) 0;
}

.revision-snapshot-content {
  margin-top: var(--space-sm);
  padding: var(--space-md);
  background: var(--color-bg);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  max-height: 300px;
  overflow-y: auto;
}

/* ============================================
   Admin Page
   ============================================ */
.admin-page {
  max-width: var(--content-max-width);
  margin: 0 auto;
}

.admin-page h1 {
  font-size: var(--font-size-2xl);
  margin-bottom: var(--space-xl);
}

.admin-stats {
  display: flex;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
  flex-wrap: wrap;
}

.stat-warning .stat-number {
  color: var(--color-danger);
}

.admin-tabs {
  display: flex;
  gap: var(--space-xs);
  margin-bottom: var(--space-lg);
  border-bottom: 2px solid var(--color-border);
}

.tab-btn {
  background: none;
  border: none;
  padding: var(--space-sm) var(--space-lg);
  font-family: var(--font-primary);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition-fast);
}

.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.tab-btn:hover {
  color: var(--color-text);
}

.admin-table-wrapper {
  overflow-x: auto;
}

.admin-table .action-btns {
  display: flex;
  gap: var(--space-xs);
}

.row-banned {
  background: var(--color-danger-light) !important;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  font-weight: 500;
}

.badge-success {
  background: var(--color-success-light);
  color: var(--color-success);
}

.badge-danger {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

.reports-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.report-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-left: 4px solid var(--color-warning);
  border-radius: var(--radius-md);
  padding: var(--space-md);
}

.report-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--space-sm);
}

.report-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
  .header {
    padding: 0 var(--space-md);
  }

  #sidebar-toggle {
    display: block;
  }

  .header-center {
    max-width: none;
  }

  .logo-text {
    display: none;
  }

  .user-name {
    display: none;
  }

  .breadcrumb {
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-xs);
  }

  .main-content {
    padding: var(--space-md);
  }

  .hero {
    padding: var(--space-xl) var(--space-md);
  }

  .hero-title {
    font-size: var(--font-size-2xl);
  }

  .hero-stats {
    gap: var(--space-md);
  }

  .stat-card {
    padding: var(--space-sm) var(--space-md);
    min-width: 80px;
  }

  .stat-number {
    font-size: var(--font-size-xl);
  }

  .article-layout {
    flex-direction: column;
  }

  .toc {
    position: static;
    width: 100%;
    max-height: none;
    margin-bottom: var(--space-lg);
  }

  .infobox,
  .member-infobox {
    float: none;
    width: 100%;
    margin: 0 0 var(--space-lg) 0;
  }

  .article-title {
    font-size: var(--font-size-2xl);
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .schools-grid,
  .classes-grid,
  .members-grid {
    grid-template-columns: 1fr;
  }

  .steps-grid {
    grid-template-columns: 1fr 1fr;
  }

  .modal {
    max-width: 100%;
    margin: var(--space-md);
  }
}

@media (max-width: 480px) {
  .steps-grid {
    grid-template-columns: 1fr;
  }

  .btn-login span:not(.btn-login svg) {
    display: inline;
  }

  .edit-header {
    flex-direction: column;
    gap: var(--space-sm);
  }
}

/* ============================================
   Quill Dark Mode Overrides
   ============================================ */
[data-theme="dark"] .ql-toolbar {
  background: var(--color-surface);
  border-color: var(--color-border) !important;
}

[data-theme="dark"] .ql-container {
  background: var(--color-surface);
  border-color: var(--color-border) !important;
}

[data-theme="dark"] .ql-editor {
  color: var(--color-text);
}

[data-theme="dark"] .ql-stroke {
  stroke: var(--color-text-secondary) !important;
}

[data-theme="dark"] .ql-fill {
  fill: var(--color-text-secondary) !important;
}

[data-theme="dark"] .ql-picker-label {
  color: var(--color-text-secondary) !important;
}

[data-theme="dark"] .ql-picker-options {
  background: var(--color-surface) !important;
  border-color: var(--color-border) !important;
}

[data-theme="dark"] .ql-picker-item {
  color: var(--color-text) !important;
}

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

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

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

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

/* ============================================
   Print Styles
   ============================================ */
@media print {

  .header,
  .breadcrumb,
  .footer,
  .btn,
  .article-actions,
  .toc {
    display: none !important;
  }

  .main-content {
    padding: 0;
  }

  .infobox {
    float: none;
    width: 100%;
  }
}

/* ============================================
   Wiki Hovercard Popover
   ============================================ */
.wiki-popover {
  position: absolute;
  z-index: 1000;
  width: 320px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  padding: 0;
  display: flex;
  flex-direction: column;
  animation: fadeIn 200ms ease;
  overflow: hidden;
}

.wiki-popover-header {
  padding: var(--space-md);
  background: var(--color-surface-hover);
  border-bottom: 1px solid var(--color-border-light);
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.wiki-popover-avatar {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-full);
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.wiki-popover-title {
  flex: 1;
}

.wiki-popover-title h4 {
  font-family: 'Linux Libertine', 'Georgia', 'Times', serif;
  font-size: var(--font-size-lg);
  margin: 0 0 4px 0;
  line-height: 1.2;
}

.wiki-popover-role {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.wiki-popover-body {
  padding: var(--space-md);
  font-size: var(--font-size-sm);
  color: var(--color-text);
  line-height: 1.5;
  max-height: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  -webkit-box-orient: vertical;
}

.wiki-popover-footer {
  padding: var(--space-sm) var(--space-md);
  border-top: 1px solid var(--color-border-light);
  background: var(--color-surface-hover);
  text-align: left;
}

.wiki-popover-link {
  font-size: var(--font-size-sm);
  font-weight: 500;
}