/* ============================================================
   Fatima Memorial Academy School Management System — shared design system
   One stylesheet, cached once. Continues the Fatima Memorial Academy identity:
   emerald + gold + cream, Instrument Sans, soft bento cards.
   ============================================================ */

:root {
  /* brand */
  --emerald-900: #073d26;
  --emerald-800: #08472c;
  --emerald-700: #0b5a38;
  --emerald-600: #0d6340;
  --emerald-500: #11704a;
  --emerald-400: #158354;

  --gold-500: #c9a227;   /* primary gold */
  --gold-400: #d8b443;
  --gold-300: #e8ce6e;
  --gold-200: #f3e6b5;
  --gold-ink: #a8861b;   /* gold text on light */
  --gold-ink-2: #8c6e14;
  --gold-soft: #f7efd2;
  --gold-soft-2: #efdfa6;

  --green-600: #0f6b46;  /* success accent */
  --green-500: #178a5b;
  --green-soft: #dcefe4;

  --red-600: #b3401e;
  --red-soft: #f6ddd3;
  --amber-600: #a9781a;
  --amber-soft: #f7ead0;

  /* neutrals — cream-biased, chosen not defaulted */
  --cream-bg1: #f6f2ea;
  --cream-bg2: #f1ead9;
  --cream-bg3: #e9ddc2;
  --cream-bg4: #e4d4b0;
  --panel-1: #fbfaf8;
  --panel-2: #f5f3ef;
  --surface: #ffffff;
  --surface-soft: #f7f5f0;
  --line: #e6e1d5;
  --line-soft: #efece4;

  --ink: #0b5a38;
  --ink-soft: #66736c;
  --ink-faint: #8a8375;
  --ink-mute: #9a9485;

  --bg-app: linear-gradient(160deg,#f6f2ea 0%,#f1ead9 35%,#e9ddc2 70%,#e4d4b0 100%);
  --panel-grad: linear-gradient(180deg,#fbfaf8 0%,#f5f3ef 100%);
  --sidebar-grad: linear-gradient(180deg,#0d6340 0%,#08472c 100%);

  --shadow-card: 0 20px 50px -18px rgba(8,71,44,.22);
  --shadow-soft: 0 14px 34px -14px rgba(8,71,44,.2);
  --shadow-pop: 0 30px 60px -18px rgba(8,71,44,.3);
  --shadow-panel: 0 60px 120px -30px rgba(8,71,44,.35);

  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 12px;
  --r-pill: 999px;

  --sidebar-w: 236px;
  --maxw: 1240px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Instrument Sans', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  color: var(--ink);
  background: var(--bg-app);
  background-attachment: fixed;
  min-height: 100vh;
}
.num { font-variant-numeric: tabular-nums; }
[dir="rtl"], .arabic { font-family: 'Scheherazade New', 'Amiri', 'Noto Naskh Arabic', serif; }
a { color: inherit; }

/* ---------- decorative ambient blobs ---------- */
.ambient { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.ambient .glow { position: absolute; top: -160px; right: -120px; width: 480px; height: 480px; border-radius: 50%;
  background: radial-gradient(circle at 40% 40%,#fbf6e6 0%,#f5ecc6 55%,rgba(245,236,198,0) 75%); filter: blur(6px); }
.ambient .halo { position: absolute; left: -60px; top: 42%; width: 340px; height: 340px; border-radius: 50%;
  background: radial-gradient(circle,#d8b443 0%,rgba(216,180,67,0) 70%); filter: blur(40px); opacity: .55; }
@keyframes floatSlow { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-14px); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }

/* ============================================================
   APP SHELL
   ============================================================ */
.app-wrap { position: relative; z-index: 1; display: flex; justify-content: center; padding: 26px 22px 70px; }
.app-shell {
  position: relative; width: 100%; max-width: var(--maxw);
  background: var(--panel-grad); border-radius: 28px; box-shadow: var(--shadow-panel);
  display: flex; overflow: hidden; min-height: 760px;
}

/* ---------- sidebar ---------- */
.sidebar {
  width: var(--sidebar-w); flex: none; background: var(--sidebar-grad);
  padding: 24px 16px; display: flex; flex-direction: column; gap: 4px;
  position: relative; overflow: hidden;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 6px; margin-bottom: 16px; }
.sidebar .brand img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; object-position: center 38%; background: #06351f; flex: none; }
.sidebar .brand b { color: #fff; font-size: 13px; font-weight: 700; line-height: 1.15; display: block; }
.sidebar .brand span { color: rgba(255,255,255,.55); font-size: 10px; display: block; }
.nav-group { font-size: 10px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase;
  color: rgba(255,255,255,.4); padding: 14px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  font-family: inherit; font-size: 12.5px; font-weight: 600; color: rgba(255,255,255,.82);
  border: 0; cursor: pointer; background: transparent; padding: 10px 12px; border-radius: var(--r-sm);
  text-decoration: none; transition: background .18s, color .18s;
}
.nav-item .ico { width: 17px; height: 17px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.9; opacity: .9; }
.nav-item .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gold-400); flex: none; }
.nav-item:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.14); color: #fff; box-shadow: inset 0 0 0 1px rgba(216,180,67,.35); }
.nav-item .count { margin-left: auto; font-size: 10.5px; font-weight: 700; background: var(--gold-500); color: #3a2c06;
  border-radius: var(--r-pill); padding: 1px 7px; }
.sidebar .foot { margin-top: auto; padding-top: 12px; position: relative; z-index: 1; }
.sidebar .foot a, .sidebar .foot button { display: block; width: 100%; text-align: left; font-family: inherit;
  font-size: 11.5px; font-weight: 600; color: rgba(255,255,255,.6); text-decoration: none; border: 0; cursor: pointer;
  background: rgba(255,255,255,.06); padding: 9px 12px; border-radius: 10px; margin-top: 6px; }
.sidebar .foot a:hover, .sidebar .foot button:hover { background: rgba(255,255,255,.14); color: #fff; }
/* decorative wave at sidebar base */
.sidebar .sb-wave { position: absolute; left: 0; right: 0; bottom: 0; height: 96px; z-index: 0; pointer-events: none; line-height: 0; }
.sidebar .sb-wave svg { width: 100%; height: 100%; display: block; }

/* ---------- main column ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 22px 30px 12px; flex-wrap: wrap; }
.topbar h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.topbar .sub { margin: 3px 0 0; font-size: 12px; color: var(--ink-faint); }
.topbar .spacer { margin-left: auto; }
.userchip { display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: var(--r-pill);
  padding: 6px 16px 6px 6px; box-shadow: 0 8px 20px -8px rgba(8,71,44,.2); }
.userchip .av { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 12.5px;
  font-weight: 700; color: #443206; background: linear-gradient(150deg,#e8ce6e,#c9a227); }
.userchip span { font-size: 12.5px; font-weight: 600; }
.content { padding: 12px 30px 34px; overflow: auto; }

/* ============================================================
   PRAYER + DATE BAR (Hijri/Gregorian, next salah)
   ============================================================ */
.prayerbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: linear-gradient(120deg,#0d6340,#073d26); border-radius: var(--r-md); padding: 12px 18px;
  color: #fff; box-shadow: var(--shadow-soft); margin: 0 30px; }
.prayerbar .cal { display: flex; flex-direction: column; }
.prayerbar .cal b { font-size: 13px; font-weight: 700; }
.prayerbar .cal span { font-size: 11px; color: rgba(255,255,255,.6); }
.prayerbar .times { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.salah { display: flex; flex-direction: column; align-items: center; background: rgba(255,255,255,.07);
  border-radius: 10px; padding: 6px 12px; min-width: 58px; }
.salah small { font-size: 10px; color: rgba(216,180,67,.9); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.salah b { font-size: 12.5px; font-weight: 700; }
.salah.next { background: var(--gold-500); color: #3a2c06; }
.salah.next small { color: rgba(58,44,6,.7); }

/* ============================================================
   CARDS / STATS / GRID
   ============================================================ */
.grid { display: grid; gap: 18px; }
.g-2 { grid-template-columns: repeat(2,1fr); }
.g-3 { grid-template-columns: repeat(3,1fr); }
.g-4 { grid-template-columns: repeat(4,1fr); }
.g-sidebar { grid-template-columns: minmax(0,1.5fr) minmax(0,1fr); }
.g-sidebar-l { grid-template-columns: minmax(0,1fr) minmax(0,1.5fr); }

.card { background: var(--surface); border-radius: var(--r-lg); padding: 22px; box-shadow: var(--shadow-card); }
.card.pad-sm { padding: 18px; }
.card > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card h3 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.card .cardsub { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }
.card-link { font-size: 12px; font-weight: 600; color: var(--gold-ink); text-decoration: none; cursor: pointer; }
.card-link:hover { color: var(--gold-ink-2); }

/* stat tiles — themed variants */
.stat { border-radius: var(--r-md); padding: 20px 22px; box-shadow: var(--shadow-card); }
.stat .label { margin: 0 0 6px; font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.stat .value { margin: 0; font-size: 29px; font-weight: 700; letter-spacing: -.02em; }
.stat .delta { font-size: 11.5px; font-weight: 600; margin-top: 6px; display: inline-flex; gap: 4px; align-items: center; }
.stat.navy { background: linear-gradient(160deg,#11704a,#073d26); color: #fff; }
.stat.navy .label { color: rgba(216,180,67,.85); }
.stat.gold { background: linear-gradient(150deg,#f3e6b5,#c9a227); color: #443206; }
.stat.gold .label { color: rgba(68,50,6,.6); }
.stat.green { background: linear-gradient(155deg,#178a5b,#0f6b46); color: #fff; }
.stat.green .label { color: rgba(255,255,255,.75); }
.stat.plain { background: var(--surface); color: var(--ink); }
.stat.plain .label { color: var(--ink-mute); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-family: inherit;
  font-size: 12.5px; font-weight: 600; border: 0; cursor: pointer; padding: 11px 22px; border-radius: var(--r-pill);
  text-decoration: none; transition: transform .18s, background .18s, border-color .18s, opacity .18s; white-space: nowrap; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--emerald-700); color: #fff; box-shadow: 0 8px 18px rgba(11,90,56,.32); }
.btn-primary:hover { background: var(--emerald-600); }
.btn-gold { background: linear-gradient(150deg,#e8ce6e,#c9a227); color: #3a2c06; box-shadow: 0 8px 18px rgba(168,134,27,.35); }
.btn-green { background: var(--green-600); color: #fff; box-shadow: 0 8px 18px rgba(15,107,70,.3); }
.btn-ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--gold-ink); }
.btn-soft { background: var(--gold-soft); color: var(--gold-ink-2); }
.btn-soft:hover { background: var(--gold-soft-2); }
.btn-sm { padding: 8px 15px; font-size: 12px; }
.btn-block { width: 100%; }
.btn:focus-visible { outline: 2px solid var(--gold-500); outline-offset: 2px; }

/* ============================================================
   BADGES / PILLS
   ============================================================ */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700;
  padding: 3px 10px; border-radius: var(--r-pill); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.b-none::before { display: none; }
.badge.ok   { background: var(--green-soft); color: var(--green-600); }
.badge.warn { background: var(--amber-soft); color: var(--amber-600); }
.badge.bad  { background: var(--red-soft); color: var(--red-600); }
.badge.info { background: #dff0e7; color: var(--emerald-500); }
.badge.gold { background: var(--gold-soft); color: var(--gold-ink-2); }
.badge.mute { background: var(--line-soft); color: var(--ink-faint); }

/* ============================================================
   FORMS
   ============================================================ */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 600; color: var(--ink); }
.field label .req { color: var(--red-600); }
.field .hint { font-size: 11px; color: var(--ink-mute); }
.input, .select, .textarea {
  font-family: inherit; font-size: 12.5px; color: var(--ink); background: var(--surface-soft);
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 11px 13px; outline: none; width: 100%;
  transition: border-color .18s, background .18s;
}
.textarea { resize: vertical; min-height: 84px; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--gold-ink); background: #fff; }
.input::placeholder, .textarea::placeholder { color: var(--ink-mute); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
fieldset.section { border: 0; padding: 0; margin: 0 0 22px; }
fieldset.section > legend { font-size: 13px; font-weight: 700; color: var(--emerald-700); padding: 0 0 4px;
  display: flex; align-items: center; gap: 8px; }
fieldset.section > legend .ci { width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center;
  background: var(--gold-soft); color: var(--gold-ink-2); font-size: 13px; }

/* segmented control */
.seg { display: inline-flex; background: var(--line-soft); border-radius: var(--r-pill); padding: 4px; gap: 2px; }
.seg button { border: 0; background: transparent; font-family: inherit; font-size: 12px; font-weight: 600;
  color: var(--ink-faint); cursor: pointer; padding: 8px 16px; border-radius: var(--r-pill); }
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: 0 4px 10px -4px rgba(8,71,44,.25); }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 560px; }
table.data thead th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-mute); font-weight: 700; padding: 0 14px 10px; border-bottom: 1px solid var(--line); }
table.data tbody td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--surface-soft); }
table.data td.r, table.data th.r { text-align: right; }
.person { display: flex; align-items: center; gap: 11px; }
.person .av { width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: #443206; background: linear-gradient(150deg,#eed98c,#c9a227); }
.person b { font-weight: 600; }
.person small { display: block; color: var(--ink-faint); font-size: 11px; }

/* ============================================================
   LISTS / FEED / PROGRESS
   ============================================================ */
.rowlist { display: flex; flex-direction: column; }
.rowlist .row { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line-soft); }
.rowlist .row:last-child { border-bottom: 0; }
.rowlist .row .ic-badge { width: 34px; height: 34px; border-radius: 10px; flex: none; display: grid; place-items: center; }
.rowlist .row .meta { margin-left: auto; text-align: right; font-size: 11.5px; color: var(--ink-faint); }

.progress { display: flex; flex-direction: column; gap: 7px; }
.progress + .progress { margin-top: 14px; }
.progress .pt { display: flex; justify-content: space-between; font-size: 12.5px; }
.progress .track { height: 8px; border-radius: var(--r-pill); background: var(--line-soft); overflow: hidden; }
.progress .track > i { display: block; height: 100%; border-radius: var(--r-pill);
  background: linear-gradient(90deg,var(--gold-300),var(--gold-500)); }
.progress .track > i.green { background: linear-gradient(90deg,#2aa06c,var(--green-600)); }
.progress .track > i.navy { background: linear-gradient(90deg,var(--emerald-400),var(--emerald-600)); }

/* ============================================================
   BILINGUAL — EN / HA visibility toggled by <html lang>
   ============================================================ */
.ha { display: none; }
html[lang="ha"] .en { display: none; }
html[lang="ha"] .ha { display: initial; }

/* ============================================================
   PORTAL / AUTH (centered card)
   ============================================================ */
.auth-wrap { position: relative; z-index: 1; min-height: 100vh; display: flex; align-items: center;
  justify-content: center; padding: 48px 22px; }
.auth-card { width: 100%; max-width: 440px; background: var(--panel-grad); border-radius: 28px;
  box-shadow: var(--shadow-panel); padding: 38px 36px; }
.role-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.role-tile { display: flex; flex-direction: column; gap: 8px; text-decoration: none; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 18px;
  transition: transform .2s, box-shadow .2s, border-color .2s; }
.role-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-card); border-color: var(--gold-300); }
.role-tile .ci { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; color: #fff; }
.role-tile b { font-size: 14px; }
.role-tile small { font-size: 11.5px; color: var(--ink-faint); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
/* hamburger + overlay: hidden on desktop, shown when the drawer kicks in */
.sb-toggle { display: none; }
.sb-overlay { display: none; }

@media (max-width: 1080px) {
  .g-4 { grid-template-columns: repeat(2,1fr); }
  .g-3 { grid-template-columns: repeat(2,1fr); }
  .g-sidebar, .g-sidebar-l { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  /* full-bleed shell, main takes the whole width */
  .app-wrap { padding: 0; display: block; }
  .app-shell { display: block; border-radius: 0; min-height: 100vh; box-shadow: none; overflow: visible; }
  .main { width: 100%; }

  /* sidebar becomes an off-canvas drawer (nav + foot stay visible) */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 266px; max-width: 84vw;
    flex-direction: column; z-index: 60; overflow-y: auto;
    transform: translateX(-100%); transition: transform .26s ease; will-change: transform;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 44px rgba(0,0,0,.42); }

  .sb-overlay { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(4,35,21,.45);
    opacity: 0; visibility: hidden; transition: opacity .26s ease, visibility .26s ease; }
  .sb-overlay.open { opacity: 1; visibility: visible; }

  .sb-toggle { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px;
    flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 11px;
    cursor: pointer; font-size: 19px; line-height: 1; color: var(--ink); }

  .topbar { padding: 16px; gap: 12px; }
  .topbar h1 { font-size: 19px; }
  .content { padding: 12px 16px 34px; }
  .prayerbar { margin: 0 16px; }
  .form-grid, .g-2 { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .userchip span:not(.av) { display: none; }   /* avatar only, saves room */
  .userchip { padding: 6px; }
}

/* ============================================================
   PRINT — report cards & receipts
   ============================================================ */
@media print {
  body { background: #fff; }
  .ambient, .sidebar, .topbar .spacer, .no-print { display: none !important; }
  .app-shell { box-shadow: none; border-radius: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}
