:root {
  --primary-color: #2563eb;
  /* Blue 600 */
  --primary-hover: #1d4ed8;
  /* Blue 700 */
  --secondary-color: #1e3a8a;
  /* Blue 900 (Dark Navy for sidebar context) */
  --accent-color: #93c5fd;
  /* Blue 300 (headings on dark sidebar) */
  --primary-soft: #dbeafe;
  /* Blue 100 (soft tint / backgrounds) */
  --bg-color: #f8fafc;
  /* Slate 50 */
  --text-dark: #1e293b;
  --text-light: #64748b;
  --sidebar-width: 250px;
  --topbar-height: 70px;
}

body {
  font-family: 'IBM Plex Sans Thai Looped', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-dark);
  margin: 0;
  overflow-x: hidden;
}

/* Sidebar Styling */
#sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  background: var(--secondary-color);
  color: #fff;
  transition: all 0.3s;
  z-index: 1000;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
  overflow-y: auto;
  /* Added vertical scroll */
}

#sidebar .sidebar-header {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

#sidebar .sidebar-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
}

#sidebar ul.components {
  padding: 20px 0;
}

#sidebar ul li a {
  padding: 12px 25px;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  color: #cbd5e1;
  text-decoration: none;
  transition: all 0.2s;
  font-weight: 500;
}

#sidebar ul li a i {
  width: 20px;
  margin-right: 15px;
  text-align: center;
  font-size: 1.1rem;
}

#sidebar ul li a:hover,
#sidebar ul li.active>a {
  color: #fff;
  background: var(--primary-color);
  border-left: 4px solid #fff;
}

#sidebar .collapse-inner {
  background: rgba(0, 0, 0, 0.2);
  margin: 5px 15px;
  border-radius: 8px;
}

#sidebar .collapse-inner .collapse-item {
  padding: 10px 15px;
  display: block;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 0.9rem;
  border-radius: 5px;
  margin: 2px 10px;
  transition: all 0.2s;
}

#sidebar .collapse-inner .collapse-item:hover,
#sidebar .collapse-inner .collapse-item.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* Main Content */
#content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: all 0.3s;
}

/* Topbar Styling */
.topbar {
  height: var(--topbar-height);
  background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  padding: 0 30px;
  justify-content: space-between;
}

.topbar .navbar-brand {
  font-weight: 600;
  color: var(--text-dark);
}

/* ── Modern Stat Cards ── */
.stat-card {
  border-radius: 20px;
  color: #fff;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  transition: transform .25s ease, box-shadow .25s ease;
  display: flex;
  flex-direction: column;
}

.stat-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 16px 40px rgba(0,0,0,.18);
}

/* colour themes */
.stat-card-blue  { background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%); }
.stat-card-green { background: linear-gradient(135deg, #0891b2 0%, #0e7490 100%); }
.stat-card-amber { background: linear-gradient(135deg, #0ea5e9 0%, #2563eb 100%); }
.stat-card-red   { background: linear-gradient(135deg, #4f46e5 0%, #1e3a8a 100%); }

.stat-card-body {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px 22px 14px;
}

.stat-icon-wrap {
  flex-shrink: 0;
  width: 58px;
  height: 58px;
  border-radius: 16px;
  background: rgba(255,255,255,.22);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  backdrop-filter: blur(4px);
}

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

.stat-label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  opacity: .85;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.02em;
}

.stat-unit {
  font-size: 1rem;
  font-weight: 600;
  opacity: .8;
}

/* thin progress bar (attendance card) */
.stat-progress {
  height: 5px;
  background: rgba(255,255,255,.25);
  margin: 0 22px 0;
  border-radius: 99px;
  overflow: hidden;
}

.stat-progress-bar {
  height: 100%;
  background: rgba(255,255,255,.9);
  border-radius: 99px;
  transition: width 1s ease;
}

.stat-footer {
  padding: 10px 22px 16px;
  font-size: .78rem;
  font-weight: 600;
  opacity: .8;
  letter-spacing: .02em;
}

/* Legacy card helpers kept for other pages */
.dashboard-card {
  background: #fff;
  border-radius: 12px;
  border: none;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  transition: transform 0.2s, box-shadow 0.2s;
}

.dashboard-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.card-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: #fff;
}

.bg-primary-soft { background: var(--primary-soft); color: var(--primary-color); }
.bg-success-soft { background: #dcfce7; color: #16a34a; }
.bg-warning-soft { background: #fef3c7; color: #d97706; }
.bg-danger-soft  { background: #fee2e2; color: #dc2626; }

/* Utilities */
.text-xs {
  font-size: .75rem;
}

.font-weight-bold {
  font-weight: 700 !important;
}

@media (max-width: 768px) {
  #sidebar {
    margin-left: calc(var(--sidebar-width) * -1);
  }

  #sidebar.active {
    margin-left: 0;
  }

  #content {
    margin-left: 0;
  }

  #content.active {
    margin-left: var(--sidebar-width);
  }
}