/* ============================================================
   PurdyM LMS — Main Stylesheet
   ============================================================ */

:root {
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 72px;
  --topbar-height: 60px;
  --primary:    #2563eb;
  --primary-dark:#1d4ed8;
  --secondary:  #64748b;
  --success:    #16a34a;
  --warning:    #d97706;
  --danger:     #dc2626;
  --info:       #0891b2;
  --sidebar-bg: #1e293b;
  --sidebar-hover: #334155;
  --sidebar-active: #2563eb;
  --topbar-bg:  #ffffff;
  --body-bg:    #f1f5f9;
  --card-bg:    #ffffff;
  --border:     #e2e8f0;
  --text-main:  #1e293b;
  --text-muted: #64748b;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08);
  --shadow:     0 4px 12px rgba(0,0,0,.08);
  --radius:     10px;
  --radius-sm:  6px;
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body.lms-body {
  display: flex;
  min-height: 100vh;
  background: var(--body-bg);
  color: var(--text-main);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ── Login page ───────────────────────────────────────────── */
body.login-page {
  background: linear-gradient(135deg, #1e293b 0%, #2563eb 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 18px;
  padding: 2.5rem 2rem;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

.login-logo { max-height: 70px; object-fit: contain; }

.login-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

.login-subtitle { color: var(--text-muted); font-size: .875rem; }

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  color: #cbd5e1;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 1000;
  transition: width .25s ease, transform .25s ease;
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar.collapsed { width: var(--sidebar-collapsed-width); }
.sidebar.collapsed .brand-name,
.sidebar.collapsed .sidebar-user-info,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .nav-link span,
.sidebar.collapsed .nav-arrow { display: none; }
.sidebar.collapsed .sidebar-brand { justify-content: center; }
.sidebar.collapsed .sidebar-user { justify-content: center; }
.sidebar.collapsed .nav-link { justify-content: center; padding: 12px; }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); }
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  min-height: var(--topbar-height);
  flex-shrink: 0;
}

.brand-logo {
  width: 36px; height: 36px;
  border-radius: 8px;
  object-fit: contain;
  background: #fff;
  padding: 3px;
  flex-shrink: 0;
}

.brand-name {
  font-size: .85rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}

.sidebar-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,.3);
  flex-shrink: 0;
}

.sidebar-user-name { font-size: .82rem; font-weight: 600; color: #fff; }
.sidebar-user-role { font-size: .72rem; color: #94a3b8; }

.sidebar-nav { padding: 8px 0; }

.nav-section-label {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #475569;
  padding: 10px 20px 4px;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: #94a3b8;
  border-radius: 0;
  transition: background .15s, color .15s;
  white-space: nowrap;
  font-size: .83rem;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active {
  background: var(--sidebar-hover);
  color: #fff;
}

.sidebar-nav .nav-link.active { background: var(--sidebar-active); }

.nav-icon { width: 18px; text-align: center; flex-shrink: 0; font-size: .85rem; }
.nav-arrow { font-size: .65rem; transition: transform .2s; }
.nav-link[aria-expanded="true"] .nav-arrow { transform: rotate(90deg); }

.sub-nav { background: rgba(0,0,0,.15); }
.sub-nav .nav-link { padding-left: 50px; font-size: .8rem; }

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,.08);
  padding: 10px 0;
  flex-shrink: 0;
}

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

.main-content.expanded { margin-left: var(--sidebar-collapsed-width); }

@media (max-width: 768px) { .main-content { margin-left: 0; } }

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 900;
  box-shadow: var(--shadow-sm);
}

.topbar-icon-btn {
  color: var(--text-muted);
  font-size: 1.1rem;
  position: relative;
  padding: 6px;
  border-radius: 8px;
}

.topbar-icon-btn:hover { background: var(--body-bg); color: var(--text-main); }

.badge-dot {
  position: absolute;
  top: 2px; right: 2px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid #fff;
}

.topbar-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
}

.sidebar-toggle-btn {
  color: var(--text-muted);
  font-size: 1.1rem;
  padding: 4px 8px;
}

/* ── Content Area ─────────────────────────────────────────── */
.content-area {
  padding: 1.5rem;
  flex: 1;
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  background: var(--card-bg);
}

.card-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0 !important;
  padding: .85rem 1.25rem;
  font-weight: 600;
}

/* ── Stat Cards ───────────────────────────────────────────── */
.stat-card {
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  color: #fff;
  box-shadow: var(--shadow);
}

