/* global window */
// Eyad Academy — Portal data layer (student dashboard, sessions, gamification, etc.)
// All times are illustrative — replace with API data when wiring real Zoom SDK.

const PORTAL_USER = {
  name: { ar: "ليان عبدالعزيز", en: "Layan Abdulaziz" },
  age: 12,
  grade: { ar: "السادس الابتدائي", en: "Grade 6" },
  avatar: "L",
  avatarBg: "linear-gradient(135deg, #C9B8FF, #8B7AD9)",
  parent: { ar: "أم محمد", en: "Umm Mohammed" },
  parentEmail: "parent@example.com",
  level: 14,
  xp: 2840,
  xpNext: 3500,
  streak: 23,
  totalHours: 84,
  rank: 42,
};

// ====== SESSIONS ============================================
// Each session: id, subject (key into SUBJECTS), teacher, dayOffset (today = 0),
// startHour (24h, local), durationMin, status, zoomMeetingId, materials, notes
const PORTAL_SESSIONS = [
  {
    id: "s-101", subject: "quran",
    titleAr: "حفظ سورة الفجر", titleEn: "Memorizing Surat Al-Fajr",
    teacher: { name_ar: "أ. فاطمة الزهراني", name_en: "Fatima Al-Zahrani", initials: "فز" },
    dayOffset: 0, startHour: 17, durationMin: 45, status: "upcoming",
    zoomMeetingId: "846 5829 1147",
    materials: [
      { id: "m1", name_ar: "مصحف سورة الفجر (PDF)", name_en: "Surat Al-Fajr (PDF)", kind: "pdf", size: "1.2 MB", uploaded_by: "teacher" },
      { id: "m2", name_ar: "تسجيل صوتي للتلاوة", name_en: "Audio recitation", kind: "audio", size: "4.8 MB", uploaded_by: "teacher" },
    ],
    notes_ar: "نبدأ بمراجعة الآيات ١–٥، ثم نحفظ الآيات ٦–١٠. التركيز على المدود.",
    notes_en: "We'll review ayat 1–5, then memorize 6–10. Focus on madd rules.",
  },
  {
    id: "s-102", subject: "math",
    titleAr: "المعادلات الخطية — الدرس ٤", titleEn: "Linear Equations — Lesson 4",
    teacher: { name_ar: "أ. ياسر الفهد", name_en: "Yasser Al-Fahd", initials: "يف" },
    dayOffset: 0, startHour: 19, durationMin: 60, status: "upcoming",
    zoomMeetingId: "912 4471 0238",
    materials: [
      { id: "m3", name_ar: "أوراق عمل المعادلات.pdf", name_en: "equations-worksheet.pdf", kind: "pdf", size: "780 KB", uploaded_by: "teacher" },
    ],
    notes_ar: "حضّر الأوراق وأنجز التمارين ١–٣ قبل الحصة.",
    notes_en: "Print the worksheet and try problems 1–3 before class.",
  },
  {
    id: "s-103", subject: "arabic",
    titleAr: "النحو — الجملة الفعلية", titleEn: "Grammar — Verbal Sentence",
    teacher: { name_ar: "أ. هدى المنصور", name_en: "Huda Al-Mansour", initials: "هم" },
    dayOffset: 1, startHour: 17, durationMin: 45, status: "scheduled",
    zoomMeetingId: "732 1102 4458",
    materials: [],
    notes_ar: "—", notes_en: "—",
  },
  {
    id: "s-104", subject: "science",
    titleAr: "الضوء والانعكاس", titleEn: "Light & Reflection",
    teacher: { name_ar: "أ. عمر الراشد", name_en: "Omar Al-Rashed", initials: "عر" },
    dayOffset: 2, startHour: 18, durationMin: 50, status: "scheduled",
    zoomMeetingId: "104 8839 7723",
    materials: [],
    notes_ar: "تجربة مرآة بسيطة في البيت.", notes_en: "Simple home mirror experiment.",
  },
  {
    id: "s-105", subject: "quran",
    titleAr: "مراجعة جزء عمّ", titleEn: "Juz' Amma Review",
    teacher: { name_ar: "أ. فاطمة الزهراني", name_en: "Fatima Al-Zahrani", initials: "فز" },
    dayOffset: 3, startHour: 17, durationMin: 45, status: "scheduled",
    zoomMeetingId: "846 5829 1147",
    materials: [],
    notes_ar: "", notes_en: "",
  },
  {
    id: "s-106", subject: "math",
    titleAr: "المتباينات", titleEn: "Inequalities",
    teacher: { name_ar: "أ. ياسر الفهد", name_en: "Yasser Al-Fahd", initials: "يف" },
    dayOffset: 4, startHour: 19, durationMin: 60, status: "scheduled",
    zoomMeetingId: "912 4471 0238",
    materials: [],
    notes_ar: "", notes_en: "",
  },
  // Past
  {
    id: "s-099", subject: "quran",
    titleAr: "حفظ سورة الغاشية", titleEn: "Memorizing Al-Ghashiya",
    teacher: { name_ar: "أ. فاطمة الزهراني", name_en: "Fatima Al-Zahrani", initials: "فز" },
    dayOffset: -1, startHour: 17, durationMin: 45, status: "completed",
    zoomMeetingId: "846 5829 1147",
    materials: [
      { id: "m4", name_ar: "ملخص الحصة.pdf", name_en: "session-summary.pdf", kind: "pdf", size: "320 KB", uploaded_by: "teacher" },
    ],
    notes_ar: "أحسنت ليان! أكملنا الحفظ بإتقان.", notes_en: "Excellent work Layan — fully memorized.",
    grade: "ممتاز", grade_en: "Excellent",
  },
  {
    id: "s-098", subject: "math",
    titleAr: "المعادلات الخطية — الدرس ٣", titleEn: "Linear Equations — Lesson 3",
    teacher: { name_ar: "أ. ياسر الفهد", name_en: "Yasser Al-Fahd", initials: "يف" },
    dayOffset: -2, startHour: 19, durationMin: 60, status: "completed",
    zoomMeetingId: "912 4471 0238",
    materials: [],
    notes_ar: "جيد. نحتاج مراجعة الجمع الجبري.", notes_en: "Good. Need a review of algebraic addition.",
    grade: "جيد جدًا", grade_en: "Very Good",
  },
  {
    id: "s-097", subject: "arabic",
    titleAr: "النحو — الجملة الاسمية", titleEn: "Grammar — Nominal Sentence",
    teacher: { name_ar: "أ. هدى المنصور", name_en: "Huda Al-Mansour", initials: "هم" },
    dayOffset: -3, startHour: 17, durationMin: 45, status: "completed",
    zoomMeetingId: "732 1102 4458",
    materials: [],
    notes_ar: "مشاركة مميزة.", notes_en: "Outstanding participation.",
    grade: "ممتاز", grade_en: "Excellent",
  },
];

