<!DOCTYPE html>
<html dir="rtl" lang="ar">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>MONSTERMC</title>
    <meta name="description" content="موقع MONSTERMC للأداوات الخاصه">
    <meta name="keywords" content="MONSTERMC, Rat, Tools, Crypter, Fud, Exploit, Course Cybersecurity">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    
        @import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700&display=swap');

        :root {
            --primary: #007bff;
            --secondary: #00ff88;
            --dark: #0a0a0a;
            --card-bg: #111111;
            --border: #2a2a2a;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Tajawal', system-ui, sans-serif;
        }

        body {
            background-color: var(--dark);
            color: #ffffff;
        }

        .header {
            background-color: rgba(17, 17, 17, 0.95);
            padding: 1.5rem;
            position: fixed;
            width: 100%;
            top: 0;
            z-index: 100;
            backdrop-filter: blur(10px);
            box-shadow: 0 2px 20px rgba(0,0,0,0.5);
            transition: padding 0.3s ease;
        }

        .header.scrolled {
            padding: 1rem;
        }

        .nav-container {
            max-width: 1400px;
            margin: 0 auto;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .logo-text {
            font-size: 2rem;
            font-weight: 700;
            background: linear-gradient(45deg, var(--primary), var(--secondary));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            text-shadow: 0 2px 10px rgba(0,123,255,0.3);
        }

        .social-links {
            display: flex;
            gap: 1.5rem;
        }

        .social-link {
            color: #fff;
            font-size: 1.5rem;
            transition: all 0.3s ease;
            opacity: 0;
            animation: slideIn 0.5s ease forwards;
        }

        .social-link.telegram:hover { color: #0088cc; }
        .social-link.discord:hover { color: #7289da; }
		.social-link.chat:hover { color: #4caf50; }

        .container {
            max-width: 1400px;
            margin: 7rem auto 2rem;
            padding: 2rem;
        }

        .features-section {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
            gap: 2rem;
            margin: 2rem auto;
        }

        .feature-card {
            background: linear-gradient(145deg, #111111, #1a1a1a);
            border-radius: 20px;
            padding: 2.5rem;
            text-align: center;
            border: 1px solid var(--border);
            transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
            position: relative;
            opacity: 0;
            transform: translateY(30px);
            animation: featureCardFadeIn 0.6s ease forwards;
        }

        .feature-card:nth-child(1) { animation-delay: 0.2s; }
        .feature-card:nth-child(2) { animation-delay: 0.4s; }
        .feature-card:nth-child(3) { animation-delay: 0.6s; }
        .feature-card:nth-child(4) { animation-delay: 0.8s; }

        @keyframes featureCardFadeIn {
            from {
                opacity: 0;
                transform: translateY(30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .feature-card:hover {
            transform: translateY(-10px);
            border-color: var(--primary);
            box-shadow: 0 10px 30px rgba(0,123,255,0.2);
        }

        .feature-icon {
            font-size: 3rem;
            margin-bottom: 1.5rem;
            background: linear-gradient(45deg, var(--primary), var(--secondary));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }

        .feature-title {
            font-size: 1.5rem;
            margin-bottom: 1rem;
        }

        .feature-description {
            color: #aaa;
            line-height: 1.6;
        }

        .search-container {
            margin-bottom: 2rem;
            opacity: 0;
            animation: fadeIn 1s ease 0.3s forwards;
        }

        .search-input {
            width: 100%;
            max-width: 600px;
            padding: 1.2rem 1.8rem;
            background: rgba(26, 26, 26, 0.8);
            border: 2px solid var(--border);
            border-radius: 12px;
            color: white;
            font-size: 1.1rem;
            backdrop-filter: blur(8px);
            margin: 0 auto;
            display: block;
            transition: all 0.3s ease;
        }

        .search-input:focus {
            outline: none;
            border-color: var(--primary);
            box-shadow: 0 0 0 4px rgba(0,123,255,0.15);
            transform: scale(1.02);
        }

        .tabs {
            display: flex;
            justify-content: center;
            gap: 1rem;
            margin-bottom: 3rem;
            opacity: 0;
            animation: fadeIn 1s ease 0.5s forwards;
            flex-wrap: wrap;
        }

        .tab-button {
            padding: 1rem 2.5rem;
            background: linear-gradient(45deg, rgba(0,123,255,0.1), rgba(0,255,136,0.1));
            border: 2px solid var(--border);
            color: white;
            font-weight: 500;
            border-radius: 12px;
            cursor: pointer;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }

        .tab-button:hover {
            background: linear-gradient(45deg, rgba(0,123,255,0.2), rgba(0,255,136,0.2));
            transform: translateY(-2px);
        }

        .tab-button.active {
            background: linear-gradient(45deg, var(--primary), var(--secondary));
            border: none;
            box-shadow: 0 4px 12px rgba(0,123,255,0.3);
        }

        .tools-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
            gap: 2.5rem;
            opacity: 0;
            animation: fadeIn 1s ease 0.7s forwards;
        }

        /* تحسين بطاقات المنتجات - الجزء الأهم */
        .tool-card {
            background: linear-gradient(145deg, #111111, #1a1a1a);
            border-radius: 20px;
            overflow: hidden;
            transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
            border: 1px solid var(--border);
            opacity: 0;
            transform: translateY(20px);
            animation: cardAppear 0.6s ease forwards;
            /* إضافة ارتفاع ثابت للبطاقات */
            display: flex;
            flex-direction: column;
            height: auto;
            min-height: 500px;
        }

        .tool-card:hover {
            transform: translateY(-10px);
            border-color: var(--primary);
            box-shadow: 0 10px 30px rgba(0,123,255,0.2);
        }

        .tool-image {
            height: 250px;
            position: relative;
            overflow: hidden;
            flex-shrink: 0; /* منع تقليص الصورة */
        }

        .tool-image img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            transition: transform 0.5s ease;
        }

        .tool-card:hover .tool-image img {
            transform: scale(1.1);
        }

        /* تحسين محتوى البطاقة */
        .tool-content {
            padding: 2rem;
            display: flex;
            flex-direction: column;
            flex-grow: 1;
            justify-content: space-between;
        }

        .tool-content-top {
            flex-grow: 1;
        }

        .tool-content-bottom {
            margin-top: auto;
            padding-top: 1rem;
        }

        .category-tag {
            display: inline-block;
            padding: 0.5rem 1rem;
            background: linear-gradient(45deg, rgba(0,123,255,0.1), rgba(0,255,136,0.1));
            border-radius: 8px;
            font-size: 0.9rem;
            margin-bottom: 1rem;
            border: 1px solid rgba(0,123,255,0.2);
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .category-tag:hover {
            background: linear-gradient(45deg, rgba(0,123,255,0.2), rgba(0,255,136,0.2));
            transform: translateY(-2px);
            box-shadow: 0 2px 8px rgba(0,123,255,0.2);
        }

        .tool-title {
            font-size: 1.4rem;
            margin-bottom: 1rem;
            color: #fff;
            line-height: 1.3;
            /* تحديد ارتفاع ثابت للعنوان */
            min-height: 3.6rem;
            display: flex;
            align-items: center;
        }

        .tool-description {
            color: #aaa;
            margin-bottom: 1.5rem;
            line-height: 1.6;
            /* تحديد ارتفاع ثابت للوصف */
            min-height: 4.8rem;
            display: -webkit-box;
            -webkit-line-clamp: 3;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }

        /* تحسين الأزرار */
        .tool-buttons {
            display: flex;
            gap: 10px;
            justify-content: center;
            flex-wrap: wrap;
            margin-bottom: 1rem;
        }

        .tool-button {
            display: inline-block;
            padding: 0.8rem 1.5rem;
            background: linear-gradient(45deg, var(--primary), var(--secondary));
            color: white;
            text-decoration: none;
            border-radius: 12px;
            font-weight: 500;
            transition: all 0.3s ease;
            position: relative;
            overflow: hidden;
            flex: 1;
            min-width: 120px;
            text-align: center;
        }

        .tool-button.secondary {
            background: rgba(255,255,255,0.1);
            border: 1px solid #00ff88;
        }

        .tool-button:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(0,123,255,0.3);
        }

        .views {
            margin-top: 0.5rem;
            font-size: 0.9rem;
            color: #bbb;
            text-align: center;
            padding: 0.5rem;
            background: rgba(255,255,255,0.05);
            border-radius: 8px;
        }

        .favorite-button {
            position: absolute;
            top: 1rem;
            right: 1rem;
            background: rgba(0, 0, 0, 0.5);
            border: 2px solid rgba(255, 255, 255, 0.2);
            border-radius: 50%;
            width: 40px;
            height: 40px;
            color: #fff;
            font-size: 1.2rem;
            cursor: pointer;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            z-index: 1;
            backdrop-filter: blur(4px);
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .favorite-button:hover {
            transform: scale(1.1);
            background: rgba(255, 255, 255, 0.1);
            border-color: rgba(255, 255, 255, 0.3);
        }

        .favorite-button.active {
            background: rgba(255, 77, 77, 0.2);
            border-color: rgba(255, 77, 77, 0.4);
            color: #ff4d4d;
            animation: favorite-pulse 1.5s infinite;
        }

        @keyframes favorite-pulse {
            0% {
                transform: scale(1);
                box-shadow: 0 0 0 0 rgba(255, 77, 77, 0.4);
            }
            70% {
                transform: scale(1.05);
                box-shadow: 0 0 0 10px rgba(255, 77, 77, 0);
            }
            100% {
                transform: scale(1);
                box-shadow: 0 0 0 0 rgba(255, 77, 77, 0);
            }
        }

        .hero-section {
            min-height: 90vh;
            display: flex;
            align-items: center;
            justify-content: center;
            text-align: center;
            padding: 6rem 2rem;
            margin-bottom: 2rem;
            position: relative;
            overflow: hidden;
        }

        .hero-background {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            z-index: -1;
        }

        .gradient-sphere {
            position: absolute;
            border-radius: 50%;
            filter: blur(80px);
        }

        .sphere-1 {
            width: 400px;
            height: 400px;
            background: linear-gradient(45deg, rgba(0,123,255,0.2), rgba(0,255,136,0.2));
            top: -100px;
            left: -100px;
            animation: float 8s ease-in-out infinite;
        }

        .sphere-2 {
            width: 300px;
            height: 300px;
            background: linear-gradient(45deg, rgba(0,255,136,0.2), rgba(0,123,255,0.2));
            bottom: -50px;
            right: -50px;
            animation: float 6s ease-in-out infinite reverse;
        }

        .grid-overlay {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-image: linear-gradient(var(--border) 1px, transparent 1px),
                              linear-gradient(90deg, var(--border) 1px, transparent 1px);
            background-size: 30px 30px;
            opacity: 0.1;
        }

        .hero-content {
            max-width: 800px;
            position: relative;
            z-index: 1;
        }

        .badge {
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.5rem 1rem;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 50px;
            margin-bottom: 2rem;
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.1);
        }

        .pulse {
            width: 8px;
            height: 8px;
            background: var(--secondary);
            border-radius: 50%;
            animation: pulse 2s infinite;
        }

        .hero-title {
            font-size: 5.5rem;
            font-weight: 700;
            margin-bottom: 1.5rem;
            background: linear-gradient(45deg, var(--primary), var(--secondary));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            animation: fadeInUp 1s ease;
            text-shadow: 0 0 30px rgba(0,123,255,0.3);
        }

        .hero-description {
            font-size: 1.8rem;
            color: #aaa;
            line-height: 1.6;
            margin-bottom: 2.5rem;
            animation: fadeInUp 1s ease 0.2s backwards;
        }

        .hero-buttons {
            display: flex;
            gap: 1rem;
            justify-content: center;
            margin-bottom: 3rem;
            animation: fadeInUp 1s ease 0.4s backwards;
        }

        .hero-button {
            padding: 1rem 2.5rem;
            font-size: 1.2rem;
            border-radius: 50px;
            cursor: pointer;
            transition: all 0.3s ease;
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
        }

        .hero-button.primary {
            background: linear-gradient(45deg, var(--primary), var(--secondary));
            border: none;
            color: white;
        }

        .hero-button.secondary {
            background: transparent;
            border: 1px solid var(--border);
            color: #fff;
        }

        .hero-button:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 20px rgba(0,123,255,0.2);
        }

        .hero-stats {
            display: flex;
            justify-content: center;
            gap: 3rem;
            animation: fadeInUp 1s ease 0.6s backwards;
        }

        .stat-item {
            display: flex;
            flex-direction: column;
            gap: 0.5rem;
        }

        .stat-number {
            font-size: 2rem;
            font-weight: 700;
            background: linear-gradient(45deg, var(--primary), var(--secondary));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }

        .stat-label {
            color: #aaa;
            font-size: 0.9rem;
        }

        @keyframes float {
            0%, 100% { transform: translate(0, 0); }
            50% { transform: translate(20px, 20px); }
        }

        @keyframes pulse {
            0% { box-shadow: 0 0 0 0 rgba(0,255,136,0.4); }
            70% { box-shadow: 0 0 0 10px rgba(0,255,136,0); }
            100% { box-shadow: 0 0 0 0 rgba(0,255,136,0); }
        }

        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }

        @keyframes slideIn {
            from { 
                opacity: 0;
                transform: translateX(-20px);
            }
            to { 
                opacity: 1;
                transform: translateX(0);
            }
        }

        @keyframes cardAppear {
            from { 
                opacity: 0;
                transform: translateY(20px);
            }
            to { 
                opacity: 1;
                transform: translateY(0);
            }
        }

        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        /* تحسينات الهاتف المحمول */
        @media (max-width: 768px) {
            .container {
                padding: 1rem;
            }
            
            .tools-grid {
                grid-template-columns: 1fr;
            }

            .nav-container {
                flex-direction: column;
                gap: 1rem;
            }

            .feature-card {
                padding: 2rem;
            }

            .tool-image {
                height: 200px;
            }

            .tabs {
                flex-wrap: wrap;
                gap: 0.5rem;
            }

            .tab-button {
                flex: 1;
                min-width: calc(33.33% - 0.33rem);
                font-size: 0.9rem;
                padding: 0.8rem 1rem;
            }

            .hero-title {
                font-size: 3.5rem;
            }
            
            .hero-description {
                font-size: 1.4rem;
            }

            .hero-buttons {
                flex-direction: column;
            }

            .hero-stats {
                flex-direction: column;
                gap: 1.5rem;
            }

            .tool-buttons {
                flex-direction: column;
            }

            .tool-button {
                flex: none;
            }
        }

        .modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0,0,0,0.9);
            z-index: 1000;
            opacity: 0;
            transition: opacity 0.3s ease;
        }

        .modal.active {
            opacity: 1;
        }

        .modal-content {
            background: linear-gradient(145deg, #111111, #1a1a1a);
            border-radius: 20px;
            padding: 3rem;
            max-width: 1000px;
            width: 90%;
            margin: 2rem auto;
            position: relative;
            transform: translateY(-50px);
            opacity: 0;
            transition: all 0.3s ease;
            border: 1px solid var(--border);
        }

        .modal.active .modal-content {
            transform: translateY(0);
            opacity: 1;
        }

        .close-button {
            position: absolute;
            top: 1rem;
            left: 1rem;
            font-size: 1.5rem;
            cursor: pointer;
            color: #fff;
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background: rgba(255,255,255,0.1);
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.3s ease;
        }

        .close-button:hover {
            background: rgba(255,255,255,0.2);
            transform: rotate(90deg);
        }

        .removing-favorite {
            animation: removeCard 0.3s ease-in-out forwards;
        }

        @keyframes removeCard {
            0% { transform: scale(1); opacity: 1; }
            100% { transform: scale(0.8); opacity: 0; }
        }
    
	   <!-- استدعاء ملف SEO -->
   <script src="monstermc-seo.js"></script>
</head>
<body>
    <div class="hero-section">
        <div class="hero-background">
            <div class="gradient-sphere sphere-1"></div>
            <div class="gradient-sphere sphere-2"></div>
            <div class="grid-overlay"></div>
        </div>
        <div class="hero-content">
            <div class="badge">
                <span class="pulse"></span>
                Available now
            </div>
            <h1 class="hero-title">MONSTERMC</h1>
            <p class="hero-description">The most powerful site for security tools and advanced services in the Arab world.</p>
            <div class="hero-buttons">
                <button class="hero-button primary" onclick="scrollToTools()">
                    Start now
                    <i class="fas fa-arrow-down"></i>
                </button>
                <button class="hero-button secondary">
                    Contact us
                    <i class="fas fa-envelope"></i>
                </button>
            </div>
            <div class="hero-stats">
                <div class="stat-item">
                    <span class="stat-number">1000+</span>
                    <span class="stat-label">Active user</span>
                </div>
                <div class="stat-item">
                    <span class="stat-number">50+</span>
                    <span class="stat-label">Tool available</span>
                </div>
                <div class="stat-item">
                    <span class="stat-number">24/7</span>
                    <span class="stat-label">Technical support</span>
                </div>
            </div>
        </div>
    </div>

<header class="header">
    <div class="nav-container">
        <div class="logo-section">
            <h1 class="logo-text">MONSTERMC</h1>
        </div>
        <div class="social-links">
            <a href="https://t.me/MONSTERMCSY1" class="social-link telegram" target="_blank">
                <i class="fab fa-telegram"></i>
            </a>
            <a href="https://discord.gg/vaGzJtVQtt" class="social-link discord" target="_blank">
                <i class="fab fa-discord"></i>
            </a>
            <a href="https://monstermc.com/Anonymous-Message/index.html" class="social-link chat" target="_blank">
                <i class="fas fa-comments"></i>
            </a>
        </div>
    </div>
</header>


    <div class="container">
        <div class="features-section">
            <div class="feature-card">
                <i class="fas fa-shield-alt feature-icon"></i>
                <h3 class="feature-title">Advanced protection</h3>
                <p class="feature-description">The latest protection and encryption technologies to ensure the security of your data</p>
            </div>
            <div class="feature-card">
                <i class="fas fa-rocket feature-icon"></i>
                <h3 class="feature-title">Superior performance</h3>
                <p class="feature-description">Speed ​​and quick handling with powerful tools</p>
            </div>
            <div class="feature-card">
                <i class="fas fa-headset feature-icon"></i>
                <h3 class="feature-title">24/7 support</h3>
                <p class="feature-description">Technical support team is available all the time</p>
            </div>
            <div class="feature-card">
                <i class="fas fa-sync-alt feature-icon"></i>
                <h3 class="feature-title">Continuous updates</h3>
                <p class="feature-description">Update automatically</p>
            </div>
        </div>

        <div class="search-container">
            <input type="text" class="search-input" placeholder="Find tools..." onkeyup="searchTools()">
        </div>

        <div class="tabs">
            <button class="tab-button active" onclick="filterTools('all')">All tools</button>
            <button class="tab-button" onclick="filterTools('free')">Free tools</button>
            <button class="tab-button" onclick="filterTools('paid')">Paid tools</button>
            <button class="tab-button" onclick="filterTools('rat')">RAT</button>
            <button class="tab-button" onclick="filterTools('crypter')">Crypter</button>
            <button class="tab-button" onclick="filterTools('course')">Courses</button>
            <button class="tab-button" onclick="filterTools('exploit')">Exploits</button>
            <button class="tab-button" onclick="filterTools('web')">Web</button>
            <button class="tab-button" onclick="filterTools('different tools')">Different Tools</button>
            <button class="tab-button" onclick="filterTools('favorites')">Favorites</button>
        </div>
        
        <div class="tools-grid" id="tools-container">
            <!-- سيتم تحميل المنتجات هنا -->
        </div>          
    </div>

    <div class="modal" id="toolModal">
        <div class="modal-content">
            <span class="close-button" onclick="closeModal()">&times;</span>
            <div id="modalContent"></div>
        </div>
    </div>

    <footer style="text-align: center; padding: 2rem 1rem; background: linear-gradient(145deg, #111111, #1a1a1a); border-top: 1px solid var(--border); margin-top: 3rem;">
        <p style="font-size: 1.1rem; color: #aaa;">
            بِسْمِ اللهِ نَحْتَسِبُ، وبِـ 
            <a href="https://github.com/noradlb1" target="_blank" style="background: linear-gradient(45deg, var(--primary), var(--secondary)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; font-weight: bold; text-decoration: none;">
                لا إله إلا الله
            </a>
            نَحْيَا، وعليها نَمُوت، وبها نلقى الله ❤ فهي كَلِمَةُ التَّقْوَى، وميثاقُ الفِطْرَة، ومفتاحُ الجنة.
        </p>
    </footer>

    <script>
        // متغيرات عامة
        let allProducts = [];
        let globalViewCounts = {};

        // تحميل البيانات عند بدء الصفحة
        document.addEventListener('DOMContentLoaded', function() {
            loadProducts();
            loadFavorites();
            updateToolCount();
        });

        // تحميل المنتجات
       async function loadProducts() {
    try {
        // تحميل البيانات الحقيقية من products.json
        const response = await fetch(`products.json?v=${new Date().getTime()}`);
        const products = await response.json();
        allProducts = products;
        displayProducts(allProducts);
        updateSiteStats();
    } catch (error) {
        console.error('خطأ في تحميل المنتجات:', error);
        showErrorMessage();
    }
}

        // عرض المنتجات
        function displayProducts(products) {
            const container = document.getElementById('tools-container');
            container.innerHTML = '';

            if (products.length === 0) {
                container.innerHTML = `
                    <div style="grid-column: 1/-1; text-align: center; padding: 3rem; color: #aaa;">
                        <i class="fas fa-search" style="font-size: 3rem; margin-bottom: 1rem; opacity: 0.5;"></i>
                        <h3>لا توجد نتائج</h3>
                        <p>لم يتم العثور على أدوات تطابق البحث</p>
                    </div>
                `;
                return;
            }

            products.forEach((product, index) => {
                const card = createProductCard(product, index);
                container.appendChild(card);
                
                // تحديث عداد المشاهدات لكل منتج
                updateProductViews(product.title, card);
            });
        }

        // إنشاء بطاقة المنتج المحسنة
       // في دالة createProductCard - حيث بتنشئ كروت المنتجات
function createProductCard(product, index) {
    const card = document.createElement('div');
    card.className = 'tool-card';
    card.setAttribute('data-category', product.type);
    card.setAttribute('data-type', product.category.toLowerCase());

    // التحقق من حالة التفعيل
    if (!(product.active ?? true)) {
        return null; // لا تعرض المنتجات المعطلة
    }

    // إنشاء علامة "جديد" وتاريخ
    const isNew = product.is_new ?? false;
    const createdDate = product.created_at ? new Date(product.created_at) : null;
    
    let newBadge = '';
    let dateDisplay = '';
    
    if (isNew) {
        newBadge = '<span class="new-badge">🔥 جديد</span>';
    }
    
    if (createdDate) {
        const now = new Date();
        const diffTime = Math.abs(now - createdDate);
        const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
        
        if (diffDays === 1) {
            dateDisplay = '<span class="date-badge">📅 اليوم</span>';
        } else if (diffDays <= 7) {
            dateDisplay = `<span class="date-badge">📅 منذ ${diffDays} أيام</span>`;
        } else if (diffDays <= 30) {
            dateDisplay = `<span class="date-badge">📅 منذ ${Math.ceil(diffDays/7)} أسابيع</span>`;
        }
    }

    const buyButton = (product.buy_link && product.buy_text)
        ? `<a href="${product.buy_link}" target="_blank" class="tool-button">${product.buy_text}</a>`
        : '';

    const demoButton = (product.demo_link && product.demo_text)
        ? `<a href="${product.demo_link}" target="_blank" class="tool-button secondary">${product.demo_text}</a>`
        : '';

    const buttonsHtml = (buyButton || demoButton) 
        ? `<div class="tool-buttons">${buyButton}${demoButton}</div>` 
        : '';

    card.innerHTML = `
        <button class="favorite-button" onclick="toggleFavorite(event, this)">
            <i class="fas fa-heart"></i>
        </button>
        <div class="tool-image">
            <img src="${product.image}" alt="${product.title}" loading="lazy">
        </div>
        <div class="tool-content">
            <div class="tool-content-top">
<div class="badges-container">
    <div class="special-badges">
        ${newBadge}
        ${dateDisplay}
    </div>
    <div class="category-section">
        <span class="category-tag" onclick="filterByCategory('${product.category}')">${product.category}</span>
    </div>
</div>
                <h2 class="tool-title">${product.title}</h2>
                <p class="tool-description">${product.description}</p>
            </div>
            <div class="tool-content-bottom">
                ${buttonsHtml}
                <div class="views" data-product="${product.title}">
                    <i class="fas fa-eye"></i> جاري التحميل...
                </div>
            </div>
        </div>
    `;

    return card;
}

        // تحديث عداد المشاهدات المحسن
        function updateProductViews(productTitle, cardElement) {
            // محاكاة عداد المشاهدات (استبدل هذا بـ API حقيقي)
            const simulatedViews = Math.floor(Math.random() * 500) + 50;
            
            // حفظ العداد في المتغير العام
            globalViewCounts[productTitle] = simulatedViews;
            
            // تحديث العرض
            const viewsElement = cardElement.querySelector('.views');
            if (viewsElement) {
                setTimeout(() => {
                    viewsElement.innerHTML = `<i class="fas fa-eye"></i> ${simulatedViews} مشاهدة`;
                }, Math.random() * 1000 + 500); // تأخير عشوائي للواقعية
            }
        }

        // البحث المحسن
        function searchTools() {
            const searchTerm = document.querySelector('.search-input').value.toLowerCase().trim();
            
            if (searchTerm === '') {
                displayProducts(allProducts);
                return;
            }

            const filteredProducts = allProducts.filter(product => {
                return product.title.toLowerCase().includes(searchTerm) ||
                       product.description.toLowerCase().includes(searchTerm) ||
                       product.category.toLowerCase().includes(searchTerm);
            });

            displayProducts(filteredProducts);
            
            // إضافة تأثير بصري للبحث
            const searchInput = document.querySelector('.search-input');
            searchInput.style.transform = 'scale(1.02)';
            setTimeout(() => {
                searchInput.style.transform = 'scale(1)';
            }, 200);
        }

        // تصفية الأدوات المحسنة
        function filterTools(category) {
            const buttons = document.querySelectorAll('.tab-button');
            buttons.forEach(button => button.classList.remove('active'));
            event.target.classList.add('active');
            
            let filteredProducts = [];

            switch(category) {
                case 'all':
                    filteredProducts = allProducts;
                    break;
                case 'favorites':
                    const favorites = JSON.parse(localStorage.getItem('favorites') || '[]');
                    filteredProducts = allProducts.filter(product => 
                        favorites.includes(product.title)
                    );
                    break;
                case 'free':
                case 'paid':
                    filteredProducts = allProducts.filter(product => 
                        product.type === category
                    );
                    break;
                default:
                    filteredProducts = allProducts.filter(product => 
                        product.category.toLowerCase() === category.toLowerCase()
                    );
            }

            displayProducts(filteredProducts);
            
            // تأثير بصري للتبديل
            const toolsGrid = document.querySelector('.tools-grid');
            toolsGrid.style.opacity = '0.7';
            setTimeout(() => {
                toolsGrid.style.opacity = '1';
            }, 300);
        }

        // تصفية حسب الفئة من العلامة
        function filterByCategory(category) {
            const buttons = document.querySelectorAll('.tab-button');
            buttons.forEach(button => button.classList.remove('active'));
            
            const filteredProducts = allProducts.filter(product => 
                product.category === category
            );
            
            displayProducts(filteredProducts);
            
            // تمييز الزر المناسب
            buttons.forEach(button => {
                if (button.textContent.toLowerCase().includes(category.toLowerCase())) {
                    button.classList.add('active');
                }
            });
        }

        // إدارة Favorites المحسنة
        function toggleFavorite(event, button) {
            event.stopPropagation();
            button.classList.toggle('active');
            
            const toolCard = button.closest('.tool-card');
            const toolTitle = toolCard.querySelector('.tool-title').textContent;
            
            let favorites = JSON.parse(localStorage.getItem('favorites') || '[]');
            
            if (button.classList.contains('active')) {
                if (!favorites.includes(toolTitle)) {
                    favorites.push(toolTitle);
                    // تأثير بصري للإضافة
                    button.style.transform = 'scale(1.3)';
                    setTimeout(() => {
                        button.style.transform = 'scale(1)';
                    }, 200);
                }
            } else {
                favorites = favorites.filter(title => title !== toolTitle);
                
                // إذا كنا في صفحة Favorites، أخفِ البطاقة
                const favTab = document.querySelector('.tab-button[onclick*="favorites"]');
                if (favTab && favTab.classList.contains('active')) {
                    toolCard.classList.add('removing-favorite');
                    setTimeout(() => {
                        toolCard.style.display = 'none';
                        toolCard.classList.remove('removing-favorite');
                    }, 300);
                }
            }
            
            localStorage.setItem('favorites', JSON.stringify(favorites));
        }

        // تحميل Favorites عند بدء الصفحة
        function loadFavorites() {
            const favorites = JSON.parse(localStorage.getItem('favorites') || '[]');
            
            // تأخير صغير للتأكد من تحميل المنتجات أولاً
            setTimeout(() => {
                document.querySelectorAll('.tool-card').forEach(card => {
                    const toolTitle = card.querySelector('.tool-title').textContent;
                    const favoriteButton = card.querySelector('.favorite-button');
                    
                    if (favorites.includes(toolTitle)) {
                        favoriteButton.classList.add('active');
                    }
                });
            }, 500);
        }

        // تحديث إحصائيات الموقع
        function updateSiteStats() {
            const toolCount = allProducts.length;
            const userCount = 1000 + Math.floor(Math.random() * 500); // عدد وهمي
            
            const toolStatElement = document.querySelector('.stat-item:nth-child(2) .stat-number');
            const userStatElement = document.querySelector('.stat-item:nth-child(1) .stat-number');
            
            if (toolStatElement) {
                animateNumber(toolStatElement, toolCount);
            }
            
            if (userStatElement) {
                animateNumber(userStatElement, userCount);
            }
        }

        // تحريك الأرقام
        function animateNumber(element, target) {
            let current = 0;
            const increment = target / 20;
            const timer = setInterval(() => {
                current += increment;
                if (current >= target) {
                    current = target;
                    clearInterval(timer);
                }
                element.textContent = Math.floor(current) + '+';
            }, 50);
        }

        // عرض رسالة خطأ
        function showErrorMessage() {
            const container = document.getElementById('tools-container');
            container.innerHTML = `
                <div style="grid-column: 1/-1; text-align: center; padding: 3rem; color: #ff4d4d;">
                    <i class="fas fa-exclamation-triangle" style="font-size: 3rem; margin-bottom: 1rem;"></i>
                    <h3>خطأ في التحميل</h3>
                    <p>حدث خطأ أثناء تحميل المنتجات. يرجى المحاولة مرة أخرى.</p>
                    <button onclick="loadProducts()" style="margin-top: 1rem; padding: 0.5rem 1rem; background: var(--primary); color: white; border: none; border-radius: 8px; cursor: pointer;">
                        إعادة المحاولة
                    </button>
                </div>
            `;
        }

        // التمرير إلى الأدوات
        function scrollToTools() {
            const featuresSection = document.querySelector('.features-section');
            const header = document.querySelector('.header');
            const headerHeight = header.offsetHeight;
            
            window.scrollTo({
                top: featuresSection.offsetTop - headerHeight - 20,
                behavior: 'smooth'
            });
        }

        // تأثير التمرير للهيدر
        window.addEventListener('scroll', () => {
            const header = document.querySelector('.header');
            if (window.scrollY > 50) {
                header.classList.add('scrolled');
            } else {
                header.classList.remove('scrolled');
            }
        });

        // إدارة النافذة المنبثقة
        function showToolDetails(toolCard) {
            const modal = document.getElementById('toolModal');
            const modalContent = document.getElementById('modalContent');
            const toolContent = toolCard.innerHTML;
            
            modalContent.innerHTML = toolContent;
            modal.style.display = 'block';
            setTimeout(() => {
                modal.classList.add('active');
            }, 10);

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

        function closeModal() {
            const modal = document.getElementById('toolModal');
            modal.classList.remove('active');
            setTimeout(() => {
                modal.style.display = 'none';
            }, 300);

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

        // إغلاق النافذة المنبثقة بالنقر خارجها أو بمفتاح Escape
        window.onclick = function(event) {
            const modal = document.getElementById('toolModal');
            if (event.target === modal) {
                closeModal();
            }
        }

        document.addEventListener('keydown', function(event) {
            if (event.key === 'Escape') {
                closeModal();
            }
        });

        // تحسين الأداء: تحميل الصور بطريقة lazy
        function lazyLoadImages() {
            const images = document.querySelectorAll('img[loading="lazy"]');
            
            if ('IntersectionObserver' in window) {
                const imageObserver = new IntersectionObserver((entries) => {
                    entries.forEach(entry => {
                        if (entry.isIntersecting) {
                            const img = entry.target;
                            img.classList.add('loaded');
                            imageObserver.unobserve(img);
                        }
                    });
                });

                images.forEach(img => imageObserver.observe(img));
            }
        }

        // تشغيل lazy loading بعد تحميل الصفحة
        document.addEventListener('DOMContentLoaded', lazyLoadImages);

        // إضافة تأثيرات صوتية (اختيارية)
        function playClickSound() {
            // يمكن إضافة صوت نقر هنا إذا رغبت
        }

        // إضافة متابعة للنقرات على الأزرار
        document.addEventListener('click', function(event) {
            if (event.target.classList.contains('tool-button') || 
                event.target.classList.contains('tab-button') || 
                event.target.classList.contains('hero-button')) {
                playClickSound();
            }
        });

        // حماية من النسخ (اختيارية)
        document.addEventListener('selectstart', function(e) {
            // يمكن منع تحديد النص إذا رغبت
        });

        // تحديث عام للصفحة
        function updateToolCount() {
            // سيتم تحديث العدد تلقائياً عند تحميل المنتجات
        }
    </script>
</body>
</html>