<?php
/** @var \Banyo\CustomProduct\Block\FormPage $block */
$product = $block->getProduct();
$productId = $product ? $product->getId() : null;
?>


<div class="container mx-auto max-w-7xl px-4 py-10">
    <h1 class="text-3xl font-semibold text-gray-800 mb-6">
        <?= __('Contact Information') ?>
    </h1>
    <p class="text-gray-700 mb-8">
        <?= __('For an instant emailed price, please enter the information below and click on the submit button. This service is available 24/7.') ?>
    </p>

    <div class="grid grid-cols-1 md:grid-cols-2 gap-8">
        <!-- ✅ Contact Form -->
        <form method="post" action="<?= $block->getUrl('callprice/form/submit') ?>" class="space-y-6">
            <?= $block->getBlockHtml('formkey') ?>
            <input type="hidden" name="product_id" value="<?= $block->escapeHtmlAttr($productId) ?>"/>

            <div>
                <label class="block text-sm font-medium text-gray-700"><?= __('Name') ?> <span class="text-red-600">*</span></label>
                <input type="text" name="customer_name" required
                       class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500"/>
            </div>

            <div>
                <label class="block text-sm font-medium text-gray-700"><?= __('Email') ?> <span class="text-red-600">*</span></label>
                <input type="email" name="customer_email" required
                       class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500"/>
            </div>

            <div>
                <button type="submit"
                        class=" btn btn-primary text-white px-6 py-2 rounded-md shadow hover:bg-blue-700 transition duration-200">
                    <?= __('Submit') ?>
                </button>
            </div>
        </form>

        <?php if ($product): ?>
            <div class="border border-gray-300 rounded-md p-6 bg-white shadow-sm text-lg">
                <h2 class="text-3xl font-bold mb-4"><?= __('Product Information') ?></h2>
                <p><strong><?= __('Product Name:') ?></strong> <?= $block->escapeHtml($product->getName()) ?></p>
                <p class="my-4">
                    <?= __('If you want to go back on this product so please') ?>

                </p>
                <a href="<?= $block->escapeUrl($product->getProductUrl()) ?>" class="text-blue-600 underline hover:text-blue-800">
                    <?= __('click here') ?>
                </a>
            </div>
        <?php endif; ?>
    </div>
</div>