.stat-card .stat-icon {
  width: 54px; height: 54px;
  border-radius: 12px;
  background: rgba(255,255,255,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.stat-card .stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1; }
.stat-card .stat-label { font-size: .78rem; opacity: .85; margin-top: 2px; }

.stat-bg-blue    { background: linear-gradient(135deg, #2563eb, #1d4ed8); }
.stat-bg-green   { background: linear-gradient(135deg, #16a34a, #15803d); }
.stat-bg-orange  { background: linear-gradient(135deg, #d97706, #b45309); }
.stat-bg-purple  { background: linear-gradient(135deg, #7c3aed, #6d28d9); }
.stat-bg-pink    { background: linear-gradient(135deg, #db2777, #be185d); }
.stat-bg-teal    { background: linear-gradient(135deg, #0891b2, #0e7490); }

/* ── Page Header ──────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: .75rem;
}

.page-title { font-size: 1.3rem; font-weight: 700; margin: 0; }
.page-subtitle { font-size: .82rem; color: var(--text-muted); margin: 2px 0 0; }

/* ── Tables ───────────────────────────────────────────────── */
.table th {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.table td { vertical-align: middle; font-size: .83rem; }

/* ── Badges ───────────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
}

.status-active    { background: #dcfce7; color: #15803d; }
.status-inactive  { background: #f1f5f9; color: #64748b; }
.status-suspended { background: #fee2e2; color: #dc2626; }
.status-pending   { background: #fef3c7; color: #b45309; }
.status-enrolled  { background: #dbeafe; color: #1d4ed8; }
.status-graduated { background: #f3e8ff; color: #7c3aed; }

/* ── Avatar stack ─────────────────────────────────────────── */
.avatar-sm {
  width: 32px; height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.avatar-md {
  width: 48px; height: 48px;
  border-radius: 50%;
  object-fit: cover;
}

.avatar-lg {
  width: 80px; height: 80px;
  border-radius: 50%;
  object-fit: cover;
}

/* ── Forms ────────────────────────────────────────────────── */
.form-label { font-size: .82rem; font-weight: 600; color: var(--text-main); }

.form-control, .form-select {
  font-size: .85rem;
  border-color: var(--border);
  border-radius: var(--radius-sm);
}

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

/* ── Mark Book Grid ───────────────────────────────────────── */
.markbook-table th, .markbook-table td {
  padding: .4rem .6rem;
  font-size: .8rem;
}

.markbook-table td input {
  width: 70px;
  padding: .25rem .4rem;
  font-size: .82rem;
  text-align: center;
}

/* ── Report Card ──────────────────────────────────────────── */
.report-card { font-family: Georgia, serif; }
.report-header { border-bottom: 3px double #1e293b; padding-bottom: 1rem; margin-bottom: 1rem; }
.report-school-name { font-size: 1.4rem; font-weight: 700; text-align: center; }
.report-subjects-table th { background: #1e293b; color: #fff; }
.report-subjects-table td, .report-subjects-table th { padding: .4rem .6rem; }

/* ── Timetable Grid ───────────────────────────────────────── */
.timetable-grid { overflow-x: auto; }
.timetable-grid table { min-width: 700px; }
.timetable-grid td, .timetable-grid th { border: 1px solid var(--border); padding: .4rem .5rem; font-size: .78rem; }
.timetable-grid th { background: #f8fafc; font-weight: 600; }
.timetable-period { font-size: .7rem; color: var(--text-muted); }
.timetable-subject { font-weight: 600; }
.timetable-teacher { font-size: .72rem; color: var(--text-muted); }
.timetable-break { background: #fef9c3; color: #854d0e; text-align: center; font-style: italic; }

/* ── Activity Log ─────────────────────────────────────────── */
.log-entry { border-left: 3px solid var(--border); padding: .5rem 1rem; margin-bottom: .5rem; }
.log-entry.login       { border-color: var(--success); }
.log-entry.delete      { border-color: var(--danger); }
.log-entry.create      { border-color: var(--primary); }
.log-entry.update      { border-color: var(--warning); }

/* ── Calendar ─────────────────────────────────────────────── */
.cal-event { font-size: .72rem; border-radius: 4px; padding: 1px 5px; margin-bottom: 2px; color: #fff; }

/* ── Utilities ────────────────────────────────────────────── */
.cursor-pointer { cursor: pointer; }
.text-xs { font-size: .72rem; }
.text-sm { font-size: .82rem; }
.fw-semibold { font-weight: 600; }
.gap-2 { gap: .5rem; }
.rounded-pill-sm { border-radius: 999px; }
.border-start-primary { border-left: 3px solid var(--primary) !important; }

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 576px) {
  .content-area { padding: 1rem; }
  .stat-card { flex-direction: column; text-align: center; }
  .page-header { flex-direction: column; }
}

/* ── Print ────────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .btn, .no-print { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .content-area { padding: 0; }
  body { background: #fff; }
}
