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

:root {
  --bg: #fafafa;
  --bg-card: #ffffff;
  --bg-sidebar: #111827;
  --text: #1f2937;
  --text-secondary: #6b7280;
  --text-light: #9ca3af;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #059669;
  --success-light: #d1fae5;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.1);
  --transition: 0.2s ease;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

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

/* ========== LUCIDE ICONS ========== */
.lucide {
  width: 20px;
  height: 20px;
  stroke-width: 2;
  vertical-align: middle;
  flex-shrink: 0;
}

.icon-sm .lucide { width: 16px; height: 16px; }
.icon-lg .lucide { width: 24px; height: 24px; }
.icon-xl .lucide { width: 32px; height: 32px; }

/* ========== TYPOGRAPHY ========== */
h1 { font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 1.125rem; font-weight: 600; }

/* ========== AUTH PAGES ========== */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 16px;
}

.auth-card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  position: relative;
}

.auth-card .logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-card .logo h1 {
  font-size: 1.75rem;
  background: linear-gradient(135deg, #667eea, #764ba2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-card .logo p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-top: 4px;
}

/* ========== FORM ELEMENTS ========== */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-card);
  transition: border-color var(--transition);
  outline: none;
}

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

.form-group textarea {
  resize: vertical;
  min-height: 100px;
}

/* ========== BUTTONS ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
  line-height: 1.4;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }

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

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

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

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 12px;
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-ghost .lucide { width: 18px; height: 18px; }

.btn-full { width: 100%; }
.btn-sm { padding: 6px 14px; font-size: 0.8125rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }

.btn .lucide { width: 18px; height: 18px; }
.btn-sm .lucide { width: 16px; height: 16px; }
.btn-lg .lucide { width: 20px; height: 20px; }

/* ========== LAYOUT ========== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  color: #fff;
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-logo {
  padding: 0 24px;
  margin-bottom: 32px;
}

.sidebar-logo h2 {
  font-size: 1.25rem;
  color: #fff;
}

.sidebar-logo span {
  font-size: 0.75rem;
  color: #9ca3af;
}

.sidebar-nav {
  flex: 1;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  color: #d1d5db;
  font-size: 0.9375rem;
  transition: all var(--transition);
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(255,255,255,0.08);
  color: #fff;
  border-left-color: var(--primary);
}

.sidebar-nav a .lucide {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-bottom {
  padding: 8px 24px;
  display: flex;
  justify-content: center;
}

.lang-btn {
  background: rgba(255,255,255,0.1);
  color: #e5e7eb;
  border: 1px solid rgba(255,255,255,0.15);
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
  letter-spacing: 0.5px;
}

.lang-btn:hover {
  background: rgba(255,255,255,0.2);
}

.auth-lang {
  position: absolute;
  top: 16px;
  right: 16px;
}

.auth-lang .lang-btn {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.auth-lang .lang-btn:hover {
  background: var(--border);
}

.sidebar-user {
  padding: 16px 24px;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-user .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.sidebar-user .user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user .user-info .name {
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user .user-info .role {
  font-size: 0.75rem;
  color: #9ca3af;
}

.main-content {
  flex: 1;
  margin-left: 260px;
  padding: 32px;
  max-width: 1200px;
}

/* ========== HEADER BAR ========== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 1.75rem;
}

/* ========== SEARCH ========== */
.search-box {
  position: relative;
  width: 100%;
  max-width: 400px;
}

.search-box input {
  width: 100%;
  padding: 10px 14px 10px 40px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  background: var(--bg-card);
  outline: none;
  transition: all var(--transition);
}

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

.search-box .lucide {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-light);
}

/* ========== CARDS ========== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 24px;
  transition: all var(--transition);
}

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

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.course-card {
  cursor: pointer;
}

.course-card .course-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 16px;
}

.course-card h3 {
  margin-bottom: 8px;
}

.course-card p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 16px;
}

.course-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.8125rem;
  color: var(--text-light);
}

.course-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.course-meta .lucide {
  width: 14px;
  height: 14px;
}

/* ========== STATS ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
}

.stat-card .stat-label {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
}

.stat-card .stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  font-size: 1.25rem;
}

.stat-card .stat-icon .lucide {
  width: 22px;
  height: 22px;
}

/* ========== PROGRESS BAR ========== */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 12px;
}

.progress-bar .progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.5s ease;
}

.progress-text {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 6px;
}

/* ========== MODULE PAGE ========== */
.module-layout {
  max-width: 800px;
}

.module-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.module-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  margin-bottom: 24px;
  line-height: 1.8;
}

.module-content h2 { margin: 24px 0 12px; font-size: 1.375rem; }
.module-content h3 { margin: 20px 0 10px; font-size: 1.125rem; }
.module-content p { margin-bottom: 12px; }
.module-content ul, .module-content ol { margin: 0 0 16px 24px; }
.module-content li { margin-bottom: 6px; }

