<?php
// Session Start
if (session_status() === PHP_SESSION_NONE) {
    session_start();
}
require_once 'config/database.php';

// ১. হোস্টিং প্যাকেজগুলো আনা (Top 3)
$packages = [];
try {
    $stmt = $db->query("SELECT * FROM hosting_packages WHERE status='active' ORDER BY id ASC LIMIT 3");
    $packages = $stmt->fetchAll();
} catch(PDOException $e) {}

// ২. ডোমেইন প্রাইসিং আনা
$domains = [];
try {
    $stmt = $db->query("SELECT * FROM domain_pricing WHERE status='active' ORDER BY id ASC");
    $domains = $stmt->fetchAll();
} catch(PDOException $e) {}

// হেডার ইনক্লুড করা
require_once 'includes/user_header.php';
require_once 'includes/user_sidebar.php';
?>

<style>
    /* ==========================================
       Premium Light Theme & Grid Background
       ========================================== */
    body {
        background-color: #ffffff !important;
        background-image: 
            linear-gradient(rgba(37, 99, 235, 0.025) 1px, transparent 1px),
            linear-gradient(90deg, rgba(37, 99, 235, 0.025) 1px, transparent 1px) !important;
        background-size: 30px 30px !important;
        color: #1e293b !important;
    }
    
    a { text-decoration: none !important; }

    .soft-blue-text { color: #2563eb; }
    .bg-soft-blue { background-color: #f8fafc; }

    /* ==========================================
       Hero Section (Mobile Fixed 100%)
       ========================================== */
    .hero-section {
        padding: 100px 15px 60px;
        text-align: center;
        width: 100%;
        max-width: 100vw;
        overflow: hidden;
    }
    .hero-title {
        font-size: clamp(2.5rem, 8vw, 4.5rem); /* পারফেক্ট স্কেলিং */
        font-weight: 900;
        line-height: 1.1;
        color: #0f172a;
        margin-bottom: 20px;
        letter-spacing: -1px;
    }
    .hero-subtitle {
        font-size: clamp(1rem, 4vw, 1.15rem);
        color: #64748b;
        max-width: 650px;
        margin: 0 auto 35px;
        line-height: 1.6;
    }

    /* Buttons Mobile Fix */
    .btn-premium, .btn-soft {
        white-space: nowrap; 
        padding: 14px 35px;
        border-radius: 50px;
        font-weight: 600;
        font-size: 16px;
        transition: all 0.3s ease;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .btn-premium {
        background: #2563eb;
        color: #ffffff !important;
        border: none;
        box-shadow: 0 10px 25px -5px rgba(37, 99, 235, 0.4);
    }
    .btn-premium:hover { transform: translateY(-3px); box-shadow: 0 15px 35px -5px rgba(37, 99, 235, 0.5); }
    
    .btn-soft {
        background: #ffffff;
        color: #0f172a !important;
        border: 1px solid rgba(15, 23, 42, 0.1);
    }
    .btn-soft:hover { background: #f8fafc; border-color: rgba(15, 23, 42, 0.2); }

    /* ==========================================
       Hosting Cards
       ========================================== */
    .hosting-card {
        background: #ffffff;
        border: 1px solid rgba(37, 99, 235, 0.1);
        border-radius: 24px;
        padding: 40px 30px;
        transition: all 0.4s ease;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
        height: 100%;
    }
    .hosting-card:hover {
        transform: translateY(-8px);
        box-shadow: 0 20px 40px -10px rgba(37, 99, 235, 0.15);
        border-color: rgba(37, 99, 235, 0.3);
    }
    .save-badge {
        background: #eff6ff;
        color: #2563eb;
        padding: 6px 16px;
        border-radius: 50px;
        font-weight: 700;
        font-size: 13px;
    }
    .price-big { font-size: 3.5rem; font-weight: 800; color: #2563eb; line-height: 1; }
    .price-currency { font-size: 1.5rem; vertical-align: top; margin-right: 5px; color: #64748b; font-weight: 600; }
    .price-month { font-size: 1.1rem; color: #64748b; font-weight: 500; }
    
    .renewal-notice {
        background: #f8fafc;
        color: #475569;
        padding: 10px 15px;
        border-radius: 10px;
        font-size: 13px;
        font-weight: 600;
        margin: 20px 0;
        text-align: center;
        border: 1px dashed rgba(15, 23, 42, 0.1);
    }
    .feature-list { list-style: none; padding: 0; margin: 0; text-align: left; }
    .feature-list li { margin-bottom: 14px; font-size: 15px; color: #334155; display: flex; align-items: flex-start; }
    .feature-list li i { color: #2563eb; margin-top: 4px; margin-right: 12px; font-size: 14px; background: #eff6ff; padding: 4px; border-radius: 50%; }

    /* ==========================================
       Premium Info Boxes
       ========================================== */
    .premium-box {
        background: #ffffff;
        border: 1px solid rgba(37, 99, 235, 0.1);
        border-radius: 30px;
        padding: 50px;
        box-shadow: 0 10px 40px -10px rgba(37, 99, 235, 0.08);
        margin-bottom: 40px;
    }
    @media (max-width: 768px) {
        .premium-box { padding: 30px 20px; text-align: center; }
        .premium-box ul { text-align: left; }
    }

    /* ==========================================
       Domain Search & Tags (Fixed completely)
       ========================================== */
    .domain-search-wrapper {
        background: #ffffff;
        border-radius: 50px;
        padding: 8px;
        display: flex;
        box-shadow: 0 10px 30px -5px rgba(37, 99, 235, 0.1);
        border: 1px solid rgba(37, 99, 235, 0.15);
        max-width: 700px;
        margin: 0 auto 40px;
    }
    .domain-search-wrapper input {
        border: none;
        padding: 10px 20px;
        width: 100%;
        font-size: 16px;
        outline: none;
        background: transparent;
        color: #0f172a;
    }
    .domain-ext-card {
        background: #ffffff;
        border: 1px solid rgba(15, 23, 42, 0.05);
        border-radius: 16px;
        padding: 25px 15px 15px; /* উপরের ট্যাগের জন্য ২৫পিক্সেল জায়গা */
        text-align: center;
        box-shadow: 0 4px 6px -1px rgba(0,0,0,0.02);
        transition: transform 0.3s;
        position: relative; /* ট্যাগের জন্য জরুরি */
        margin-top: 15px; /* ট্যাগের জন্য মার্জিন */
    }
    .domain-ext-card:hover { transform: translateY(-5px); border-color: rgba(37, 99, 235, 0.2); }
    
    /* Domain Tag CSS (Fixed z-index and border-radius) */
    .domain-tag {
        position: absolute;
        top: -12px;
        left: 50%;
        transform: translateX(-50%);
        background: #8b5cf6; /* 퍼্পল কালার */
        color: #ffffff;
        padding: 4px 12px;
        border-radius: 8px; /* স্ক্রিনশটের মতো বক্সি ডিজাইন */
        font-size: 11px;
        font-weight: 800;
        text-transform: uppercase;
        box-shadow: 0 4px 6px rgba(139, 92, 246, 0.25);
        white-space: nowrap;
        z-index: 10; /* যাতে অন্য কিছুর নিচে না যায় */
    }
</style>

<div class="main-content flex-grow-1 w-100" style="min-height: 100vh; overflow-x: hidden;">

    <!-- 1. Hero Section -->
    <section class="hero-section">
        <div class="container px-3">
            <h1 class="hero-title mx-auto text-center">Launch Your Next Big Idea<br>With <span class="soft-blue-text">Plexio IT</span></h1>
            <p class="hero-subtitle text-center">High-performance BDIX hosting, premium domains, and elite 24/7 support. Everything you need to build your digital empire effortlessly.</p>
            
            <!-- Mobile Responsive Button Group (Fixed) -->
            <div class="d-flex flex-column flex-sm-row justify-content-center align-items-center gap-3 mt-4">
                <a href="#hosting-plans" class="btn-premium w-100 w-sm-auto"><i class="fa-solid fa-rocket me-2"></i> View Pricing</a>
                <a href="https://wa.me/8801601387812?text=Hello%20Plexio%20IT,%20I%20need%20some%20help" target="_blank" class="btn-soft w-100 w-sm-auto"><i class="fa-brands fa-whatsapp text-success me-2 fs-5"></i> Talk to Experts</a>
            </div>

            <div class="mt-5 pt-3 text-center">
                <div class="d-inline-flex align-items-center bg-white rounded-pill px-4 py-2 border shadow-sm">
                    <div class="d-flex me-3">
                        <img src="https://randomuser.me/api/portraits/men/32.jpg" alt="User" class="rounded-circle border border-2 border-white" width="35" style="margin-right: -10px;">
                        <img src="https://randomuser.me/api/portraits/women/44.jpg" alt="User" class="rounded-circle border border-2 border-white" width="35" style="margin-right: -10px;">
                        <img src="https://randomuser.me/api/portraits/men/46.jpg" alt="User" class="rounded-circle border border-2 border-white" width="35">
                    </div>
                    <span class="text-secondary fw-semibold" style="font-size: 13px;">Trusted by <span class="soft-blue-text fw-bold">1.5K+</span> Experts</span>
                </div>
            </div>
        </div>
    </section>

    <!-- 2. Hosting Plans Section -->
    <section id="hosting-plans" class="py-5">
        <div class="container">
            <div class="text-center mb-5">
                <h2 class="fw-bold text-dark mb-2">Choose BDIX Budget Hosting Plan</h2>
                <p class="text-secondary fw-medium"><i class="fa-solid fa-shield-check text-success me-1"></i> 7-Day Money-Back Guarantee. No Questions Asked.</p>
            </div>

            <div class="row g-4 justify-content-center">
                <?php if(!empty($packages)): ?>
                    <?php foreach($packages as $pkg): 
                        $save_percent = 0;
                        if($pkg['regular_price'] > $pkg['actual_price']) {
                            $save_percent = round((($pkg['regular_price'] - $pkg['actual_price']) / $pkg['regular_price']) * 100);
                        }
                    ?>
                    <div class="col-lg-4 col-md-6">
                        <div class="hosting-card text-center">
                            <h4 class="fw-bold mb-4 text-dark"><?= htmlspecialchars($pkg['name']) ?></h4>
                            
                            <div class="mb-3">
                                <div><span class="price-currency">BDT</span><span class="price-big"><?= number_format($pkg['actual_price']) ?></span><span class="price-month">/m</span></div>
                                <?php if($save_percent > 0): ?>
                                    <div class="mt-3 d-flex align-items-center justify-content-center gap-2">
                                        <span class="text-secondary text-decoration-line-through" style="font-size: 14px;">BDT <?= number_format($pkg['regular_price']) ?></span>
                                        <span class="save-badge"><?= $save_percent ?>% Save</span>
                                    </div>
                                <?php endif; ?>
                            </div>

                            <a href="cart.php?add=<?= $pkg['id'] ?>" class="btn-soft w-100 mb-3 justify-content-center" style="border-color: #2563eb; color: #2563eb !important;">Buy Now</a>
                            
                            <div class="renewal-notice">
                                Lifetime Same Renewal Price
                            </div>

                            <ul class="feature-list mt-4">
                                <?php 
                                $feats = json_decode($pkg['features'], true);
                                if(is_array($feats)): 
                                    $limit = min(count($feats), 8);
                                    for($i=0; $i<$limit; $i++):
                                ?>
                                    <li><i class="fa-solid fa-check"></i> <?= htmlspecialchars($feats[$i]['text']) ?></li>
                                <?php endfor; endif; ?>
                            </ul>
                            
                            <a href="#" class="d-block mt-4 soft-blue-text fw-bold">See all features <i class="fa-solid fa-chevron-down ms-1 fs-6"></i></a>
                        </div>
                    </div>
                    <?php endforeach; ?>
                <?php else: ?>
                    <div class="col-12 text-center text-secondary py-5">Packages are currently being updated.</div>
                <?php endif; ?>
            </div>
            
            <div class="text-center mt-5">
                <h5 class="fw-bold text-dark mb-3">Want a More Powerful Hosting Plan?</h5>
                <a href="categories.php" class="btn-premium"><i class="fa-solid fa-layer-group me-2"></i> View All Plans</a>
            </div>
        </div>
    </section>

    <!-- 3. Security Box (hr1.png on Right) -->
    <section class="py-4">
        <div class="container">
            <div class="premium-box">
                <div class="row align-items-center">
                    <div class="col-lg-6 mb-4 mb-lg-0 pe-lg-5">
                        <h2 class="fw-bold text-dark mb-4"><i class="fa-solid fa-shield-halved soft-blue-text me-3"></i>Top Security. Full Confidence.</h2>
                        <p class="text-secondary fs-5 mb-4 lh-base">Web Hosting is even better with all these free features. We provide LiteSpeed Web Server, free SSL Certificates, daily backups, and top-tier security to ensure your website is always fast, safe, and online.</p>
                        <ul class="feature-list">
                            <li><i class="fa-solid fa-lock"></i> Free Unlimited SSL Certificates</li>
                            <li><i class="fa-solid fa-server"></i> LiteSpeed Web Server Included</li>
                            <li><i class="fa-solid fa-cloud-arrow-up"></i> Automated Daily Backups</li>
                        </ul>
                    </div>
                    <div class="col-lg-6 text-center">
                        <img src="../assets/images/hr1.png" alt="Top Security" class="img-fluid" style="max-height: 320px; object-fit: contain;">
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- 4. Support Box (hr2.png on Left) -->
    <section class="py-2">
        <div class="container">
            <div class="premium-box">
                <div class="row align-items-center flex-column-reverse flex-lg-row">
                    <div class="col-lg-6 text-center mt-4 mt-lg-0">
                        <img src="../assets/images/hr2.png" alt="Elite Support" class="img-fluid" style="max-height: 320px; object-fit: contain;">
                    </div>
                    <div class="col-lg-6 ps-lg-5">
                        <h2 class="fw-bold text-dark mb-4"><i class="fa-solid fa-headset soft-blue-text me-3"></i>Elite Support, Available 24/7</h2>
                        <p class="text-secondary fs-5 mb-4 lh-base">Stuck somewhere? Our expert support team is always awake and ready to assist you via Ticket, Live Chat, and WhatsApp. We don't just host your site; we care for it.</p>
                        <ul class="feature-list">
                            <li><i class="fa-solid fa-bolt"></i> Instant WhatsApp Support</li>
                            <li><i class="fa-solid fa-ticket"></i> Priority Ticketing System</li>
                            <li><i class="fa-solid fa-user-tie"></i> Expert Technical Engineers</li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- 5. Domain Search Section -->
    <section class="py-5 mt-4">
        <div class="container text-center px-3">
            <h2 class="fw-bold mb-3 text-dark">Find Your Perfect Domain</h2>
            <p class="mb-5 text-secondary fs-5">Launch your idea with a memorable domain name with Plexio IT.</p>

            <form action="register-domain.php" method="GET" class="domain-search-wrapper flex-column flex-sm-row">
                <input type="text" name="domain" placeholder="Type your domain name..." required class="mb-2 mb-sm-0 text-center text-sm-start">
                <button type="submit" class="btn-premium w-100 w-sm-auto justify-content-center m-1">Search</button>
            </form>

            <h6 class="fw-bold text-secondary mb-4 text-uppercase mt-5" style="letter-spacing: 1px; font-size: 13px;">Popular Domain Extensions</h6>
            
            <div class="row g-3 justify-content-center">
                <?php if(!empty($domains)): ?>
                    <?php 
                    $show_limit = min(count($domains), 6);
                    for($i=0; $i<$show_limit; $i++): 
                        $dom = $domains[$i];
                    ?>
                    <!-- Grid System Fixed for Mobile (2 columns on mobile, 6 on desktop) -->
                    <div class="col-6 col-md-4 col-lg-2">
                        <div class="domain-ext-card">
                            
                            <!-- Domain Tag Fixed Position & Z-index -->
                            <?php if(!empty($dom['tag'])): ?>
                                <span class="domain-tag"><?= htmlspecialchars($dom['tag']) ?></span>
                            <?php endif; ?>
                            
                            <div class="fw-bold fs-4 text-dark">.<?= htmlspecialchars($dom['extension']) ?></div>
                            <?php if($dom['fake_price']): ?>
                                <small class="text-secondary text-decoration-line-through d-block mt-2">BDT <?= number_format($dom['fake_price']) ?></small>
                            <?php endif; ?>
                            <div class="fw-bold mt-1 soft-blue-text">BDT <?= number_format($dom['register_price']) ?></div>
                        </div>
                    </div>
                    <?php endfor; ?>
                <?php endif; ?>
            </div>
        </div>
    </section>

    <!-- 6. Statistics -->
    <section class="py-5 bg-soft-blue mt-5 rounded-top-5">
        <div class="container">
            <div class="row text-center">
                <div class="col-md-4 mb-4 mb-md-0">
                    <div class="stat-number">2,450+</div>
                    <div class="text-secondary fw-bold mt-2 text-uppercase" style="letter-spacing: 1px; font-size: 13px;">Domains Registered</div>
                </div>
                <div class="col-md-4 mb-4 mb-md-0 border-start border-end border-opacity-10 border-primary">
                    <div class="stat-number">1,800+</div>
                    <div class="text-secondary fw-bold mt-2 text-uppercase" style="letter-spacing: 1px; font-size: 13px;">Hosting Orders</div>
                </div>
                <div class="col-md-4">
                    <div class="stat-number">1,500+</div>
                    <div class="text-secondary fw-bold mt-2 text-uppercase" style="letter-spacing: 1px; font-size: 13px;">Happy Clients</div>
                </div>
            </div>
        </div>
    </section>

    <!-- 7. FAQ Section -->
    <section class="py-5 mb-5 bg-soft-blue rounded-bottom-5">
        <div class="container" style="max-width: 800px;">
            <h2 class="text-center fw-bold mb-5 text-dark">Frequently Asked Questions</h2>
            <div class="accordion" id="faqAccordion">
                
                <div class="accordion-item mb-3 border-0 shadow-sm rounded-4 overflow-hidden">
                    <h2 class="accordion-header">
                        <button class="accordion-button collapsed fw-bold fs-5 text-dark bg-white" type="button" data-bs-toggle="collapse" data-bs-target="#faq1">What is BDIX Hosting?</button>
                    </h2>
                    <div id="faq1" class="accordion-collapse collapse" data-bs-parent="#faqAccordion">
                        <div class="accordion-body text-secondary bg-white border-top">BDIX hosting provides high-speed connectivity for visitors from Bangladesh. It ensures 10x faster load times for local audiences by routing traffic through the national internet exchange.</div>
                    </div>
                </div>

                <div class="accordion-item mb-3 border-0 shadow-sm rounded-4 overflow-hidden">
                    <h2 class="accordion-header">
                        <button class="accordion-button collapsed fw-bold fs-5 text-dark bg-white" type="button" data-bs-toggle="collapse" data-bs-target="#faq2">How does the 7-day money-back guarantee work?</button>
                    </h2>
                    <div id="faq2" class="accordion-collapse collapse" data-bs-parent="#faqAccordion">
                        <div class="accordion-body text-secondary bg-white border-top">If you are not satisfied with our hosting services within the first 7 days of purchase, simply open a support ticket and we will refund your hosting amount in full. No questions asked.</div>
                    </div>
                </div>

                <div class="accordion-item border-0 shadow-sm rounded-4 overflow-hidden">
                    <h2 class="accordion-header">
                        <button class="accordion-button collapsed fw-bold fs-5 text-dark bg-white" type="button" data-bs-toggle="collapse" data-bs-target="#faq3">Do I get free SSL and Email?</button>
                    </h2>
                    <div id="faq3" class="accordion-collapse collapse" data-bs-parent="#faqAccordion">
                        <div class="accordion-body text-secondary bg-white border-top">Yes! All our hosting packages include unlimited Free Auto-SSL certificates and the ability to create professional business email accounts (e.g., info@yourdomain.com).</div>
                    </div>
                </div>

            </div>
        </div>
    </section>

</div> <!-- End of .main-content -->

<?php require_once 'includes/user_footer.php'; ?>