/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Color Palette */
  --primary:        #1F4E79;
  --primary-dark:   #163A5E;
  --primary-light:  #2E75B6;
  --primary-faint:  #EBF3FA;
  --accent:         #BDD7EE;
  --bg:             #F8FAFC;
  --card-bg:        #FFFFFF;
  --border:         #E2EAF4;
  --text-main:      #1A2636;
  --text-sub:       #5A7491;
  --text-muted:     #94A8BC;

  /* Status Colors */
  --success:        #70AD47;
  --success-light:  #EDF7E5;
  --warning:        #ED7D31;
  --warning-light:  #FEF3EC;
  --danger:         #C00000;
  --danger-light:   #FDECEA;

  /* Layout */
  --sidebar-w:      240px;
  --topbar-h:       60px;
  --radius:         8px;
  --radius-lg:      12px;
  --shadow-sm:      0 1px 4px rgba(31,78,121,.07);
  --shadow-md:      0 4px 16px rgba(31,78,121,.10);
  --shadow-lg:      0 8px 32px rgba(31,78,121,.14);

  /* Typography */
  --font:           'Inter', 'Segoe UI', Arial, sans-serif;
}

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-main);
  display: flex;
  min-height: 100vh;
  line-height: 1.55;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: var(--font); }
input, select, textarea { font-family: var(--font); }

.hidden { display: none !important; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--primary);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0;
  z-index: 200;
  transition: transform .25s ease;
}

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}

.brand-logo {
  width: 40px; height: 40px;
  background: rgba(255,255,255,.15);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.brand-name {
  display: block;
  font-weight: 700;
  font-size: .95rem;
  color: #fff;
  letter-spacing: .01em;
}
.brand-sub {
  display: block;
  font-size: .72rem;
  color: rgba(255,255,255,.6);
  margin-top: 1px;
}

/* Nav List */
.sidebar-nav { flex: 1; padding: 16px 0; }
.nav-list { list-style: none; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  color: rgba(255,255,255,.72);
  font-size: .9rem;
  border-left: 3px solid transparent;
  transition: background .18s, color .18s, border-color .18s;
}

.nav-link:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
}

.nav-link.active {
  background: rgba(255,255,255,.12);
  color: #fff;
  border-left-color: #BDD7EE;
  font-weight: 600;
}

.nav-icon { font-size: 1.1rem; width: 22px; text-align: center; }
.nav-label { flex: 1; }

/* Footer */
.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,.10);
}
.sidebar-version { font-size: .72rem; color: rgba(255,255,255,.4); }

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

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  height: var(--topbar-h);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.topbar-left { display: flex; align-items: center; gap: 14px; }

.menu-toggle {
  background: none; border: none;
  font-size: 1.25rem; color: var(--text-sub);
  padding: 4px 6px;
  border-radius: 6px;
  transition: background .15s;
  display: none;
}
.menu-toggle:hover { background: var(--primary-faint); }

.page-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: .01em;
}

.topbar-right {
  display: flex; align-items: center; gap: 16px;
}

.last-updated {
  display: flex; align-items: center; gap: 6px;
  font-size: .8rem; color: var(--text-muted);
}
.last-updated-icon { font-size: .9rem; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px;
  font-size: .88rem; font-weight: 600;
  border-radius: var(--radius);
  border: none;
  transition: background .18s, box-shadow .18s, transform .1s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--primary-light);
  color: #fff;
}
.btn-primary:hover { background: var(--primary); }

.btn-secondary {
  background: var(--bg);
  color: var(--text-sub);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--primary-faint); color: var(--primary); }

