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

// Kategorileri önceden yükle (modal içinde kullanılacak)
$categories = get_terms([
    'taxonomy' => 'product_cat',
    'hide_empty' => false,
    'orderby' => 'name',
    'order' => 'ASC'
]);
?>
<div id="knsdd-campaign-modal" class="knsdd-modal" style="display:none;">
    <div class="knsdd-modal-content">
        <span class="knsdd-modal-close">&times;</span>
        <h3><?php esc_html_e( 'Özel Kampanyayı Yapılandır', 'kns-dynamic-discounts-for-woocommerce' ); ?></h3>
        <div class="knsdd-campaign-form">
            <div class="knsdd-form-field">
                <label for="knsdd-campaign-type"><?php esc_html_e( 'Kampanya Türü', 'kns-dynamic-discounts-for-woocommerce' ); ?></label>
                <select id="knsdd-campaign-type">
                    <option value=""><?php esc_html_e( 'Seçiniz...', 'kns-dynamic-discounts-for-woocommerce' ); ?></option>
                    <option value="buy_x_pay_y"><?php esc_html_e( 'X Al, Y Öde', 'kns-dynamic-discounts-for-woocommerce' ); ?></option>
                    <option value="nth_percent_off"><?php esc_html_e( "N'inci Ürüne İndirim", 'kns-dynamic-discounts-for-woocommerce' ); ?></option>
                    <option value="cart_total_discount"><?php esc_html_e( 'Sepet Tutarına Göre İndirim', 'kns-dynamic-discounts-for-woocommerce' ); ?></option>
                    <option value="buy_x_get_y_discount"><?php esc_html_e( 'A Al, B\'ye İndirim', 'kns-dynamic-discounts-for-woocommerce' ); ?></option>
                </select>
            </div>
            <div id="knsdd-campaign-settings"></div>
            <!-- Inline info area: shown for a few seconds on type switch -->
            <div id="knsdd-campaign-info-message" class="knsdd-info-message" style="display:none;"></div>
            <div id="knsdd-campaign-validation-message" class="knsdd-validation-message"></div>
        </div>
        <div class="knsdd-modal-actions">
            <button class="button" id="knsdd-cancel-campaign"><?php esc_html_e( 'İptal', 'kns-dynamic-discounts-for-woocommerce' ); ?></button>
            <button class="button button-primary" id="knsdd-save-campaign"><?php esc_html_e( 'Kampanyayı Kaydet', 'kns-dynamic-discounts-for-woocommerce' ); ?></button>
        </div>
    </div>
    
    <!-- Kategori listesi template (JS tarafından kullanılacak) -->
    <script type="text/template" id="knsdd-category-options-template">
        <option value=""><?php esc_html_e( 'Seçiniz...', 'kns-dynamic-discounts-for-woocommerce' ); ?></option>
        <?php foreach ($categories as $cat) : ?>
            <option value="<?php echo esc_attr($cat->term_id); ?>"><?php echo esc_html($cat->name); ?></option>
        <?php endforeach; ?>
    </script>
</div>
