/* ==========================================================================
   GLOBAL STYLES  —  Green Mount Academy Staff Portal
   Bootstrap provides grid/form mechanics only; every visual is overridden.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 15px; }

body {
  font-family: var(--font-body);
  background: var(--color-paper);
  color: var(--color-ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Display type — only page/card titles */
h1, h2, h3, h4, .font-display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--color-ink);
}
.card-header { font-family: var(--font-body); font-weight: 600; }

/* Tabular numerals so columns of money align like a real ledger */
.amount, .amount-col, .text-amount, td.amount-col { font-variant-numeric: tabular-nums; }
td.amount-col { text-align: right; }

a { color: var(--color-mid-green); text-decoration: none; }
a:hover { color: var(--color-forest); text-decoration: underline; }

/* Keyboard focus — never remove */
:focus-visible {
  outline: 2px solid var(--color-mid-green);
  outline-offset: 2px;
  border-radius: 2px;
}
button:focus-visible, .btn:focus-visible { outline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}


/* ==========================================================================
   BUTTONS  — override Bootstrap entirely
   ========================================================================== */
.btn {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-sm);
  box-shadow: none !important;
  transition: background 0.12s, border-color 0.12s;
}
.btn-primary, .btn-primary:visited {
  background: var(--color-forest);
  border-color: var(--color-forest);
  color: #fff;
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--color-forest-dark);
  border-color: var(--color-forest-dark);
  color: #fff;
}
.btn-outline-primary {
  color: var(--color-forest);
  border-color: var(--color-forest);
}
.btn-outline-primary:hover, .btn-outline-primary:focus {
  background: var(--color-forest);
  border-color: var(--color-forest);
  color: #fff;
}


/* ==========================================================================
   FORM CONTROLS — tighter, less Bootstrap-ish
   ========================================================================== */
.form-control, .form-select {
  border-radius: var(--radius-sm);
  border-color: var(--color-border);
  font-size: 0.9rem;
  padding: 0.45rem 0.75rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--color-mid-green);
  box-shadow: 0 0 0 3px rgba(45,106,79,0.12);
}
.form-label { font-size: 0.82rem; font-weight: 500; color: var(--color-ink-muted); margin-bottom: 4px; }
.form-text  { font-size: 0.78rem; color: var(--color-ink-muted); }
.required-star { color: var(--color-danger); margin-left: 2px; line-height: 1; }


/* ==========================================================================
   CARDS
   ========================================================================== */
.card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: none;
}
.card-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0.75rem 1rem;
  font-weight: 600;
  font-size: 0.9rem;
  /* Module accent stripe: default forest, overridden per body class */
  border-left: 4px solid var(--color-forest);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.card-body  { padding: 1rem; }
.card-footer { background: var(--color-paper); border-top: 1px solid var(--color-border); padding: 0.75rem 1rem; }

/* Module identity — set via <body class="module-X"> on each page */
.module-students  .card-header { border-left-color: var(--accent-students); }
.module-admission .card-header { border-left-color: var(--accent-admission); }
.module-receipts  .card-header { border-left-color: var(--accent-receipts); }
.module-reports   .card-header { border-left-color: var(--accent-reports); }
.module-alerts    .card-header { border-left-color: var(--accent-alerts); }
.module-session   .card-header { border-left-color: var(--accent-session); }


/* ==========================================================================
   TABLES — ruled-ledger aesthetic
   ========================================================================== */
.table-ledger { font-size: 0.88rem; width: 100%; margin-bottom: 0; border-collapse: collapse; }
.table-ledger thead th {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-ink-muted);
  padding: 0.6rem 1rem;
  border-bottom: 2px solid var(--color-border);
  white-space: nowrap;
  background: var(--color-paper);
}
.table-ledger thead th a { color: var(--color-ink-muted); }
.table-ledger thead th a:hover { color: var(--color-ink); }
.table-ledger tbody td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}
.table-ledger tbody tr:last-child td { border-bottom: none; }
.table-ledger tbody tr:hover { background: var(--color-green-tint); cursor: pointer; }
.table-ledger tfoot td {
  padding: 0.65rem 1rem;
  font-weight: 600;
  border-top: 2px solid var(--color-border);
}


/* ==========================================================================
   STATUS PILLS / BADGES
   ========================================================================== */