.btn-refresh {
  background: var(--primary-faint);
  color: var(--primary);
  border: 1px solid var(--accent);
  font-size: .85rem;
}
.btn-refresh:hover { background: var(--primary); color: #fff; }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: #9a0000; }

.btn-danger-outline {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}
.btn-danger-outline:hover { background: var(--danger-light); }

.btn-icon {
  padding: 5px 9px;
  font-size: .82rem;
  border-radius: 6px;
}

.btn-edit {
  background: var(--primary-faint);
  color: var(--primary-light);
  border: 1px solid var(--accent);
}
.btn-edit:hover { background: var(--primary-light); color: #fff; }

.btn-del {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid #f5c6c6;
}
.btn-del:hover { background: var(--danger); color: #fff; }

/* ============================================================
   PAGE CONTENT
   ============================================================ */
.page-content {
  flex: 1;
  padding: 28px 32px;
  max-width: 1440px;
  width: 100%;
}

/* ============================================================
   CARD
   ============================================================ */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 24px;
}

.card-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.card-header-flex {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 2px;
}

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

/* ============================================================
   DASHBOARD: SCHOOL BANNER
   ============================================================ */
.school-banner {
  background: linear-gradient(120deg, var(--primary) 0%, var(--primary-light) 100%);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  box-shadow: var(--shadow-md);
  color: #fff;
}

.school-banner-info {
  display: flex;
  align-items: center;
  gap: 18px;
}

.school-avatar {
  width: 60px; height: 60px;
  background: rgba(255,255,255,.18);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
  flex-shrink: 0;
}

.school-name {
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 8px;
}

.school-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.meta-chip {
  background: rgba(255,255,255,.15);
  color: rgba(255,255,255,.9);
  font-size: .77rem;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,.25);
}
.meta-chip.accent { background: rgba(189,215,238,.3); }

.school-banner-right { text-align: center; }
.banner-stat-num {
  display: block;
  font-size: 2.2rem;
  font-weight: 800;
  color: #BDD7EE;
  line-height: 1;
}
.banner-stat-label {
  font-size: .78rem;
  color: rgba(255,255,255,.7);
  margin-top: 4px;
  display: block;
}

/* ============================================================
   DASHBOARD: STAT CARDS
   ============================================================ */
.stat-cards-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 20px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: box-shadow .18s;
}
.stat-card:hover { box-shadow: var(--shadow-md); }

.stat-icon {
  font-size: 2rem;
  width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-faint);
  border-radius: 12px;
  flex-shrink: 0;
}

.stat-total .stat-icon { background: #EBF3FA; }
.stat-pns .stat-icon  { background: #EDF7E5; }
.stat-gty .stat-icon  { background: var(--warning-light); }
.stat-honorer .stat-icon { background: var(--danger-light); }

.stat-body { flex: 1; }
.stat-value {
  display: block;
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}
.stat-label {
  font-size: .8rem;
  color: var(--text-sub);
  margin-top: 4px;
  display: block;
}

/* ============================================================
   DASHBOARD: CHARTS
   ============================================================ */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr .6fr;
  gap: 20px;
  margin-bottom: 24px;
}

.chart-card { margin-bottom: 0; }

.chart-wrapper {
  padding: 16px 20px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
}

.chart-wrapper canvas {
  max-height: 200px;
}

/* ============================================================
   DASHBOARD: QUICK NAV
   ============================================================ */
.quick-nav-card .quick-nav-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  padding: 20px 24px;
}

.quick-nav-btn {
  background: var(--primary-faint);
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: background .18s, box-shadow .18s;
  color: var(--primary);
}
.quick-nav-btn:hover {
  background: var(--primary-light);
  color: #fff;
  box-shadow: var(--shadow-md);
}
.qn-icon { font-size: 1.6rem; }
.qn-label { font-size: .82rem; font-weight: 600; }

/* ============================================================
   FORM STYLES
   ============================================================ */
.form-card { margin-bottom: 0; }

.form-section-title {
  font-size: .82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--primary-light);
  padding: 18px 24px 0;
  margin-bottom: -4px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 24px;
  padding: 16px 24px;
}

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group-full { grid-column: 1 / -1; }

.form-label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-main);
}
.req { color: var(--danger); }

.form-control {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .88rem;
  color: var(--text-main);
  background: var(--card-bg);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-control:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(46,117,182,.14);
}
.form-control.is-error { border-color: var(--danger); }

textarea.form-control { resize: vertical; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235A7491' stroke-width='1.5' fill='none'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }

.field-error {
  font-size: .77rem;
  color: var(--danger);
  display: block;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px 24px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

/* ============================================================
   FILTER BAR (GURU PAGE)
   ============================================================ */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
}
.search-icon {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  font-size: .95rem;
}
.search-input {
  width: 100%;
  padding: 9px 12px 9px 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .88rem;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  font-family: var(--font);
}
.search-input:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(46,117,182,.12);
}

.filter-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-select {
  min-width: 140px;
  font-size: .82rem;
  padding: 8px 30px 8px 10px;
}

