<?php
/**
 * Theme Layout & Spacing Settings.
 *
 * @package pawfect
 */

// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;

/**
 * Theme Layout & Spacing Settings.
 */
if ( ! class_exists( 'Pawfect_Options_Theme_Layout' ) ) :

    class Pawfect_Options_Theme_Layout extends pawfect_Customize_Base_Option {

        public function elements() {

            return array(

                // =======================================================
                // == LAYOUT HEADING
                // =======================================================

                'pawfect_layout_heading' => array(
                    'setting' => array(),
                    'control' => array(
                        'type'    => 'heading',
                        'priority' => 1,
                        'label'   => esc_html__( 'Layout & Spacing', 'pawfect' ),
                        'section' => 'pawfect_theme_layout',
                    ),
                ),

                // =======================================================
                // == CONTAINER SETTINGS
                // =======================================================

                'pawfect_container_heading' => array(
                    'setting' => array(),
                    'control' => array(
                        'type'    => 'heading',
                        'priority' => 10,
                        'label'   => esc_html__( 'Container Settings', 'pawfect' ),
                        'section' => 'pawfect_theme_layout',
                    ),
                ),

                'pawfect_container_max_width' => array(
                    'setting' => array(
                        'default' => 1200,
                        'sanitize_callback' => array( 'pawfect_Customizer_Sanitize', 'sanitize_range_value' ),
                    ),
                    'control' => array(
                        'type' => 'pawfect-range-slider',
                        'priority' => 20,
                        'label' => esc_html__( 'Container Max Width', 'pawfect' ),
                        'description' => esc_html__( 'Maximum width for main content container', 'pawfect' ),
                        'section' => 'pawfect_theme_layout',
                        'input_attrs' => array(
                            'min' => 960,
                            'max' => 1600,
                            'step' => 20,
                        ),
                    ),
                ),

                'pawfect_container_padding' => array(
                    'setting' => array(
                        'default' => 20,
                        'sanitize_callback' => array( 'pawfect_Customizer_Sanitize', 'sanitize_range_value' ),
                    ),
                    'control' => array(
                        'type' => 'pawfect-range-slider',
                        'priority' => 30,
                        'label' => esc_html__( 'Container Padding', 'pawfect' ),
                        'description' => esc_html__( 'Left and right padding for containers', 'pawfect' ),
                        'section' => 'pawfect_theme_layout',
                        'input_attrs' => array(
                            'min' => 10,
                            'max' => 50,
                            'step' => 5,
                        ),
                    ),
                ),

                // =======================================================
                // == SECTION SPACING
                // =======================================================

                'pawfect_spacing_heading' => array(
                    'setting' => array(),
                    'control' => array(
                        'type'    => 'heading',
                        'priority' => 40,
                        'label'   => esc_html__( 'Section Spacing', 'pawfect' ),
                        'section' => 'pawfect_theme_layout',
                    ),
                ),

                'pawfect_section_spacing_preset' => array(
                    'setting' => array(
                        'default' => 'normal',
                        'sanitize_callback' => array( 'pawfect_Customizer_Sanitize', 'sanitize_radio' ),
                    ),
                    'control' => array(
                        'type' => 'select',
                        'priority' => 45,
                        'is_default_type' => true,
                        'label' => esc_html__( 'Section Spacing Preset', 'pawfect' ),
                        'description' => esc_html__( 'Quick spacing presets. Use manual controls below for custom values.', 'pawfect' ),
                        'section' => 'pawfect_theme_layout',
                        'choices' => array(
                            'compact' => esc_html__( 'Compact (60px)', 'pawfect' ),
                            'normal'  => esc_html__( 'Normal (80px)', 'pawfect' ),
                            'relaxed' => esc_html__( 'Relaxed (120px)', 'pawfect' ),
                            'custom'  => esc_html__( 'Custom (use manual controls)', 'pawfect' ),
                        ),
                    ),
                ),

                'pawfect_section_padding_top' => array(
                    'setting' => array(
                        'default' => 80,
                        'sanitize_callback' => array( 'pawfect_Customizer_Sanitize', 'sanitize_range_value' ),
                    ),
                    'control' => array(
                        'type' => 'pawfect-range-slider',
                        'priority' => 50,
                        'label' => esc_html__( 'Section Top Padding', 'pawfect' ),
                        'description' => esc_html__( 'Default top padding for sections (only used when Custom preset is selected)', 'pawfect' ),
                        'section' => 'pawfect_theme_layout',
                        'input_attrs' => array(
                            'min' => 40,
                            'max' => 150,
                            'step' => 10,
                        ),
                        'active_callback' => array( $this, 'is_section_spacing_custom' ),
                    ),
                ),

                'pawfect_section_padding_bottom' => array(
                    'setting' => array(
                        'default' => 80,
                        'sanitize_callback' => array( 'pawfect_Customizer_Sanitize', 'sanitize_range_value' ),
                    ),
                    'control' => array(
                        'type' => 'pawfect-range-slider',
                        'priority' => 60,
                        'label' => esc_html__( 'Section Bottom Padding', 'pawfect' ),
                        'description' => esc_html__( 'Default bottom padding for sections (only used when Custom preset is selected)', 'pawfect' ),
                        'section' => 'pawfect_theme_layout',
                        'input_attrs' => array(
                            'min' => 40,
                            'max' => 150,
                            'step' => 10,
                        ),
                        'active_callback' => array( $this, 'is_section_spacing_custom' ),
                    ),
                ),

                // =======================================================
                // == HEADER LAYOUT
                // =======================================================

                'pawfect_header_layout_heading' => array(
                    'setting' => array(),
                    'control' => array(
                        'type'    => 'heading',
                        'priority' => 70,
                        'label'   => esc_html__( 'Header Layout', 'pawfect' ),
                        'section' => 'pawfect_theme_layout',
                    ),
                ),

                'pawfect_header_height' => array(
                    'setting' => array(
                        'default' => 80,
                        'sanitize_callback' => array( 'pawfect_Customizer_Sanitize', 'sanitize_range_value' ),
                    ),
                    'control' => array(
                        'type' => 'pawfect-range-slider',
                        'priority' => 80,
                        'label' => esc_html__( 'Header Height', 'pawfect' ),
                        'section' => 'pawfect_theme_layout',
                        'input_attrs' => array(
                            'min' => 60,
                            'max' => 120,
                            'step' => 5,
                        ),
                    ),
                ),

                'pawfect_header_full_width' => array(
                    'setting' => array(
                        'default' => false,
                        'sanitize_callback' => array( 'pawfect_Customizer_Sanitize', 'sanitize_checkbox' ),
                    ),
                    'control' => array(
                        'type' => 'pawfect-toggle',
                        'priority' => 85,
                        'label' => esc_html__( 'Full Width Header', 'pawfect' ),
                        'description' => esc_html__( 'Enable to make header content span the full width of the screen.', 'pawfect' ),
                        'section' => 'pawfect_theme_layout',
                    ),
                ),



                // =======================================================
                // == FOOTER LAYOUT
                // =======================================================

                'pawfect_footer_layout_heading' => array(
                    'setting' => array(),
                    'control' => array(
                        'type'    => 'heading',
                        'priority' => 100,
                        'label'   => esc_html__( 'Footer Layout', 'pawfect' ),
                        'section' => 'pawfect_theme_layout',
                    ),
                ),

                'pawfect_footer_padding_top' => array(
                    'setting' => array(
                        'default' => 200,
                        'sanitize_callback' => array( 'pawfect_Customizer_Sanitize', 'sanitize_range_value' ),
                    ),
                    'control' => array(
                        'type' => 'pawfect-range-slider',
                        'priority' => 110,
                        'label' => esc_html__( 'Footer Top Padding', 'pawfect' ),
                        'section' => 'pawfect_theme_layout',
                        'input_attrs' => array(
                            'min' => 40,
                            'max' => 200,
                            'step' => 10,
                        ),
                    ),
                ),

                'pawfect_footer_padding_bottom' => array(
                    'setting' => array(
                        'default' => 20,
                        'sanitize_callback' => array( 'pawfect_Customizer_Sanitize', 'sanitize_range_value' ),
                    ),
                    'control' => array(
                        'type' => 'pawfect-range-slider',
                        'priority' => 120,
                        'label' => esc_html__( 'Footer Bottom Padding', 'pawfect' ),
                        'section' => 'pawfect_theme_layout',
                        'input_attrs' => array(
                            'min' => 20,
                            'max' => 80,
                            'step' => 10,
                        ),
                    ),
                ),

            );
        }

        /**
         * Check if section spacing is set to custom
         */
        public function is_section_spacing_custom( $control ) {
            return get_theme_mod( 'pawfect_section_spacing_preset', 'normal' ) === 'custom';
        }
    }

    // Remove automatic instantiation - let main customizer class handle this
    // new Pawfect_Options_Theme_Layout();

endif;
