/* =====================================================================
   SCHOOL PORTAL — LIGHT THEME
   Palette:
     --navy       #1F3A5F  (headers, primary text on light)
     --navy-deep  #14283F  (hover/active)
     --gold       #C79A3D  (accent, buttons, highlights)
     --gold-soft  #F3E6C6  (badges, subtle highlight bg)
     --bg         #F7F8FA  (page background)
     --card       #FFFFFF  (card surfaces)
     --border     #E3E7ED
     --text       #26313F
     --text-mute  #64748B
     --success    #2F855A
     --danger     #C0392B
   ===================================================================== */

:root {
  --navy: #1F3A5F;
  --navy-deep: #14283F;
  --gold: #C79A3D;
  --gold-soft: #F3E6C6;
  --bg: #F7F8FA;
  --card: #FFFFFF;
  --border: #E3E7ED;
  --text: #26313F;
  --text-mute: #64748B;
  --success: #2F855A;
  --danger: #C0392B;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(31, 58, 95, 0.08), 0 1px 2px rgba(31, 58, 95, 0.06);
  --shadow-md: 0 4px 12px rgba(31, 58, 95, 0.10);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

h1, h2, h3, h4 {
  font-family: "Source Serif Pro", Georgia, "Times New Roman", serif;
  color: var(--navy);
  margin: 0 0 .4em;
}

a { color: var(--navy); }

/* ---------------- Top bar ---------------- */
.topbar {
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  box-shadow: var(--shadow-md);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 1.1rem; }
.topbar .brand .crest {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--gold); color: var(--navy-deep);
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.topbar .user-chip {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.08);
  padding: 6px 12px; border-radius: 999px; font-size: .85rem;
}
.topbar .role-badge {
  background: var(--gold); color: var(--navy-deep);
  font-size: .7rem; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: .04em;
}
.topbar button.logout {
  background: transparent; border: 1px solid rgba(255,255,255,.35); color: #fff;
  padding: 6px 14px; border-radius: 8px; cursor: pointer; font-size: .85rem;
}
.topbar button.logout:hover { background: rgba(255,255,255,.12); }

/* ---------------- Layout ---------------- */
.layout { display: flex; min-height: calc(100vh - 62px); }

.sidebar {
  width: 220px; background: var(--card); border-right: 1px solid var(--border);
  padding: 18px 12px;
}
.sidebar a {
  display: block; padding: 10px 14px; margin-bottom: 4px; border-radius: 8px;
  color: var(--text); text-decoration: none; font-size: .92rem; font-weight: 500;
}
.sidebar a:hover { background: var(--bg); }
.sidebar a.active { background: var(--gold-soft); color: var(--navy-deep); font-weight: 700; }

.main { flex: 1; padding: 28px 32px; max-width: 1200px; }

/* ---------------- Cards ---------------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px; margin-bottom: 20px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.stat-card .value { font-size: 1.8rem; font-weight: 700; color: var(--navy); }
.stat-card .label { color: var(--text-mute); font-size: .85rem; }

/* ---------------- Forms ---------------- */
label { display: block; font-size: .82rem; font-weight: 600; color: var(--text-mute); margin: 12px 0 4px; }
input, select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: .92rem; font-family: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--gold); outline-offset: 1px; border-color: var(--gold);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.form-grid.thirds { grid-template-columns: 1fr 1fr 1fr; }
.form-section-title {
  grid-column: 1 / -1; margin-top: 18px; padding-bottom: 6px; border-bottom: 2px solid var(--gold-soft);
  font-weight: 700; color: var(--navy); text-transform: uppercase; font-size: .78rem; letter-spacing: .05em;
}

.upload-box {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 14px;
  text-align: center; color: var(--text-mute); cursor: pointer; background: var(--bg);
  font-size: .82rem;
}
.upload-box img { max-height: 100px; border-radius: 6px; }

/* Photo directly above signature, boxed together — official document style */
.photo-sig-block {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 14px;
  background: #fff;
}
.photo-sig-block label:first-child { margin-top: 0; }
.photo-sig-block .upload-box:first-of-type img { max-height: 130px; }
.photo-sig-block .upload-box:last-of-type { margin-top: 4px; }
.photo-sig-block .upload-box:last-of-type img { max-height: 50px; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: none; border-radius: 8px;
  padding: 10px 18px; font-weight: 600; font-size: .88rem; cursor: pointer;
  transition: transform .05s ease;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-deep); }
.btn-gold { background: var(--gold); color: var(--navy-deep); }
.btn-gold:hover { filter: brightness(0.95); }
.btn-outline { background: #fff; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: .8rem; }

/* ---------------- Table ---------------- */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--text-mute); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
tr:hover td { background: var(--bg); }
.table-toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.table-toolbar input, .table-toolbar select { width: auto; min-width: 160px; }

