/* =========================================================
   ANSHA MONTESSORI LMS — DASHBOARD CSS
   Sidebar, header, layout, nav items
   ========================================================= */

/* ---- App Shell ---- */
.app-shell {
  display: flex;
  min-height: 100vh;
  background: var(--gray-100);
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #171233 0%, #1e1b4b 55%, #211442 100%);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  transition: var(--transition);
  border-right: 1px solid rgba(255,255,255,0.04);
}

.sidebar-logo {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}
.sidebar-logo .logo-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(124,58,237,0.4);
}
.sidebar-logo .logo-text { flex: 1; min-width: 0; }
.sidebar-logo .logo-text h2 {
  font-size: 0.875rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-logo .logo-text p { font-size: 0.7rem; color: var(--gray-400); }

.sidebar-user {
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}
.sidebar-user .user-info { flex: 1; min-width: 0; }
.sidebar-user .user-name { font-size: 0.875rem; font-weight: 600; color: #ffffff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .user-role { font-size: 0.75rem; color: var(--gray-400); text-transform: capitalize; }

.sidebar-nav {
  flex: 1;
  padding: var(--space-4) 0;
  overflow-y: auto;
}

.nav-section-title {
  padding: var(--space-3) var(--space-6) var(--space-1);
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 9px 14px;
  margin: 2px 12px;
  border-radius: 10px;
  color: #b7aed6;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  position: relative;
}
.nav-item:hover {
  color: #ffffff;
  background: rgba(255,255,255,0.07);
}
.nav-item.active {
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  box-shadow: 0 4px 12px rgba(124,58,237,0.35);
  font-weight: 600;
}
.nav-item .nav-icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--primary);
  color: #ffffff;
  font-size: 0.6875rem;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 600;
}

.sidebar-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.logout-btn {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--gray-400);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  padding: 8px 0;
  background: none;
  border: none;
  width: 100%;
  transition: var(--transition);
}
.logout-btn:hover { color: var(--danger); }

/* ---- Main Content ---- */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---- Top Header ---- */
.top-header {
  height: var(--header-height);
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--gray-200);
  padding: 0 var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 3px rgba(15,23,42,0.04);
}

.header-left { display: flex; align-items: center; gap: var(--space-4); }
.page-title { font-size: 1.125rem; font-weight: 600; color: var(--gray-900); }
.breadcrumb { font-size: 0.8125rem; color: var(--gray-500); }
.breadcrumb span { color: var(--gray-300); margin: 0 6px; }

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

.header-search {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--gray-100);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-full);
  padding: 7px 16px;
  width: 240px;
  transition: var(--transition);
}
.header-search:focus-within {
  border-color: var(--primary);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.1);
}
.header-search input {
  border: none; background: transparent; outline: none;
  font-size: 0.875rem; color: var(--gray-800); width: 100%;
}
.header-search input::placeholder { color: var(--gray-400); }
.header-search .search-icon { color: var(--gray-400); font-size: 0.875rem; }

.notif-btn {
  width: 38px; height: 38px;
  background: var(--gray-100);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  cursor: pointer;
  position: relative;
  transition: var(--transition);
}
.notif-btn:hover { background: var(--primary-light); border-color: var(--primary); }
.notif-dot {
  position: absolute; top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: var(--radius-full);
  border: 2px solid var(--white);
}

/* ---- Page Content ---- */
.page-content {
  flex: 1;
  padding: var(--space-6);
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}
.page-header h1 { font-size: 1.5rem; font-weight: 700; }
.page-header p { color: var(--gray-500); font-size: 0.9rem; margin-top: 2px; }

/* ---- Stat Cards ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-5);
  margin-bottom: var(--space-6);
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-100);
  border-top: 3px solid var(--gray-200);
  transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.stat-card:nth-child(1) { border-top-color: var(--primary); }
.stat-card:nth-child(2) { border-top-color: var(--success); }
.stat-card:nth-child(3) { border-top-color: var(--accent); }
.stat-card:nth-child(4) { border-top-color: var(--info); }

.stat-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}
.stat-icon.teal   { background: var(--primary-light); }
.stat-icon.gold   { background: var(--accent-light); }
.stat-icon.green  { background: var(--success-light); }
.stat-icon.blue   { background: var(--info-light); }
.stat-icon.red    { background: var(--danger-light); }

.stat-info { flex: 1; }
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--gray-900); line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: 0.8125rem; color: var(--gray-500); font-weight: 500; }
.stat-change { font-size: 0.75rem; margin-top: 6px; }
.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ---- Content Cards ---- */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-100);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h2 { font-size: 1rem; font-weight: 600; }
.card-body { padding: var(--space-5) var(--space-6); }
.card-footer { padding: var(--space-4) var(--space-6); border-top: 1px solid var(--gray-100); background: var(--gray-50); }

/* ---- Course Card ---- */
.course-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-100);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
}
.course-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-3px); }

.course-thumbnail {
  height: 160px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex; align-items: center; justify-content: center;
  font-size: 3rem;
  position: relative;
  overflow: hidden;
  color: rgba(255,255,255,0.9);
}
.course-thumbnail::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(to bottom, transparent 50%, rgba(0,0,0,0.3));
}

