/* Admin Panel CSS */
:root {
  --green: #00a650;
  --dark-green: #1a5c35;
  --blue: #2B6CB0;
  --navy: #1A202C;
  --gray: #4A5568;
  --light-gray: #EDF2F7;
  --bg: #F7FAFC;
  --white: #ffffff;
  --red: #cc0000;
  --sidebar-width: 260px;
  --transition: all 0.3s ease;
  --shadow: 0 2px 8px rgba(0,0,0,0.10);
  --radius: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--navy);
  font-size: 14px;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a5c35, #00a650 60%, #2B6CB0);
}
.login-box {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  animation: fadeInUp 0.5s ease;
}
.login-logo {
  text-align: center;
  margin-bottom: 24px;
}
.login-logo img { height: 70px; object-fit: contain; }
.login-logo h2 {
  font-size: 18px;
  color: var(--dark-green);
  font-weight: 800;
  margin-top: 8px;
}
.login-logo p { font-size: 12px; color: var(--gray); }
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--navy);
  outline: none;
  transition: var(--transition);
  background: #fff;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(0,166,80,0.15);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.admin-layout {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: var(--sidebar-width);
  background: var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: var(--transition);
  overflow-y: auto;
}
.sidebar-logo {
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  text-align: center;
}
.sidebar-logo img { height: 50px; object-fit: contain; filter: brightness(0) invert(1); }
.sidebar-logo h3 {
  font-size: 13px;
  color: #a0aec0;
  margin-top: 8px;
  font-weight: 600;
}
.sidebar-logo span {
  font-size: 11px;
  background: var(--green);
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
  display: inline-block;
  margin-top: 4px;
}

.sidebar-nav { flex: 1; padding: 15px 0; }
.nav-section-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #718096;
  padding: 10px 20px 5px;
  font-weight: 700;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px;
  color: #a0aec0;
  font-size: 13.5px;
  font-weight: 500;
  transition: var(--transition);
  border-left: 3px solid transparent;
  text-decoration: none;
}
.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(0,166,80,0.15);
  color: #fff;
  border-left-color: var(--green);
}
.sidebar-nav a .icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-bottom {
  padding: 15px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.sidebar-bottom .admin-name {
  font-size: 12px;
  color: #718096;
  margin-bottom: 10px;
}
.sidebar-bottom .admin-name strong { display: block; color: #e2e8f0; font-size: 14px; }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.top-bar-admin {
  background: #fff;
  box-shadow: var(--shadow);
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
}
.top-bar-admin h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--navy);
}
.top-bar-actions { display: flex; align-items: center; gap: 10px; }

.content-area { padding: 24px; flex: 1; }

/* ============================================================
   STATS CARDS
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}
.stat-card-admin {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
  border-left: 4px solid var(--green);
  transition: var(--transition);
}
.stat-card-admin:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.12); }
.stat-card-admin:nth-child(2) { border-left-color: var(--blue); }
.stat-card-admin:nth-child(3) { border-left-color: #f39c12; }
.stat-card-admin:nth-child(4) { border-left-color: var(--red); }
.stat-icon {
  width: 50px;
  height: 50px;
  border-radius: 10px;
  background: var(--light-gray);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.stat-info .num {
  font-size: 26px;
  font-weight: 800;
  color: var(--navy);
  line-height: 1;
}
.stat-info .label { font-size: 12px; color: var(--gray); margin-top: 4px; }

/* ============================================================
   TABLE
   ============================================================ */
