<?php

if( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly.
}

$prefix = BREEK_LITE_THEMEPREFIX . '_';

/* Header Section */
$wp_customize->add_section( $prefix . 'header_section', array(
    'title'       => esc_html_x( 'Header', 'admin', 'breek-lite' ),
    'description' => esc_html_x( 'Configure header settings including search, logo, and notices.', 'admin', 'breek-lite' ),
    'priority'    => 20,
));

// Enable Search Button on Header
$wp_customize->add_setting( $prefix . 'enable_search_header', array(
    'default'           => '1',
    'sanitize_callback' => 'sanitize_text_field',
));

$wp_customize->add_control( $prefix . 'enable_search_header', array(
    'label'   => esc_html_x( 'Enable Search Button on Header', 'admin', 'breek-lite' ),
    'section' => $prefix . 'header_section',
    'type'    => 'radio',
    'choices' => array(
        '1' => esc_html_x( 'ON', 'admin', 'breek-lite' ),
        '0' => esc_html_x( 'OFF', 'admin', 'breek-lite' ),
    ),
));

// Logo Type
$wp_customize->add_setting( $prefix . 'logo_type', array(
    'default'           => '2',
    'sanitize_callback' => 'sanitize_text_field',
));

$wp_customize->add_control( $prefix . 'logo_type', array(
    'label'       => esc_html_x( 'Logo Type', 'admin', 'breek-lite' ),
    'description' => esc_html_x( 'Select image if you want to upload a custom logo.', 'admin', 'breek-lite' ),
    'section'     => $prefix . 'header_section',
    'type'        => 'select',
    'choices'     => array(
        '1' => esc_html_x( 'Image', 'admin', 'breek-lite' ),
        '2' => esc_html_x( 'Text', 'admin', 'breek-lite' ),
    ),
));

// Logo Image
$wp_customize->add_setting( $prefix . 'logo_image', array(
    'default'           => '',
    'sanitize_callback' => 'absint',
));

$wp_customize->add_control( new WP_Customize_Media_Control( $wp_customize, $prefix . 'logo_image', array(
    'label'       => esc_html_x( 'Logo Uploader', 'admin', 'breek-lite' ),
    'description' => esc_html_x( 'Recommended sizes - width: 320px, height: 120px.', 'admin', 'breek-lite' ),
    'section'     => $prefix . 'header_section',
    'mime_type'   => 'image',
    'active_callback' => function() use ( $prefix ) {
        return get_theme_mod( $prefix . 'logo_type', '2' ) === '1';
    },
)));

// Logo Width
$wp_customize->add_setting( $prefix . 'logo_width', array(
    'default'           => '',
    'sanitize_callback' => 'absint',
));

$wp_customize->add_control( $prefix . 'logo_width', array(
    'label'       => esc_html_x( 'Logo Width (Optional)', 'admin', 'breek-lite' ),
    'description' => esc_html_x( 'Default: 160 pixels. Note: this is the half width of your uploaded logo for retina display purposes.', 'admin', 'breek-lite' ),
    'section'     => $prefix . 'header_section',
    'type'        => 'number',
    'input_attrs' => array(
        'min'  => 1,
        'max'  => 1000,
        'step' => 1,
    ),
    'default' => 160,
    'active_callback' => function() use ( $prefix ) {
        return get_theme_mod( $prefix . 'logo_type', '2' ) === '1';
    },
));

// Display Header Notice
$wp_customize->add_setting( $prefix . 'enable_notice', array(
    'default'           => '0',
    'sanitize_callback' => 'sanitize_text_field',
));

$wp_customize->add_control( $prefix . 'enable_notice', array(
    'label'   => esc_html_x( 'Display Header Notice', 'admin', 'breek-lite' ),
    'section' => $prefix . 'header_section',
    'type'    => 'radio',
    'choices' => array(
        '1' => esc_html_x( 'ON', 'admin', 'breek-lite' ),
        '0' => esc_html_x( 'OFF', 'admin', 'breek-lite' ),
    ),
));

// Notice Text
$wp_customize->add_setting( $prefix . 'notice_text', array(
    'default'           => '',
    'sanitize_callback' => 'wp_kses_post',
));

$wp_customize->add_control( $prefix . 'notice_text', array(
    'label'       => esc_html_x( 'Notice Text', 'admin', 'breek-lite' ),
    'description' => esc_html_x( 'HTML and shortcodes are allowed.', 'admin', 'breek-lite' ),
    'section'     => $prefix . 'header_section',
    'type'        => 'textarea',
    'active_callback' => function() use ( $prefix ) {
        return get_theme_mod( $prefix . 'enable_notice', '0' ) === '1';
    },
));
