اااا

 <!DOCTYPE html>

<html lang="ar" dir="rtl">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=yes">

    <title>مسلسلات رمضان 2026</title>

    <!-- Font Awesome 6 -->

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">

    <!-- Swiper CSS -->

    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css" />

    <!-- Google Fonts -->

    <link href="https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&display=swap" rel="stylesheet">

    <!-- dash.js لتشغيل روابط MPD -->

    <script src="https://cdn.dashjs.org/latest/dash.all.min.js"></script>

    <style>

        * {

            margin: 0;

            padding: 0;

            box-sizing: border-box;

        }


        :root {

            --primary: #ffd966;

            --bg-dark: #0a0f1e;

            --bg-darker: #1a1f2f;

            --transition: all 0.3s ease;

        }


        body {

            font-family: 'Cairo', sans-serif;

            background: linear-gradient(135deg, var(--bg-dark) 0%, #141a2a 100%);

            color: #fff;

            overflow-x: hidden;

        }


        /* مطر رمضاني بسيط - هلال ونجوم */

        .ramadan-rain {

            position: fixed;

            top: 0;

            left: 0;

            width: 100%;

            height: 100%;

            pointer-events: none;

            z-index: 9999;

        }


        .rain-item {

            position: absolute;

            color: var(--primary);

            animation: float linear infinite;

            opacity: 0.15;

            font-size: 1rem;

        }


        @keyframes float {

            0% {

                transform: translateY(-10vh) rotate(0deg);

                opacity: 0.15;

            }

            100% {

                transform: translateY(110vh) rotate(360deg);

                opacity: 0;

            }

        }


        /* صفحة التحميل */

        .splash-screen {

            position: fixed;

            top: 0;

            left: 0;

            width: 100%;

            height: 100%;

            background: var(--bg-dark);

            display: flex;

            justify-content: center;

            align-items: center;

            z-index: 10000;

            transition: opacity 0.4s ease;

        }


        .splash-content {

            text-align: center;

        }


        .splash-icon {

            font-size: 3rem;

            color: var(--primary);

            margin-bottom: 1rem;

            animation: pulse 1.5s infinite;

        }


        .splash-title {

            font-size: 2rem;

            color: var(--primary);

            margin-bottom: 1.5rem;

        }


        .splash-progress {

            width: 220px;

            height: 3px;

            background: rgba(255,255,255,0.1);

            border-radius: 10px;

            margin: 0 auto;

        }


        .splash-progress-bar {

            width: 0%;

            height: 100%;

            background: var(--primary);

            transition: width 0.3s ease;

        }


        @keyframes pulse {

            0%,100%{transform:scale(1)}50%{transform:scale(1.1)}

        }


        /* التطبيق الرئيسي */

        .app-container {

            display: flex;

            min-height: 100vh;

            opacity: 0;

            transition: opacity 0.4s ease;

        }


        /* القائمة الجانبية */

        .sidebar-right {

            width: 200px;

            background: rgba(10,15,30,0.98);

            backdrop-filter: blur(10px);

            border-left: 1px solid rgba(255,217,102,0.2);

            padding: 1rem 0.5rem;

            position: fixed;

            right: 0;

            top: 0;

            bottom: 0;

            overflow-y: auto;

            z-index: 100;

            transform: translateX(0);

            transition: transform 0.3s ease;

        }


        .sidebar-header {

            display: flex;

            justify-content: space-between;

            align-items: center;

            padding: 0.5rem;

            margin-bottom: 1rem;

            border-bottom: 1px solid var(--primary);

        }


        .sidebar-logo {

            font-size: 1.1rem;

            font-weight: 700;

            color: var(--primary);

        }


        .close-sidebar {

            background: none;

            border: none;

            color: var(--primary);

            font-size: 1.2rem;

            cursor: pointer;

            width: 28px;

            height: 28px;

            border-radius: 50%;

            display: flex;

            align-items: center;

            justify-content: center;

        }


        .close-sidebar:hover {

            background: rgba(255,217,102,0.2);

        }


        .sidebar-overlay {

            display: none;

            position: fixed;

            top: 0;

            left: 0;

            right: 0;

            bottom: 0;

            background: rgba(0,0,0,0.5);

            z-index: 99;

        }


        .sidebar-overlay.active {

            display: block;

        }


        .sidebar-menu {

            list-style: none;

        }


        .sidebar-menu li {

            margin-bottom: 0.3rem;

        }


        .sidebar-menu a {

            color: #fff;

            text-decoration: none;

            display: flex;

            align-items: center;

            gap: 8px;

            padding: 0.5rem 0.8rem;

            border-radius: 8px;

            transition: var(--transition);

            font-size: 0.9rem;

            cursor: pointer;

        }


        .sidebar-menu a:hover,

        .sidebar-menu a.active {

            background: var(--primary);

            color: var(--bg-dark);

        }


        .sidebar-menu i {

            width: 18px;

            font-size: 1rem;

        }


        .menu-toggle {

            display: none;

            background: var(--primary);

            border: none;

            color: var(--bg-dark);

            font-size: 1.2rem;

            cursor: pointer;

            padding: 0.4rem 1rem;

            border-radius: 30px;

        }


        /* المحتوى الرئيسي */

        .main-content {

            flex: 1;

            margin-right: 200px;

            padding: 1rem;

            width: calc(100% - 200px);

        }


        /* الهيدر */

        .header {

            display: flex;

            justify-content: space-between;

            align-items: center;

            gap: 0.8rem;

            margin-bottom: 1.5rem;

            background: rgba(255,255,255,0.03);

            padding: 0.5rem 1.2rem;

            border-radius: 40px;

            border: 1px solid rgba(255,217,102,0.2);

        }


        .header-right {

            display: flex;

            align-items: center;

            gap: 0.8rem;

        }


        .app-name {

            font-size: 1.2rem;

            font-weight: 700;

            color: var(--primary);

        }


        .app-name i {

            margin-left: 5px;

        }


        /* البحث */

        .search-wrapper {

            position: relative;

            width: 260px;

        }


        .search-box {

            display: flex;

            align-items: center;

            background: rgba(255,255,255,0.05);

            border-radius: 30px;

            padding: 0.3rem 0.8rem;

            border: 1px solid rgba(255,217,102,0.2);

        }


        .search-box input {

            background: transparent;

            border: none;

            outline: none;

            color: white;

            width: 100%;

            padding: 0.2rem;

            font-size: 0.9rem;

            font-family: 'Cairo', sans-serif;

        }


        .search-box input::placeholder {

            color: rgba(255,255,255,0.3);

            font-size: 0.8rem;

        }


        .search-box i {

            color: var(--primary);

            cursor: pointer;

            font-size: 0.9rem;

        }


        .search-suggestions {

            position: absolute;

            top: 100%;

            right: 0;

            left: 0;

            background: var(--bg-darker);

            border-radius: 10px;

            margin-top: 5px;

            padding: 0.3rem 0;

            border: 1px solid var(--primary);

            max-height: 250px;

            overflow-y: auto;

            z-index: 1000;

            display: none;

        }


        .suggestion-item {

            padding: 0.5rem;

            cursor: pointer;

            display: flex;

            align-items: center;

            gap: 8px;

            font-size: 0.9rem;

            border-bottom: 1px solid rgba(255,255,255,0.05);

        }


        .suggestion-item:hover {

            background: var(--primary);

            color: var(--bg-dark);

        }


        .suggestion-img {

            width: 30px;

            height: 40px;

            border-radius: 4px;

            background-size: cover;

            background-position: center;

        }


        /* سلايدر */

        .hero-slider {

            margin-bottom: 2rem;

            border-radius: 15px;

            overflow: hidden;

        }


        .swiper-slide {

            position: relative;

            height: 200px;

            background-size: cover;

            background-position: center;

            cursor: pointer;

        }


        .slide-overlay {

            position: absolute;

            top: 0;

            left: 0;

            right: 0;

            bottom: 0;

            background: linear-gradient(transparent, rgba(0,0,0,0.8));

        }


        .slide-content {

            position: absolute;

            bottom: 0;

            padding: 1rem;

            z-index: 2;

        }


        .slide-title {

            font-size: 1.2rem;

            font-weight: 700;

            color: var(--primary);

        }


        /* أقسام المحتوى */

        .section {

            margin-bottom: 2rem;

        }


        .section-header {

            display: flex;

            justify-content: space-between;

            align-items: center;

            margin-bottom: 0.8rem;

        }


        .section-title {

            font-size: 1.2rem;

            font-weight: 600;

            color: var(--primary);

            display: flex;

            align-items: center;

            gap: 5px;

        }


        .view-all {

            color: rgba(255,255,255,0.6);

            text-decoration: none;

            font-size: 0.9rem;

            cursor: pointer;

            display: flex;

            align-items: center;

            gap: 3px;

            transition: var(--transition);

        }


        .view-all:hover {

            color: var(--primary);

        }


        /* صفوف المحتوى (أفقية) */

        .shows-row {

            display: flex;

            gap: 1rem;

            overflow-x: auto;

            padding: 0.3rem 0 1rem;

            scrollbar-width: thin;

            scrollbar-color: var(--primary) #2a2f3f;

            -webkit-overflow-scrolling: touch;

        }


        .shows-row::-webkit-scrollbar {

            height: 5px;

        }


        .shows-row::-webkit-scrollbar-track {

            background: #2a2f3f;

            border-radius: 10px;

        }


        .shows-row::-webkit-scrollbar-thumb {

            background: var(--primary);

            border-radius: 10px;

        }


        /* بطاقة المسلسل */

        .show-card {

            min-width: 130px;

            width: 130px;

            background: rgba(255,255,255,0.03);

            border-radius: 10px;

            overflow: hidden;

            cursor: pointer;

            transition: var(--transition);

            border: 1px solid rgba(255,217,102,0.1);

        }


        .show-card:hover {

            transform: translateY(-5px);

            border-color: var(--primary);

        }


        .show-poster {

            position: relative;

            width: 100%;

            padding-top: 133%;

            background-size: cover;

            background-position: center;

        }


        .show-poster::after {

            content: '\f144';

            font-family: 'Font Awesome 6 Free';

            font-weight: 900;

            position: absolute;

            top: 50%;

            left: 50%;

            transform: translate(-50%, -50%);

            font-size: 2rem;

            color: var(--primary);

            opacity: 0;

            transition: var(--transition);

        }


        .show-card:hover .show-poster::after {

            opacity: 0.8;

        }


        .show-info {

            padding: 0.5rem;

        }


        .show-title {

            font-size: 0.85rem;

            font-weight: 600;

            color: var(--primary);

            white-space: nowrap;

            overflow: hidden;

            text-overflow: ellipsis;

        }


        /* شبكة المحتوى (لصفحة عرض الكل) */

        .shows-grid {

            display: grid;

            grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));

            gap: 1rem;

            padding: 0.5rem 0;

        }


        /* القائمة السفلية */

        .bottom-nav {

            display: none;

            position: fixed;

            bottom: 0;

            left: 0;

            right: 0;

            background: rgba(10,15,30,0.98);

            backdrop-filter: blur(10px);

            border-top: 1px solid var(--primary);

            padding: 0.4rem 0.5rem;

            z-index: 98;

        }


        .bottom-nav-items {

            display: flex;

            justify-content: space-around;

        }


        .bottom-nav-item {

            display: flex;

            flex-direction: column;

            align-items: center;

            color: rgba(255,255,255,0.5);

            font-size: 0.65rem;

            padding: 0.3rem 0.8rem;

            border-radius: 20px;

            cursor: pointer;

            background: transparent;

            border: none;

            font-family: 'Cairo', sans-serif;

        }


        .bottom-nav-item i {

            font-size: 1.1rem;

        }


        .bottom-nav-item.active {

            color: var(--primary);

            background: rgba(255,217,102,0.1);

        }


        /* مشغل الفيديو المتطور مع دعم MPD */

        .player-overlay {

            position: fixed;

            top: 0;

            left: 0;

            width: 100%;

            height: 100%;

            background: rgba(0,0,0,0.98);

            z-index: 10001;

            display: none;

            justify-content: center;

            align-items: center;

        }


        .player-container {

            width: 95%;

            max-width: 1000px;

            background: var(--bg-darker);

            border-radius: 15px;

            overflow: hidden;

            border: 1px solid var(--primary);

        }


        .player-header {

            padding: 0.8rem 1.2rem;

            background: #2a2f3f;

            display: flex;

            justify-content: space-between;

            align-items: center;

            border-bottom: 1px solid var(--primary);

        }


        .player-title {

            font-size: 1.1rem;

            color: var(--primary);

            font-weight: 600;

        }


        .close-player {

            background: none;

            border: none;

            color: white;

            font-size: 1.3rem;

            cursor: pointer;

            width: 35px;

            height: 35px;

            border-radius: 50%;

            display: flex;

            align-items: center;

            justify-content: center;

        }


        .close-player:hover {

            background: rgba(255,217,102,0.2);

            color: var(--primary);

        }


        #videoContainer {

            width: 100%;

            aspect-ratio: 16/9;

            background: #000;

            position: relative;

        }


        #videoPlayer {

            width: 100%;

            height: 100%;

        }


        .episodes-section {

            padding: 1rem;

            max-height: 200px;

            overflow-y: auto;

        }


        .episodes-title {

            color: var(--primary);

            font-size: 1rem;

            margin-bottom: 0.8rem;

            display: flex;

            align-items: center;

            gap: 5px;

        }


        .episodes-grid {

            display: grid;

            grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));

            gap: 0.5rem;

        }


        .episode-item {

            background: rgba(255,255,255,0.05);

            border: 1px solid rgba(255,217,102,0.2);

            border-radius: 8px;

            padding: 0.5rem;

            cursor: pointer;

            font-size: 0.8rem;

            text-align: center;

            transition: var(--transition);

        }


        .episode-item:hover {

            background: var(--primary);

            color: var(--bg-dark);

            transform: translateY(-2px);

        }


        /* تحسينات الجوال */

        @media (max-width: 992px) {

            .sidebar-right {

                transform: translateX(100%);

                width: 180px;

            }

            

            .sidebar-right.open {

                transform: translateX(0);

            }

            

            .menu-toggle {

                display: block;

            }

            

            .main-content {

                margin-right: 0;

                width: 100%;

                padding: 0.8rem;

                padding-bottom: 65px;

            }

            

            .bottom-nav {

                display: block;

            }

            

            .header {

                flex-wrap: wrap;

            }

            

            .search-wrapper {

                width: 100%;

            }

            

            .show-card {

                min-width: 110px;

                width: 110px;

            }

        }

    </style>

