:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --secondary: #7c3aed;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --dark: #1e293b;
  --gray: #64748b;
  --gray-light: #e2e8f0;
  --white: #ffffff;
  --bg: #f8fafc;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

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

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

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

img { max-width: 100%; }

/* === NAVBAR === */
.navbar {
  background: var(--white);
  border-bottom: 1px solid var(--gray-light);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.navbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: nowrap;
}

.navbar-brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: .5rem;
  white-space: nowrap;
}

.navbar-brand:hover { text-decoration: none; }

.navbar-nav {
  display: flex;
  align-items: center;
  gap: .25rem;
  flex: 1;
}

.nav-link {
  padding: .4rem .8rem;
  border-radius: var(--radius);
  color: var(--gray);
  font-size: .9rem;
  font-weight: 500;
  transition: background .15s, color .15s;
}

.nav-link:hover { background: var(--bg); color: var(--dark); text-decoration: none; }
.nav-link.active { color: var(--primary); background: var(--primary-light); }

.navbar-right {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-left: auto;
}

.credits-badge {
  background: var(--primary-light);
  color: var(--primary);
  padding: .3rem .75rem;
  border-radius: 20px;
  font-size: .85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: .3rem;
}

.user-menu {
  position: relative;
}

.user-btn {
  background: none;
  border: 1px solid var(--gray-light);
  border-radius: 20px;
  padding: .35rem .9rem;
  cursor: pointer;
  font-size: .9rem;
  color: var(--dark);
  display: flex;
  align-items: center;
  gap: .4rem;
  transition: border-color .15s;
}

.user-btn:hover { border-color: var(--primary); }

.dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + .5rem);
  background: var(--white);
  border: 1px solid var(--gray-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 180px;
  overflow: hidden;
}

.dropdown.open { display: block; }

.dropdown a, .dropdown button {
  display: block;
  width: 100%;
  padding: .65rem 1rem;
  text-align: left;
  color: var(--dark);
  background: none;
  border: none;
  cursor: pointer;
  font-size: .9rem;
  border-bottom: 1px solid var(--gray-light);
}

.dropdown a:hover, .dropdown button:hover { background: var(--bg); text-decoration: none; }
.dropdown a:last-child, .dropdown button:last-child { border-bottom: none; }
.dropdown .danger { color: var(--danger); }

/* === HERO === */
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: var(--white);
  padding: 5rem 1.5rem;
  text-align: center;
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 1rem;
  line-height: 1.2;
}

.hero p {
  font-size: 1.15rem;
  opacity: .9;
  max-width: 600px;
  margin: 0 auto 2rem;
}

.hero-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* === BUTTONS === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .6rem 1.25rem;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-dark); color: var(--white); }

.btn-secondary { background: var(--secondary); color: var(--white); }
.btn-secondary:hover { background: #6d28d9; color: var(--white); }

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

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

.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #b91c1c; color: var(--white); }

.btn-success { background: var(--success); color: var(--white); }
.btn-success:hover { background: #15803d; color: var(--white); }

.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-lg { padding: .8rem 1.75rem; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }

.btn[disabled] { opacity: .6; cursor: not-allowed; transform: none; }

/* === CONTAINER === */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.section {
  padding: 3rem 0;
}

/* === CARDS === */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow .2s, transform .2s;
}

.card:hover { box-shadow: var(--shadow-md); }

.card-body { padding: 1.25rem; }
.card-footer { padding: .75rem 1.25rem; background: var(--bg); border-top: 1px solid var(--gray-light); }

/* === COURSE CARD === */
.courses-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.course-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow .2s, transform .2s;
  display: flex;
  flex-direction: column;
}

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

.course-card .thumbnail {
  width: 100%;
  height: 160px;
  object-fit: cover;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 2rem;
}

.course-card .thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.course-card .card-body {
  flex: 1;
  padding: 1rem;
}

.course-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: .4rem;
  color: var(--dark);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.course-card .teacher-name {
  font-size: .8rem;
  color: var(--gray);
  margin-bottom: .6rem;
}

.course-card .description {
  font-size: .85rem;
  color: var(--gray);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: .75rem;
}

.course-card .card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
}

