/* ============================================================================
   LYCEE DE KICUKIRO APADE - Fees Management
   Theme: deep teal accent (school identity), restrained serif display +
   highly legible system-ui body. Overdue = amber/red only.
   ==========================================================================*/

:root {
  --accent: #00695c;
  --accent-dark: #004d40;
  --accent-light: #e0f2f1;
  --accent-mid: #00897b;
  --ink: #212529;
  --muted: #5f6b74;
  --line: #e3e6e8;
  --bg: #f4f5f6;
  --card: #ffffff;
  --ok: #1b7f3b;
  --ok-bg: #e6f4ea;
  --warn: #b26a00;
  --warn-bg: #fff3e0;
  --danger: #b3261e;
  --danger-bg: #fdecea;
  --info: #0b5394;
  --info-bg: #e7f1fa;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(15, 40, 40, .12);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body, .site-body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
}

/* Display face for headings and big money figures */
h1, h2, h3, h4, h5, .site-brand-name, .site-topbar-title {
  font-family: Georgia, "Times New Roman", "Times New Roman", serif;
  font-weight: 600;
  letter-spacing: .01em;
}

h1 { font-size: 1.55rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.12rem; }

/* Accessible focus states everywhere */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--accent-mid);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ------------------------------- sidebar ---------------------------------- */
.site-sidebar {
  background: var(--accent-dark);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}
.site-sidebar .w3-bar-item { color: #e8f5f2; }
.site-brand {
  flex: 0 0 auto;
  padding: 20px 18px 14px;
  border-bottom: 1px solid rgba(255,255,255,.14);
}
.site-brand-mark {
  width: 44px; height: 44px;
  border-radius: 8px;
  background: var(--accent-mid);
  color: #fff;
  font-family: Georgia, serif;
  font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 10px;
}
.site-brand-name { color: #fff; font-size: .95rem; line-height: 1.25; }
.site-brand-sub { color: rgba(255,255,255,.65); font-size: .72rem; margin-top: 4px; }

.site-navlink {
  min-height: 48px;               /* touch target */
  padding: 13px 18px !important;
  font-size: .92rem;
  border-left: 4px solid transparent;
  transition: background-color .12s ease;
}
.site-navlink:hover { background: rgba(255,255,255,.08); }
.site-navlink.active {
  background: var(--accent-mid);
  border-left-color: #fff;
  color: #fff;
}

.site-nav-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.35) transparent;
}
.site-nav-scroll::-webkit-scrollbar { width: 8px; }
.site-nav-scroll::-webkit-scrollbar-track { background: transparent; }
.site-nav-scroll::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.3);
  border-radius: 999px;
}
.site-nav-scroll::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.5); }

.site-sidebar-foot {
  flex: 0 0 auto;
  padding: 14px 18px;
  color: rgba(255,255,255,.7);
  font-size: .74rem;
  border-top: 1px solid rgba(255,255,255,.14);
}

.site-badge {
  float: right;
  background: #fff; color: var(--accent-dark);
  border-radius: 999px;
  font-size: .72rem; font-weight: 700;
  padding: 1px 8px;
  margin-top: 1px;
}

