# Page Spec 01 — الصفحة الرئيسية (Home)

**Page ID:** `page-home`  
**Route:** `/`  
**Component:** `App\Livewire\Home` (Full-page Livewire)  
**Objective:** اكتشاف سريع + تحويل للتسجيل + بناء ثقة  
**Language:** AR (RTL) افتراضي + FR (LTR) كامل

---

## 1) Purpose + CTAs

### Primary CTA (واحد فقط)
| Lang | Text | Destination |
|------|------|-------------|
| AR | **استعرض البرامج** | `/courses` |
| FR | **Découvrir les programmes** | `/courses` |

### Secondary CTA
| Lang | Text | Destination |
|------|------|-------------|
| AR | احجز الآن | `/courses?sort=soonest` |
| FR | S'inscrire | `/courses?sort=soonest` |

---

## 2) Layout Structure

```
┌─────────────────────────────────────────────────────────────────┐
│ HEADER (Sticky)                                                 │
│ Logo ◄─► Nav: البرامج │ من نحن │ اتصل │ [AR/FR] │ تسجيل دخول    │
├─────────────────────────────────────────────────────────────────┤
│ HERO (Full-width, Video/Image BG)                               │
│ ┌─────────────────────────────────────────────────────────────┐ │
│ │ "اكتشف البرامج التكوينية التي تناسب طموحك"                 │ │
│ │ Subline: تكوين حضوري/مختلط مع مدربين محترفين               │ │
│ │                                                             │ │
│ │ [استعرض البرامج] ← Primary (White on Teal)                  │ │
│ │ [احجز الآن →] ← Secondary (Outline)                         │ │
│ └─────────────────────────────────────────────────────────────┘ │
├─────────────────────────────────────────────────────────────────┤
│ TRUST BAR (Horizontal)                                          │
│ ┌───────────┬───────────┬───────────┬───────────┐              │
│ │ 🎓 500+   │ 📚 25+    │ ⭐ 98%    │ 🏆 معتمد  │              │
│ │ متكوّن   │ برنامج    │ رضا       │ وطنياً   │              │
│ └───────────┴───────────┴───────────┴───────────┘              │
├─────────────────────────────────────────────────────────────────┤
│ FEATURED PROGRAMS (3-4 Cards, Horizontal Scroll on Mobile)      │
│ Section Title: "البرامج الأكثر طلباً"                           │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐               │
│ │ Prog 1  │ │ Prog 2  │ │ Prog 3  │ │ Prog 4  │               │
│ │ Badge   │ │ Badge   │ │ Badge   │ │ Badge   │               │
│ │ "قريباً"│ │         │ │         │ │         │               │
│ └─────────┘ └─────────┘ └─────────┘ └─────────┘               │
│ [عرض جميع البرامج →]                                           │
├─────────────────────────────────────────────────────────────────┤
│ VALUE PROPOSITION (3 Columns)                                   │
│ Section Title: "لماذا تختارنا؟"                                 │
│ ┌───────────────┐ ┌───────────────┐ ┌───────────────┐          │
│ │ 🎯 تكوين عملي │ │ 📜 شهادات    │ │ 💳 دفع مرن   │          │
│ │ تطبيقي 100%  │ │ معترف بها   │ │ CCP/BaridiMob │          │
│ └───────────────┘ └───────────────┘ └───────────────┘          │
├─────────────────────────────────────────────────────────────────┤
│ UPCOMING SESSIONS (Quick Access)                                │
│ Section Title: "البرامج التي تنطلق قريباً"                      │
│ ┌───────────────────────────────────────────────────────────┐  │
│ │ Session 1 │ 15 جانفي │ Python │ 5 مقاعد │ [سجّل الآن]    │  │
│ │ Session 2 │ 22 جانفي │ Excel  │ 8 مقاعد │ [سجّل الآن]    │  │
│ │ Session 3 │ 01 فيفري │ Compta │ 3 مقاعد │ [سجّل الآن]    │  │
│ └───────────────────────────────────────────────────────────┘  │
├─────────────────────────────────────────────────────────────────┤
│ CTA BANNER (Full-width Gradient)                                │
│ "هل أنت جاهز للخطوة القادمة؟"                                   │
│ [استعرض البرامج] ← Repeat Primary CTA                          │
├─────────────────────────────────────────────────────────────────┤
│ FOOTER                                                          │
│ Columns: عن المركز │ روابط سريعة │ تواصل معنا │ تابعنا         │
│ Copyright + Legal Links                                         │
└─────────────────────────────────────────────────────────────────┘
```