.module-content pre {
  background: #1e293b;
  color: #e2e8f0;
  padding: 16px 20px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 0.875rem;
  margin: 16px 0;
  line-height: 1.5;
}

.module-content code {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.875rem;
}

.module-content pre code {
  background: none;
  padding: 0;
}

.video-container {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius);
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.25rem;
  overflow: hidden;
}

.video-container iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.module-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 24px;
}

/* ========== QUIZ ========== */
.quiz-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

.quiz-section h3 {
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.quiz-question {
  margin-bottom: 24px;
}

.quiz-question p {
  font-weight: 500;
  margin-bottom: 12px;
}

.quiz-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all var(--transition);
  font-size: 0.9375rem;
}

.quiz-option:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.quiz-option.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

.quiz-option.correct {
  border-color: var(--success);
  background: var(--success-light);
}

.quiz-option.wrong {
  border-color: var(--danger);
  background: var(--danger-light);
}

.quiz-result {
  text-align: center;
  padding: 20px;
  border-radius: var(--radius-sm);
  margin-top: 16px;
  font-weight: 600;
}

.quiz-result.pass {
  background: var(--success-light);
  color: var(--success);
}

.quiz-result.fail {
  background: var(--warning-light);
  color: var(--warning);
}

/* ========== FORUM ========== */
.forum-topic {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all var(--transition);
}

.forum-topic:hover {
  box-shadow: var(--shadow);
  border-color: var(--primary);
}

.forum-topic h3 { margin-bottom: 6px; }

.forum-topic .topic-meta {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 16px;
}

.forum-topic .topic-meta .lucide {
  width: 14px;
  height: 14px;
}

.forum-topic .topic-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

h1 .lucide, h2 .lucide, h3 .lucide {
  vertical-align: -2px;
  margin-right: 4px;
}

.reply-item {
  display: flex;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.reply-item:last-child { border-bottom: none; }

.reply-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.reply-body { flex: 1; }

.reply-body .reply-author {
  font-weight: 500;
  font-size: 0.875rem;
  margin-bottom: 4px;
}

.reply-body .reply-date {
  font-size: 0.75rem;
  color: var(--text-light);
}

.reply-body .reply-text {
  margin-top: 6px;
  font-size: 0.9375rem;
  line-height: 1.6;
}

/* ========== CHAT ========== */
.chat-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  height: 500px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.chat-msg {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.chat-msg .msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.chat-msg .msg-content {
  flex: 1;
}

.chat-msg .msg-name {
  font-size: 0.8125rem;
  font-weight: 600;
}

.chat-msg .msg-name .badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.625rem;
  font-weight: 500;
  margin-left: 6px;
  text-transform: uppercase;
}

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

.chat-msg .msg-text {
  font-size: 0.875rem;
  margin-top: 2px;
  line-height: 1.5;
}

.chat-msg .msg-time {
  font-size: 0.6875rem;
  color: var(--text-light);
  margin-top: 2px;
}

.chat-input {
  display: flex;
  gap: 8px;
  padding: 16px;
  border-top: 1px solid var(--border);
}

.chat-input input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  outline: none;
  font-family: var(--font);
}

.chat-input input:focus {
  border-color: var(--primary);
}

/* ========== BADGES ========== */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-blue { background: var(--primary-light); color: var(--primary); }
.badge-green { background: var(--success-light); color: var(--success); }
.badge-yellow { background: var(--warning-light); color: var(--warning); }

/* ========== TABS ========== */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}

.tab-btn {
  padding: 10px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
}

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

/* ========== MODAL ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform var(--transition);
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal h2 {
  margin-bottom: 24px;
}

/* ========== TOAST ========== */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  animation: slideIn 0.3s ease;
  max-width: 360px;
}

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

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ========== EMPTY STATE ========== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-state .lucide {
  width: 64px;
  height: 64px;
  color: var(--text-light);
  margin-bottom: 16px;
}

.empty-state h3 { margin-bottom: 8px; color: var(--text); }
.empty-state p { font-size: 0.875rem; }

/* ========== LOADING ========== */
.loader {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ========== MOBILE MENU ========== */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 200;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  cursor: pointer;
  box-shadow: var(--shadow);
  line-height: 0;
}

.mobile-menu-btn .lucide { width: 22px; height: 22px; }

.sidebar-close {
  display: none;
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close { display: block; }
  .mobile-menu-btn { display: block; }

  .main-content {
    margin-left: 0;
    padding: 16px;
    padding-top: 60px;
  }

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

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .search-box { max-width: 100%; }

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

  .module-content {
    padding: 20px;
  }

  .auth-card {
    padding: 24px;
  }
}

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