.price-badge {
  background: var(--primary-light);
  color: var(--primary);
  padding: .25rem .6rem;
  border-radius: 20px;
  font-size: .85rem;
  font-weight: 700;
}

.meta-info {
  display: flex;
  gap: .75rem;
  font-size: .8rem;
  color: var(--gray);
}

/* === FORMS === */
.form-group {
  margin-bottom: 1.25rem;
}

label {
  display: block;
  font-size: .875rem;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: .4rem;
}

input, select, textarea {
  width: 100%;
  padding: .65rem .9rem;
  border: 1px solid var(--gray-light);
  border-radius: var(--radius);
  font-size: .9rem;
  font-family: var(--font);
  color: var(--dark);
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

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

.form-hint { font-size: .8rem; color: var(--gray); margin-top: .3rem; }
.form-error { font-size: .8rem; color: var(--danger); margin-top: .3rem; }

.checkbox-group {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.checkbox-group input[type="checkbox"] {
  width: auto;
  cursor: pointer;
}

/* === AUTH PAGES === */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
}

.auth-box {
  background: var(--white);
  border-radius: 12px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.auth-box h1 {
  text-align: center;
  font-size: 1.6rem;
  margin-bottom: .5rem;
  color: var(--dark);
}

.auth-box .subtitle {
  text-align: center;
  color: var(--gray);
  font-size: .9rem;
  margin-bottom: 2rem;
}

.role-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
  margin-bottom: 1.5rem;
}

.role-option {
  border: 2px solid var(--gray-light);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
}

.role-option:hover { border-color: var(--primary); }
.role-option.selected { border-color: var(--primary); background: var(--primary-light); }
.role-option .icon { font-size: 1.5rem; margin-bottom: .25rem; }
.role-option .name { font-size: .85rem; font-weight: 600; }

.divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.25rem 0;
  color: var(--gray);
  font-size: .8rem;
}

.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--gray-light);
}

/* === ALERTS === */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: 1rem;
}

.alert-error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: var(--success); border: 1px solid #bbf7d0; }
.alert-info { background: var(--primary-light); color: var(--primary); border: 1px solid #bfdbfe; }
.alert-warning { background: #fffbeb; color: var(--warning); border: 1px solid #fde68a; }

/* === PAGE HEADER === */
.page-header {
  background: var(--white);
  border-bottom: 1px solid var(--gray-light);
  padding: 2rem 0;
}

.page-header h1 { font-size: 1.75rem; font-weight: 700; }
.page-header p { color: var(--gray); margin-top: .25rem; }

/* === DASHBOARD === */
.dashboard-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 0;
  min-height: calc(100vh - 64px);
}

.sidebar {
  background: var(--white);
  border-right: 1px solid var(--gray-light);
  padding: 1.5rem 0;
}

.sidebar .sidebar-title {
  padding: 0 1rem .5rem;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--gray);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .65rem 1rem;
  color: var(--gray);
  font-size: .9rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all .15s;
}

.sidebar-link:hover { background: var(--bg); color: var(--dark); text-decoration: none; }
.sidebar-link.active { color: var(--primary); border-left-color: var(--primary); background: var(--primary-light); }

.main-content {
  padding: 2rem;
  overflow-x: hidden;
}

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

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: .25rem;
}

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

.stat-card .stat-label {
  font-size: .8rem;
  color: var(--gray);
}

.stat-card .stat-icon {
  font-size: 1.5rem;
  margin-bottom: .25rem;
}

/* === TABLES === */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

th {
  background: var(--bg);
  padding: .75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--gray);
  border-bottom: 2px solid var(--gray-light);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}

td {
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--gray-light);
  color: var(--dark);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

/* === MODAL === */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--white);
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

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

.modal-header h2 { font-size: 1.1rem; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--gray);
  padding: .25rem;
  border-radius: 4px;
}

.modal-close:hover { background: var(--bg); }
.modal-body { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--gray-light); display: flex; gap: .75rem; justify-content: flex-end; }

/* === COURSE DETAIL === */
.course-detail-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.course-info h1 { font-size: 1.75rem; font-weight: 700; margin-bottom: .75rem; }
.course-info .teacher-info { display: flex; align-items: center; gap: .5rem; color: var(--gray); font-size: .9rem; margin-bottom: 1rem; }
.course-info .description { color: var(--gray); line-height: 1.7; margin-bottom: 1.5rem; }