// ====== PROGRESS ============================================
const PORTAL_PROGRESS = {
  subjects: [
    { id: "quran",   completed: 28, total: 40, hours: 24, accent: "#8B7AD9", trend: +12 },
    { id: "arabic",  completed: 18, total: 32, hours: 18, accent: "#D9A441", trend: +8 },
    { id: "math",    completed: 14, total: 28, hours: 22, accent: "#6FA8DC", trend: +15 },
    { id: "science", completed: 9,  total: 20, hours: 12, accent: "#E89B8B", trend: +5 },
  ],
  weeklyHours: [3.5, 4, 5.2, 6, 4.5, 5.8, 6.5], // last 7 days
  weeklyDayLabels_ar: ["السبت", "الأحد", "الإثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة"],
  weeklyDayLabels_en: ["Sat", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri"],
};

// ====== BADGES & ACHIEVEMENTS ===============================
const PORTAL_BADGES = [
  { id: "b1", name_ar: "القارئ المتقن", name_en: "Master Reader", desc_ar: "أتممت ٢٠ تلاوة بإتقان", desc_en: "Completed 20 perfect recitations", icon: "trophy", glow: "#D9A441", earned: true, date: "2026-03-12" },
  { id: "b2", name_ar: "نجم النحو", name_en: "Grammar Star", desc_ar: "أنهيت وحدة النحو بتقدير ممتاز", desc_en: "Finished grammar unit with excellence", icon: "star", glow: "#8B7AD9", earned: true, date: "2026-02-28" },
  { id: "b3", name_ar: "مفكر الرياضيات", name_en: "Math Thinker", desc_ar: "حللت ٥٠ مسألة بدون خطأ", desc_en: "Solved 50 problems without errors", icon: "spark", glow: "#6FA8DC", earned: true, date: "2026-02-14" },
  { id: "b4", name_ar: "ملتزم الحضور", name_en: "Loyal Learner", desc_ar: "حضور كامل لشهر متواصل", desc_en: "Full attendance for a whole month", icon: "check", glow: "#E89B8B", earned: true, date: "2026-01-30" },
  { id: "b5", name_ar: "متمرّن العلوم", name_en: "Science Apprentice", desc_ar: "أنجزت ١٠ تجارب علمية", desc_en: "Completed 10 science experiments", icon: "science", glow: "#7BC79E", earned: true, date: "2026-01-15" },
  { id: "b6", name_ar: "قارئ مبدع", name_en: "Creative Reader", desc_ar: "أنجزت ٣ مقالات إبداعية", desc_en: "Wrote 3 creative essays", icon: "book", glow: "#D9A441", earned: false },
  { id: "b7", name_ar: "حافظ متفوّق", name_en: "Hifz Champion", desc_ar: "احفظ جزء عمّ كاملًا", desc_en: "Memorize all of Juz' Amma", icon: "quran", glow: "#8B7AD9", earned: false },
  { id: "b8", name_ar: "بطل الشهر", name_en: "Student of the Month", desc_ar: "كن الأول في فصلك لشهر كامل", desc_en: "Be top of your class for a month", icon: "trophy", glow: "#F5D67A", earned: false },
];

// ====== CERTIFICATES ========================================
const PORTAL_CERTS = [
  { id: "c-501", title_ar: "إتمام حفظ سورة الفاتحة", title_en: "Memorized Al-Fatiha", subject: "quran", grade_ar: "ممتاز ١٠٠٪", grade_en: "Excellent 100%", date_ar: "ديسمبر ٢٠٢٥", date_en: "Dec 2025", earned: true },
  { id: "c-502", title_ar: "حفظ سورة الناس والفلق", title_en: "Memorized An-Nas & Al-Falaq", subject: "quran", grade_ar: "ممتاز ٩٨٪", grade_en: "Excellent 98%", date_ar: "يناير ٢٠٢٦", date_en: "Jan 2026", earned: true },
  { id: "c-503", title_ar: "أساسيات النحو", title_en: "Grammar Foundations", subject: "arabic", grade_ar: "جيد جدًا ٩٢٪", grade_en: "Very Good 92%", date_ar: "فبراير ٢٠٢٦", date_en: "Feb 2026", earned: true },
  { id: "c-504", title_ar: "المعادلات الخطية", title_en: "Linear Equations", subject: "math", grade_ar: "—", grade_en: "—", date_ar: "—", date_en: "—", earned: false, progress: 60 },
  { id: "c-505", title_ar: "تجارب الفيزياء", title_en: "Physics Experiments", subject: "science", grade_ar: "—", grade_en: "—", date_ar: "—", date_en: "—", earned: false, progress: 35 },
  { id: "c-506", title_ar: "حفظ جزء عمّ كاملًا", title_en: "Full Juz' Amma", subject: "quran", grade_ar: "—", grade_en: "—", date_ar: "—", date_en: "—", earned: false, progress: 72 },
];

// ====== LEADERBOARD =========================================
const PORTAL_LEADERS = [
  { rank: 1, name_ar: "أحمد محمد",      name_en: "Ahmed Mohammed",      xp: 4120, streak: 41, you: false, init: "أم", color: "#D9A441" },
  { rank: 2, name_ar: "ميسم العبدالله",   name_en: "Maysam Al-Abdullah",  xp: 3680, streak: 35, you: false, init: "مع", color: "#8B7AD9" },
  { rank: 3, name_ar: "خالد الحربي",     name_en: "Khalid Al-Harbi",     xp: 3250, streak: 28, you: false, init: "خح", color: "#6FA8DC" },
  { rank: 4, name_ar: "ليان عبدالعزيز",   name_en: "Layan Abdulaziz",     xp: 2840, streak: 23, you: true,  init: "ل",  color: "#E89B8B" },
  { rank: 5, name_ar: "سارة العنزي",     name_en: "Sara Al-Anzi",        xp: 2510, streak: 19, you: false, init: "سع", color: "#7BC79E" },
];

// ====== REPORTS =============================================
const PORTAL_REPORTS = [
  { id: "r-12", week_ar: "أسبوع ٢٧ – ٣ مارس",  week_en: "Mar 27 – Apr 3",   attended: 5, total: 5, avg_ar: "ممتاز",  avg_en: "Excellent",  highlights_ar: "حفظ كامل لسورة الفجر بدون خطأ. تحسن ملحوظ في النحو.", highlights_en: "Full memorization of Al-Fajr with zero errors. Notable progress in grammar.", flags_ar: "—", flags_en: "—" },
  { id: "r-11", week_ar: "أسبوع ٢٠ – ٢٧ فبراير", week_en: "Feb 20 – 27",      attended: 4, total: 5, avg_ar: "جيد جدًا", avg_en: "Very Good",   highlights_ar: "تقدم في المعادلات الخطية. تواصل ممتاز مع المعلم.", highlights_en: "Progress in linear equations. Excellent rapport with the teacher.", flags_ar: "غياب يوم الثلاثاء", flags_en: "Absent on Tuesday" },
  { id: "r-10", week_ar: "أسبوع ١٣ – ٢٠ فبراير", week_en: "Feb 13 – 20",      attended: 5, total: 5, avg_ar: "ممتاز",  avg_en: "Excellent",  highlights_ar: "مشاركة قوية في حصص العلوم. شارة جديدة!", highlights_en: "Strong participation in science. Earned a new badge!", flags_ar: "—", flags_en: "—" },
  { id: "r-09", week_ar: "أسبوع ٦ – ١٣ فبراير",  week_en: "Feb 6 – 13",       attended: 5, total: 5, avg_ar: "جيد جدًا", avg_en: "Very Good",   highlights_ar: "إنهاء وحدة النحو الأولى.", highlights_en: "Completed first grammar unit.", flags_ar: "—", flags_en: "—" },
];

// ====== INSIGHTS (AI-style messages, illustrative) ==========
const PORTAL_INSIGHTS_AR = [
  { tone: "good",    text: "ليان تتحسن في الرياضيات بنسبة ١٥٪ هذا الأسبوع — أعلى تقدم بين المواد." },
  { tone: "good",    text: "أسبوعك الثالث على التوالي بحضور كامل. واصلي ✨" },
  { tone: "neutral", text: "ننصح بزيادة وقت المراجعة في النحو يوم الجمعة." },
  { tone: "good",    text: "اقتربتِ من فتح شارة \"حافظ متفوّق\" — ٢٨٪ متبقي." },
];
const PORTAL_INSIGHTS_EN = [
  { tone: "good",    text: "Layan is improving in Math by 15% this week — the biggest gain across subjects." },
  { tone: "good",    text: "Three consecutive weeks of perfect attendance. Keep going ✨" },
  { tone: "neutral", text: "We recommend a bit more grammar review on Friday." },
  { tone: "good",    text: "You're 28% away from unlocking the \"Hifz Champion\" badge." },
];

Object.assign(window, {
  PORTAL_USER, PORTAL_SESSIONS, PORTAL_PROGRESS, PORTAL_BADGES,
  PORTAL_CERTS, PORTAL_LEADERS, PORTAL_REPORTS, PORTAL_INSIGHTS_AR, PORTAL_INSIGHTS_EN,
});