.badge { padding: 2px 10px; border-radius: 999px; font-size: .72rem; font-weight: 700; }
.badge-active { background: #E4F3EA; color: var(--success); }
.badge-inactive { background: #FBE9E7; color: var(--danger); }

/* ---------------- Login page ---------------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-deep) 60%);
  padding: 20px;
}
.login-card {
  background: #fff; border-radius: 14px; padding: 36px 32px; width: 100%; max-width: 380px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25); text-align: center;
}
.login-card .crest {
  width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 14px;
  background: var(--gold); color: var(--navy-deep); display: flex; align-items: center;
  justify-content: center; font-weight: 800; font-size: 1.3rem;
}
.login-card .btn-primary { width: 100%; margin-top: 10px; }
.login-error { color: var(--danger); font-size: .85rem; margin-top: 10px; display: none; }

/* ---------------- Utility ---------------- */
.flex { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }
.muted { color: var(--text-mute); }
.mt-0 { margin-top: 0; }
.text-center { text-align: center; }
.pill-photo {
  width: 48px; height: 56px; border-radius: 6px;
  object-fit: contain; object-position: center top;
  border: 1px solid var(--border);
  background: var(--bg);
  display: block;
}
/* ---------------- Tabs (used on Fees / Class Report pages) ---------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.tabs button {
  background: none; border: none; padding: 10px 16px; font-weight: 600; font-size: .88rem;
  color: var(--text-mute); cursor: pointer; border-bottom: 2px solid transparent;
}
.tabs button.active { color: var(--navy); border-bottom-color: var(--gold); }

/* ---------------- Hamburger (mobile) ---------------- */
.hamburger {
  display: none; background: none; border: none; color: #fff; font-size: 1.4rem;
  cursor: pointer; padding: 4px 8px;
}

/* ---------------- Responsive ---------------- */
@media (max-width: 800px) {
  .hamburger { display: block; }
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%; display: none; flex-direction: column; overflow-x: visible;
    border-right: none; border-bottom: 1px solid var(--border);
  }
  .sidebar.open { display: flex; }
  .main { padding: 18px 16px; }
  .form-grid, .form-grid.thirds { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  table { display: block; overflow-x: auto; white-space: nowrap; }
  .topbar .brand span:not(.crest) { display: none; } /* keep just crest on very small screens */
  .topbar { padding: 12px 14px; }
  .card { padding: 16px; }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .login-card { padding: 28px 20px; }
}

/* ---------------- Login page with campus background ---------------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: url("login-bg.png") center center / cover no-repeat fixed;
  padding: 20px;
  position: relative;
}
.login-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(20, 40, 63, 0.55);
  z-index: 0;
}
.login-card {
  position: relative;
  z-index: 1;
  background: rgba(255, 255, 255, 0.97);
  border-radius: 14px;
  padding: 36px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
  text-align: center;
}
.login-card .crest {
  width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 14px;
  background: var(--gold); color: var(--navy-deep); display: flex; align-items: center;
  justify-content: center; font-weight: 800; font-size: 1.3rem;
}
.login-card form {
  text-align: left;
}
.login-card .btn-primary {
  width: 100%;
  margin-top: 18px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.login-error {
  color: var(--danger);
  font-size: .85rem;
  margin-top: 12px;
  display: none;
  text-align: center;
}
.login-card label { text-align: left; }
.login-card input { text-align: left; }

/* Bilingual label helper */
label .hi { font-weight: 400; color: var(--text-mute); font-size: .78rem; margin-left: 4px; }

/* Status badges for attendance */
.badge-present { background: #E4F3EA; color: var(--success); }
.badge-absent { background: #FBE9E7; color: var(--danger); }
.badge-late { background: #FFF3E0; color: #E65100; }
.badge-leave { background: #E3F2FD; color: #1565C0; }




/* ===== Students table — clear, roomy, non-technical friendly ===== */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
th, td {
  text-align: left;
  padding: 14px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
th {
  color: var(--text-mute);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
tr.student-row:hover td {
  background: #f7f9fc;
}

.col-photo { width: 64px; }
.col-actions {
  width: 200px;
  text-align: right;
  white-space: nowrap;
}

.row-actions {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  white-space: nowrap;
}

.btn-action {
  min-width: 72px;
  padding: 9px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 8px;
  text-align: center;
  text-decoration: none;
  line-height: 1.2;
}

.pill-photo {
  width: 44px;
  height: 52px;
  border-radius: 6px;
  object-fit: contain;
  object-position: center top;
  border: 1px solid var(--border);
  background: #f5f5f5;
  display: block;
}

.table-toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
  align-items: center;
}
.table-toolbar input,
.table-toolbar select {
  width: auto;
  min-width: 150px;
  padding: 10px 12px;
  font-size: 0.9rem;
}
