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

:root {
  /* Colors - Premium Light Theme */
  --bg-body: #F8FAFC;
  --bg-surface: #FFFFFF;
  --bg-surface-hover: #F1F5F9;
  --text-primary: #0F172A;
  --text-secondary: #64748B;
  --text-muted: #94A3B8;
  --primary: #10B981; /* QBO Green */
  --primary-hover: #059669;
  --primary-light: #D1FAE5;
  --danger: #EF4444;
  --danger-light: #FEE2E2;
  --warning: #F59E0B;
  --warning-light: #FEF3C7;
  --info: #3B82F6;
  --info-light: #DBEAFE;
  
  /* Borders & Shadows */
  --border-color: #E2E8F0;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  
  /* Radius */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  /* Transitions */
  --transition: all 0.3s ease;
}

/* ============================================================
   PAGE LOADER
============================================================ */
.page-loader {
  position: fixed;
  inset: 0;
  background: var(--bg-body);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.3s ease;
}
.loader {
  width: 40px;
  height: 40px;
  border: 4px solid var(--primary-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: qbo-spin 0.75s linear infinite;
}
@keyframes qbo-spin { to { transform: rotate(360deg); } }

/* Reset & Base */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; transition: var(--transition); }
button { cursor: pointer; font-family: inherit; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: #94A3B8; }

/* Layout: Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  padding: 24px 20px;
  overflow-y: auto;
  z-index: 1000;
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 40px;
  padding: 0 10px;
}
.sidebar-logo img { width: 40px; height: 40px; object-fit: contain; }
.sidebar-logo span { color: var(--primary); }

.sidebar-section {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin: 24px 0 12px 10px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 4px;
}
.sidebar-link i { font-size: 1.1rem; width: 24px; text-align: center; }
.sidebar-link:hover, .sidebar-link.active {
  background: var(--bg-surface-hover);
  color: var(--primary);
}
.sidebar-link.active {
  background: var(--primary-light);
}

/* Sidebar Dropdowns */
.sidebar-group-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 4px;
  transition: var(--transition);
  user-select: none;
}
.sidebar-group-btn span { display: flex; align-items: center; gap: 12px; }
.sidebar-group-btn span i { font-size: 1.1rem; width: 24px; text-align: center; }
.sidebar-group-btn:hover { background: var(--bg-surface-hover); color: var(--text-primary); }
.sidebar-group-btn i.fa-chevron-down {
  font-size: 0.8rem;
  transition: transform 0.3s ease;
}
.sidebar-group-btn.open i.fa-chevron-down { transform: rotate(180deg); }
.sidebar-submenu { padding-left: 20px; }

/* Layout: Main Wrapper & Topbar */
.main-wrapper {
  margin-left: 280px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.topbar {
  height: 80px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 900;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}
.topbar h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
}
.mobile-menu-btn:hover {
  background: var(--bg-surface-hover);
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-surface);
  padding: 6px 16px 6px 6px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
}
.topbar-user-info { display: flex; flex-direction: column; }
.topbar-user-info .name { font-weight: 600; font-size: 0.9rem; color: var(--text-primary); line-height: 1.2; }
.topbar-user-info .role { font-size: 0.75rem; color: var(--text-muted); text-transform: capitalize; }

/* Page Content */
.page-content {
  padding: 32px;
  flex: 1;
}

/* UI Components: Cards */
.premium-card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  transition: var(--transition);
  margin-bottom: 24px;
}
.premium-card:hover {
  box-shadow: var(--shadow-md);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 16px;
}
.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.card-title i { color: var(--primary); }

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.stat-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}
.stat-icon.green { background: var(--primary-light); color: var(--primary); }
.stat-icon.blue { background: var(--info-light); color: var(--info); }
.stat-icon.orange { background: var(--warning-light); color: var(--warning); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }

