/* =========================================================
   KHALIL AL REHMAN GRAMMAR HIGH SCHOOL - Stylesheet
   ========================================================= */

:root {
  --navy: #0b3d5c;
  --navy-dark: #082c42;
  --navy-light: #12507a;
  --gold: #c99a2e;
  --gold-light: #e0b84f;
  --bg: #eef2f5;
  --card-bg: #ffffff;
  --text: #1e2a32;
  --muted: #6b7c88;
  --border: #e1e7eb;
  --green: #1e7a46;
  --red: #b3311c;
  --orange: #b5720f;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 10px rgba(11,61,92,0.07);
  --shadow-lift: 0 10px 28px rgba(11,61,92,0.14);
}

* { box-sizing: border-box; }

html { scrollbar-color: #b9c6cf var(--bg); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c3ced6; border-radius: 20px; }
::-webkit-scrollbar-thumb:hover { background: #a9b8c2; }

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
h1, h2, h3 { font-family: inherit; }

/* ---------- Login ---------- */
.login-screen {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 15% 15%, rgba(201,154,46,0.18), transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(255,255,255,0.06), transparent 40%),
    linear-gradient(135deg, var(--navy) 0%, var(--navy-dark) 100%);
}
.login-box {
  background: var(--card-bg);
  padding: 40px 36px;
  border-radius: 16px;
  width: 370px;
  max-width: 90vw;
  box-shadow: 0 25px 60px rgba(0,0,0,0.3);
  text-align: center;
  animation: loginRise 0.35s ease;
}
@keyframes loginRise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.login-logo {
  width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  color: var(--gold-light); font-size: 26px; font-weight: 700;
  box-shadow: 0 8px 20px rgba(11,61,92,0.3);
  overflow: hidden;
}
.login-logo img { width: 100%; height: 100%; object-fit: cover; }
.login-box h1 {
  font-size: 18px;
  color: var(--navy);
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.login-sub { color: var(--muted); margin-bottom: 24px; font-size: 13px; }
.login-box form { text-align: left; }
.login-box label { display: block; font-size: 12px; margin: 10px 0 4px; color: var(--muted); font-weight: 600; }
.login-box input {
  width: 100%; padding: 11px 12px; border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 14px; transition: border-color 0.15s, box-shadow 0.15s;
}
.login-box input:focus { outline: none; border-color: var(--navy-light); box-shadow: 0 0 0 3px rgba(11,61,92,0.12); }
.login-error { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 8px; }
.login-hint { margin-top: 20px; font-size: 11px; color: var(--muted); text-align: left; background: var(--bg); padding: 12px; border-radius: 8px; line-height: 1.7; }

/* ---------- App shell ---------- */
.app-shell { display: flex; height: 100vh; }
.sidebar {
  width: 258px;
  background: linear-gradient(180deg, var(--navy-dark) 0%, #061f30 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.brand { padding: 20px 18px; border-bottom: 1px solid rgba(255,255,255,0.1); display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 42px; height: 42px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--navy-light), var(--navy));
  display: flex; align-items: center; justify-content: center;
  color: var(--gold-light); font-weight: 700; font-size: 15px; overflow: hidden;
  border: 1px solid rgba(255,255,255,0.15);
}
.brand-logo img { width: 100%; height: 100%; object-fit: cover; }
.brand-name { font-weight: 700; font-size: 13.5px; line-height: 1.4; }
.brand-sub { font-size: 11px; color: var(--gold); margin-top: 4px; }
#nav-list { flex: 1; padding: 10px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  background: transparent; border: none; color: #cfe0ea;
  padding: 10px 12px; border-radius: 8px; font-size: 13.5px;
  margin-bottom: 3px; transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: rgba(255,255,255,0.08); }
.nav-item.active { background: linear-gradient(90deg, var(--gold), var(--gold-light)); color: var(--navy-dark); font-weight: 700; box-shadow: 0 4px 12px rgba(201,154,46,0.35); }
.nav-icon { font-size: 15px; }
.sidebar-footer { padding: 14px; border-top: 1px solid rgba(255,255,255,0.1); }
.user-chip { font-size: 12px; margin-bottom: 10px; color: #cfe0ea; display: flex; align-items: center; gap: 8px; }
.role-tag { display: block; color: var(--gold); font-size: 11px; margin-top: 2px; }

.main-area { flex: 1; overflow-y: auto; padding: 24px 28px; min-width: 0; }

/* ---------- Mobile top bar + sidebar drawer (hidden above the mobile breakpoint) ---------- */
.mobile-topbar { display: none; }
.sidebar-backdrop { display: none; }

/* ---------- Layout bits ---------- */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.page-header h2 { margin: 0; color: var(--navy); font-size: 20px; letter-spacing: 0.2px; }

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 18px;
  transition: box-shadow 0.2s;
}
.card h3 { margin-top: 0; color: var(--navy); font-size: 15px; }
.card-danger { border: 1.5px solid #f3c8c0; background: #fff8f7; }
.card-danger h3 { color: var(--red); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  display: flex; align-items: center; gap: 14px;
  border-left: 4px solid var(--gold);
  transition: transform 0.15s, box-shadow 0.15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.stat-icon {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
  background: linear-gradient(135deg, var(--navy), var(--navy-light)); color: var(--gold-light);
}
.stat-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.stat-num { font-size: 22px; font-weight: 700; color: var(--navy); line-height: 1.1; }
.stat-label { font-size: 12px; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  border: none; border-radius: 8px; padding: 9px 16px; font-size: 13.5px; font-weight: 600;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(135deg, var(--navy), var(--navy-light)); color: #fff; box-shadow: 0 2px 8px rgba(11,61,92,0.25); }
.btn-primary:hover { background: var(--navy-dark); }
.btn-secondary { background: #e7edf1; color: var(--navy); }
.btn-secondary:hover { background: #dbe3e8; }
.btn-gold { background: linear-gradient(135deg, var(--gold), var(--gold-light)); color: var(--navy-dark); }
.btn-gold:hover { filter: brightness(0.96); }
.btn-danger { background: var(--red); color: #fff; box-shadow: 0 2px 8px rgba(179,49,28,0.3); }
.btn-danger:hover { background: #8f2716; }
.btn-block { width: 100%; margin-top: 14px; }
.btn-small { padding: 5px 10px; font-size: 12px; }
.file-btn { display: inline-block; text-align: center; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; background: var(--bg); color: var(--navy);
  padding: 10px 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.3px;
  border-bottom: 2px solid var(--border);
}
.data-table td { padding: 9px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:hover td { background: #f9fbfc; }
.actions { display: flex; gap: 6px; }
.icon-btn { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 5px 8px; font-size: 13px; }
.icon-btn:hover { background: #e7edf1; }

.thumb { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); }
.thumb.placeholder { display: flex; align-items: center; justify-content: center; background: var(--bg); color: var(--muted); }
.thumb-initials { display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; border: none; }

/* ---------- Photo upload widget (students, staff, school logo) ---------- */
.photo-upload { display: flex; align-items: center; gap: 16px; margin: 4px 0 8px; }
.photo-circle {
  border-radius: 50%; overflow: hidden; flex-shrink: 0;
  background: var(--bg); border: 2px dashed var(--border);
  display: flex; align-items: center; justify-content: center;
}
.photo-circle.photo-square { border-radius: 12px; }
.photo-circle img { width: 100%; height: 100%; object-fit: cover; }
.photo-placeholder-icon { font-size: 26px; opacity: 0.5; }
.photo-upload-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.hint-tiny { font-size: 11px; color: var(--muted); margin: 0; }

/* ---------- Badges ---------- */
.badge { padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; letter-spacing: 0.2px; }
.badge-green { background: #e2f4e9; color: var(--green); }
.badge-red { background: #fbe6e2; color: var(--red); }
.badge-orange { background: #fbeed9; color: var(--orange); }
.badge-gray { background: #eceff1; color: var(--muted); }
.badge-gold { background: #fbf1da; color: #8a6a10; }

/* ---------- Filter bars ---------- */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filter-bar input, .filter-bar select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tab-btn { background: none; border: none; padding: 10px 16px; font-size: 13.5px; color: var(--muted); border-bottom: 3px solid transparent; transition: color 0.15s; }
.tab-btn:hover { color: var(--navy); }
.tab-btn.active { color: var(--navy); font-weight: 700; border-bottom-color: var(--gold); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row { display: flex; flex-direction: column; gap: 4px; }
.form-row.full { grid-column: 1 / -1; }
.form-row label { font-size: 12px; color: var(--muted); font-weight: 600; }
.form-row input, .form-row select, .form-row textarea {
  padding: 9px 10px; border: 1px solid var(--border); border-radius: 7px; font-size: 13.5px; font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  outline: none; border-color: var(--navy-light); box-shadow: 0 0 0 3px rgba(11,61,92,0.1);
}
.form-row textarea { resize: vertical; min-height: 60px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.photo-preview { width: 70px; height: 70px; object-fit: cover; border-radius: 8px; margin-top: 8px; border: 1px solid var(--border); }
.hint { font-size: 12px; color: var(--muted); background: var(--bg); padding: 10px; border-radius: 7px; }
.notice { font-size: 12.5px; background: #fff7e6; border: 1px solid #f0d999; color: #7a5c00; padding: 10px; border-radius: 7px; margin-bottom: 14px; }
.section-title { color: var(--navy); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; margin: 18px 0 8px; }
.section-title:first-child { margin-top: 0; }

.fee-item-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.fee-item-row input, .fee-item-row select { flex: 1; padding: 8px; border: 1px solid var(--border); border-radius: 6px; font-family: inherit; }

.recipient-list { max-height: 160px; overflow-y: auto; font-size: 13px; padding-left: 18px; }
.report-footer { font-weight: 600; color: var(--navy); margin-top: 10px; }

.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(8,44,66,0.5);
  align-items: center; justify-content: center; z-index: 1000; backdrop-filter: blur(2px);
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: #fff; border-radius: 14px; width: 560px; max-width: 92vw;
  max-height: 88vh; overflow-y: auto; box-shadow: 0 25px 70px rgba(0,0,0,0.35);
  animation: modalPop 0.18s ease;
}
@keyframes modalPop { from { opacity: 0; transform: scale(0.97) translateY(6px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; border-bottom: 1px solid var(--border); }
.modal-header h3 { margin: 0; color: var(--navy); font-size: 16px; }
.modal-close { background: none; border: none; font-size: 22px; color: var(--muted); line-height: 1; border-radius: 6px; padding: 2px 6px; }
.modal-close:hover { background: var(--bg); color: var(--red); }
.modal-body { padding: 22px; }

/* ---------- Toasts ---------- */
#toast-box { position: fixed; top: 18px; right: 18px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--navy-dark); color: #fff; padding: 12px 18px; border-radius: 9px;
  font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,0.28);
  opacity: 0; transform: translateY(-8px); transition: all 0.25s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-error { background: var(--red); }

/* ---------- Empty states ---------- */
.empty-row { text-align: center; color: var(--muted); padding: 34px !important; font-size: 13px; }

@media (max-width: 900px) {
  .grid-2, .grid-3, .stat-grid, .form-grid { grid-template-columns: 1fr; }
}

/* ---------- Mobile phones/small tablets: off-canvas sidebar drawer ---------- */
@media (max-width: 760px) {
  .app-shell { display: block; height: auto; min-height: 100vh; }

  .mobile-topbar {
    display: flex; align-items: center; gap: 12px;
    background: var(--navy-dark); color: #fff; padding: 12px 14px;
    position: sticky; top: 0; z-index: 500;
  }
  .hamburger-btn {
    background: none; border: none; color: #fff; font-size: 21px; line-height: 1;
    padding: 6px 9px; border-radius: 7px;
  }
  .hamburger-btn:hover, .hamburger-btn:active { background: rgba(255,255,255,0.12); }
  .mobile-topbar-title { font-weight: 700; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 258px; max-width: 82vw;
    z-index: 900; transform: translateX(-100%); transition: transform 0.25s ease;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,0.45); }
  .sidebar-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(8,44,66,0.5);
    z-index: 800; opacity: 0; pointer-events: none; transition: opacity 0.2s;
  }
  .sidebar-backdrop.open { opacity: 1; pointer-events: auto; }

  .main-area { padding: 14px; }
  .page-header { flex-wrap: wrap; gap: 10px; }
  .page-header h2 { font-size: 17px; }

  .modal-box { width: 96vw; max-width: 96vw; max-height: 94vh; }
  .modal-body { padding: 14px; }
  .modal-header { padding: 12px 14px; }

  .login-box { padding: 30px 20px; }

  .stat-grid { gap: 10px; }
  .stat-card { padding: 13px 14px; gap: 10px; }

  .data-table th, .data-table td { padding: 8px 6px; font-size: 12.5px; }

  .fee-item-row { flex-wrap: wrap; }
}
