<?php include ROOT_PATH . '/admin/templates/header.php'; ?>

<div class="container-fluid py-4">

    <h3 class="mb-2">
        <?= __('footer.create_section', 'Create Footer Section') ?>
    </h3>

    <p class="text-muted mb-4">
        <?= __('footer.section_help', 'Each section represents one column in the footer. Choose what type of content this column will display.') ?>
    </p>

    <div class="card">
        <div class="card-body">

            <form method="POST" action="/admin/footer/store">
                <?= \Core\System\Csrf::field(); ?>

                <!-- Section Title -->
                <div class="mb-3">
                    <label class="form-label">
                        <?= __('footer.section_title', 'Section Title') ?>
                    </label>
                    <input
                        type="text"
                        name="title"
                        class="form-control"
                        required
                        placeholder="<?= __('footer.section_title_placeholder', 'e.g. Pages, Support, Company') ?>"
                    >
                </div>

                <!-- Section Type -->
                <div class="mb-3">
                    <label class="form-label">
                        <?= __('footer.section_type', 'Section Type') ?>
                    </label>

                    <select name="type" id="sectionType" class="form-select" required>
                        <option value="pages">
                            <?= __('footer.section_type_pages', 'Pages (Internal & External Links)') ?>
                        </option>

                        <option value="social">
                            <?= __('footer.section_type_social', 'Social Links (Icons Only)') ?>
                        </option>

                        <option value="contact">
                            <?= __('footer.section_type_contact', 'Contact Information (Phone & WhatsApp)') ?>
                        </option>

                        <option value="branding">
                            <?= __('footer.section_type_branding', 'Branding (Logo & Description)') ?>
                        </option>
                    </select>

                    <div id="sectionTypeHelp" class="form-text mt-2">
                        <?= __('footer.type_help_pages', 'This section will display a list of links or internal pages.') ?>
                    </div>
                </div>

                <!-- Status -->
                <div class="mb-3">
                    <label class="form-label">
                        <?= __('footer.section_status', 'Status') ?>
                    </label>
                    <select name="status" class="form-select">
                        <option value="1">
                            <?= __('actions.active', 'Active') ?>
                        </option>
                        <option value="0">
                            <?= __('actions.inactive', 'Inactive') ?>
                        </option>
                    </select>
                </div>

                <!-- Actions -->
                <div class="d-flex gap-2">
                    <button type="submit" class="btn btn-success">
                        <?= __('footer.create_section', 'Create Footer Section') ?>
                    </button>

                    <a href="/admin/footer" class="btn btn-secondary">
                        <?= __('actions.cancel', 'Cancel') ?>
                    </a>
                </div>

            </form>

        </div>
    </div>

</div>

<script>
(function () {
    const select = document.getElementById('sectionType');
    const help   = document.getElementById('sectionTypeHelp');

    const texts = {
        pages: <?= json_encode(__('footer.type_help_pages', 'This section will display a list of links or internal pages.')) ?>,
        social: <?= json_encode(__('footer.type_help_social', 'This section will display social media icons only.')) ?>,
        contact: <?= json_encode(__('footer.type_help_contact', 'This section will display phone and WhatsApp contact icons.')) ?>,
        branding: <?= json_encode(__('footer.type_help_branding', 'This section will display your store logo and a short description.')) ?>
    };

    function updateHelp() {
        if (!select || !help) return;
        help.textContent = texts[select.value] || '';
    }

    if (select) {
        select.addEventListener('change', updateHelp);
        updateHelp();
    }
})();
</script>

<?php include ROOT_PATH . '/admin/templates/footer.php'; ?>