.stat-info { display: flex; flex-direction: column; }
.stat-info h3 { font-size: 1.75rem; font-weight: 800; color: var(--text-primary); margin: 0 0 4px 0; line-height: 1; }
.stat-info p { font-size: 0.875rem; color: var(--text-secondary); margin: 0; font-weight: 500; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  border: none;
  transition: var(--transition);
  cursor: pointer;
  text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border-color); color: var(--text-primary); }
.btn-outline:hover { background: var(--bg-surface-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #DC2626; color: #fff;}
.btn-sm { padding: 6px 12px; font-size: 0.8rem; border-radius: var(--radius-sm); }

/* Forms */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 0.875rem; font-weight: 600; color: var(--text-primary); margin-bottom: 8px; }
.form-control {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  color: var(--text-primary);
  background: var(--bg-surface);
  transition: var(--transition);
  font-family: inherit;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
textarea.form-control { resize: vertical; min-height: 100px; }

/* Tables */
.table-responsive { overflow-x: auto; }
.table-modern { width: 100%; border-collapse: separate; border-spacing: 0; }
.table-modern th {
  background: var(--bg-surface-hover);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}
.table-modern td {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.9rem;
  vertical-align: middle;
}
.table-modern tbody tr { transition: var(--transition); }
.table-modern tbody tr:hover { background: var(--bg-body); }
.table-modern tbody tr:last-child td { border-bottom: none; }

/* Badges */
.badge {
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.badge-success { background: var(--primary-light); color: var(--primary-hover); }
.badge-warning { background: var(--warning-light); color: #D97706; }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--info-light); color: #2563EB; }
.badge-secondary { background: var(--bg-body); color: var(--text-secondary); border: 1px solid var(--border-color); }

/* Alerts */
.alert { padding: 16px; border-radius: var(--radius-md); margin-bottom: 20px; font-size: 0.9rem; border: 1px solid transparent; display: flex; align-items: center; gap: 12px; }
.alert-success { background: var(--primary-light); color: var(--primary-hover); border-color: #A7F3D0; }
.alert-danger { background: var(--danger-light); color: var(--danger); border-color: #FECACA; }
.alert-info { background: var(--info-light); color: #2563EB; border-color: #BFDBFE; }

/* Dashboard specific Layouts */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}
.hero-banner {
  background: linear-gradient(135deg, var(--primary-light), #ECFDF5);
  border-radius: var(--radius-lg);
  padding: 40px;
  margin-bottom: 32px;
  border: 1px solid var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.hero-content h1 { font-size: 2rem; font-weight: 800; color: var(--text-primary); margin-bottom: 12px; }
.hero-content h1 span { color: var(--primary); }
.hero-content p { color: var(--text-secondary); font-size: 1.1rem; max-width: 500px; }

/* Course Cards Specific */
.course-card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-color);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  height: 100%;
}
.course-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.course-thumb {
  height: 180px;
  background: var(--bg-body);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.course-thumb img { width: 100%; height: 100%; object-fit: cover; }
.course-thumb-placeholder { font-size: 3rem; color: var(--text-muted); }
.course-body { padding: 20px; flex: 1; display: flex; flex-direction: column; }
.course-title { font-size: 1.1rem; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; }
.course-desc { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 16px; flex: 1; }
.course-footer { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--border-color); padding-top: 16px; margin-top: auto; }

/* Dashboard Stat Cards & Student Stats */
.stat-card, .student-stat {
  background: var(--bg-surface);
  padding: 24px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  gap: 18px;
  height: 100%;
  border: 1px solid var(--border-color);
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}
.stat-card:hover, .student-stat:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
}
.stat-card-icon, .student-icon {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}
.sc-green, .s-green { background: var(--primary-light); color: var(--primary-hover); }
.sc-blue, .s-blue { background: var(--info-light); color: var(--info); }
.sc-yellow, .s-yellow { background: var(--warning-light); color: #D97706; }
.sc-red, .s-red { background: var(--danger-light); color: var(--danger); }

.stat-card-info h3, .student-info h3 {
  font-size: 1.75rem;
  font-weight: 800;
  margin: 0;
  color: var(--text-primary);
  line-height: 1.2;
}
.stat-card-info p, .student-info p {
  margin: 4px 0 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Dashboard Hero (Legacy Support) */
.hero-welcome, .hero-title { font-size: 2rem; font-weight: 800; color: var(--text-primary); margin-bottom: 12px; }
.hero-text, .hero-sub { color: var(--text-secondary); font-size: 1.1rem; max-width: 600px; }
.student-hero {
  background: linear-gradient(135deg, var(--primary-light), #ECFDF5);
  border-radius: var(--radius-lg);
  padding: 40px;
  margin-bottom: 32px;
  border: 1px solid var(--primary-light);
  display: flex;
  flex-direction: column;
}

/* Dashboard generic cards */
.dashboard-card, .premium-card {
  background: var(--bg-surface);
  padding: 24px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  height: 100%;
  box-shadow: var(--shadow-sm);
}

/* Quick Action Buttons & General Buttons */
.quick-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  font-weight: 600;
  color: var(--text-secondary);
  transition: var(--transition);
}
.quick-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  transform: translateY(-2px);
  border-color: var(--text-muted);
}

.btn-accent {
  background: var(--primary);
  color: #fff;
  border: none;
  font-weight: 600;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  transition: var(--transition);
}
.btn-accent:hover {
  background: var(--primary-hover);
  color: #fff;
  box-shadow: var(--shadow-md);
}

/* Login Page Styles */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-body);
  padding: 20px;
}
.login-card {
  background: var(--bg-surface);
  padding: 40px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 450px;
  border: 1px solid var(--border-color);
}


/* Payment Items */
.payment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-color);
}
.payment-item:last-child { border-bottom: none; padding-bottom: 0; }
.payment-user { display: flex; align-items: center; gap: 14px; }
.payment-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--info-light);
  color: var(--info);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
}
.payment-name { font-weight: 600; color: var(--text-primary); font-size: 0.95rem; }
.payment-date { font-size: 0.8rem; color: var(--text-secondary); margin-top: 4px; }
.payment-amount { font-weight: 700; color: var(--primary); font-size: 1.1rem; }

