/* ============================================================
   School Mini ERP – Main Stylesheet
   ============================================================ */

:root {
  --sidebar-w: 240px;
  --topbar-h: 56px;
  --primary: #0f6e56;
  --primary-light: #e1f5ee;
  --primary-dark: #085041;
  --accent: #1d9e75;
  --gray-50: #f8f9fa;
  --gray-100: #f1f3f5;
  --gray-200: #e9ecef;
  --gray-400: #ced4da;
  --gray-600: #6c757d;
  --gray-800: #343a40;
  --danger: #e03131;
  --warning: #f59f00;
  --info: #1971c2;
  --success: #2f9e44;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,.1);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  background: var(--gray-100);
  color: var(--gray-800);
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  transition: transform .25s ease;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 1.1rem 1.25rem;
  font-size: 17px;
  font-weight: 700;
  color: var(--primary);
  border-bottom: 1px solid var(--gray-200);
  background: var(--primary-light);
}

.sidebar-brand i { font-size: 22px; }

.sidebar-nav { flex: 1; padding: .5rem 0; }

.nav-section {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--gray-600);
  padding: .9rem 1.25rem .25rem;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: .52rem 1.25rem;
  color: var(--gray-800);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: background .15s, color .15s;
  font-size: 13.5px;
}

.sidebar-nav .nav-link i { font-size: 16px; width: 18px; text-align: center; }
.sidebar-nav .nav-link:hover { background: var(--gray-100); color: var(--primary); }
.sidebar-nav .nav-link.active { background: var(--primary-light); color: var(--primary-dark); border-left-color: var(--primary); font-weight: 600; }

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-info { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }

.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
  flex-shrink: 0;
}

.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--gray-600); }

.btn-logout {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  color: var(--gray-600);
  text-decoration: none;
  transition: background .15s, color .15s;
}
.btn-logout:hover { background: #ffe3e3; color: var(--danger); }

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

.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.btn-menu {
  background: none; border: none; cursor: pointer;
  font-size: 22px; color: var(--gray-600);
  display: none;
  padding: 4px 6px; border-radius: 6px;
}
.btn-menu:hover { background: var(--gray-100); }

.page-title { margin: 0; font-size: 17px; font-weight: 600; color: var(--gray-800); }

.content-area { padding: 1.5rem; flex: 1; }

/* ---- Cards ---- */
.card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}

.card-header {
  padding: .9rem 1.25rem;
  border-bottom: 1px solid var(--gray-200);
  font-weight: 600;
  font-size: 14.5px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-body { padding: 1.25rem; }

/* ---- Stat cards ---- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }

.stat-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
}

.stat-card.danger { border-left-color: var(--danger); }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.info { border-left-color: var(--info); }
.stat-card.success { border-left-color: var(--success); }

.stat-label { font-size: 12px; color: var(--gray-600); margin-bottom: 4px; font-weight: 500; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--gray-800); line-height: 1.1; }
.stat-sub { font-size: 12px; color: var(--gray-600); margin-top: 4px; }
.stat-icon { font-size: 28px; color: var(--primary); }

/* ---- Tables ---- */
.table { font-size: 13.5px; }
.table th { font-weight: 600; background: var(--gray-50); font-size: 12.5px; letter-spacing: .02em; color: var(--gray-600); border-bottom: 2px solid var(--gray-200); }
.table td, .table th { vertical-align: middle; }

.table-hover tbody tr:hover { background: var(--primary-light); }

/* ---- Badges ---- */
.badge-status {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
}

.badge-paid, .badge-converted { background: #d3f9d8; color: #2b8a3e; }
.badge-pending, .badge-new { background: #fff3bf; color: #7d4f00; }
.badge-partial, .badge-contacted { background: #dbe4ff; color: #364fc7; }
.badge-closed { background: var(--gray-200); color: var(--gray-600); }
.badge-overdue { background: #ffe3e3; color: #c92a2a; }

/* ---- Forms ---- */
.form-label { font-weight: 500; font-size: 13px; margin-bottom: 4px; }
.form-control, .form-select { font-size: 13.5px; border-radius: 8px; border: 1px solid var(--gray-400); transition: border-color .15s, box-shadow .15s; }
.form-control:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(29,158,117,.15); outline: none; }

/* ---- Buttons ---- */
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); }
.btn-sm { font-size: 12px; padding: 3px 10px; }

/* ---- Filter bar ---- */
.filter-bar {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: .85rem 1rem;
  margin-bottom: 1rem;
}

/* ---- Login page ---- */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary-light) 0%, #f0fdf9 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
}

.login-logo { text-align: center; margin-bottom: 1.5rem; }
.login-logo i { font-size: 48px; color: var(--primary); }
.login-logo h1 { font-size: 22px; font-weight: 700; color: var(--primary-dark); margin: 4px 0 2px; }
.login-logo p { font-size: 13px; color: var(--gray-600); margin: 0; }

/* ---- Chart container ---- */
.chart-container { position: relative; height: 220px; }

/* ---- Empty state ---- */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--gray-600); }
.empty-state i { font-size: 48px; margin-bottom: .75rem; display: block; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-md); }
  .main-content { margin-left: 0; }
  .btn-menu { display: flex; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .content-area { padding: 1rem; }
}