.pill {
  display: inline-block;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.pill-success { background: var(--color-success-tint); color: var(--color-success); }
.pill-warning { background: var(--color-warning-tint); color: var(--color-warning); }
.pill-danger  { background: var(--color-danger-tint);  color: var(--color-danger);  }
.pill-neutral { background: #EAECEB;                   color: var(--color-ink-muted); }


/* ==========================================================================
   ALERT OVERRIDES
   ========================================================================== */
.alert { font-size: 0.875rem; border-radius: var(--radius-sm); }


/* ==========================================================================
   LOGIN MODAL — the design's one signature moment
   ========================================================================== */
.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 18, 12, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1050;
  padding: 1rem;
  backdrop-filter: blur(2px);
}
.login-card {
  display: flex;
  width: 100%;
  max-width: 760px;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,0.28);
}

/* Green left panel with the signature ledger-line watermark */
.login-card__panel {
  flex: 0 0 38%;
  background: var(--color-forest);
  color: #D4E8DC;
  padding: 2.5rem 2rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  /* Ruled-ledger texture — thin horizontal lines echoing the school's paper receipt books */
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,0.04) 0px,
    rgba(255,255,255,0.04) 1px,
    transparent 1px,
    transparent 26px
  );
}
.login-card__panel img.logo { width: 60px; height: 70px; margin-bottom: 1rem;  }
.login-card__panel h2 { font-family: var(--font-display); color: #fff; font-size: 1.35rem; margin-bottom: 0.4rem; }
.login-card__panel p  { color: rgba(255,255,255,0.65); font-size: 0.83rem; line-height: 1.5; }

.login-card__form { flex: 1; padding: 2.5rem 2rem; }

.role-tabs { display: flex; gap: 0.4rem; margin-bottom: 1.5rem; }
.role-tab {
  flex: 1;
  text-align: center;
  padding: 0.4rem 0.25rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-paper);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--color-ink-muted);
  cursor: pointer;
  transition: all 0.12s;
  user-select: none;
}
.role-tab:hover   { border-color: var(--color-mid-green); color: var(--color-forest); }
.role-tab.active  {
  background: var(--color-green-tint);
  border-color: var(--color-mid-green);
  color: var(--color-forest);
  font-weight: 600;
}
.field-error { color: var(--color-danger); font-size: 0.8rem; margin-top: 4px; }

@media (max-width: 600px) {
  .login-card { flex-direction: column; }
  .login-card__panel { flex: none; padding: 1.5rem; }
}


/* ==========================================================================
   LANDING PAGE (dummy, shown behind login once modal is closed)
   ========================================================================== */
.landing-hero {
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  padding: 2rem;
  gap: 0.75rem;
}
.landing-hero h1 { font-size: clamp(1.6rem, 4vw, 2.6rem); color: var(--color-forest); max-width: 560px; }
.landing-hero p  { color: var(--color-ink-muted); max-width: 460px; font-size: 1rem; }


/* ==========================================================================
   APP SHELL — sidebar + content wrapper
   ========================================================================== */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ------ SIDEBAR ------ */
.sidebar {
  width: var(--sidebar-width-expanded);
  background: #1E2420; /* near-neutral dark with just a whisper of green — NOT --color-forest */
  flex-shrink: 0;
  transition: width 0.18s ease;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;          /* hide text while collapsing */
  overflow-y: auto;
  scrollbar-width: none;     /* Firefox */
  z-index: 100;
}
.sidebar::-webkit-scrollbar { display: none; }
.sidebar.collapsed { width: var(--sidebar-width-collapsed); }
.sidebar.collapsed.is-hovered,
.sidebar.collapsed:hover { width: var(--sidebar-width-expanded); }

/* Brand row */
.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  min-height: var(--header-height);
  flex-shrink: 0;
}
.sidebar__brand img  { width: 32px; height: 32px; flex-shrink: 0; }
.sidebar__brand span {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.88rem;
  color: #e8ede9;
  white-space: nowrap;
  overflow: hidden;
  opacity: 1;
  transition: opacity 0.12s;
}
.sidebar.collapsed .sidebar__brand span { opacity: 0; pointer-events: none; }
.sidebar.collapsed.is-hovered .sidebar__brand span,
.sidebar.collapsed:hover .sidebar__brand span { opacity: 1; pointer-events: auto; }