---

## 3) Core Components

### 3.1 Header

```blade
<header x-data="{ mobileOpen: false }" class="sticky top-0 z-50 bg-white/95 backdrop-blur-sm border-b border-slate-100">
  <div class="max-w-7xl mx-auto px-4 py-3 flex justify-between items-center">
    <!-- Logo -->
    <a href="/" class="flex items-center gap-2">
      <img src="/images/logo.svg" alt="ECOIN" class="h-10">
    </a>
    
    <!-- Desktop Nav -->
    <nav class="hidden md:flex items-center gap-8">
      <a href="{{ route('courses.index') }}" class="font-medium hover:text-teal-600 transition">{{ __('البرامج') }}</a>
      <a href="/about" class="font-medium hover:text-teal-600 transition">{{ __('من نحن') }}</a>
      <a href="/contact" class="font-medium hover:text-teal-600 transition">{{ __('اتصل بنا') }}</a>
    </nav>
    
    <!-- Right Actions -->
    <div class="flex items-center gap-4">
      <button @click="$dispatch('toggle-lang')" class="text-sm font-bold text-slate-500 hover:text-slate-900">
        {{ app()->getLocale() === 'ar' ? 'FR' : 'AR' }}
      </button>
      @guest
        <a href="{{ route('login') }}" class="hidden md:inline-flex px-4 py-2 text-sm font-medium border border-slate-200 rounded-lg hover:bg-slate-50">
          {{ __('تسجيل الدخول') }}
        </a>
      @else
        <a href="{{ route('dashboard') }}" class="hidden md:inline-flex px-4 py-2 text-sm font-medium bg-teal-600 text-white rounded-lg hover:bg-teal-700">
          {{ __('لوحتي') }}
        </a>
      @endguest
      
      <!-- Mobile Menu Toggle -->
      <button @click="mobileOpen = !mobileOpen" class="md:hidden p-2">
        <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
          <path x-show="!mobileOpen" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16"/>
          <path x-show="mobileOpen" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>
        </svg>
      </button>
    </div>
  </div>
  
  <!-- Mobile Menu -->
  <div x-show="mobileOpen" x-transition class="md:hidden border-t bg-white px-4 py-4 space-y-3">
    <a href="{{ route('courses.index') }}" class="block py-2 font-medium">{{ __('البرامج') }}</a>
    <a href="/about" class="block py-2 font-medium">{{ __('من نحن') }}</a>
    <a href="/contact" class="block py-2 font-medium">{{ __('اتصل بنا') }}</a>
    <a href="{{ route('login') }}" class="block py-2 font-medium text-teal-600">{{ __('تسجيل الدخول') }}</a>
  </div>
</header>
```

### 3.2 Hero Section

```blade
<section class="relative min-h-[80vh] flex items-center bg-gradient-to-br from-slate-900 via-slate-800 to-teal-900 overflow-hidden">
  <!-- Background Pattern -->
  <div class="absolute inset-0 opacity-10">
    <div class="absolute inset-0" style="background-image: url('/images/pattern.svg')"></div>
  </div>
  
  <!-- Content -->
  <div class="relative z-10 max-w-5xl mx-auto px-4 text-center text-white py-20">
    <h1 class="text-4xl md:text-5xl lg:text-6xl font-bold leading-tight mb-6">
      {{ __('اكتشف البرامج التكوينية التي تناسب طموحك') }}
    </h1>
    <p class="text-xl md:text-2xl text-slate-300 mb-10 max-w-3xl mx-auto">
      {{ __('تكوين حضوري ومختلط مع مدربين محترفين وشهادات معتمدة') }}
    </p>
    
    <!-- CTAs -->
    <div class="flex flex-col sm:flex-row items-center justify-center gap-4">
      <a href="{{ route('courses.index') }}" 
         class="w-full sm:w-auto px-8 py-4 bg-teal-500 hover:bg-teal-400 text-white font-bold rounded-xl shadow-lg shadow-teal-500/30 transition text-lg">
        {{ __('استعرض البرامج') }}
      </a>
      <a href="{{ route('courses.index', ['sort' => 'soonest']) }}" 
         class="w-full sm:w-auto px-8 py-4 border-2 border-white/30 hover:border-white/60 text-white font-medium rounded-xl transition text-lg">
        {{ __('احجز الآن') }} →
      </a>
    </div>
  </div>
</section>
```