/* -------------------------------- topbar ---------------------------------- */
.site-topbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  min-height: 58px;
  padding: 0 12px;
  position: sticky; top: 0; z-index: 2;
  box-shadow: var(--shadow);
}
.site-topbar-title {
  font-size: 1.05rem;
  color: var(--accent-dark);
  flex: 1;
  padding-left: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.site-user { font-weight: 600; }
.site-role { color: var(--muted); font-size: .85rem; margin-left: 8px; }
.site-user-mob { font-weight: 600; font-size: .95rem; }
.site-logout {
  color: var(--accent-dark) !important;
  font-weight: 600;
}

.site-main { transition: margin-left .25s ease; }
.site-content { padding: 14px; max-width: 1240px; margin: 0 auto; }

/* ------------------------------- cards ------------------------------------ */
.site-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.site-card h2, .site-card h3 { margin-top: 0; color: var(--accent-dark); }

.stat {
  padding: 16px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card);
}
.stat .stat-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.stat .stat-value {
  font-family: Georgia, serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--accent-dark);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.stat .stat-sub { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.stat--danger .stat-value { color: var(--danger); }
.stat--warn .stat-value { color: var(--warn); }

/* ------------------------- money & number styling ------------------------- */
.money {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}
.money--neg { color: var(--danger); }
td.money, th.money { text-align: right; }

/* ------------------------------- tables ----------------------------------- */
.w3-table { border-collapse: collapse; }
.w3-table th {
  background: var(--accent-light);
  color: var(--accent-dark);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  white-space: nowrap;
}
.w3-table td, .w3-table th { padding: 10px 10px; vertical-align: middle; }
.w3-table tbody tr { border-bottom: 1px solid var(--line); }
.w3-table tbody tr:last-child { border-bottom: none; }
.w3-table tbody tr:hover { background: #f7faf9; }

.table-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }

/* ------------------------------- status ----------------------------------- */
.pill {
  display: inline-block;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  padding: 3px 10px;
  white-space: nowrap;
}
.pill--ok     { background: var(--ok-bg);     color: var(--ok); }
.pill--warn   { background: var(--warn-bg);   color: var(--warn); }
.pill--danger { background: var(--danger-bg); color: var(--danger); }
.pill--info   { background: var(--info-bg);   color: var(--info); }
.pill--muted  { background: #eef0f2;          color: var(--muted); }
.pill--accent { background: var(--accent-light); color: var(--accent-dark); }

/* -------------------------------- forms ----------------------------------- */
label.site-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--muted);
  margin-bottom: 4px;
}
input.site-input, select.site-input, textarea.site-input {
  width: 100%;
  padding: 5px 10px;
  border: 1px solid #c9d2d6;
  border-radius: 6px;
  font-size: .85rem;
  background: #fff;
  min-height: 30px;
}
textarea.site-input { min-height: 88px; }
input.site-input:focus, select.site-input:focus, textarea.site-input:focus {
  border-color: var(--accent-mid);
}
.form-hint { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.form-actions { margin-top: 16px; display: flex; gap: 10px; flex-wrap: wrap; }

/* ------------------------------ class tabs -------------------------------- */
.stu-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.stu-tab {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
}
.stu-tab:hover { border-color: var(--accent-mid); color: var(--accent-dark); }
.stu-tab.active { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.stu-tab span { opacity: .75; font-weight: 500; }
.stu-search { margin-bottom: 10px; max-width: 340px; }

/* --------------------------- searchable select ---------------------------- */
/* Native <select> is kept (hidden) for form posts; the widget input handles
   typing/search and drives the dropdown built from live <option> nodes. */
.ss { position: relative; width: 100%; }
.ss .ss-input { padding-right: 34px; }
.ss::after {
  content: "";
  position: absolute; right: 14px; top: 50%; margin-top: -3px;
  border-left: 5px solid transparent; border-right: 5px solid transparent;
  border-top: 6px solid var(--muted);
  pointer-events: none;
}
.ss .ss-native, select.ss-native { display: none !important; }
.ss-list {
  position: absolute; top: calc(100% + 2px); left: 0; right: 0; z-index: 40;
  max-height: 280px; overflow-y: auto; background: #fff;
  border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 6px 18px rgba(15,40,40,.18);
  list-style: none !important; list-style-type: none !important; margin: 0; padding: 4px;
}
.ss-list li {
  padding: 5px 10px; cursor: pointer; border-radius: 4px; font-size: .9rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  list-style: none !important; list-style-type: none !important;
}
.ss-list li.ss-hl, .ss-list li:hover { background: var(--accent-light); color: var(--accent-dark); }
.ss-list li.ss-empty { color: var(--muted); cursor: default; }
.ss-input.ss-invalid { border-color: var(--danger); }

/* ------------------------------- buttons ---------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background-color .12s ease;
}
.btn--accent { background: var(--accent); color: #fff; }
.btn--accent:hover { background: var(--accent-dark); }
.btn--outline { background: #fff; border-color: var(--accent); color: var(--accent); }
.btn--outline:hover { background: var(--accent-light); }
.btn--muted { background: #eef0f2; color: var(--ink); }
.btn--muted:hover { background: #dfe3e6; }
.btn--danger { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }
.btn--block { width: 100%; }
.btn--sm { min-height: 36px; padding: 0 12px; font-size: .85rem; }

/* -------------------------------- flashes --------------------------------- */
.site-flash-wrap { padding: 10px 14px 0; max-width: 1240px; margin: 0 auto; }
.site-flash {
  border-radius: 6px;
  padding: 11px 14px;
  margin-bottom: 8px;
  font-weight: 500;
}
.site-flash-ok     { background: var(--ok-bg);     color: var(--ok); border: 1px solid #bfe3cb; }
.site-flash-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid #f1c3c0; }
.site-flash-warn   { background: var(--warn-bg);   color: var(--warn); border: 1px solid #efd9b0; }

/* ------------------------------ bottom nav --------------------------------- */
.site-bottomnav {
  display: none;
}

/* -------------------------------- footer ---------------------------------- */
.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: .78rem;
  padding: 18px 10px 84px;
}

/* ----------------------------- page building ------------------------------- */
.section-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px; margin-bottom: 14px;
}
.filter-bar .f { min-width: 150px; flex: 1 1 150px; }
.filter-bar .f--search { flex: 2 1 240px; }
.filter-bar .f-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.pager {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line);
}
.pager .form-hint { margin-top: 0; }

.overdue-days { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ------------------------------ login page -------------------------------- */
.login-body {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background:
    radial-gradient(circle at 15% 20%, rgba(0,137,123,.18), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(0,77,64,.22), transparent 45%),
    var(--accent-dark);
}
.login-card {
  width: 100%; max-width: 380px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  padding: 26px 24px;
}
.login-brand { text-align: center; margin-bottom: 18px; }
.login-school { font-family: Georgia, serif; font-size: 1.1rem; font-weight: 600; color: var(--accent-dark); }
.login-sub { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.login-demo {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  font-size: .8rem; color: var(--muted);
}
.login-demo .w3-table { margin-bottom: 0; }

/* Align W3.CSS theme helpers with the school accent (defaults to W3 blue) */
.w3-theme { background-color: var(--accent) !important; color: #fff !important; }
.w3-theme:hover { background-color: var(--accent-dark) !important; }
.w3-bar-item.w3-theme { border-radius: 0; }

/* ------------------------------- print -------------------------------------- */
@media print {
  .site-sidebar, .site-topbar, .site-bottomnav, .site-footer,
  .no-print, .filter-bar, .table-tools { display: none !important; }
  .site-main { margin-left: 0 !important; }
  body { background: #fff; }
  .site-card { box-shadow: none; border: 1px solid #ccc; }
  a { color: var(--ink); text-decoration: none; }
  .w3-table th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------------------------- reduced motion ------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ------------------------------- responsive -------------------------------- */
@media (min-width: 993px) {
  .site-main { margin-left: 280px; }
  .w3-sidebar { display: block !important; }
}

@media (max-width: 992px) {
  .site-sidebar { width: 280px; }
}

/* Phones: fixed bottom nav with big touch targets */
@media (max-width: 600px) {
  .site-content { padding: 10px; }
  .site-bottomnav {
    display: flex;
    position: fixed; left: 0; right: 0; bottom: 0;
    background: #fff;
    border-top: 1px solid var(--line);
    box-shadow: 0 -2px 8px rgba(0,0,0,.08);
    z-index: 4;
  }
  .site-bottomnav-item {
    flex: 1;
    min-height: 58px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: var(--muted);
    text-decoration: none;
    font-size: .72rem;
    font-weight: 600;
    border: none; background: none; cursor: pointer;
    text-transform: uppercase; letter-spacing: .02em;
  }
  .site-bottomnav-item.active { color: var(--accent); }
  .site-bottomnav-icon { font-size: 1.3rem; line-height: 1; }
  h1 { font-size: 1.3rem; }
  .w3-table th, .w3-table td { font-size: .88rem; }
}
