/* ===== RESET & BASE ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; }
body { font-family: 'Poppins', sans-serif; background: #f0f2f8; color: #1a1a2e; display: flex; min-height: 100vh; overflow-x: hidden; }

:root {
  --primary: #0D1B4B;
  --primary-light: #1a2d6b;
  --accent: #FF6B00;
  --accent-light: #FF8C38;
  --gold: #F5A623;
  --green: #1B7A3E;
  --red: #e53e3e;
  --sidebar-w: 260px;
  --topbar-h: 64px;
  --white: #ffffff;
  --bg: #f0f2f8;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1a1a2e;
  --text-muted: #718096;
  --shadow: 0 4px 20px rgba(0,0,0,0.08);
  --shadow-md: 0 8px 30px rgba(0,0,0,0.12);
  --radius: 14px;
  --radius-sm: 8px;
  --transition: all 0.25s ease;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w); min-height: 100vh;
  background: var(--primary);
  display: flex; flex-direction: column;
  position: fixed; left: 0; top: 0; bottom: 0; z-index: 100;
  transition: var(--transition);
  box-shadow: 4px 0 20px rgba(0,0,0,0.15);
}
.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; justify-content: space-between;
}
.sidebar-logo { display: flex; align-items: center; gap: 12px; }
.logo-icon {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--gold));
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: white; flex-shrink: 0;
}
.logo-name { display: block; font-size: 14px; font-weight: 700; color: white; line-height: 1.2; }
.logo-sub { display: block; font-size: 10px; color: rgba(255,255,255,0.5); }
.sidebar-toggle { background: none; border: none; color: rgba(255,255,255,0.6); font-size: 18px; cursor: pointer; padding: 4px; }
.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-section-label {
  font-size: 10px; font-weight: 700; letter-spacing: 1.5px;
  text-transform: uppercase; color: rgba(255,255,255,0.35);
  padding: 12px 10px 6px; margin-top: 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 10px; margin-bottom: 2px;
  color: rgba(255,255,255,0.65); font-size: 13.5px; font-weight: 500;
  text-decoration: none; transition: var(--transition); cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: white; }
.nav-item.active { background: linear-gradient(135deg, var(--accent), var(--accent-light)); color: white; box-shadow: 0 4px 15px rgba(255,107,0,0.35); }
.nav-item i { width: 18px; text-align: center; font-size: 15px; }
.sidebar-footer { padding: 16px 12px; border-top: 1px solid rgba(255,255,255,0.08); }
.sidebar-website-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: 10px;
  background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.7);
  font-size: 13px; font-weight: 500; text-decoration: none; transition: var(--transition);
}
.sidebar-website-btn:hover { background: rgba(255,255,255,0.12); color: white; }

/* ===== MAIN WRAPPER ===== */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1; display: flex; flex-direction: column; min-height: 100vh;
  transition: var(--transition);
}

/* ===== TOPBAR ===== */
.topbar {
  height: var(--topbar-h); background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; position: sticky; top: 0; z-index: 50;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.mobile-menu-btn { display: none; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text); }