### 3.3 Trust Bar

```blade
<section class="bg-white border-b border-slate-100 py-8">
  <div class="max-w-5xl mx-auto px-4">
    <div class="grid grid-cols-2 md:grid-cols-4 gap-8 text-center">
      <div>
        <div class="text-3xl md:text-4xl font-black text-teal-600">500+</div>
        <div class="text-sm text-slate-500 mt-1">{{ __('متكوّن') }}</div>
      </div>
      <div>
        <div class="text-3xl md:text-4xl font-black text-teal-600">25+</div>
        <div class="text-sm text-slate-500 mt-1">{{ __('برنامج') }}</div>
      </div>
      <div>
        <div class="text-3xl md:text-4xl font-black text-teal-600">98%</div>
        <div class="text-sm text-slate-500 mt-1">{{ __('نسبة الرضا') }}</div>
      </div>
      <div>
        <div class="text-3xl md:text-4xl font-black text-teal-600">🏆</div>
        <div class="text-sm text-slate-500 mt-1">{{ __('معتمد وطنياً') }}</div>
      </div>
    </div>
  </div>
</section>
```

### 3.4 Featured Programs Card

```blade
<article class="group bg-white rounded-2xl shadow-sm hover:shadow-xl transition-all duration-300 overflow-hidden border border-slate-100">
  <!-- Image -->
  <div class="relative h-48 bg-slate-200 overflow-hidden">
    @if($course->cover_image)
      <img src="{{ asset('storage/' . $course->cover_image) }}" 
           alt="{{ $course->title[app()->getLocale()] }}"
           class="w-full h-full object-cover group-hover:scale-105 transition-transform duration-500">
    @endif
    
    <!-- Badge: Upcoming -->
    @if($nextSession = $course->sessions->first())
      <span class="absolute top-4 {{ app()->getLocale() === 'ar' ? 'right-4' : 'left-4' }} bg-amber-500 text-white text-xs font-bold px-3 py-1 rounded-full">
        {{ __('ينطلق') }} {{ $nextSession->start_date->format('d M') }}
      </span>
    @endif
    
    <!-- Category -->
    <span class="absolute bottom-4 {{ app()->getLocale() === 'ar' ? 'right-4' : 'left-4' }} bg-white/90 backdrop-blur-sm text-xs font-medium px-3 py-1 rounded-full">
      {{ $course->category->name[app()->getLocale()] ?? $course->category->name['ar'] }}
    </span>
  </div>
  
  <!-- Content -->
  <div class="p-6">
    <h3 class="font-bold text-lg text-slate-900 group-hover:text-teal-600 transition line-clamp-2">
      {{ $course->title[app()->getLocale()] ?? $course->title['ar'] }}
    </h3>
    
    <p class="text-slate-500 text-sm mt-2 line-clamp-2">
      {{ $course->short_description[app()->getLocale()] ?? Str::limit($course->description[app()->getLocale()] ?? '', 80) }}
    </p>
    
    <!-- Meta -->
    <div class="flex items-center justify-between mt-4 pt-4 border-t border-slate-100">
      <div class="flex items-center gap-4 text-sm text-slate-500">
        <span class="flex items-center gap-1">
          <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/>
          </svg>
          {{ $course->duration_hours }}{{ __('س') }}
        </span>
        @if($nextSession)
          <span class="flex items-center gap-1 text-teal-600 font-medium">
            <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
              <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0z"/>
            </svg>
            {{ max(0, $nextSession->max_capacity - $nextSession->enrolled_count) }} {{ __('مقعد') }}
          </span>
        @endif
      </div>
      <span class="font-bold text-teal-600">
        {{ number_format($course->price, 0) }} {{ __('دج') }}
      </span>
    </div>
  </div>
  
  <!-- Hover CTA -->
  <div class="px-6 pb-6">
    <a href="{{ route('courses.show', $course) }}" 
       class="block w-full text-center py-3 bg-slate-100 hover:bg-teal-600 hover:text-white text-slate-700 font-medium rounded-xl transition">
      {{ __('التفاصيل والتسجيل') }}
    </a>
  </div>
</article>
```