/* Nav links */
.sidebar-nav { padding: 0.5rem 0; flex: 1; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  color: #A8BEB0;
  font-size: 0.85rem;
  font-weight: 450;
  white-space: nowrap;
  border-left: 3px solid transparent;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
  text-decoration: none !important;
  position: relative;
}
.nav-link i { width: 18px; text-align: center; flex-shrink: 0; font-size: 1rem; }
.nav-link:hover,
.nav-link:focus-visible,
.nav-sublink:hover,
.nav-sublink:focus-visible {
  background: rgba(255,255,255,0.06);
  color: #E8EDE9;
  text-decoration: none !important;
}
.nav-link.active { background: rgba(255,255,255,0.09); border-left-color: var(--color-mid-green); color: #fff; }
.nav-group:hover > .nav-link,
.nav-group:focus-within > .nav-link,
.nav-group > .nav-link[aria-expanded="true"] {
  color: #E8EDE9;
}

/* Sublinks (inside dropdown groups like Admission, Receipts) */
.nav-sublink { padding-left: 2.75rem; font-size: 0.82rem; border-left: 3px solid transparent; }
.nav-sublink.active { border-left-color: rgba(45,106,79,0.6); color: #fff; background: rgba(255,255,255,0.05); }

/* Hide text labels when collapsed */
.sidebar.collapsed .nav-link span,
.sidebar.collapsed .nav-link .bi-chevron-down { display: none; }
.sidebar.collapsed.is-hovered .nav-link span,
.sidebar.collapsed:hover .nav-link span,
.sidebar.collapsed.is-hovered .nav-link .bi-chevron-down,
.sidebar.collapsed:hover .nav-link .bi-chevron-down {
  display: inline;
}

/* Collapsed tooltips — label appears to the right of the icon on hover */
.sidebar.collapsed .nav-link::after {
  content: attr(data-label);
  position: absolute;
  left: calc(var(--sidebar-width-collapsed) + 4px);
  background: #333;
  color: #fff;
  font-size: 0.78rem;
  padding: 4px 10px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 200;
}
.sidebar.collapsed .nav-link:hover::after { opacity: 1; }
.sidebar.collapsed.is-hovered .nav-link::after,
.sidebar.collapsed:hover .nav-link::after { opacity: 0; pointer-events: none; }

/* Submenus hidden when sidebar is collapsed */
.sidebar.collapsed .nav-group .collapse { display: none !important; }
.sidebar.collapsed.is-hovered .nav-group:hover .collapse,
.sidebar.collapsed:hover .nav-group:hover .collapse,
.sidebar.collapsed.is-hovered .nav-group .collapse.show,
.sidebar.collapsed:hover .nav-group .collapse.show {
  display: block !important;
}
.sidebar.collapsed .nav-group > .nav-link .bi-chevron-down { display: none; }

/* Toggle button */
.sidebar__toggle {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(255,255,255,0.05);
  border: none;
  border-top: 1px solid rgba(255,255,255,0.07);
  color: #7A9882;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: background 0.1s;
  flex-shrink: 0;
}
.sidebar__toggle:hover { background: rgba(255,255,255,0.1); color: #e8ede9; }
.sidebar__toggle i { font-size: 1rem; }
.sidebar.collapsed .sidebar__toggle span { display: none; }
.sidebar.collapsed.is-hovered .sidebar__toggle span,
.sidebar.collapsed:hover .sidebar__toggle span { display: inline-flex; }


/* ------ TOPBAR ------ */
.main-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: var(--header-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 90;
}
.topbar h1 { font-size: 1.05rem; margin: 0; font-family: var(--font-body); font-weight: 600; }

/* ------ MAIN CONTENT ------ */
.main-content { flex: 1; padding: 1.5rem; }


/* ==========================================================================
   DRAFT BANNER (inline on pages with drafts pending)
   ========================================================================== */
.draft-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: var(--color-warning-tint);
  border: 1px solid #D4A432;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  color: var(--color-warning);
}
.draft-banner i { flex-shrink: 0; margin-top: 1px; }

/* Auto-save indicator (small floating badge) */
#autosaveIndicator {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: #333;
  color: #fff;
  font-size: 0.75rem;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 1000;
}
#autosaveIndicator.visible { opacity: 1; }

/* Navigate-away drafted alert */
#draftedAlert {
  position: fixed;
  top: 5rem;
  right: 1.5rem;
  background: var(--color-warning-tint);
  border: 1px solid #D4A432;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  color: var(--color-warning);
  z-index: 1100;
  max-width: 320px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  display: none;
}


/* ==========================================================================
   STATS CARDS (dashboard)
   ========================================================================== */
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}
.stat-card__label { font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-ink-muted); }
.stat-card__value { font-size: 1.75rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; margin: 0.25rem 0; }
.stat-card__sub   { font-size: 0.8rem; color: var(--color-ink-muted); }
.stat-card.accent-green { border-left: 4px solid var(--color-mid-green); }
.stat-card.accent-red   { border-left: 4px solid var(--color-danger); }
.stat-card.accent-amber { border-left: 4px solid var(--color-warning); }