.course-sidebar-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  position: sticky;
  top: 80px;
}

.course-sidebar-card .price-section {
  padding: 1.5rem;
  text-align: center;
  border-bottom: 1px solid var(--gray-light);
}

.course-sidebar-card .price {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
}

.course-sidebar-card .price-label { font-size: .85rem; color: var(--gray); }
.course-sidebar-card .actions { padding: 1.25rem; }

/* === CONTENT LIST === */
.content-list { list-style: none; }

.content-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--gray-light);
  cursor: pointer;
  transition: background .15s;
  border-radius: 0;
}

.content-item:last-child { border-bottom: none; }
.content-item:hover { background: var(--bg); }
.content-item.active { background: var(--primary-light); }
.content-item.locked { cursor: default; opacity: .6; }

.content-item .icon { font-size: 1.1rem; flex-shrink: 0; }
.content-item .content-title { font-size: .9rem; font-weight: 500; flex: 1; }
.content-item .free-tag { font-size: .7rem; background: #ecfdf5; color: var(--success); padding: .15rem .4rem; border-radius: 4px; font-weight: 600; }
.content-item .lock-icon { font-size: .9rem; color: var(--gray); }

/* === VIDEO PLAYER === */
.content-player {
  background: var(--dark);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.content-player iframe {
  width: 100%;
  aspect-ratio: 16/9;
  border: none;
  display: block;
}

.content-player .text-content {
  padding: 2rem;
  background: var(--white);
  color: var(--dark);
  line-height: 1.8;
  white-space: pre-wrap;
  font-size: .95rem;
}

/* === TAGS === */
.tag {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  background: var(--bg);
  color: var(--gray);
  border: 1px solid var(--gray-light);
}

.tag-primary { background: var(--primary-light); color: var(--primary); border-color: #bfdbfe; }
.tag-success { background: #f0fdf4; color: var(--success); border-color: #bbf7d0; }

/* === EMPTY STATE === */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--gray);
}

.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h3 { font-size: 1.1rem; color: var(--dark); margin-bottom: .5rem; }
.empty-state p { font-size: .9rem; }

/* === LOADING === */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
}

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

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

/* === TOAST === */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.toast {
  background: var(--dark);
  color: var(--white);
  padding: .75rem 1.25rem;
  border-radius: var(--radius);
  font-size: .875rem;
  box-shadow: var(--shadow-md);
  animation: slideIn .25s ease;
  max-width: 320px;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

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

/* === RESPONSIVE === */
@media (max-width: 900px) {
  .dashboard-layout { grid-template-columns: 1fr; }
  .sidebar { 
    border-right: none; 
    border-bottom: 1px solid var(--gray-light); 
    padding: .25rem .5rem; 
    display: flex; 
    overflow-x: auto; 
    gap: .25rem;
    position: sticky;
    top: 64px;
    z-index: 90;
    background: var(--white);
  }
  .sidebar-link { 
    border-left: none; 
    border-bottom: 3px solid transparent; 
    white-space: nowrap; 
    padding: .8rem 1rem;
    height: 100%;
    display: flex;
    align-items: center;
  }
  .sidebar-link.active { border-left: none; border-bottom-color: var(--primary); }
  .sidebar .sidebar-title { display: none; }
  .course-detail-layout { grid-template-columns: 1fr; }
  .course-sidebar-card { position: static; }
}

@media (max-width: 600px) {
  .hero h1 { font-size: 1.75rem; }
  .navbar-nav { display: none; }
  .courses-grid { grid-template-columns: 1fr; }
  .auth-box { padding: 1.75rem; }
  .main-content { padding: 1rem; }
  .role-selector { grid-template-columns: 1fr; }
}

/* === UTILITIES === */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-gray { color: var(--gray); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.font-bold { font-weight: 700; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.hidden { display: none !important; }
.badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: #f0fdf4; color: var(--success); }
.badge-warning { background: #fffbeb; color: var(--warning); }
.badge-gray { background: var(--bg); color: var(--gray); }