.table-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.table-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--light-gray);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.table-header h3 { font-size: 16px; font-weight: 700; }
.table-filters { display: flex; gap: 10px; flex-wrap: wrap; }
.table-filters input,
.table-filters select {
  padding: 7px 12px;
  border: 1.5px solid #e2e8f0;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  transition: var(--transition);
}
.table-filters input:focus,
.table-filters select:focus { border-color: var(--green); }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  background: #f7fafc;
  font-weight: 700;
  padding: 11px 14px;
  text-align: left;
  border-bottom: 2px solid var(--light-gray);
  color: var(--gray);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--light-gray);
  vertical-align: middle;
}
.data-table tr:hover td { background: #f7fafc; }
.data-table tr:last-child td { border-bottom: none; }
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.badge-pass { background: #d4edda; color: #155724; }
.badge-fail { background: #f8d7da; color: #721c24; }
.badge-absent { background: #fff3cd; color: #856404; }
.badge-sec { background: #d1ecf1; color: #0c5460; }
.badge-sr { background: #e8d5ff; color: #491d8b; }

.action-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-icon {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: var(--transition);
}
.btn-icon:hover { transform: scale(1.1); }
.btn-edit { background: #e8f0fe; color: var(--blue); }
.btn-delete { background: #fce8e8; color: var(--red); }
.btn-pdf { background: #e8f5e9; color: var(--dark-green); }
.btn-migration { background: #fff3cd; color: #856404; }
.btn-view { background: #f0f4ff; color: #4a3fa0; }

.table-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--light-gray);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--gray);
}
.pagination { display: flex; gap: 5px; }
.page-btn {
  width: 32px;
  height: 32px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: var(--transition);
}
.page-btn.active { background: var(--green); color: #fff; border-color: var(--green); }
.page-btn:hover:not(.active) { background: var(--light-gray); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}
.modal {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  transform: translateY(20px);
  transition: transform 0.3s ease;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--light-gray);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}
.modal-header h3 { font-size: 18px; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--gray);
  padding: 4px;
  border-radius: 50%;
  transition: var(--transition);
}
.modal-close:hover { background: var(--light-gray); color: var(--navy); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--light-gray);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  position: sticky;
  bottom: 0;
  background: #fff;
}

/* Subjects dynamic rows */
.subjects-section {
  border: 1.5px solid #e2e8f0;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}
.subjects-header {
  background: var(--dark-green);
  color: #fff;
  padding: 10px 14px;
  display: grid;
  grid-template-columns: 1fr 80px 80px 80px 80px 36px;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.subject-row {
  display: grid;
  grid-template-columns: 1fr 80px 80px 80px 80px 36px;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--light-gray);
  align-items: center;
}
.subject-row:last-child { border-bottom: none; }
.subject-row input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-size: 12px;
  outline: none;
  transition: var(--transition);
}
.subject-row input:focus { border-color: var(--green); }
.btn-remove-sub {
  background: #fce8e8;
  color: var(--red);
  border: none;
  border-radius: 4px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: var(--transition);
}
.btn-remove-sub:hover { background: var(--red); color: #fff; }

/* Photo upload */
.photo-upload-area {
  border: 2px dashed #e2e8f0;
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}
.photo-upload-area:hover { border-color: var(--green); background: var(--bg); }
.photo-preview {
  width: 100px;
  height: 120px;
  border: 2px solid var(--green);
  border-radius: 4px;
  object-fit: cover;
  margin: 0 auto 10px;
  display: block;
}
.photo-upload-area input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--dark-green); }
.btn-secondary { background: var(--blue); color: #fff; }
.btn-secondary:hover { background: #1a4a8a; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #990000; }
.btn-outline { background: transparent; border: 2px solid #e2e8f0; color: var(--gray); }
.btn-outline:hover { border-color: var(--green); color: var(--dark-green); background: var(--light-gray); }
.btn-ghost { background: transparent; color: var(--gray); }
.btn-ghost:hover { background: var(--light-gray); color: var(--navy); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  background: #fff;
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  max-width: 400px;
  animation: slideInRight 0.3s ease;
  border-left: 4px solid var(--green);
  font-size: 13px;
}
.toast.error { border-left-color: var(--red); }
.toast.warning { border-left-color: #f39c12; }
.toast-icon { font-size: 18px; }
.toast-msg { flex: 1; }
.toast-close { cursor: pointer; color: var(--gray); font-size: 16px; background: none; border: none; padding: 2px; }
.toast-close:hover { color: var(--navy); }

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .form-row { grid-template-columns: 1fr; }
  .form-row-3 { grid-template-columns: 1fr 1fr; }
  .subjects-header, .subject-row { grid-template-columns: 1fr 60px 60px 60px 36px; }
  .subjects-header span:nth-child(4), .subject-row input:nth-child(4) { display: none; }
}
@media (max-width: 480px) {
  .content-area { padding: 14px; }
  .form-row-3 { grid-template-columns: 1fr; }
  .modal-body { padding: 16px; }
  .login-box { padding: 24px; }
}