.page-title { font-size: 18px; font-weight: 700; color: var(--primary); }
.topbar-right { display: flex; align-items: center; gap: 20px; }
.topbar-school { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); }
.topbar-school i { color: var(--accent); }
.topbar-date { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.topbar-user { display: flex; align-items: center; gap: 8px; }
.user-avatar {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 15px;
}
.topbar-user span { font-size: 13px; font-weight: 600; color: var(--text); }

/* ===== CONTENT AREA ===== */
.content-area { flex: 1; padding: 28px; overflow-y: auto; }

/* ===== PAGES ===== */
.page { display: none; animation: fadeInPage 0.3s ease; }
.page.active { display: block; }
@keyframes fadeInPage { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ===== DASHBOARD ===== */
.dashboard-welcome {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: var(--radius); padding: 28px 32px; margin-bottom: 24px;
  display: flex; align-items: center; justify-content: space-between;
  color: white; box-shadow: var(--shadow-md);
}
.welcome-text h2 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.welcome-text p { font-size: 13px; color: rgba(255,255,255,0.7); }
.welcome-date { font-size: 13px; color: rgba(255,255,255,0.6); text-align: right; }

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 28px; }
.stat-card {
  background: var(--card); border-radius: var(--radius); padding: 22px 24px;
  display: flex; align-items: center; gap: 16px;
  box-shadow: var(--shadow); border: 1px solid var(--border);
  transition: var(--transition); position: relative; overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.stat-card.blue::before { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.stat-card.orange::before { background: linear-gradient(90deg, var(--accent), var(--gold)); }
.stat-card.green::before { background: linear-gradient(90deg, var(--green), #4ade80); }
.stat-card.purple::before { background: linear-gradient(90deg, #7c3aed, #a78bfa); }
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.stat-icon {
  width: 52px; height: 52px; border-radius: 14px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.stat-card.blue .stat-icon { background: rgba(59,130,246,0.1); color: #3b82f6; }
.stat-card.orange .stat-icon { background: rgba(255,107,0,0.1); color: var(--accent); }
.stat-card.green .stat-icon { background: rgba(27,122,62,0.1); color: var(--green); }
.stat-card.purple .stat-icon { background: rgba(124,58,237,0.1); color: #7c3aed; }
.stat-info { flex: 1; }
.stat-val { display: block; font-size: 30px; font-weight: 800; color: var(--text); line-height: 1; }
.stat-lbl { display: block; font-size: 12px; color: var(--text-muted); margin-top: 4px; font-weight: 500; }
.stat-trend { font-size: 11px; color: var(--green); font-weight: 600; }

/* Quick Actions */
.section-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; margin-top: 8px; }
.section-title-row h3 { font-size: 16px; font-weight: 700; color: var(--text); }
.view-all-btn { background: none; border: 1px solid var(--border); color: var(--accent); font-size: 12px; font-weight: 600; padding: 6px 14px; border-radius: 8px; cursor: pointer; transition: var(--transition); }
.view-all-btn:hover { background: var(--accent); color: white; border-color: var(--accent); }
.quick-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 28px; }
.qa-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 20px; border-radius: 12px; border: 2px solid var(--border);
  background: var(--card); color: var(--text); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: var(--transition); box-shadow: var(--shadow);
}
.qa-btn:hover { border-color: var(--primary); background: var(--primary); color: white; transform: translateY(-2px); }
.qa-btn.cert:hover { border-color: var(--accent); background: var(--accent); }
.qa-btn i { font-size: 16px; }

/* ===== PAGE HEADER ===== */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-header h2 { font-size: 22px; font-weight: 700; color: var(--text); }
.btn-add {
  display: flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: white; padding: 10px 20px; border-radius: 10px; border: none;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: var(--transition);
  box-shadow: 0 4px 15px rgba(255,107,0,0.3);
}
.btn-add:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(255,107,0,0.4); }

/* ===== FILTER BAR ===== */
.filter-bar { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; align-items: center; }
.search-input {
  flex: 1; min-width: 200px; padding: 10px 16px;
  border: 2px solid var(--border); border-radius: 10px;
  font-family: 'Poppins', sans-serif; font-size: 13px; color: var(--text);
  background: var(--card); outline: none; transition: var(--transition);
}
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,107,0,0.1); }
.filter-select {
  padding: 10px 14px; border: 2px solid var(--border); border-radius: 10px;
  font-family: 'Poppins', sans-serif; font-size: 13px; color: var(--text);
  background: var(--card); outline: none; cursor: pointer; transition: var(--transition);
}
.filter-select:focus { border-color: var(--accent); }
.btn-export {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px; border: 2px solid var(--border);
  background: var(--card); color: var(--text); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: var(--transition);
}
.btn-export:hover { border-color: var(--green); background: var(--green); color: white; }

/* ===== TABLE ===== */
.table-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); overflow: hidden; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead tr { background: linear-gradient(135deg, var(--primary), var(--primary-light)); }
.data-table th { padding: 14px 16px; text-align: left; font-size: 12px; font-weight: 700; color: rgba(255,255,255,0.9); text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; }
.data-table td { padding: 13px 16px; font-size: 13px; color: var(--text); border-bottom: 1px solid var(--border); }
.data-table tbody tr:hover { background: rgba(255,107,0,0.03); }
.data-table tbody tr:last-child td { border-bottom: none; }
.table-empty { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.table-empty i { font-size: 48px; margin-bottom: 12px; opacity: 0.3; display: block; }
.table-empty p { font-size: 14px; }

/* Action Buttons in Table */
.action-btns { display: flex; gap: 6px; }
.btn-edit, .btn-delete, .btn-cert {
  padding: 6px 12px; border-radius: 7px; border: none;
  font-size: 11px; font-weight: 600; cursor: pointer; transition: var(--transition);
  display: flex; align-items: center; gap: 4px;
}
.btn-edit { background: rgba(59,130,246,0.1); color: #3b82f6; }
.btn-edit:hover { background: #3b82f6; color: white; }
.btn-delete { background: rgba(229,62,62,0.1); color: var(--red); }
.btn-delete:hover { background: var(--red); color: white; }
.btn-cert { background: rgba(255,107,0,0.1); color: var(--accent); }
.btn-cert:hover { background: var(--accent); color: white; }

/* ===== TEACHERS GRID ===== */
.teachers-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }
.teacher-card {
  background: var(--card); border-radius: var(--radius); padding: 24px;
  box-shadow: var(--shadow); border: 1px solid var(--border);
  text-align: center; transition: var(--transition);
}
.teacher-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--accent); }
.teacher-avatar {
  width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; color: white; font-weight: 700;
}
.teacher-card h4 { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.teacher-designation { display: block; font-size: 12px; color: var(--accent); font-weight: 600; margin-bottom: 4px; }
.teacher-subject { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.teacher-contact { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.teacher-actions { display: flex; gap: 8px; justify-content: center; margin-top: 14px; }

/* ===== FORM CARD ===== */
.form-card { background: var(--card); border-radius: var(--radius); padding: 32px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.form-section-title {
  font-size: 13px; font-weight: 700; color: var(--primary);
  text-transform: uppercase; letter-spacing: 0.5px;
  padding: 10px 0 14px; margin-bottom: 4px;
  border-bottom: 2px solid var(--border); margin-top: 20px;
  display: flex; align-items: center; gap: 8px;
}
.form-section-title:first-child { margin-top: 0; }
.form-section-title i { color: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 8px; padding-top: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; }
.form-group input, .form-group select, .form-group textarea {
  padding: 11px 14px; border: 2px solid var(--border); border-radius: 10px;
  font-family: 'Poppins', sans-serif; font-size: 13px; color: var(--text);
  background: var(--bg); outline: none; transition: var(--transition);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--accent); background: white; box-shadow: 0 0 0 3px rgba(255,107,0,0.08);
}
.form-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); }
.btn-save {
  display: flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: white; padding: 12px 28px; border-radius: 10px; border: none;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: var(--transition);
  box-shadow: 0 4px 15px rgba(255,107,0,0.3);
}
.btn-save:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(255,107,0,0.4); }
.btn-cancel {
  padding: 12px 24px; border-radius: 10px; border: 2px solid var(--border);
  background: var(--card); color: var(--text-muted); font-size: 14px; font-weight: 600;
  cursor: pointer; transition: var(--transition);
}
.btn-cancel:hover { border-color: var(--red); color: var(--red); }

/* ===== CERTIFICATE LAYOUT ===== */
.cert-layout { display: grid; grid-template-columns: 420px 1fr; gap: 24px; align-items: start; }
.cert-form-panel .form-card { padding: 24px; }
.cert-form-panel .form-grid { grid-template-columns: 1fr 1fr; }
.student-select {
  width: 100%; padding: 11px 14px; border: 2px solid var(--border); border-radius: 10px;
  font-family: 'Poppins', sans-serif; font-size: 13px; color: var(--text);
  background: var(--bg); outline: none; transition: var(--transition);
}
.student-select:focus { border-color: var(--accent); }
.btn-preview {
  display: flex; align-items: center; gap: 8px;
  background: rgba(59,130,246,0.1); color: #3b82f6;
  padding: 11px 22px; border-radius: 10px; border: 2px solid rgba(59,130,246,0.2);
  font-size: 13px; font-weight: 600; cursor: pointer; transition: var(--transition);
}
.btn-preview:hover { background: #3b82f6; color: white; border-color: #3b82f6; }
.btn-print {
  display: flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white; padding: 11px 22px; border-radius: 10px; border: none;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: var(--transition);
  box-shadow: 0 4px 15px rgba(13,27,75,0.3);
}
.btn-print:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(13,27,75,0.4); }
.cert-preview-panel { position: sticky; top: 90px; }
.preview-label { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 12px; }
.cert-preview-box {
  background: white; border-radius: var(--radius); box-shadow: var(--shadow-md);
  border: 1px solid var(--border); min-height: 400px; overflow: hidden;
}

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 28px; right: 28px; z-index: 9999;
  background: var(--primary); color: white;
  padding: 14px 24px; border-radius: 12px; font-size: 14px; font-weight: 500;
  box-shadow: 0 8px 30px rgba(0,0,0,0.2); transform: translateY(100px);
  opacity: 0; transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
  display: flex; align-items: center; gap: 10px; max-width: 360px;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: none; align-items: center; justify-content: center; z-index: 9000;
  backdrop-filter: blur(4px);
}
.modal-overlay.show { display: flex; }
.modal {
  background: white; border-radius: 20px; padding: 40px; text-align: center;
  max-width: 380px; width: 90%; box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  animation: modalIn 0.3s ease;
}
@keyframes modalIn { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-icon { font-size: 48px; color: var(--red); margin-bottom: 16px; }
.modal h3 { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.modal p { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }
.modal-actions { display: flex; gap: 12px; justify-content: center; }
.btn-delete-confirm {
  padding: 11px 28px; border-radius: 10px; border: none;
  background: var(--red); color: white; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: var(--transition);
}
.btn-delete-confirm:hover { background: #c53030; }

/* ===== BADGE ===== */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 50px;
  font-size: 11px; font-weight: 700;
}
.badge-male { background: rgba(59,130,246,0.1); color: #3b82f6; }
.badge-female { background: rgba(236,72,153,0.1); color: #ec4899; }
.badge-class { background: rgba(255,107,0,0.1); color: var(--accent); }

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .cert-layout { grid-template-columns: 1fr; }
  .cert-preview-panel { position: static; }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .mobile-menu-btn { display: block; }
  .topbar-school { display: none; }
}
@media (max-width: 640px) {
  .content-area { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .dashboard-welcome { flex-direction: column; gap: 12px; }
  .quick-actions { gap: 8px; }
  .qa-btn { padding: 10px 14px; font-size: 12px; }
}