/* ==========================================================================
   NAVIGATION TABS (Bootstrap override)
   ========================================================================== */
.nav-tabs { border-bottom: 2px solid var(--color-border); }
.nav-tabs .nav-link { color: var(--color-ink-muted); border: none; border-bottom: 3px solid transparent; padding: 0.5rem 1rem; font-size: 0.88rem; font-weight: 500; margin-bottom: -2px; }
.nav-tabs .nav-link:hover  { color: var(--color-forest); }
.nav-tabs .nav-link.active { color: var(--color-forest); border-bottom-color: var(--color-forest); font-weight: 600; background: none; }


/* ==========================================================================
   MODALS (Bootstrap override)
   ========================================================================== */
.modal-header { border-bottom: 1px solid var(--color-border); }
.modal-footer { border-top: 1px solid var(--color-border); }
.modal-title  { font-family: var(--font-display); font-size: 1.1rem; }
.modal-content { border: none; border-radius: var(--radius-md); }


/* ==========================================================================
   DROPDOWN (Bootstrap override)
   ========================================================================== */
.dropdown-menu { border: 1px solid var(--color-border); border-radius: var(--radius-md); box-shadow: 0 8px 24px rgba(0,0,0,0.1); padding: 0.4rem; }
.dropdown-item { border-radius: var(--radius-sm); font-size: 0.88rem; }
.dropdown-item:hover { background: var(--color-green-tint); color: var(--color-forest); }


/* ==========================================================================
   PROMOTION CONSOLE (used on promotion_console.php)
   ========================================================================== */
.promo-row { display: flex; align-items: center; gap: 0.75rem; padding: 0.65rem 0; border-bottom: 1px solid var(--color-border); }
.promo-row:last-child { border-bottom: none; }
.promo-row__name { flex: 1; font-weight: 500; }
.promo-row__class { color: var(--color-ink-muted); font-size: 0.85rem; min-width: 80px; }
.promo-row__due   { min-width: 90px; text-align: right; font-variant-numeric: tabular-nums; }
.promo-row.restricted { background: #fff8f0; border-radius: var(--radius-sm); padding-left: 0.5rem; }


/* ==========================================================================
   PRINT / PDF STYLES
   ========================================================================== */
@media print {
  /* Hide everything not meant for paper */
  .sidebar, .topbar, .no-print, nav, footer,
  .btn, button, .dropdown, .modal, #autosaveIndicator, #draftedAlert { display: none !important; }

  body { background: #fff !important; font-size: 11pt; color: #000; margin: 0; padding: 0; }
  .app-shell { display: block; }
  .main-content { padding: 0; }

  /* Full A4 page usage for office receipts */
  .receipt-print-wrap {
    width: 210mm;
    min-height: 297mm;
    padding: 12mm 14mm;
    margin: 0 auto;
    font-size: 11pt;
    page-break-after: always;
  }

  /* Two-up receipt on one A4 (parent copy + office copy) */
  .receipt-half {
    height: 140mm;
    padding: 8mm 10mm;
    box-sizing: border-box;
    position: relative;
  }
  .receipt-half + .receipt-half {
    border-top: 2px dashed #999;
    margin-top: 4mm;
  }
  .receipt-half__label {
    position: absolute;
    top: 2mm;
    right: 3mm;
    font-size: 7pt;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.06em;
  }

  .table-ledger tbody tr:hover { background: transparent !important; }
  a { color: #000 !important; }
  .pill { border: 1px solid #999; background: transparent !important; }

  @page {
    size: A4 portrait;
    margin: 0;
  }
}


/* ==========================================================================
   RESPONSIVE  —  mobile / tablet adjustments
   ========================================================================== */
@media (max-width: 991px) {
  :root {
    --sidebar-width-expanded: 220px;
  }
}

@media (max-width: 767px) {
  .sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    height: 100vh;
    transition: left 0.22s ease, width 0.18s ease;
    z-index: 1040;
    width: var(--sidebar-width-expanded) !important; /* always show full width on mobile when open */
  }
  .sidebar.mobile-open { left: 0; }
  .sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1039;
  }
  .sidebar-backdrop.visible { display: block; }
  .topbar { padding: 0 1rem; }
  .topbar #mobileSidebarBtn { display: flex !important; }
  .main-content { padding: 1rem; }
  .login-card { flex-direction: column; max-width: 420px; }
  .login-card__panel { flex: none; padding: 1.5rem; }
}

@media (min-width: 768px) {
  #mobileSidebarBtn { display: none !important; }
}