/* ============================================================
   DATA TABLE
   ============================================================ */
.table-wrapper {
  overflow-x: auto;
  padding: 0;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

.data-table thead tr {
  background: var(--primary-faint);
}

.data-table th {
  padding: 12px 14px;
  text-align: left;
  font-size: .77rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--primary);
  white-space: nowrap;
  border-bottom: 2px solid var(--border);
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  vertical-align: middle;
}

.data-table tbody tr:hover { background: var(--primary-faint); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .76rem;
  font-weight: 600;
  letter-spacing: .02em;
}
.badge-pns     { background: var(--success-light); color: #3a7d1e; }
.badge-gty     { background: var(--warning-light); color: #a0500a; }
.badge-honorer { background: var(--danger-light);  color: var(--danger); }
.badge-s2      { background: #F0EAFB; color: #5B21B6; }
.badge-s1      { background: var(--primary-faint); color: var(--primary); }
.badge-default { background: var(--bg); color: var(--text-sub); }

/* Actions column */
.action-group { display: flex; gap: 6px; }

/* Empty state */
.table-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.table-empty span { font-size: 2.5rem; display: block; margin-bottom: 10px; }
.table-empty p { font-size: .9rem; }

.table-footer {
  display: flex;
  justify-content: flex-end;
  padding: 12px 24px;
  border-top: 1px solid var(--border);
}
.table-count { font-size: .8rem; color: var(--text-muted); }

/* LOG TABLE specifics */
.log-table td { font-size: .8rem; }
.log-val {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}
.log-action-add    { color: var(--success); font-weight: 600; }
.log-action-edit   { color: var(--primary-light); font-weight: 600; }
.log-action-delete { color: var(--danger); font-weight: 600; }
.log-action-save   { color: var(--warning); font-weight: 600; }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
}

.btn-page {
  background: var(--primary-faint);
  border: 1px solid var(--accent);
  color: var(--primary);
  padding: 7px 16px;
  border-radius: var(--radius);
  font-size: .84rem;
  font-weight: 600;
  transition: background .15s;
}
.btn-page:hover:not(:disabled) { background: var(--primary-light); color: #fff; }
.btn-page:disabled { opacity: .4; cursor: not-allowed; }

.page-info {
  font-size: .84rem;
  color: var(--text-sub);
  font-weight: 500;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,30,50,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 20px;
  backdrop-filter: blur(2px);
}

.modal {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn .22s ease;
}

.modal-sm { max-width: 400px; }

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-16px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.modal-header-danger { background: var(--warning-light); }
.modal-header-error  { background: var(--danger-light); }

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
}
.modal-header-error .modal-title { color: var(--danger); }

.modal-close {
  background: none; border: none;
  font-size: 1.1rem;
  color: var(--text-muted);
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background .15s;
}
.modal-close:hover { background: var(--border); }

.modal-body { padding: 22px; }
.modal-body .form-grid { padding: 0; }
.modal-body .form-section-title { padding: 0 0 4px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
}

/* Confirm modal content */
.confirm-icon { font-size: 2.5rem; text-align: center; margin-bottom: 12px; }
.confirm-text { text-align: center; font-size: .92rem; color: var(--text-main); margin-bottom: 6px; }
.confirm-sub  { text-align: center; font-size: .8rem; color: var(--text-muted); }

/* ============================================================
   TOAST NOTIFICATION
   ============================================================ */
.toast {
  position: fixed;
  bottom: 28px; right: 28px;
  background: var(--text-main);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .88rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  animation: toastIn .22s ease;
  min-width: 240px;
}

.toast.toast-success { background: #2D6A1D; }
.toast.toast-error   { background: var(--danger); }
.toast.toast-warn    { background: var(--warning); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

/* ============================================================
   RESPONSIVE: SIDEBAR COLLAPSE
   ============================================================ */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-wrapper {
    margin-left: 0;
  }
  .menu-toggle { display: flex; }

  .stat-cards-row { grid-template-columns: repeat(2, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
  .quick-nav-card .quick-nav-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .page-content { padding: 16px; }
  .topbar { padding: 0 14px; }
  .stat-cards-row { grid-template-columns: 1fr 1fr; gap: 12px; }
  .school-banner { flex-direction: column; align-items: flex-start; gap: 16px; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-group { flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .modal { max-width: 98vw; }
}
