<?php
use Core\Theme;
$site = Theme::all();
?>
<section class="page-hero">
    <div class="container">
        <h1>联系我们</h1>
        <p>提交需求，专属顾问 1 对 1 为您设计降温解决方案</p>
    </div>
</section>
<section class="section" style="padding-top:28px">
    <div class="container">
        <div style="display:grid;grid-template-columns:1fr 1fr;gap:40px;align-items:start">
            <div>
                <h3 style="font-size:20px;margin-bottom:16px">联系方式</h3>
                <p class="footer-line" style="font-size:16px">📞 电话：<a href="tel:<?php echo e($site['contact_phone']); ?>"><?php echo e($site['contact_phone']); ?></a></p>
                <p class="footer-line" style="font-size:16px">✉️ 邮箱：<?php echo e($site['contact_email']); ?></p>
                <p class="footer-line" style="font-size:16px">📍 地址：<?php echo e($site['contact_address']); ?></p>
                <div class="form-note" style="margin-top:20px">我们支持企业 LOGO 绣字、一人一码量体、柔性化小单定制，10 套起订。</div>
            </div>
            <div class="form-card">
                <?php if ($sent): ?><div class="alert alert-ok">提交成功！我们会尽快与您联系。</div><?php endif; ?>
                <?php if ($error): ?><div class="alert alert-err"><?php echo e($error); ?></div><?php endif; ?>
                <form method="post" action="<?php echo site_url('contact'); ?>" autocomplete="on">
                    <?php echo csrf_field(); ?>
                    <!-- 蜜罐：对真人隐藏，机器人填了即被静默丢弃 -->
                    <div class="hp-field" aria-hidden="true" style="position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden">
                        <label>请勿填写此栏</label>
                        <input type="text" name="website" tabindex="-1" autocomplete="off">
                    </div>
                    <div class="field">
                        <label>姓名 / 企业 *</label>
                        <input name="name" required maxlength="40" autocomplete="name" value="<?php echo e($_POST['name'] ?? ''); ?>">
                    </div>
                    <div class="field">
                        <label>联系电话 *</label>
                        <input name="phone" required maxlength="20" inputmode="tel" pattern="[0-9+\-\s]{5,20}" autocomplete="tel" value="<?php echo e($_POST['phone'] ?? ''); ?>">
                    </div>
                    <div class="field">
                        <label>需求描述 *</label>
                        <textarea name="message" required maxlength="1000" placeholder="请简述使用场景、人数、期望降温方式等"><?php echo e($_POST['message'] ?? ''); ?></textarea>
                    </div>
                    <div class="field">
                        <label>验证码</label>
                        <div style="display:flex;align-items:center;gap:12px">
                            <input name="captcha" required inputmode="text" autocomplete="off" maxlength="4" placeholder="请输入验证码" style="flex:1;text-transform:uppercase">
                            <img id="captchaImg" src="<?php echo e($captcha['url']); ?>" alt="验证码" title="点击刷新" style="width:130px;height:44px;border:1px solid #d1d5db;border-radius:6px;cursor:pointer;vertical-align:middle">
                        </div>
                    </div>
                    <button class="btn btn-primary magnetic" type="submit" style="width:100%">提交需求</button>
                </form>
                <script>
                document.getElementById('captchaImg').addEventListener('click', function() {
                    this.src = '<?php echo e($captcha['url']); ?>'.replace(/_t=\w+/, '_t=' + Date.now().toString(16));
                });
                </script>
            </div>
        </div>
    </div>
</section>