</head>

<body>

    <!-- مطر رمضاني -->

    <div class="ramadan-rain" id="ramadanRain"></div>


    <!-- صفحة التحميل -->

    <div class="splash-screen" id="splashScreen">

        <div class="splash-content">

            <div class="splash-icon">

                <i class="fas fa-moon"></i>

            </div>

            <h2 class="splash-title">رمضان 2026</h2>

            <div class="splash-progress">

                <div class="splash-progress-bar" id="progressBar"></div>

            </div>

        </div>

    </div>


    <!-- طبقة القائمة -->

    <div class="sidebar-overlay" id="sidebarOverlay" onclick="closeSidebar()"></div>


    <!-- التطبيق الرئيسي -->

    <div class="app-container" id="appContainer">

        <!-- القائمة الجانبية -->

        <div class="sidebar-right" id="sidebar">

            <div class="sidebar-header">

                <span class="sidebar-logo"><i class="fas fa-tv"></i> رمضان</span>

                <button class="close-sidebar" onclick="closeSidebar()"><i class="fas fa-times"></i></button>

            </div>

            <ul class="sidebar-menu">

                <li><a onclick="showSection('home')" class="active"><i class="fas fa-home"></i> الرئيسية</a></li>

                <li><a onclick="showSection('channels')"><i class="fas fa-satellite-dish"></i> القنوات</a></li>

                <li><a onclick="shareApp()"><i class="fas fa-share-alt"></i> مشاركة</a></li>

                <li><a onclick="showAbout()"><i class="fas fa-info-circle"></i> عن التطبيق</a></li>

                <li><a onclick="contactUs()"><i class="fas fa-envelope"></i> تواصل</a></li>

                <li><a onclick="earnMoney()"><i class="fas fa-coins"></i> ربح المال</a></li>

            </ul>

        </div>


        <!-- المحتوى الرئيسي -->

        <div class="main-content">

            <!-- الهيدر -->

            <div class="header">

                <div class="header-right">

                    <button class="menu-toggle" onclick="toggleSidebar()">

                        <i class="fas fa-bars"></i>

                    </button>

                    <div class="app-name">

                        <i class="fas fa-star-and-crescent"></i> مسلسلات

                    </div>

                </div>

                <div class="search-wrapper">

                    <div class="search-box">

                        <input type="text" id="searchInput" placeholder="بحث عن مسلسل..." autocomplete="off">

                        <i class="fas fa-search" onclick="performSearch()"></i>

                    </div>

                    <div class="search-suggestions" id="searchSuggestions"></div>

                </div>

            </div>


            <!-- الصفحة الرئيسية -->

            <div id="homeSection">

                <!-- سلايدر -->

                <div class="hero-slider">

                    <div class="swiper" id="heroSwiper">

                        <div class="swiper-wrapper" id="sliderWrapper"></div>

                        <div class="swiper-pagination"></div>

                    </div>

                </div>


                <!-- أحدث المسلسلات -->

                <div class="section">

                    <div class="section-header">

                        <h3 class="section-title"><i class="fas fa-clock"></i> أحدث المسلسلات</h3>

                        <span class="view-all" onclick="showAll('latest')">عرض الكل <i class="fas fa-arrow-left"></i></span>

                    </div>

                    <div class="shows-row" id="latestShowsRow"></div>

                </div>


                <!-- الأكثر مشاهدة -->

                <div class="section">

                    <div class="section-header">

                        <h3 class="section-title"><i class="fas fa-fire"></i> الأكثر مشاهدة</h3>

                        <span class="view-all" onclick="showAll('popular')">عرض الكل <i class="fas fa-arrow-left"></i></span>

                    </div>

                    <div class="shows-row" id="popularShowsRow"></div>

                </div>


                <!-- القنوات -->

                <div class="section">

                    <div class="section-header">

                        <h3 class="section-title"><i class="fas fa-satellite-dish"></i> القنوات</h3>

                        <span class="view-all" onclick="showSection('channels')">عرض الكل <i class="fas fa-arrow-left"></i></span>

                    </div>

                    <div class="shows-row" id="channelsRow"></div>

                </div>

            </div>


            <!-- قسم عرض الكل للمسلسلات -->

            <div id="allShowsSection" style="display: none;">

                <div class="section-header" style="margin-bottom: 1rem;">

                    <h3 class="section-title" id="allShowsTitle"></h3>

                    <span class="view-all" onclick="showSection('home')">العودة <i class="fas fa-arrow-right"></i></span>

                </div>

                <div class="shows-grid" id="allShowsGrid"></div>

            </div>


            <!-- قسم القنوات -->

            <div id="channelsSection" style="display: none;">

                <div class="section-header" style="margin-bottom: 1rem;">

                    <h3 class="section-title"><i class="fas fa-satellite-dish"></i> جميع القنوات</h3>

                    <span class="view-all" onclick="showSection('home')">العودة <i class="fas fa-arrow-right"></i></span>

                </div>

                <div class="shows-row" style="flex-wrap: wrap; overflow-x: visible;" id="allChannelsGrid"></div>

            </div>

        </div>


        <!-- القائمة السفلية -->

        <nav class="bottom-nav">

            <div class="bottom-nav-items">

                <button class="bottom-nav-item active" onclick="showSection('home')"><i class="fas fa-home"></i><span>الرئيسية</span></button>

                <button class="bottom-nav-item" onclick="showSection('channels')"><i class="fas fa-satellite-dish"></i><span>القنوات</span></button>

                <button class="bottom-nav-item" onclick="showAll('latest')"><i class="fas fa-film"></i><span>المسلسلات</span></button>

                <button class="bottom-nav-item" onclick="focusSearch()"><i class="fas fa-search"></i><span>بحث</span></button>

                <button class="bottom-nav-item" onclick="earnMoney()"><i class="fas fa-coins"></i><span>ربح</span></button>

            </div>

        </nav>

    </div>


    <!-- مشغل الفيديو المتطور -->

    <div class="player-overlay" id="playerOverlay">

        <div class="player-container">

            <div class="player-header">

                <h4 class="player-title" id="playerTitle"></h4>

                <button class="close-player" onclick="closePlayer()"><i class="fas fa-times"></i></button>

            </div>

            <div id="videoContainer">

                <video id="videoPlayer" controls></video>

            </div>

            <div class="episodes-section">

                <div class="episodes-title">

                    <i class="fas fa-list"></i> قائمة الحلقات

                </div>

                <div class="episodes-grid" id="episodesGrid"></div>

            </div>

        </div>

    </div>


    <!-- Swiper JS -->

    <script src="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.js"></script>

    <script>

        // ========== إعدادات API ==========

        const API_BASE = 'https://salah.000.pe';

        const PROXY_URL = 'proxy.php?url='; // ملف الوسيط لتشغيل روابط MPD

        

        let allShows = [];

        let allEpisodes = [];

        let swiper = null;

        let searchTimeout;

        let player = null; // مشغل dash.js


        // ========== مطر رمضاني (هلال ونجوم) ==========

        function createRamadanRain() {

            const rain = document.getElementById('ramadanRain');

            rain.innerHTML = '';

            const items = ['🌙', '⭐', '✨', '☪️'];

            

            for (let i = 0; i < 20; i++) {

                const drop = document.createElement('div');

                drop.className = 'rain-item';

                drop.textContent = items[Math.floor(Math.random() * items.length)];

                drop.style.left = Math.random() * 100 + '%';

                drop.style.animationDuration = (Math.random() * 8 + 6) + 's';

                drop.style.animationDelay = Math.random() * 5 + 's';

                drop.style.fontSize = (Math.random() * 12 + 8) + 'px';

                drop.style.opacity = '0.1';

                rain.appendChild(drop);

            }

        }


        // ========== جلب البيانات من API ==========

        async function fetchData() {

            try {

                // جلب المسلسلات

                const response = await fetch(`${API_BASE}/api.php?cat=31`);

                const data = await response.json();

                

                if (data.status === 200 && data.data && data.data.length > 0) {

                    allShows = data.data.map((item, index) => ({

                        id: item.id || index + 1,

                        title: item.title || 'مسلسل',

                        image: item.image || `https://via.placeholder.com/200x260/1a1f2f/ffd966?text=${encodeURIComponent(item.title || '')}`,

                        channel: item.channel || ['MBC', 'DMC', 'ON'][Math.floor(Math.random() * 3)],

                        rating: (Math.random() * 2 + 7).toFixed(1),

                        episodes_count: 30

                    }));


                    // جلب الحلقات - هنا يجب تعديل الرابط حسب API الخاص بك

                    // هذه دالة تجريبية، استبدلها بالرابط الحقيقي

                    try {

                        // مثال: إذا كان API يعيد الحلقات بهذا الشكل

                        const epRes = await fetch(`${API_BASE}/api.php?episodes=all`);

                        const epData = await epRes.json();

                        if (epData.status === 200 && epData.data) {

                            allEpisodes = epData.data;

                        } else {

                            generateSampleEpisodes();

                        }

                    } catch {

                        generateSampleEpisodes();

                    }

                } else {

                    useFallbackData();

                }

                

                loadContent();

            } catch (error) {

                console.log('خطأ في الاتصال، استخدام البيانات الاحتياطية');

                useFallbackData();

                loadContent();

            }

        }


        // ========== بيانات احتياطية ==========

        function useFallbackData() {

            const titles = [

                "المداح", "رامز ليفل", "عين سحرية", "إفراج", "علي كلاي", 

                "الكينج", "فن الحرب", "درش", "أولاد الراعي", "وننسى اللي كان",

                "الست موناليزا", "صحاب الأرض", "هي كيميا", "فرصة أخيرة"

            ];

            

            allShows = titles.map((title, index) => ({

                id: index + 1,

                title: title,

                image: `https://via.placeholder.com/200x260/1a1f2f/ffd966?text=${encodeURIComponent(title)}`,

                channel: ['MBC مصر', 'DMC', 'ON'][Math.floor(Math.random() * 3)],

                rating: (Math.random() * 2 + 7).toFixed(1),

                episodes_count: 30

            }));

            

            generateSampleEpisodes();

        }


        // ========== توليد حلقات تجريبية مع روابط MPD حقيقية ==========

        function generateSampleEpisodes() {

            // هذا مثال على رابط MPD حقيقي من Shahid

            const sampleMPDUrl = 'https://btpls.shahid.net/out/v1/aef15d6bd7f5463cbdce7c7047f6e5f3/7c201da305b543e0ae55a3673f9aa3a5/840aa317c6f34c8fb0ef18117f07c496/index.mpd?aws.manifestfilter=video_height:144-1080;audio_language:ar;subtitle_language:en,fr,ar,it,ja,pt,ru,id,no,es,bn,ms,de,tr,ko,hi,tl,nl,el,pl,ml,ct;video_codec:H264###Udx6QqmgfI44/QuJDUfzwA:tnhgKBkAS7aQ2v3dtJnKnw';

            

            allEpisodes = allShows.map(show => ({

                show_id: show.id,

                episodes: Array.from({ length: show.episodes_count || 15 }, (_, i) => ({

                    number: i + 1,

                    // استخدم الرابط الحقيقي من API الخاص بك هنا

                    watch_url: sampleMPDUrl, // في التطبيق الحقيقي، هذا الرابط سيأتي من API

                    download_url: 'https://38be483c0d4de1db159120c034eb8b17.adnan44.top' // رابط التحميل

                }))

            }));

        }


        // ========== تحميل المحتوى ==========

        function loadContent() {

            // سلايدر

            document.getElementById('sliderWrapper').innerHTML = allShows.slice(0, 5).map(show => `

                <div class="swiper-slide" onclick="playShow(${show.id})" style="background-image: linear-gradient(to bottom, rgba(0,0,0,0.3), rgba(0,0,0,0.8)), url('${show.image}')">

                    <div class="slide-overlay"></div>

                    <div class="slide-content">

                        <div class="slide-title">${show.title}</div>

                    </div>

                </div>

            `).join('');


            // أحدث المسلسلات

            document.getElementById('latestShowsRow').innerHTML = allShows.slice(0, 10).map(show => createCard(show)).join('');


            // الأكثر مشاهدة (مرتبة حسب التقييم)

            const popular = [...allShows].sort((a, b) => b.rating - a.rating);

            document.getElementById('popularShowsRow').innerHTML = popular.slice(0, 10).map(show => createCard(show)).join('');


            // القنوات

            const channels = [

                { name: 'MBC مصر', icon: 'fas fa-tv', color: '#ff4d4d' },

                { name: 'DMC', icon: 'fas fa-satellite', color: '#4dff4d' },

                { name: 'ON', icon: 'fas fa-broadcast-tower', color: '#4d4dff' },

                { name: 'الحياة', icon: 'fas fa-video', color: '#ff4dff' },

                { name: 'CBC', icon: 'fas fa-film', color: '#ffff4d' }

            ];

            

            document.getElementById('channelsRow').innerHTML = channels.map(channel => `

                <div class="show-card" onclick="openChannel('${channel.name}')">

                    <div class="show-poster" style="background: ${channel.color}20">

                        <div style="position:absolute; inset:0; display:flex; align-items:center; justify-content:center">

                            <i class="${channel.icon}" style="color: ${channel.color}; font-size: 2.5rem;"></i>

                        </div>

                        <div class="show-info">

                            <div class="show-title">${channel.name}</div>

                        </div>

                    </div>

                </div>

            `).join('');


            document.getElementById('allChannelsGrid').innerHTML = channels.map(channel => `

                <div class="show-card" onclick="openChannel('${channel.name}')">

                    <div class="show-poster" style="background: ${channel.color}20">

                        <div style="position:absolute; inset:0; display:flex; align-items:center; justify-content:center">

                            <i class="${channel.icon}" style="color: ${channel.color}; font-size: 2.5rem;"></i>

                        </div>

                        <div class="show-info">

                            <div class="show-title">${channel.name}</div>

                        </div>

                    </div>

                </div>

            `).join('');


            // تشغيل السلايدر

            if (swiper) swiper.destroy();

            swiper = new Swiper('#heroSwiper', {

                loop: true,

                autoplay: { delay: 4000 },

                pagination: { el: '.swiper-pagination' }

            });

        }


        function createCard(show) {

            return `

                <div class="show-card" onclick="playShow(${show.id})">

                    <div class="show-poster" style="background-image: url('${show.image}')"></div>

                    <div class="show-info">

                        <div class="show-title">${show.title}</div>

                    </div>

                </div>

            `;

        }


        // ========== عرض الكل ==========

        function showAll(type) {

            let title = '';

            let shows = [];

            

            if (type === 'latest') {

                title = 'أحدث المسلسلات';

                shows = allShows;

            } else if (type === 'popular') {

                title = 'الأكثر مشاهدة';

                shows = [...allShows].sort((a, b) => b.rating - a.rating);

            }

            

            document.getElementById('allShowsTitle').innerHTML = `<i class="fas fa-${type === 'latest' ? 'clock' : 'fire'}"></i> ${title}`;

            document.getElementById('allShowsGrid').innerHTML = shows.map(show => createCard(show)).join('');

            

            document.getElementById('homeSection').style.display = 'none';

            document.getElementById('channelsSection').style.display = 'none';

            document.getElementById('allShowsSection').style.display = 'block';

            

            // تحديث القائمة السفلية

            document.querySelectorAll('.bottom-nav-item').forEach(item => item.classList.remove('active'));

            document.querySelector('.bottom-nav-item:nth-child(3)').classList.add('active');

        }


        // ========== تشغيل المسلسل مع دعم MPD ==========

        function playShow(id) {

            const show = allShows.find(s => s.id == id);

            if (!show) return;

            

            document.getElementById('playerTitle').innerText = show.title;

            

            const episodes = allEpisodes.find(e => e.show_id == id)?.episodes || 

                            Array.from({ length: 15 }, (_, i) => ({ 

                                number: i + 1, 

                                watch_url: `https://btpls.shahid.net/out/v1/aef15d6bd7f5463cbdce7c7047f6e5f3/7c201da305b543e0ae55a3673f9aa3a5/840aa317c6f34c8fb0ef18117f07c496/index.mpd?aws.manifestfilter=video_height:144-1080;audio_language:ar;subtitle_language:en,fr,ar,it,ja,pt,ru,id,no,es,bn,ms,de,tr,ko,hi,tl,nl,el,pl,ml,ct;video_codec:H264###Udx6QqmgfI44/QuJDUfzwA:tnhgKBkAS7aQ2v3dtJnKnw`,

                                download_url: 'https://38be483c0d4de1db159120c034eb8b17.adnan44.top'

                            }));

            

            document.getElementById('episodesGrid').innerHTML = episodes.map(ep => `

                <div class="episode-item" onclick="playVideo('${ep.watch_url}', '${ep.download_url}')">

                    الحلقة ${ep.number}

                </div>

            `).join('');

            

            if (episodes[0]) playVideo(episodes[0].watch_url, episodes[0].download_url);

            

            document.getElementById('playerOverlay').style.display = 'flex';

            document.body.style.overflow = 'hidden';

        }


        // ========== تشغيل الفيديو (MPD أو عادي) ==========

        function playVideo(videoUrl, downloadUrl) {

            const videoElement = document.getElementById('videoPlayer');

            

            // إيقاف أي تشغيل سابق

            if (player) {

                player.reset();

                player = null;

            }

            

            // التحقق من أن الرابط هو MPD

            if (videoUrl.includes('.mpd')) {

                // استخدام proxy.php مع رابط MPD

                const proxyUrl = PROXY_URL + encodeURIComponent(videoUrl);

                

                // إنشاء مشغل dash.js جديد

                player = dashjs.MediaPlayer().create();

                player.initialize(videoElement, proxyUrl, true);

                

                // إضافة مستمع للأخطاء

                player.on(dashjs.MediaPlayer.events.ERROR, (e) => {

                    console.error('Dash.js error:', e);

                    alert('حدث خطأ في تشغيل الفيديو. قد تحتاج إلى تحديث الصفحة.');

                });

            } else {

                // إذا كان الرابط عادي (MP4 مثلاً)

                videoElement.src = videoUrl;

                videoElement.play();

            }

            

            // إضافة زر التحميل إذا وجد

            if (downloadUrl && downloadUrl !== '#') {

                // يمكن إضافة زر تحميل منفصل هنا

                console.log('رابط التحميل:', downloadUrl);

            }

        }


        function closePlayer() {

            // إيقاف التشغيل

            if (player) {

                player.reset();

                player = null;

            }

            

            const videoElement = document.getElementById('videoPlayer');

            videoElement.pause();

            videoElement.removeAttribute('src');

            videoElement.load();

            

            document.getElementById('playerOverlay').style.display = 'none';

            document.body.style.overflow = 'auto';

        }


        // ========== البحث ==========

        function setupSearch() {

            const input = document.getElementById('searchInput');

            const suggestions = document.getElementById('searchSuggestions');


            input.addEventListener('input', () => {

                clearTimeout(searchTimeout);

                const term = input.value.trim().toLowerCase();

                

                if (term.length < 2) {

                    suggestions.style.display = 'none';

                    return;

                }

                

                searchTimeout = setTimeout(() => {

                    const matches = allShows.filter(s => s.title.toLowerCase().includes(term)).slice(0, 5);

                    

                    if (matches.length) {

                        suggestions.innerHTML = matches.map(s => `

                            <div class="suggestion-item" onclick="selectSuggestion(${s.id})">

                                <div class="suggestion-img" style="background-image: url('${s.image}')"></div>

                                ${s.title}

                            </div>

                        `).join('');

                        suggestions.style.display = 'block';

                    } else {

                        suggestions.style.display = 'none';

                    }

                }, 200);

            });


            document.addEventListener('click', (e) => {

                if (!input.contains(e.target) && !suggestions.contains(e.target)) {

                    suggestions.style.display = 'none';

                }

            });

        }


        function selectSuggestion(id) {

            document.getElementById('searchInput').value = '';

            document.getElementById('searchSuggestions').style.display = 'none';

            playShow(id);

        }


        function performSearch() {

            const term = document.getElementById('searchInput').value.trim();

            if (term) {

                const match = allShows.find(s => s.title.includes(term));

                if (match) playShow(match.id);

            }

        }


        // ========== وظائف القائمة والتنقل ==========

        function toggleSidebar() {

            document.getElementById('sidebar').classList.toggle('open');

            document.getElementById('sidebarOverlay').classList.toggle('active');

        }


        function closeSidebar() {

            document.getElementById('sidebar').classList.remove('open');

            document.getElementById('sidebarOverlay').classList.remove('active');

        }


        function showSection(section) {

            document.getElementById('homeSection').style.display = section === 'home' ? 'block' : 'none';

            document.getElementById('channelsSection').style.display = section === 'channels' ? 'block' : 'none';

            document.getElementById('allShowsSection').style.display = 'none';

            

            // تحديث القائمة السفلية

            document.querySelectorAll('.bottom-nav-item').forEach(item => item.classList.remove('active'));

            if (section === 'home') {

                document.querySelector('.bottom-nav-item:first-child').classList.add('active');

            } else if (section === 'channels') {

                document.querySelector('.bottom-nav-item:nth-child(2)').classList.add('active');

            }

            

            closeSidebar();

        }


        function openChannel(name) {

            alert(`قناة ${name}\nسيتم إضافة المحتوى قريباً`);

        }


        function shareApp() {

            if (navigator.share) {

                navigator.share({

                    title: 'مسلسلات رمضان 2026',

                    text: 'تطبيق لمشاهدة جميع مسلسلات رمضان',

                    url: window.location.href

                });

            } else {

                navigator.clipboard?.writeText(window.location.href);

                alert('تم نسخ رابط التطبيق');

            }

        }


        function showAbout() {

            alert('تطبيق مسلسلات رمضان 2026\nالإصدار 2.0 - مع دعم تشغيل روابط MPD');

        }


        function contactUs() {

            alert('للتواصل: support@ramadan-series.com');

        }


        function earnMoney() {

            alert('💰 برنامج الربح من المشاهدة\nقريباً...');

        }


        function focusSearch() {

            document.getElementById('searchInput').focus();

        }


        // ========== صفحة التحميل ==========

        function showSplashAndStart() {

            const splash = document.getElementById('splashScreen');

            const progressBar = document.getElementById('progressBar');

            const app = document.getElementById('appContainer');

            

            let progress = 0;

            const interval = setInterval(() => {

                progress += 1;

                progressBar.style.width = progress + '%';

                

                if (progress >= 100) {

                    clearInterval(interval);

                    setTimeout(() => {

                        splash.style.opacity = '0';

                        setTimeout(() => {

                            splash.style.display = 'none';

                            app.style.opacity = '1';

                        }, 400);

                    }, 300);

                }

            }, 15);

        }


        // ========== تهيئة التطبيق ==========

        window.onload = () => {

            createRamadanRain();

            showSplashAndStart();

            fetchData();

            setupSearch();

            setInterval(createRamadanRain, 600000);

        };

    </script>

</body>

</html>

Comments