### 3.5 Upcoming Sessions Table

```blade
<section class="py-16 bg-slate-50">
  <div class="max-w-6xl mx-auto px-4">
    <div class="text-center mb-10">
      <h2 class="text-2xl md:text-3xl font-bold text-slate-900">{{ __('البرامج التي تنطلق قريباً') }}</h2>
      <p class="text-slate-500 mt-2">{{ __('سجّل الآن قبل اكتمال المقاعد') }}</p>
    </div>
    
    <div class="bg-white rounded-2xl shadow-sm overflow-hidden border border-slate-100">
      <div class="overflow-x-auto">
        <table class="w-full text-sm">
          <thead class="bg-slate-50 text-slate-500 text-xs uppercase tracking-wider">
            <tr>
              <th class="px-6 py-4 text-start">{{ __('البرنامج') }}</th>
              <th class="px-6 py-4 text-start">{{ __('تاريخ الانطلاق') }}</th>
              <th class="px-6 py-4 text-start">{{ __('المدة') }}</th>
              <th class="px-6 py-4 text-start">{{ __('المقاعد') }}</th>
              <th class="px-6 py-4 text-start">{{ __('السعر') }}</th>
              <th class="px-6 py-4"></th>
            </tr>
          </thead>
          <tbody class="divide-y divide-slate-100">
            @foreach($upcomingSessions as $session)
              <tr class="hover:bg-slate-50 transition">
                <td class="px-6 py-4">
                  <div class="font-medium text-slate-900">{{ $session->course->title[app()->getLocale()] }}</div>
                  <div class="text-slate-500 text-xs">{{ $session->name }}</div>
                </td>
                <td class="px-6 py-4 text-slate-600">
                  {{ $session->start_date->translatedFormat('d F Y') }}
                </td>
                <td class="px-6 py-4 text-slate-600">
                  {{ $session->course->duration_hours }}{{ __('س') }}
                </td>
                <td class="px-6 py-4">
                  @php $remaining = max(0, $session->max_capacity - $session->enrolled_count); @endphp
                  <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium 
                    {{ $remaining <= 3 ? 'bg-amber-100 text-amber-800' : 'bg-green-100 text-green-800' }}">
                    {{ $remaining }} {{ __('متبقي') }}
                  </span>
                </td>
                <td class="px-6 py-4 font-bold text-teal-600">
                  {{ number_format($session->course->price, 0) }} {{ __('دج') }}
                </td>
                <td class="px-6 py-4">
                  <a href="{{ route('register.wizard', ['course' => $session->course, 'session' => $session]) }}" 
                     class="inline-flex items-center px-4 py-2 bg-teal-600 hover:bg-teal-700 text-white text-xs font-bold rounded-lg transition">
                    {{ __('سجّل الآن') }}
                  </a>
                </td>
              </tr>
            @endforeach
          </tbody>
        </table>
      </div>
    </div>
  </div>
</section>
```

---

## 4) States + Microcopy (AR/FR)

### 4.1 Loading (Skeleton)

```blade
<div class="animate-pulse">
  <div class="h-48 bg-slate-200 rounded-t-2xl"></div>
  <div class="p-6 space-y-3">
    <div class="h-5 bg-slate-200 rounded w-3/4"></div>
    <div class="h-3 bg-slate-200 rounded w-full"></div>
    <div class="h-3 bg-slate-200 rounded w-1/2"></div>
  </div>
</div>
```

### 4.2 Empty State (No Programs)

| Element | العربية | Français |
|---------|--------|----------|
| Icon | 📚 | 📚 |
| Title | لا توجد برامج متاحة حالياً | Aucun programme disponible |
| Description | سنضيف برامج جديدة قريباً. اترك بريدك للإشعار. | De nouveaux programmes arrivent. Inscrivez-vous pour être notifié. |
| CTA | أُعلمني | Me notifier |

