<?php
/**
 * Admin settings template
 */

if (!defined('ABSPATH')) {
    exit;
}

settings_errors('bwg_settings');
?>

<div class="wrap">
    <h1><?php esc_html_e('BW Gallery Settings', 'bw-gallery'); ?></h1>
    
    <form method="post" action="">
        <?php wp_nonce_field('bwg_save_settings', 'bwg_settings_nonce'); ?>
        
        <table class="form-table">
            <tr>
                <th scope="row">
                    <label for="thumbnail_size"><?php esc_html_e('Thumbnail Size', 'bw-gallery'); ?></label>
                </th>
                <td>
                    <select id="thumbnail_size" name="thumbnail_size">
                        <?php
                        $sizes = get_intermediate_image_sizes();
                        $current_size = isset($settings['thumbnail_size']) ? $settings['thumbnail_size'] : 'medium';
                        
                        foreach ($sizes as $size) :
                            ?>
                            <option value="<?php echo esc_attr($size); ?>" <?php selected($current_size, $size); ?>>
                                <?php echo esc_html($size); ?>
                            </option>
                        <?php endforeach; ?>
                    </select>
                    <p class="description"><?php esc_html_e('Default thumbnail size for gallery images.', 'bw-gallery'); ?></p>
                </td>
            </tr>
            
            <tr>
                <th scope="row"><?php esc_html_e('Lightbox', 'bw-gallery'); ?></th>
                <td>
                    <label>
                        <input type="checkbox" name="lightbox_enabled" value="1" 
                               <?php checked(!empty($settings['lightbox_enabled'])); ?>>
                        <?php esc_html_e('Enable lightbox by default', 'bw-gallery'); ?>
                    </label>
                    <p class="description"><?php esc_html_e('Open images in a lightbox when clicked.', 'bw-gallery'); ?></p>
                </td>
            </tr>
            
            <tr>
                <th scope="row">
                    <label for="columns"><?php esc_html_e('Default Columns', 'bw-gallery'); ?></label>
                </th>
                <td>
                    <input type="number" id="columns" name="columns" min="1" max="6" 
                           value="<?php echo isset($settings['columns']) ? esc_attr($settings['columns']) : '3'; ?>" 
                           class="small-text">
                    <p class="description"><?php esc_html_e('Default number of columns in gallery grid.', 'bw-gallery'); ?></p>
                </td>
            </tr>
            
            <tr>
                <th scope="row">
                    <label for="gap"><?php esc_html_e('Default Gap', 'bw-gallery'); ?></label>
                </th>
                <td>
                    <input type="number" id="gap" name="gap" min="0" max="50" 
                           value="<?php echo isset($settings['gap']) ? esc_attr($settings['gap']) : '10'; ?>" 
                           class="small-text">
                    <span><?php esc_html_e('pixels', 'bw-gallery'); ?></span>
                    <p class="description"><?php esc_html_e('Default spacing between gallery images.', 'bw-gallery'); ?></p>
                </td>
            </tr>
        </table>
        
        <?php submit_button(); ?>
    </form>
</div>