fix: Strict env enforcement, rock-solid Alpine portal rendering, and Nabeh/Redis test diagnostics

This commit is contained in:
Hamza-Ayed
2026-08-26 22:25:35 +03:00
parent 388944cbff
commit 1f024d0c30
10 changed files with 990 additions and 702 deletions
+300 -280
View File
@@ -30,7 +30,6 @@ class TeacherPortal
cardHover: '#222F55',
cyan: '#00F5D4',
gold: '#FFD166',
goldGlow: '#FFD16633',
border: '#2E3D66',
textMuted: '#94A3B8'
}
@@ -42,272 +41,12 @@ class TeacherPortal
}
}
</script>
<!-- Alpine.js -->
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
<style>
body { font-family: 'Cairo', sans-serif; }
[x-cloak] { display: none !important; }
.glow-gold { box-shadow: 0 0 25px -5px rgba(255, 209, 102, 0.35); }
.bg-grid {
background-size: 30px 30px;
background-image: linear-gradient(to right, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
linear-gradient(to bottom, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
}
</style>
</head>
<body class="bg-saqel-dark text-slate-100 min-h-screen bg-grid antialiased flex flex-col justify-between selection:bg-saqel-gold selection:text-saqel-dark"
x-data="teacherAuth()" x-init="initApp()">
<!-- Top Navigation Bar -->
<header class="border-b border-saqel-border/60 bg-saqel-dark/80 backdrop-blur-md sticky top-0 z-40">
<div class="max-w-6xl mx-auto px-4 sm:px-6 h-16 flex items-center justify-between">
<div class="flex items-center gap-3">
<div class="w-10 h-10 rounded-xl bg-gradient-to-tr from-saqel-gold to-amber-500 p-[2px] flex items-center justify-center glow-gold">
<div class="w-full h-full bg-saqel-dark rounded-[10px] flex items-center justify-center text-saqel-gold font-black text-xl">
صـ
</div>
</div>
<div>
<span class="font-extrabold text-lg text-white tracking-wide">صَقِل</span>
<span class="text-xs px-2 py-0.5 rounded-full bg-saqel-gold/10 text-saqel-gold border border-saqel-gold/30 mr-2">استوديو المعلمين</span>
</div>
</div>
<!-- Header Right Controls -->
<div class="flex items-center gap-3">
<template x-if="isLoggedIn">
<div class="flex items-center gap-3">
<span class="text-sm text-saqel-textMuted hidden sm:inline" x-text="'أهلاً، ' + (teacherData.name || 'أستاذنا')"></span>
<button @click="logout()" class="text-xs px-3 py-1.5 rounded-lg border border-red-500/40 text-red-400 hover:bg-red-500/10 transition">
تسجيل الخروج
</button>
</div>
</template>
<template x-if="!isLoggedIn">
<a href="/student" class="text-xs sm:text-sm text-saqel-textMuted hover:text-saqel-cyan transition flex items-center gap-1">
<span>أنت طالب؟</span>
<span class="text-saqel-cyan font-bold">بوابة الطلاب ←</span>
</a>
</template>
</div>
</div>
</header>
<!-- Main Content Container -->
<main class="flex-1 max-w-6xl mx-auto px-4 sm:px-6 py-8 w-full flex items-center justify-center">
<!-- ============================================================= -->
<!-- VIEW 1: TEACHER AUTHENTICATION FLOW -->
<!-- ============================================================= -->
<div x-show="!isLoggedIn" class="w-full max-w-md" x-cloak>
<!-- Card Header -->
<div class="text-center mb-8">
<div class="inline-flex items-center justify-center w-16 h-16 rounded-2xl bg-saqel-card border border-saqel-gold/30 text-saqel-gold mb-4 glow-gold">
<svg class="w-8 h-8" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"></path>
</svg>
</div>
<h1 class="text-2xl sm:text-3xl font-black text-white">استوديو صَقِل للمعلمين</h1>
<p class="text-sm text-saqel-textMuted mt-2">منصة تصنع المعلم الرقمي الأول — حماية محتواك وأرباح متنامية</p>
</div>
<!-- Auth Box -->
<div class="bg-saqel-card/90 border border-saqel-border rounded-2xl p-6 sm:p-8 shadow-2xl backdrop-blur-xl relative overflow-hidden">
<!-- Glow Accent -->
<div class="absolute top-0 left-0 w-32 h-32 bg-saqel-gold/10 rounded-full blur-2xl pointer-events-none"></div>
<!-- Alert Messages -->
<div x-show="errorMessage" x-cloak class="mb-5 p-3.5 rounded-xl bg-red-500/10 border border-red-500/30 text-red-300 text-sm flex items-start gap-2">
<svg class="w-5 h-5 text-red-400 shrink-0 mt-0.5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
<span x-text="errorMessage"></span>
</div>
<div x-show="successMessage" x-cloak class="mb-5 p-3.5 rounded-xl bg-saqel-gold/10 border border-saqel-gold/30 text-saqel-gold text-sm flex items-start gap-2">
<svg class="w-5 h-5 text-saqel-gold shrink-0 mt-0.5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path></svg>
<span x-text="successMessage"></span>
</div>
<!-- STEP 1: PHONE NUMBER INPUT -->
<div x-show="authStep === 'phone'">
<form @submit.prevent="sendOtp()">
<!-- Full Name -->
<div class="mb-4">
<label class="block text-xs font-bold text-saqel-textMuted mb-2">اسم المعلم / الأستاذ</label>
<input type="text" x-model="fullName" placeholder="مثال: الأستاذ حمزة النجار"
class="w-full bg-saqel-dark/90 border border-saqel-border focus:border-saqel-gold focus:ring-1 focus:ring-saqel-gold rounded-xl px-4 py-3 text-sm text-white placeholder:text-slate-600 outline-none transition">
</div>
<!-- Phone Number -->
<div class="mb-6">
<label class="block text-xs font-bold text-saqel-textMuted mb-2">رقم الهاتف (الواتساب) <span class="text-red-400">*</span></label>
<div class="relative flex items-center" dir="ltr">
<span class="absolute left-3.5 text-sm font-bold text-saqel-gold bg-saqel-dark px-2 py-1 rounded-md border border-saqel-border">
🇯🇴 +962
</span>
<input type="tel" x-model="phone" required placeholder="790000000"
class="w-full bg-saqel-dark/90 border border-saqel-border focus:border-saqel-gold focus:ring-1 focus:ring-saqel-gold rounded-xl pl-28 pr-4 py-3 text-sm text-white placeholder:text-slate-600 outline-none transition font-mono tracking-wider">
</div>
<span class="text-[11px] text-saqel-textMuted block mt-1.5">يُشترط رقم مسجل ومعتمد لدى إدارة المنصة.</span>
</div>
<!-- Submit Button -->
<button type="submit" :disabled="loading"
class="w-full py-3.5 px-4 bg-gradient-to-r from-saqel-gold to-amber-500 text-saqel-dark font-extrabold rounded-xl hover:opacity-95 transition shadow-lg glow-gold flex items-center justify-center gap-2 disabled:opacity-50">
<template x-if="loading">
<svg class="animate-spin h-5 w-5 text-saqel-dark" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8v8H4z"></path></svg>
</template>
<span x-text="loading ? 'جارٍ التحقق...' : 'دخول استوديو المعلم (OTP) ←'"></span>
</button>
</form>
</div>
<!-- STEP 2: OTP VERIFICATION -->
<div x-show="authStep === 'otp'" x-cloak>
<div class="text-center mb-6">
<span class="text-xs text-saqel-textMuted">تم إرسال الرمز للواتساب:</span>
<div class="font-mono font-bold text-saqel-gold text-sm mt-0.5" x-text="phoneDisplay"></div>
</div>
<form @submit.prevent="verifyOtp()">
<!-- 6 Digits OTP Input -->
<div class="mb-6">
<label class="block text-xs font-bold text-saqel-textMuted mb-2 text-center">أدخل رمز التحقق (6 أرقام)</label>
<input type="text" x-model="otpCode" maxlength="6" autofocus placeholder="• • • • • •"
class="w-full bg-saqel-dark/90 border border-saqel-gold/50 focus:border-saqel-gold focus:ring-2 focus:ring-saqel-gold/30 rounded-xl px-4 py-3.5 text-center text-2xl font-mono tracking-[0.5em] text-saqel-gold placeholder:text-slate-700 outline-none transition">
</div>
<!-- Submit Verification -->
<button type="submit" :disabled="loading || otpCode.length < 6"
class="w-full py-3.5 px-4 bg-gradient-to-r from-saqel-gold to-amber-500 text-saqel-dark font-extrabold rounded-xl hover:opacity-95 transition shadow-lg glow-gold flex items-center justify-center gap-2 disabled:opacity-50">
<template x-if="loading">
<svg class="animate-spin h-5 w-5 text-saqel-dark" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8v8H4z"></path></svg>
</template>
<span x-text="loading ? 'جارٍ التحقق...' : 'تأكيد الدخول للاستوديو 🎓'"></span>
</button>
<!-- Actions -->
<div class="flex items-center justify-between text-xs mt-5 pt-4 border-t border-saqel-border/50 text-saqel-textMuted">
<button type="button" @click="authStep = 'phone'" class="hover:text-white transition">← تعديل الرقم</button>
<template x-if="timer > 0">
<span class="text-slate-500" x-text="'إعادة الإرسال بعد (' + timer + 'ث)'"></span>
</template>
<template x-if="timer === 0">
<button type="button" @click="sendOtp()" class="text-saqel-gold hover:underline font-bold">إعادة إرسال الرمز ↺</button>
</template>
</div>
</form>
</div>
<!-- Footer Partner Notice -->
<div class="mt-6 pt-4 border-t border-saqel-border/40 text-center text-[11px] text-slate-500">
<span>حماية محتوى DRM كاملة + تقاسم أرباح 45%–50% شفاف ومؤتمت</span>
</div>
</div>
</div>
<!-- ============================================================= -->
<!-- VIEW 2: TEACHER STUDIO WORKSPACE -->
<!-- ============================================================= -->
<div x-show="isLoggedIn" class="w-full space-y-8" x-cloak>
<!-- Teacher Summary Header -->
<div class="bg-gradient-to-r from-saqel-card to-saqel-cardHover border border-saqel-border rounded-3xl p-6 sm:p-8 shadow-xl">
<div class="flex flex-col md:flex-row md:items-center justify-between gap-6">
<div>
<div class="inline-flex items-center gap-2 px-3 py-1 rounded-full bg-saqel-gold/10 border border-saqel-gold/30 text-saqel-gold text-xs font-bold mb-3">
<span>استوديو المعلم المعتمد</span>
</div>
<h2 class="text-2xl sm:text-3xl font-black text-white" x-text="'أهلاً بك، ' + (teacherData.name || 'أستاذنا الفاضل') + ' 👨‍🏫'"></h2>
<p class="text-sm text-saqel-textMuted mt-1">إدارة دوراتك، إدراج كويزات الفيديو التفاعلية، ومتابعة نمو طلابك.</p>
</div>
<!-- Teacher Earnings Summary -->
<div class="flex items-center gap-4">
<div class="bg-saqel-dark/80 border border-saqel-border p-4 rounded-2xl text-center min-w-[130px]">
<span class="text-xs text-saqel-textMuted block font-bold">إجمالي الطلاب</span>
<span class="text-2xl font-black text-saqel-cyan">1,240</span>
</div>
<div class="bg-saqel-dark/80 border border-saqel-gold/40 p-4 rounded-2xl text-center min-w-[150px] glow-gold">
<span class="text-xs text-saqel-textMuted block font-bold">أرباحك المتراكمة</span>
<span class="text-2xl font-black text-saqel-gold">19,530 د.أ</span>
</div>
</div>
</div>
</div>
<!-- In-Video Quiz Creator Tool (Coursera Engine) -->
<div class="bg-saqel-card border border-saqel-border rounded-3xl p-6 sm:p-8 shadow-xl">
<div class="flex items-center justify-between mb-6">
<div>
<h3 class="text-lg font-black text-white">إضافة كويز تفاعلي داخل الفيديو 🎬</h3>
<p class="text-xs text-saqel-textMuted mt-1">حدد الثانية الزمنية في الفيديو التي سيتوقف عندها الشرح لفحص فهم الطالب.</p>
</div>
<span class="text-xs px-3 py-1 rounded-lg bg-saqel-cyan/10 text-saqel-cyan border border-saqel-cyan/30 font-bold">Bunny Stream Synced</span>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 bg-saqel-dark/80 p-5 rounded-2xl border border-saqel-border">
<div>
<label class="block text-xs font-bold text-saqel-textMuted mb-2">اختر الدورة والدرس</label>
<select class="w-full bg-saqel-card border border-saqel-border rounded-xl px-4 py-2.5 text-xs text-white outline-none">
<option>الرياضيات العلمي — الدرس 4: قواعد الاشتقاق الأساسية</option>
<option>الرياضيات العلمي — الدرس 5: الاشتقاق الضمني</option>
</select>
<div class="mt-4">
<label class="block text-xs font-bold text-saqel-textMuted mb-2">توقيت ظهور الكويز (بالدقيقة والثانية)</label>
<input type="text" value="08:30" class="w-full bg-saqel-card border border-saqel-border rounded-xl px-4 py-2.5 text-xs text-saqel-cyan font-mono outline-none">
</div>
<div class="mt-4">
<label class="block text-xs font-bold text-saqel-textMuted mb-2">عقوبة الخطأ (الإرجاع العلاجي)</label>
<select class="w-full bg-saqel-card border border-saqel-border rounded-xl px-4 py-2.5 text-xs text-white outline-none">
<option>إرجاع الطالب 45 ثانية للخلف (مستحسن)</option>
<option>إرجاع الطالب 60 ثانية للخلف</option>
<option>إعادة مشاهدة المقطع بالكامل</option>
</select>
</div>
</div>
<div>
<label class="block text-xs font-bold text-saqel-textMuted mb-2">نص السؤال التفاعلي</label>
<textarea rows="3" placeholder="اكتب السؤال الذي سيظهر أمام الطالب..." class="w-full bg-saqel-card border border-saqel-border rounded-xl p-3 text-xs text-white outline-none resize-none"></textarea>
<div class="mt-3 space-y-2">
<input type="text" placeholder="الخيار الأول (الصحيح)" class="w-full bg-saqel-card border border-emerald-500/40 rounded-xl px-3 py-2 text-xs text-emerald-300 outline-none">
<input type="text" placeholder="الخيار الثاني (الخاطئ)" class="w-full bg-saqel-card border border-saqel-border rounded-xl px-3 py-2 text-xs text-slate-300 outline-none">
</div>
<button class="mt-4 w-full py-2.5 bg-saqel-gold text-saqel-dark font-extrabold text-xs rounded-xl hover:opacity-90 transition">
حفظ الكويز داخل الفيديو ✓
</button>
</div>
</div>
</div>
</div>
</main>
<!-- Footer -->
<footer class="border-t border-saqel-border/40 py-6 text-center text-xs text-saqel-textMuted">
<div class="max-w-6xl mx-auto px-4 flex flex-col sm:flex-row items-center justify-between gap-3">
<span>منصة صَقِل التعليمية — نظام استوديو المعلمين © 2026</span>
<div class="flex items-center gap-4">
<a href="/student" class="hover:text-saqel-gold transition">بوابة الطلاب</a>
<span class="text-slate-700">•</span>
<span class="text-emerald-400">حماية المحتوى مشفرة 🔒</span>
</div>
</div>
</footer>
<!-- Alpine.js Application Logic -->
<!-- 1. Define Alpine Data Component BEFORE Alpine Loads -->
<script>
function teacherAuth() {
return {
isLoggedIn: false,
authStep: 'phone',
authStep: 'phone', // 'phone' | 'otp'
phone: '',
fullName: '',
otpCode: '',
@@ -321,26 +60,39 @@ class TeacherPortal
teacherData: {},
async initApp() {
this.deviceFingerprint = await this.generateDeviceFingerprint();
const token = localStorage.getItem('saqel_teacher_jwt');
if (token) {
await this.fetchProfile(token);
try {
this.deviceFingerprint = await this.generateDeviceFingerprint();
const token = localStorage.getItem('saqel_teacher_jwt');
if (token) {
await this.fetchProfile(token);
}
} catch (e) {
console.error('Teacher Init error:', e);
}
},
async generateDeviceFingerprint() {
const raw = [
navigator.userAgent,
screen.width + 'x' + screen.height,
Intl.DateTimeFormat().resolvedOptions().timeZone
].join('###');
const msgUint8 = new TextEncoder().encode(raw);
const hashBuffer = await crypto.subtle.digest('SHA-256', msgUint8);
const hashArray = Array.from(new Uint8Array(hashBuffer));
return hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
try {
const raw = [
navigator.userAgent,
navigator.language,
screen.width + 'x' + screen.height,
Intl.DateTimeFormat().resolvedOptions().timeZone
].join('###');
const msgUint8 = new TextEncoder().encode(raw);
const hashBuffer = await crypto.subtle.digest('SHA-256', msgUint8);
const hashArray = Array.from(new Uint8Array(hashBuffer));
return hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
} catch (e) {
return 'teacher_web_' + Math.random().toString(36).substring(2);
}
},
async sendOtp() {
if (!this.phone) {
this.errorMessage = 'يرجى إدخال رقم الهاتف المسجل';
return;
}
this.loading = true;
this.errorMessage = '';
this.successMessage = '';
@@ -369,13 +121,17 @@ class TeacherPortal
this.errorMessage = data.message || 'فشل إرسال رمز التحقق';
}
} catch (e) {
this.errorMessage = 'حدث خطأ في الاتصال بالخادم';
this.errorMessage = 'حدث خطأ في الاتصال بالخادم. تأكد من تفعيل السيرفر.';
} finally {
this.loading = false;
}
},
async verifyOtp() {
if (!this.otpCode || this.otpCode.length < 6) {
this.errorMessage = 'يرجى إدخال رمز التحقق المكون من 6 أرقام';
return;
}
this.loading = true;
this.errorMessage = '';
@@ -399,7 +155,7 @@ class TeacherPortal
this.isLoggedIn = true;
this.successMessage = 'تم تسجيل الدخول بنجاح!';
} else {
this.errorMessage = data.message || 'رمز التحقق غير صحيح أو غير مصرح للمعلم';
this.errorMessage = data.message || 'رمز التحقق غير صحيح أو غير مصرح للدخول كمعلم';
}
} catch (e) {
this.errorMessage = 'حدث خطأ في التحقق من الرمز';
@@ -436,12 +192,14 @@ class TeacherPortal
fetch('/api/auth/logout', {
method: 'POST',
headers: { 'Authorization': 'Bearer ' + token }
});
}).catch(() => {});
}
localStorage.removeItem('saqel_teacher_jwt');
this.isLoggedIn = false;
this.authStep = 'phone';
this.otpCode = '';
this.errorMessage = '';
this.successMessage = '';
},
startTimer(seconds) {
@@ -455,9 +213,271 @@ class TeacherPortal
}
}, 1000);
}
}
};
}
</script>
<!-- Alpine.js Core Script (Deferred) -->
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
<style>
body { font-family: 'Cairo', sans-serif; background-color: #0B132B; }
.glow-gold { box-shadow: 0 0 25px -5px rgba(255, 209, 102, 0.35); }
.bg-grid {
background-size: 30px 30px;
background-image: linear-gradient(to right, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
linear-gradient(to bottom, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
}
</style>
</head>
<body class="bg-[#0B132B] text-slate-100 min-h-screen bg-grid antialiased flex flex-col justify-between selection:bg-saqel-gold selection:text-[#0B132B]"
x-data="teacherAuth()" x-init="initApp()">
<!-- Top Navigation Bar -->
<header class="border-b border-saqel-border/80 bg-[#0B132B]/95 backdrop-blur-md sticky top-0 z-40">
<div class="max-w-6xl mx-auto px-4 sm:px-6 h-16 flex items-center justify-between">
<div class="flex items-center gap-3">
<div class="w-10 h-10 rounded-xl bg-gradient-to-tr from-saqel-gold to-amber-500 p-[2px] flex items-center justify-center glow-gold">
<div class="w-full h-full bg-[#0B132B] rounded-[10px] flex items-center justify-center text-saqel-gold font-black text-xl">
صـ
</div>
</div>
<div>
<span class="font-extrabold text-lg text-white tracking-wide">صَقِل</span>
<span class="text-xs px-2.5 py-0.5 rounded-full bg-saqel-gold/10 text-saqel-gold border border-saqel-gold/30 mr-2 font-semibold">استوديو المعلمين</span>
</div>
</div>
<!-- Header Right Controls -->
<div class="flex items-center gap-3">
<template x-if="isLoggedIn">
<div class="flex items-center gap-3">
<span class="text-sm text-slate-300 hidden sm:inline" x-text="'أهلاً، ' + (teacherData.name || 'أستاذنا')"></span>
<button @click="logout()" class="text-xs px-3 py-1.5 rounded-lg border border-red-500/40 text-red-400 hover:bg-red-500/10 transition">
تسجيل الخروج
</button>
</div>
</template>
<template x-if="!isLoggedIn">
<a href="/student" class="text-xs sm:text-sm text-slate-400 hover:text-saqel-cyan transition flex items-center gap-1.5">
<span>أنت طالب؟</span>
<span class="text-saqel-cyan font-bold underline">بوابة الطلاب ←</span>
</a>
</template>
</div>
</div>
</header>
<!-- Main Content Container -->
<main class="flex-1 max-w-6xl mx-auto px-4 sm:px-6 py-8 w-full flex items-center justify-center">
<!-- ============================================================= -->
<!-- VIEW 1: TEACHER AUTHENTICATION FLOW -->
<!-- ============================================================= -->
<div x-show="!isLoggedIn" class="w-full max-w-md">
<!-- Card Header -->
<div class="text-center mb-6">
<div class="inline-flex items-center justify-center w-16 h-16 rounded-2xl bg-[#1C2541] border border-saqel-gold/40 text-saqel-gold mb-3 glow-gold shadow-xl">
<svg class="w-8 h-8" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"></path>
</svg>
</div>
<h1 class="text-2xl sm:text-3xl font-black text-white">استوديو صَقِل للمعلمين</h1>
<p class="text-xs sm:text-sm text-slate-400 mt-1">حماية متطورة لمحتواك وأرباح متنامية بنظام الشراكة</p>
</div>
<!-- Auth Box -->
<div class="bg-[#1C2541] border border-saqel-border rounded-2xl p-6 sm:p-8 shadow-2xl relative overflow-hidden">
<!-- Glow Accent -->
<div class="absolute top-0 left-0 w-32 h-32 bg-saqel-gold/10 rounded-full blur-2xl pointer-events-none"></div>
<!-- Alert Messages -->
<template x-if="errorMessage">
<div class="mb-5 p-3.5 rounded-xl bg-red-500/10 border border-red-500/30 text-red-300 text-xs sm:text-sm flex items-start gap-2">
<svg class="w-5 h-5 text-red-400 shrink-0 mt-0.5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
<span x-text="errorMessage"></span>
</div>
</template>
<template x-if="successMessage">
<div class="mb-5 p-3.5 rounded-xl bg-saqel-gold/10 border border-saqel-gold/30 text-saqel-gold text-xs sm:text-sm flex items-start gap-2">
<svg class="w-5 h-5 text-saqel-gold shrink-0 mt-0.5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path></svg>
<span x-text="successMessage"></span>
</div>
</template>
<!-- STEP 1: PHONE NUMBER INPUT -->
<div x-show="authStep === 'phone'">
<form @submit.prevent="sendOtp()">
<!-- Full Name -->
<div class="mb-4">
<label class="block text-xs font-bold text-slate-300 mb-2">اسم المعلم / الأستاذ</label>
<input type="text" x-model="fullName" placeholder="مثال: الأستاذ حمزة النجار"
class="w-full bg-[#0B132B] border border-saqel-border focus:border-saqel-gold focus:ring-1 focus:ring-saqel-gold rounded-xl px-4 py-3 text-sm text-white placeholder:text-slate-600 outline-none transition">
</div>
<!-- Phone Number -->
<div class="mb-6">
<label class="block text-xs font-bold text-slate-300 mb-2">رقم الهاتف (الواتساب) <span class="text-red-400">*</span></label>
<div class="relative flex items-center" dir="ltr">
<span class="absolute left-3 text-xs font-bold text-saqel-gold bg-[#0B132B] px-2 py-1 rounded-md border border-saqel-border">
🇯🇴 +962
</span>
<input type="tel" x-model="phone" required placeholder="790000000"
class="w-full bg-[#0B132B] border border-saqel-border focus:border-saqel-gold focus:ring-1 focus:ring-saqel-gold rounded-xl pl-24 pr-4 py-3 text-sm text-white placeholder:text-slate-600 outline-none transition font-mono tracking-wider">
</div>
<span class="text-[11px] text-slate-400 block mt-1.5">يُشترط رقم مسجل ومعتمد لدى إدارة المنصة.</span>
</div>
<!-- Submit Button -->
<button type="submit" :disabled="loading"
class="w-full py-3.5 px-4 bg-gradient-to-r from-saqel-gold to-amber-500 text-[#0B132B] font-extrabold rounded-xl hover:opacity-95 transition shadow-lg glow-gold flex items-center justify-center gap-2 disabled:opacity-50 text-sm">
<template x-if="loading">
<svg class="animate-spin h-5 w-5 text-[#0B132B]" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8v8H4z"></path></svg>
</template>
<span x-text="loading ? 'جارٍ التحقق...' : 'دخول استوديو المعلم (OTP) ←'"></span>
</button>
</form>
</div>
<!-- STEP 2: OTP VERIFICATION -->
<div x-show="authStep === 'otp'">
<div class="text-center mb-6">
<span class="text-xs text-slate-400">تم إرسال الرمز للواتساب:</span>
<div class="font-mono font-bold text-saqel-gold text-sm mt-0.5" x-text="phoneDisplay"></div>
</div>
<form @submit.prevent="verifyOtp()">
<!-- 6 Digits OTP Input -->
<div class="mb-6">
<label class="block text-xs font-bold text-slate-300 mb-2 text-center">أدخل رمز التحقق (6 أرقام)</label>
<input type="text" x-model="otpCode" maxlength="6" autofocus placeholder="• • • • • •"
class="w-full bg-[#0B132B] border border-saqel-gold/50 focus:border-saqel-gold focus:ring-2 focus:ring-saqel-gold/30 rounded-xl px-4 py-3.5 text-center text-2xl font-mono tracking-[0.4em] text-saqel-gold placeholder:text-slate-700 outline-none transition">
</div>
<!-- Submit Verification -->
<button type="submit" :disabled="loading || otpCode.length < 6"
class="w-full py-3.5 px-4 bg-gradient-to-r from-saqel-gold to-amber-500 text-[#0B132B] font-extrabold rounded-xl hover:opacity-95 transition shadow-lg glow-gold flex items-center justify-center gap-2 disabled:opacity-50 text-sm">
<template x-if="loading">
<svg class="animate-spin h-5 w-5 text-[#0B132B]" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8v8H4z"></path></svg>
</template>
<span x-text="loading ? 'جارٍ التحقق...' : 'تأكيد الدخول للاستوديو 🎓'"></span>
</button>
<!-- Actions -->
<div class="flex items-center justify-between text-xs mt-5 pt-4 border-t border-saqel-border/50 text-slate-400">
<button type="button" @click="authStep = 'phone'" class="hover:text-white transition">← تعديل الرقم</button>
<template x-if="timer > 0">
<span class="text-slate-500" x-text="'إعادة الإرسال بعد (' + timer + 'ث)'"></span>
</template>
<template x-if="timer === 0">
<button type="button" @click="sendOtp()" class="text-saqel-gold hover:underline font-bold">إعادة إرسال الرمز ↺</button>
</template>
</div>
</form>
</div>
<!-- Footer Partner Notice -->
<div class="mt-6 pt-4 border-t border-saqel-border/40 text-center text-[11px] text-slate-500">
<span>حماية محتوى DRM كاملة + تقاسم أرباح 45%–50% شفاف ومؤتمت</span>
</div>
</div>
</div>
<!-- ============================================================= -->
<!-- VIEW 2: TEACHER STUDIO WORKSPACE -->
<!-- ============================================================= -->
<div x-show="isLoggedIn" class="w-full space-y-8">
<!-- Teacher Summary Header -->
<div class="bg-gradient-to-r from-[#1C2541] to-[#222F55] border border-saqel-border rounded-3xl p-6 sm:p-8 shadow-xl">
<div class="flex flex-col md:flex-row md:items-center justify-between gap-6">
<div>
<div class="inline-flex items-center gap-2 px-3 py-1 rounded-full bg-saqel-gold/10 border border-saqel-gold/30 text-saqel-gold text-xs font-bold mb-3">
<span>استوديو المعلم المعتمد</span>
</div>
<h2 class="text-2xl sm:text-3xl font-black text-white" x-text="'أهلاً بك، ' + (teacherData.name || 'أستاذنا الفاضل') + ' 👨‍🏫'"></h2>
<p class="text-sm text-slate-300 mt-1">إدارة دوراتك، إدراج كويزات الفيديو التفاعلية، ومتابعة نمو طلابك.</p>
</div>
<!-- Teacher Earnings Summary -->
<div class="flex items-center gap-4">
<div class="bg-[#0B132B]/80 border border-saqel-border p-4 rounded-2xl text-center min-w-[130px]">
<span class="text-xs text-slate-400 block font-bold">إجمالي الطلاب</span>
<span class="text-2xl font-black text-saqel-cyan">1,240</span>
</div>
<div class="bg-[#0B132B]/80 border border-saqel-gold/40 p-4 rounded-2xl text-center min-w-[150px] glow-gold">
<span class="text-xs text-slate-400 block font-bold">أرباحك المتراكمة</span>
<span class="text-2xl font-black text-saqel-gold">19,530 د.أ</span>
</div>
</div>
</div>
</div>
<!-- In-Video Quiz Creator Tool (Coursera Engine) -->
<div class="bg-[#1C2541] border border-saqel-border rounded-3xl p-6 sm:p-8 shadow-xl">
<div class="flex items-center justify-between mb-6">
<div>
<h3 class="text-lg font-black text-white">إضافة كويز تفاعلي داخل الفيديو 🎬</h3>
<p class="text-xs text-slate-400 mt-1">حدد الثانية الزمنية في الفيديو التي سيتوقف عندها الشرح لفحص فهم الطالب.</p>
</div>
<span class="text-xs px-3 py-1 rounded-lg bg-saqel-cyan/10 text-saqel-cyan border border-saqel-cyan/30 font-bold">Bunny Stream Synced</span>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 bg-[#0B132B] p-5 rounded-2xl border border-saqel-border">
<div>
<label class="block text-xs font-bold text-slate-300 mb-2">اختر الدورة والدرس</label>
<select class="w-full bg-[#1C2541] border border-saqel-border rounded-xl px-4 py-2.5 text-xs text-white outline-none">
<option>الرياضيات العلمي — الدرس 4: قواعد الاشتقاق الأساسية</option>
<option>الرياضيات العلمي — الدرس 5: الاشتقاق الضمني</option>
</select>
<div class="mt-4">
<label class="block text-xs font-bold text-slate-300 mb-2">توقيت ظهور الكويز (بالدقيقة والثانية)</label>
<input type="text" value="08:30" class="w-full bg-[#1C2541] border border-saqel-border rounded-xl px-4 py-2.5 text-xs text-saqel-cyan font-mono outline-none">
</div>
<div class="mt-4">
<label class="block text-xs font-bold text-slate-300 mb-2">عقوبة الخطأ (الإرجاع العلاجي)</label>
<select class="w-full bg-[#1C2541] border border-saqel-border rounded-xl px-4 py-2.5 text-xs text-white outline-none">
<option>إرجاع الطالب 45 ثانية للخلف (مستحسن)</option>
<option>إرجاع الطالب 60 ثانية للخلف</option>
<option>إعادة مشاهدة المقطع بالكامل</option>
</select>
</div>
</div>
<div>
<label class="block text-xs font-bold text-slate-300 mb-2">نص السؤال التفاعلي</label>
<textarea rows="3" placeholder="اكتب السؤال الذي سيظهر أمام الطالب..." class="w-full bg-[#1C2541] border border-saqel-border rounded-xl p-3 text-xs text-white outline-none resize-none"></textarea>
<div class="mt-3 space-y-2">
<input type="text" placeholder="الخيار الأول (الصحيح)" class="w-full bg-[#1C2541] border border-emerald-500/40 rounded-xl px-3 py-2 text-xs text-emerald-300 outline-none">
<input type="text" placeholder="الخيار الثاني (الخاطئ)" class="w-full bg-[#1C2541] border border-saqel-border rounded-xl px-3 py-2 text-xs text-slate-300 outline-none">
</div>
<button class="mt-4 w-full py-2.5 bg-saqel-gold text-[#0B132B] font-extrabold text-xs rounded-xl hover:opacity-90 transition shadow-lg glow-gold">
حفظ الكويز داخل الفيديو ✓
</button>
</div>
</div>
</div>
</div>
</main>
<!-- Footer -->
<footer class="border-t border-saqel-border/40 py-6 text-center text-xs text-slate-400 bg-[#0B132B]">
<div class="max-w-6xl mx-auto px-4 flex flex-col sm:flex-row items-center justify-between gap-3">
<span>منصة صَقِل التعليمية — نظام استوديو المعلمين © 2026</span>
<div class="flex items-center gap-4">
<a href="/student" class="hover:text-saqel-gold transition">بوابة الطلاب</a>
<span class="text-slate-700">•</span>
<span class="text-emerald-400">حماية المحتوى مشفرة 🔒</span>
</div>
</div>
</footer>
</body>
</html>
HTML;