/* Utilities */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--primary); }
.text-danger { color: var(--danger); }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }

/* Footer */
.qbo-footer {
  margin-top: auto;
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-surface);
}
.qbo-footer p { margin: 0; }
.qbo-footer span { font-weight: 600; color: var(--text-primary); }

/* Responsive - Mobile First Enhancements */
@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .mobile-menu-btn { display: block; }
  .topbar { padding: 0 16px; height: 70px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
  .hero-banner { padding: 24px; flex-direction: column; text-align: center; gap: 16px; }
  .hero-welcome { font-size: 1.5rem; }
  .hero-text { font-size: 0.95rem; }
}

@media (max-width: 768px) {
  /* Force stat cards to stack if they are in col-6 on mobile */
  .col-6 { width: 100%; } 
  .stat-card, .student-stat { padding: 16px; flex-direction: row; gap: 12px; }
  .stat-card-icon, .student-icon { width: 44px; height: 44px; font-size: 1.2rem; }
  .stat-card-info h3, .student-info h3 { font-size: 1.4rem; }
  .stat-card-info p, .student-info p { font-size: 0.8rem; }
  
  .payment-item, .course-item { flex-direction: column; align-items: flex-start; gap: 12px; }
  .payment-amount { align-self: flex-start; padding-left: 62px; }

  .dashboard-card, .premium-card { padding: 18px; }
  .quick-btn { padding: 12px; font-size: 0.9rem; }
  .student-hero { padding: 24px; }
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(2px);
  z-index: 950;
  display: none;
}
.sidebar-overlay.show { display: block; }
