<?php
/**
 * Blog Over Toggle Control
 * 
 * Custom toggle switch control for Customizer
 *
 * @package Blog_Over
 */

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

if (!class_exists('WP_Customize_Control')) {
    return;
}

/**
 * Toggle Switch Control
 */
class blog_over_Toggle_Control extends WP_Customize_Control
{
    /**
     * Control type
     *
     * @var string
     */
    public $type = 'blog-over-toggle';

    /**
     * Enqueue control styles and scripts
     */
    public function enqueue()
    {
        wp_enqueue_style(
            'blog-over-customizer-controls',
            get_template_directory_uri() . '/assets/css/customizer-controls.css',
            array(),
            Blog_Over_VERSION
        );
    }

    /**
     * Render the control content
     */
    public function render_content()
    {
        ?>
        <div class="blog-over-toggle-wrapper">
            <?php if (!empty($this->label)) : ?>
                <span class="customize-control-title"><?php echo esc_html($this->label); ?></span>
            <?php endif; ?>
            
            <?php if (!empty($this->description)) : ?>
                <span class="description customize-control-description"><?php echo esc_html($this->description); ?></span>
            <?php endif; ?>
            
            <div class="blog-over-toggle-switch">
                <input 
                    type="checkbox" 
                    id="<?php echo esc_attr($this->id); ?>" 
                    name="<?php echo esc_attr($this->id); ?>" 
                    class="blog-over-toggle-input"
                    value="<?php echo esc_attr($this->value()); ?>"
                    <?php $this->link(); ?>
                    <?php checked($this->value()); ?>
                />
                <label class="blog-over-toggle-label" for="<?php echo esc_attr($this->id); ?>">
                    <span class="blog-over-toggle-slider"></span>
                </label>
            </div>
        </div>
        <?php
    }
}