### 4.3 Error State

| Element | العربية | Français |
|---------|--------|----------|
| Title | حدث خطأ في تحميل البرامج | Erreur de chargement |
| Description | يرجى تحديث الصفحة أو المحاولة لاحقاً | Actualisez la page ou réessayez plus tard |
| CTA | تحديث الصفحة | Actualiser |

### 4.4 Low Seats Warning

| Context | العربية | Français |
|---------|--------|----------|
| Badge | آخر 3 مقاعد! | 3 dernières places ! |
| Tooltip | الطلب مرتفع على هذا البرنامج | Programme très demandé |

---

## 5) CX/LX Guidelines

### Friction Reduction

| Point | Problem | Solution |
|-------|---------|----------|
| Hero | Too much text | Headline + Subline + 2 CTAs only |
| Programs | Scroll to find | Featured first + "soonest" sort |
| Trust | Unknown brand | Stats bar + "معتمد" badge |
| Seats | FOMO unclear | Live seat count + amber warning |
| Mobile | Long scroll | Sticky CTA bar at bottom |

### "What happens next"

```blade
<!-- Under Hero CTAs -->
<p class="text-sm text-slate-400 mt-6">
  {{ __('التسجيل يأخذ 3 دقائق فقط') }} ✓
</p>
```

### Accessibility

- Focus ring on all interactive elements
- `aria-label` on icon-only buttons
- Skip to content link
- Contrast ratio ≥ 4.5:1 for text

---

## 6) Analytics Events

| Event | Trigger | Properties |
|-------|---------|------------|
| `home_viewed` | Page load | `language`, `device`, `referrer` |
| `hero_cta_clicked` | Click Primary | `cta: 'discover_programs'` |
| `hero_secondary_clicked` | Click Secondary | `cta: 'book_now'` |
| `program_card_clicked` | Click card | `course_id`, `position`, `has_upcoming` |
| `upcoming_session_clicked` | Click "سجّل الآن" | `session_id`, `course_id`, `seats_remaining` |
| `view_all_clicked` | Click "عرض جميع" | - |
| `language_switched` | Toggle | `from`, `to` |
| `scroll_to_section` | Scroll into view | `section: 'trust' | 'programs' | 'upcoming'` |

---

## 7) Security Notes

| Aspect | Rule |
|--------|------|
| **Access** | Public page, no auth required |
| **Data** | Only `published` courses via scope |
| **Images** | Public storage, no signed URLs needed |
| **Stats** | Aggregated only, no PII exposed |
| **Cache** | Page-level cache OK (5 min TTL) |
| **Rate Limit** | None for viewing |

---

## 8) Acceptance Criteria

| # | Criterion |
|---|-----------|
| 1 | Hero displays with gradient background and 2 CTAs visible above fold |
| 2 | Primary CTA "استعرض البرامج" links to `/courses` |
| 3 | Secondary CTA "احجز الآن" links to `/courses?sort=soonest` |
| 4 | Trust bar shows 4 stats horizontally on desktop, 2x2 on mobile |
| 5 | Featured programs show max 4 cards with seat count |
| 6 | Upcoming sessions table shows 3-5 rows with "سجّل الآن" buttons |
| 7 | Language toggle switches between AR (RTL) and FR (LTR) |
| 8 | Empty state displays when no published courses exist |
| 9 | Page loads in < 2.5s (LCP) on 4G connection |
| 10 | Mobile sticky bar appears after scrolling past hero |

---

## Implementation Notes

```php
// App\Livewire\Home.php
public function render()
{
    $featuredCourses = Course::published()
        ->with(['category', 'sessions' => fn($q) => $q->open()->upcoming()->orderBy('start_date')])
        ->take(4)
        ->get();
    
    $upcomingSessions = Session::open()
        ->upcoming()
        ->with(['course' => fn($q) => $q->published()])
        ->orderBy('start_date')
        ->take(5)
        ->get();
    
    return view('livewire.home', compact('featuredCourses', 'upcomingSessions'))
        ->layout('components.layouts.app');
}
```

---

*Document generated from ECOIN v3 PRD specifications.*