.course-body { padding: var(--space-4) var(--space-5); flex: 1; display: flex; flex-direction: column; }
.course-body h3 { font-size: 0.9375rem; font-weight: 600; margin-bottom: var(--space-2); line-height: 1.4; }
.course-body p { font-size: 0.8125rem; color: var(--gray-500); flex: 1; margin-bottom: var(--space-3); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.course-meta { display: flex; gap: var(--space-3); flex-wrap: wrap; font-size: 0.75rem; color: var(--gray-500); margin-bottom: var(--space-3); }
.course-meta span { display: flex; align-items: center; gap: 4px; }

.course-footer { padding: var(--space-3) var(--space-5); border-top: 1px solid var(--gray-100); display: flex; align-items: center; justify-content: space-between; }

/* ---- Tabs ---- */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--gray-200); margin-bottom: var(--space-6); }
.tab-btn {
  padding: 10px 20px;
  border: none; background: transparent;
  font-size: 0.9rem; font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  transition: var(--transition);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ---- Search & Filter Bar ---- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}
.filter-bar .search-input {
  flex: 1;
  min-width: 200px;
  max-width: 320px;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 8px 14px;
}
.filter-bar .search-input:focus-within { border-color: var(--primary); }
.filter-bar .search-input input { border: none; background: none; outline: none; font-size: 0.875rem; flex: 1; }
.filter-bar select.form-control { width: auto; min-width: 150px; padding-top: 8px; padding-bottom: 8px; }

/* ---- Hamburger button (all screens: mobile drawer / desktop collapse) ---- */
.hamburger-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--gray-700);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius);
  transition: var(--transition);
  line-height: 1;
  min-width: 38px; min-height: 38px;
}
.hamburger-btn:hover { background: var(--gray-100); color: var(--primary); }

/* ---- Sidebar overlay (mobile) ---- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 99;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ---- Desktop: collapse sidebar for full-width view ---- */
.main-content { transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1); }
@media (min-width: 769px) {
  body.sidebar-collapsed .sidebar { transform: translateX(-100%); box-shadow: none; }
  body.sidebar-collapsed .main-content { margin-left: 0; }
}

/* ---- Responsive Sidebar ---- */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  /* Hamburger */
  .hamburger-btn { display: flex; }

  /* Sidebar slides in from left */
  .sidebar { transform: translateX(-100%); z-index: 100; }
  .sidebar.open { transform: translateX(0); box-shadow: 6px 0 24px rgba(0,0,0,0.35); }

  /* Main content takes full width */
  .main-content { margin-left: 0; }

  /* Header */
  .top-header { padding: 0 var(--space-3); }
  .header-search { display: none; }
  .page-title { font-size: 1rem; }

  /* Page content */
  .page-content { padding: var(--space-3); }
  .page-header { flex-direction: column; align-items: flex-start; gap: var(--space-2); margin-bottom: var(--space-4); }
  .page-header h1 { font-size: 1.2rem; }

  /* Stats */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: var(--space-3); }
  .stat-card { padding: var(--space-4); }
  .stat-icon { width: 44px; height: 44px; font-size: 1.25rem; }
  .stat-value { font-size: 1.4rem; }

  /* Cards */
  .card-header { padding: var(--space-4); }
  .card-body   { padding: var(--space-4); }
  .card-footer { padding: var(--space-3) var(--space-4); }

  /* Tabs — horizontal scroll */
  .tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  .tab-btn { white-space: nowrap; padding: 9px 14px; font-size: 0.8125rem; flex-shrink: 0; }

  /* Nav items — bigger tap targets */
  .nav-item { padding: 13px var(--space-6); font-size: 0.9375rem; min-height: 48px; }

  /* Modals — near full screen */
  .modal { width: 96vw !important; max-width: 96vw !important; margin: 16px auto; max-height: 88vh; overflow-y: auto; }
  .modal-body { max-height: 60vh; overflow-y: auto; }

  /* Filter bar */
  .filter-bar { gap: var(--space-2); }
  .filter-bar .search-input { min-width: 0; flex: 1; }
  .filter-bar select.form-control { min-width: 110px; }

  /* Table horizontal scroll already handled by .table-wrapper */
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: var(--space-2); }
  .stat-card { padding: var(--space-3); }
  .stat-icon { width: 38px; height: 38px; font-size: 1.1rem; }
  .stat-value { font-size: 1.2rem; }
  .stat-label { font-size: 0.7rem; }
  .page-content { padding: var(--space-2); }
  .btn { padding: 8px 12px; font-size: 0.8125rem; }
  .page-header .btn { align-self: stretch; text-align: center; }
}

/* =========================================================
   MOBILE BOTTOM NAVIGATION (app-style)
   ========================================================= */
.bottom-nav {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--bottomnav-height) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--gray-200);
  box-shadow: 0 -4px 20px rgba(15,23,42,0.08);
  z-index: 90;
}
.bottom-nav-inner {
  display: flex;
  height: var(--bottomnav-height);
}
.bnav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--gray-500);
  font-size: 0.62rem;
  font-weight: 600;
  text-decoration: none;
  border: none;
  background: none;
  padding: 6px 2px;
  min-width: 0;
  transition: var(--transition);
}
.bnav-item i { font-size: 1.15rem; line-height: 1; }
.bnav-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.bnav-item.active { color: var(--primary); }
.bnav-item.active i { transform: translateY(-1px); }
.bnav-item:active { transform: scale(0.94); }

@media (max-width: 768px) {
  .bottom-nav { display: block; }
  /* keep content clear of the bar */
  .page-content { padding-bottom: calc(var(--bottomnav-height) + env(safe-area-inset-bottom, 0px) + 16px) !important; }
  /* sidebar drawer above bottom nav */
  .sidebar { z-index: 110; }
  .sidebar-overlay { z-index: 105; }
}
