<?php if (!defined('ABSPATH')) exit; ?>

<div class="hk-appointment-form"
     data-ajaxurl="<?php echo admin_url('admin-ajax.php'); ?>"
     data-otp-nonce="<?php echo wp_create_nonce('hk_otp_nonce'); ?>"
     data-appointment-nonce="<?php echo wp_create_nonce('hk_appointment_nonce'); ?>">
    <div id="hk-apt-otp-section">
        <h3>Verifikasi WhatsApp</h3>
        <div class="form-group">
            <label>Nomor WhatsApp</label>
            <input type="text" id="hk-apt-whatsapp" placeholder="08123456789" required>
        </div>
        <button type="button" id="hk-apt-send-otp" class="hk-btn">Kirim OTP</button>
    </div>

    <!-- OTP Popup Modal -->
    <div id="hk-apt-otp-modal" class="hk-modal">
        <div class="hk-modal-content">
            <span class="hk-apt-modal-close">&times;</span>
            <h3>Masukkan Kode OTP</h3>
            <p>Kode OTP telah dikirim ke WhatsApp Anda</p>
            <div class="form-group">
                <input type="text" id="hk-apt-otp-code" placeholder="1234" maxlength="4" required>
            </div>
            <button type="button" id="hk-apt-verify-otp" class="hk-btn hk-btn-primary">Verifikasi OTP</button>
        </div>
    </div>

    <form id="hk-appointment-form-main" style="display:none;">
        <input type="hidden" id="hk-apt-verified-token" name="token">
        <input type="hidden" id="hk-apt-verified-whatsapp" name="whatsapp">

        <h3>Form Janji Temu</h3>

        <div class="form-group">
            <label>Nama *</label>
            <input type="text" name="nama" required>
        </div>

        <div class="form-group">
            <label>Keperluan *</label>
            <textarea name="keperluan" rows="4" required></textarea>
        </div>

        <div class="form-group">
            <label>Tanggal & Jam *</label>
            <input type="datetime-local" name="tanggal_jam" required>
        </div>

        <button type="submit" class="hk-btn hk-btn-primary">Buat Janji Temu</button>
    </form>

    <div id="hk-apt-success-message" style="display:none;">
        <h3>Terima Kasih!</h3>
        <p>Janji temu Anda telah berhasil dibuat. Kami akan menghubungi Anda melalui WhatsApp.</p>
    </div>
</div>
