# EduNest v2 – what changed

## Design system (one look for all 3 portals)
- `assets/css/edunest.css` – single stylesheet: Inter font, light clean UI, cards, tables, buttons, forms, badges, mobile bottom-nav.
  Re-brand the whole app by editing the `--en-brand*` variables at the top.
- `includes/ui.php` – shared kit: SVG icons, role-based grouped navigation, app shell, login page, helper widgets.
- `includes/{header,sidebar,footer}.php`, `teacher/includes/*`, `student/includes/*` now just call the shell.
- Old pages (students, teachers, classes, exams, fees, notice, subjects, timetable, student fees/results/profile…)
  keep their logic and are re-skinned by the "legacy layer" at the bottom of edunest.css.

## Rewritten screens
- One login for Management / Teacher / Student with role tabs (same APIs as before): `login.php`, `teacher/login.php`, `student/login.php`
- Dashboards for all three roles.

## New features (SchoolChimes-style)
- Homework: teacher assigns, student views, management monitors.
- Events & Calendar: management creates, everyone sees.
- Teacher portal pages that existed in the menu but were missing: My Students, Attendance (segmented Present/Absent/Late), Enter Marks, Notices, Profile (+ change password).

## Fixed
- Broken menu links (student `student_dashboard.php` / `results.php`, teacher pages that didn't exist, student logout path).
- Removed test files (`teacher/test*.php`, `logout.phpn`).

## Install
1. Copy over your existing `sms/` folder (keeps your `uploads/`).
2. Run `database/001_new_modules.sql` (optional – auto-created otherwise).
3. Hard-refresh browsers / clear the PWA cache (bump `CACHE_NAME` in sw.js if needed).

## Next steps to make it more sellable
Rewrite the remaining legacy pages natively (students, fees, exams), add parent login, SMS/WhatsApp alerts, online fee payment, library, transport, ID cards, reports/PDF export.

## Database config
The DB config now lives inside the app: `config/db_sms_config.php` (edit host/db/user/password there).
`config/.htaccess` blocks direct web access. `includes/db.php` loads it for every page.

---
# v3 — Messages (text + voice) with notifications, and per-page identity

## Messages
- New **Messages** page in all three portals (`messages.php`, `teacher/messages.php`, `student/messages.php`).
  - Management: send text and/or a recorded voice note to all students, a class, one student, all teachers or one teacher; see read counts; delete.
  - Teacher: inbox from the school office + send to the classes they teach (class teacher or in timetable) or one student in them.
  - Student: inbox with unread highlight and an audio player for voice notes.
- Voice notes are recorded in the browser (MediaRecorder) or attached as a file; stored in `uploads/voice/` (direct access blocked) and streamed through `api/message_audio.php` after a permission check (supports seeking).
- New tables `sms_messages`, `sms_message_reads`, `sms_push_subs` (auto-created, or run `database/002_messages.sql`).

## Notifications
- While the app is open: polling every 15 s → toast, sound, unread badge (sidebar, bottom bar, bell, tab title, app-icon badge).
- App closed / phone locked: **Web Push** (VAPID, no Composer needed). Users tap *Turn on* once; the server signs pushes with a key it generates on first use in `config/vapid_private.pem`.
- `student/sw_student.js` and `teacher/sw_teacher.js` rewritten (also removes a duplicate fetch handler that intercepted page navigations).
- Requirements: HTTPS, `config/` and `uploads/voice/` writable by PHP, PHP `openssl` + `curl`. iPhone/iPad: add the app to the Home Screen first (iOS 16.4+).

## Every page has its own look
- Per-page accent colour + icon (`en_themes()` in `includes/ui.php`): changes buttons, focus rings, active menu, header chip and the colour strip on top of the page. Edit the table to re-colour any page.
- Sidebar items and the mobile bottom bar have individually coloured icons.
- **Timetable** redesigned: student = day pills + "happening now" banner + colour-coded subject timeline; teacher = colour-coded weekly grid. (Admin `timetable_manager.php` keeps its editing logic and gets the new colour theme.)
- Fixed: `en-btn ghost` on `<button>` rendered as a solid brand button.
