<?php
/**
 * Customizer: Layout Settings Section
 *
 * @package Paws_And_Care
 * @since 0.1.2
 */

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

/**
 * Register Layout Settings Section
 *
 * @param WP_Customize_Manager $wp_customize Customizer object.
 */
function paws_and_care_customizer_layout($wp_customize)
{
    // ========================================
    // Layout Settings Section (inside Theme Settings panel)
    // ========================================
    $wp_customize->add_section('paws_and_care_layout', array(
        'title' => __('Layout Settings', 'paws-and-care'),
        'panel' => 'paws_and_care_theme_settings',
        'priority' => 10,
    ));

    // Site Layout
    $wp_customize->add_setting('paws_and_care_site_layout', array(
        'default' => 'full-width',
        'sanitize_callback' => 'paws_and_care_sanitize_select',
        'transport' => 'refresh',
    ));
    $wp_customize->add_control('paws_and_care_site_layout', array(
        'label' => __('Site Layout', 'paws-and-care'),
        'section' => 'paws_and_care_layout',
        'type' => 'select',
        'choices' => array(
            'full-width' => __('Full Width', 'paws-and-care'),
            'boxed' => __('Boxed', 'paws-and-care'),
        ),
    ));

    // Container Width
    $wp_customize->add_setting('paws_and_care_container_width', array(
        'default' => '1320',
        'sanitize_callback' => 'paws_and_care_sanitize_select',
        'transport' => 'refresh',
    ));
    $wp_customize->add_control('paws_and_care_container_width', array(
        'label' => __('Container Width', 'paws-and-care'),
        'description' => __('Maximum width of the main container.', 'paws-and-care'),
        'section' => 'paws_and_care_layout',
        'type' => 'select',
        'choices' => array(
            '1140' => __('1140px (Bootstrap Default)', 'paws-and-care'),
            '1320' => __('1320px (Bootstrap XXL)', 'paws-and-care'),
            '1400' => __('1400px (Wide)', 'paws-and-care'),
            'custom' => __('Custom', 'paws-and-care'),
        ),
    ));

    // Custom Container Width
    $wp_customize->add_setting('paws_and_care_custom_container_width', array(
        'default' => 1320,
        'sanitize_callback' => 'absint',
        'transport' => 'refresh',
    ));
    $wp_customize->add_control(new Paws_And_Care_Customize_Range_Control($wp_customize, 'paws_and_care_custom_container_width', array(
        'label' => __('Custom Container Width (px)', 'paws-and-care'),
        'description' => __('Set a custom container width (960px - 1600px).', 'paws-and-care'),
        'section' => 'paws_and_care_layout',
        'input_attrs' => array(
            'min' => 960,
            'max' => 1600,
            'step' => 10,
        ),
    )));

    // Sidebar Heading
    $wp_customize->add_setting('paws_and_care_sidebar_heading', array(
        'sanitize_callback' => 'sanitize_text_field',
    ));
    $wp_customize->add_control(new Paws_And_Care_Customize_Heading_Control($wp_customize, 'paws_and_care_sidebar_heading', array(
        'label' => __('Sidebar Settings', 'paws-and-care'),
        'section' => 'paws_and_care_layout',
    )));

    // Blog Sidebar Position
    $wp_customize->add_setting('paws_and_care_blog_sidebar', array(
        'default' => 'right',
        'sanitize_callback' => 'paws_and_care_sanitize_select',
        'transport' => 'refresh',
    ));
    $wp_customize->add_control('paws_and_care_blog_sidebar', array(
        'label' => __('Blog Page Sidebar', 'paws-and-care'),
        'section' => 'paws_and_care_layout',
        'type' => 'select',
        'choices' => array(
            'right' => __('Right Sidebar', 'paws-and-care'),
            'left' => __('Left Sidebar', 'paws-and-care'),
            'none' => __('No Sidebar', 'paws-and-care'),
        ),
    ));

    // Archive Blog Columns
    $wp_customize->add_setting('paws_and_care_archive_blog_columns', array(
        'default' => '2',
        'sanitize_callback' => 'paws_and_care_sanitize_select',
        'transport' => 'refresh',
    ));
    $wp_customize->add_control('paws_and_care_archive_blog_columns', array(
        'label' => __('Archive Blog Columns', 'paws-and-care'),
        'description' => __('Number of columns for main blog archive and index pages.', 'paws-and-care'),
        'section' => 'paws_and_care_layout',
        'type' => 'select',
        'choices' => array(
            '1' => __('1 Column', 'paws-and-care'),
            '2' => __('2 Columns', 'paws-and-care'),
            '3' => __('3 Columns', 'paws-and-care'),
        ),
    ));

    // Single Post Sidebar Position
    $wp_customize->add_setting('paws_and_care_single_sidebar', array(
        'default' => 'right',
        'sanitize_callback' => 'paws_and_care_sanitize_select',
        'transport' => 'refresh',
    ));
    $wp_customize->add_control('paws_and_care_single_sidebar', array(
        'label' => __('Single Post Sidebar', 'paws-and-care'),
        'section' => 'paws_and_care_layout',
        'type' => 'select',
        'choices' => array(
            'right' => __('Right Sidebar', 'paws-and-care'),
            'left' => __('Left Sidebar', 'paws-and-care'),
            'none' => __('No Sidebar', 'paws-and-care'),
        ),
    ));

    // Archive Sidebar Position
    $wp_customize->add_setting('paws_and_care_archive_sidebar', array(
        'default' => 'right',
        'sanitize_callback' => 'paws_and_care_sanitize_select',
        'transport' => 'refresh',
    ));
    $wp_customize->add_control('paws_and_care_archive_sidebar', array(
        'label' => __('Archive Page Sidebar', 'paws-and-care'),
        'section' => 'paws_and_care_layout',
        'type' => 'select',
        'choices' => array(
            'right' => __('Right Sidebar', 'paws-and-care'),
            'left' => __('Left Sidebar', 'paws-and-care'),
            'none' => __('No Sidebar', 'paws-and-care'),
        ),
    ));

    // Page Sidebar Position
    $wp_customize->add_setting('paws_and_care_page_sidebar', array(
        'default' => 'none',
        'sanitize_callback' => 'paws_and_care_sanitize_select',
        'transport' => 'refresh',
    ));
    $wp_customize->add_control('paws_and_care_page_sidebar', array(
        'label' => __('Page Sidebar', 'paws-and-care'),
        'section' => 'paws_and_care_layout',
        'type' => 'select',
        'choices' => array(
            'right' => __('Right Sidebar', 'paws-and-care'),
            'left' => __('Left Sidebar', 'paws-and-care'),
            'none' => __('No Sidebar', 'paws-and-care'),
        ),
    ));
}
