<?php

include_once('include/head.php');
include_once('include/purepower-data.php');

$slug = $_GET['slug'] ?? '';

if (!isset($purepower['products'][$slug])) {
    header('Location: /404.php');
    exit;
}

$product = $purepower['products'][$slug];
$isHome = ($product['category'] ?? '') === 'home';
$categoryName = $isHome ? 'Home' : 'Commercial';

?>

<body>

<div class="main-page-wrapper">

<?php include_once('include/header.php'); ?>

<link rel="stylesheet" href="<?php path(); ?>/assets/css/purepower.css">

<main>

<div class="page-title-area text-center pt-100 pb-100 pt-lg-130 pb-lg-130"
    data-background="../assets/img/bg/main-bg.png">

    <div class="container">

        <span class="purepower-label">
            PuREPower <?= $categoryName; ?>
        </span>

        <h2 class="page-title mb-15">
            <?= htmlspecialchars($product['name']); ?>
        </h2>

        <p class="purepower-page-subtitle">
            <?= htmlspecialchars($product['capacity']); ?>
        </p>

    </div>

</div>


<section class="purepower-product-hero pt-120 pt-lg-80 pb-100">

<div class="container">

    <div class="row align-items-center">

        <div class="col-lg-6">

            <div class="purepower-product-detail-content">

                <span class="section-subtitle">
                    PuREPower <?= $categoryName; ?>
                </span>

                <h1>
                    <?= htmlspecialchars($product['name']); ?>
                </h1>

                <p class="product-short-description">
                    <?= htmlspecialchars($product['short_description']); ?>
                </p>

                <p>
                    <?= nl2br(htmlspecialchars($product['description'])); ?>
                </p>

                <div class="purepower-buttons">

                    <a href="<?php path(); ?>/contact-us.php" class="btn-brand">
                        Enquire Now
                        <i class="bi bi-arrow-right"></i>
                    </a>

                    <a href="#technical-specifications" class="btn-cus-sec">
                        View Specifications
                    </a>

                </div>

            </div>

        </div>

        <div class="col-lg-6">

            <div class="purepower-product-detail-image">

                <img src="<?php path(); ?>/<?= htmlspecialchars($product['image']); ?>"
                     alt="<?= htmlspecialchars($product['name']); ?>">

            </div>

        </div>

    </div>

</div>

</section>


<?php if (!empty($product['key_specifications'])): ?>

<section class="purepower-key-specifications pt-80 pb-80">

<div class="container">

    <div class="section-title mb-50">

        <span class="section-subtitle">
            Key Specifications
        </span>

        <h2>
            <?= htmlspecialchars($product['name']); ?> at a Glance
        </h2>

    </div>

    <div class="row">

        <?php foreach ($product['key_specifications'] as $label => $value): ?>

        <div class="col-lg-3 col-md-6 mb-25">

            <div class="purepower-key-spec-card">

                <span>
                    <?= htmlspecialchars($label); ?>
                </span>

                <strong>
                    <?= htmlspecialchars($value); ?>
                </strong>

            </div>

        </div>

        <?php endforeach; ?>

    </div>

</div>

</section>

<?php endif; ?>


<?php if (!empty($product['specifications'])): ?>

<section class="purepower-detail-section pt-90 pb-100"
         id="technical-specifications">

<div class="container">

    <div class="section-title text-center mb-55">

        <span class="section-subtitle">
            Technical Details
        </span>

        <h2>
            <?= htmlspecialchars($product['name']); ?> Specifications
        </h2>

    </div>

    <div class="purepower-spec-grid">

        <?php foreach ($product['specifications'] as $group => $specifications): ?>

        <div class="purepower-spec-card">

            <div class="purepower-spec-header">
                <?= htmlspecialchars($group); ?>
            </div>

            <div class="purepower-spec-body">

                <?php foreach ($specifications as $label => $value): ?>

                <div class="purepower-spec-row">

                    <span>
                        <?= htmlspecialchars($label); ?>
                    </span>

                    <strong>
                        <?= htmlspecialchars($value); ?>
                    </strong>

                </div>

                <?php endforeach; ?>

            </div>

        </div>

        <?php endforeach; ?>

    </div>

</div>

</section>

<?php endif; ?>


<?php if (!empty($product['features'])): ?>

<section class="purepower-features-section pt-90 pb-90">

<div class="container">

    <div class="section-title text-center mb-55">

        <span class="section-subtitle">
            PuREPower Technology
        </span>

        <h2>
            Key Features
        </h2>

    </div>

    <div class="row">

        <?php foreach ($product['features'] as $index => $feature): ?>

        <div class="col-lg-4 col-md-6 mb-25">

            <div class="purepower-detail-feature">

                <div class="detail-feature-icon">
                    <i class="bi bi-check2"></i>
                </div>

                <h3>
                    <?= htmlspecialchars($feature); ?>
                </h3>

            </div>

        </div>

        <?php endforeach; ?>

    </div>

</div>

</section>

<?php endif; ?>


<?php if (!empty($product['applications'])): ?>

<section class="purepower-applications pt-90 pb-100">

<div class="container">

    <div class="section-title text-center mb-55">

        <span class="section-subtitle">
            Applications
        </span>

        <h2>
            Suitable Loads & Applications
        </h2>

        <p>
            Designed to support a wide range of household and electrical loads.
        </p>

    </div>

    <div class="row">

        <?php foreach ($product['applications'] as $application): ?>

        <div class="col-lg-3 col-md-4 col-6 mb-25">

            <div class="purepower-application">

                <i class="bi bi-lightning-charge"></i>

                <span>
                    <?= htmlspecialchars($application); ?>
                </span>

            </div>

        </div>

        <?php endforeach; ?>

    </div>

</div>

</section>

<?php endif; ?>


<section class="purepower-product-cta pt-80 pb-80">

<div class="container">

    <div class="purepower-cta-box">

        <div>

            <span class="section-subtitle">
                Manral Solar
            </span>

            <h2>
                Looking for <?= htmlspecialchars($product['name']); ?>?
            </h2>

            <p>
                Talk to Manral Solar for PuREPower energy storage solutions
                in Uttarakhand.
            </p>

        </div>

        <div>

            <a href="<?php path(); ?>/contact-us.php" class="btn-brand">
                Get a Quote
                <i class="bi bi-arrow-right"></i>
            </a>

        </div>

    </div>

</div>

</section>

</main>

<?php include_once('include/footer.php'); ?>

</div>

</body>
</html>