<?php
/**
 * ACF local field groups and options pages.
 *
 * @package ALFASMART
 */

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

add_filter('acf/settings/save_json', function () {
    return ALFASMART_DIR . '/acf-json';
});

add_filter('acf/settings/load_json', function ($paths) {
    $paths[] = ALFASMART_DIR . '/acf-json';
    return $paths;
});

add_action('acf/init', function () {
    if (! function_exists('acf_add_options_page')) {
        return;
    }

    acf_add_options_page(array(
        'page_title' => __('Theme Settings', 'alfasmart'),
        'menu_title' => __('Theme Settings', 'alfasmart'),
        'menu_slug'  => 'theme-settings',
        'capability' => 'edit_posts',
        'icon_url'   => 'dashicons-admin-customizer',
        'position'   => 3,
        'redirect'   => false,
    ));

    acf_add_options_sub_page(array(
        'page_title'  => __('Home Page', 'alfasmart'),
        'menu_title'  => __('Home Page', 'alfasmart'),
        'menu_slug'   => 'home-page-settings',
        'parent_slug' => 'theme-settings',
        'capability'  => 'edit_posts',
    ));
});

add_action('acf/include_fields', function () {
    if (! function_exists('acf_add_local_field_group')) {
        return;
    }

    acf_add_local_field_group(array(
        'key' => 'group_alfasmart_theme_settings',
        'title' => 'Theme Settings',
        'fields' => array(
            array('key' => 'field_as_general_tab', 'label' => 'General Settings', 'name' => '', 'type' => 'tab'),
            array('key' => 'field_as_site_logo', 'label' => 'Site Logo', 'name' => 'site_logo', 'type' => 'image', 'return_format' => 'array', 'preview_size' => 'medium'),
            array('key' => 'field_as_footer_logo', 'label' => 'Footer / Dark Logo', 'name' => 'footer_logo', 'type' => 'image', 'return_format' => 'array', 'preview_size' => 'medium'),
            array('key' => 'field_as_favicon', 'label' => 'Favicon', 'name' => 'favicon', 'type' => 'image', 'return_format' => 'array', 'preview_size' => 'thumbnail'),
            array('key' => 'field_as_phone', 'label' => 'Phone Number', 'name' => 'phone_number', 'type' => 'text'),
            array('key' => 'field_as_email', 'label' => 'Email Address', 'name' => 'email_address', 'type' => 'email'),
            array('key' => 'field_as_address', 'label' => 'Address', 'name' => 'address', 'type' => 'text'),
            array('key' => 'field_as_header_tab', 'label' => 'Header Settings', 'name' => '', 'type' => 'tab'),
            array('key' => 'field_as_show_language_switcher', 'label' => 'Show Language Switcher', 'name' => 'show_language_switcher', 'type' => 'true_false', 'ui' => 1, 'default_value' => 1),
            array('key' => 'field_as_footer_tab', 'label' => 'Footer Settings', 'name' => '', 'type' => 'tab'),
            array('key' => 'field_as_footer_word', 'label' => 'Footer Background Word', 'name' => 'footer_word', 'type' => 'text'),
            array('key' => 'field_as_footer_description', 'label' => 'Footer Description', 'name' => 'footer_description', 'type' => 'textarea', 'rows' => 3),
            array('key' => 'field_as_footer_main_title', 'label' => 'Footer Main Links Title', 'name' => 'footer_main_title', 'type' => 'text'),
            array('key' => 'field_as_footer_companies_title', 'label' => 'Footer Companies Title', 'name' => 'footer_companies_title', 'type' => 'text'),
            array('key' => 'field_as_footer_contact_title', 'label' => 'Footer Contact Title', 'name' => 'footer_contact_title', 'type' => 'text'),
            array('key' => 'field_as_copyright', 'label' => 'Copyright Text', 'name' => 'copyright_text', 'type' => 'text'),
            array('key' => 'field_as_footer_privacy_text', 'label' => 'Privacy Policy Text', 'name' => 'footer_privacy_text', 'type' => 'text'),
            array('key' => 'field_as_footer_privacy_page', 'label' => 'Privacy Policy Page', 'name' => 'footer_privacy_page', 'type' => 'page_link', 'post_type' => array('page'), 'allow_null' => 1),
            array('key' => 'field_as_footer_terms_text', 'label' => 'Terms & Conditions Text', 'name' => 'footer_terms_text', 'type' => 'text'),
            array('key' => 'field_as_footer_terms_page', 'label' => 'Terms & Conditions Page', 'name' => 'footer_terms_page', 'type' => 'page_link', 'post_type' => array('page'), 'allow_null' => 1),
        ),
        'location' => array(array(array('param' => 'options_page', 'operator' => '==', 'value' => 'theme-settings'))),
        'position' => 'normal',
        'style' => 'default',
        'active' => true,
    ));

    acf_add_local_field_group(array(
        'key' => 'group_alfasmart_home',
        'title' => 'Home Page Settings',
        'fields' => array(
            array('key' => 'field_as_home_hero_tab', 'label' => 'Main Hero Banner', 'name' => '', 'type' => 'tab'),
            array('key' => 'field_as_home_hero_kicker', 'label' => 'Kicker', 'name' => 'home_hero_kicker', 'type' => 'text'),
            array('key' => 'field_as_home_hero_title', 'label' => 'Title', 'name' => 'home_hero_title', 'type' => 'wysiwyg', 'tabs' => 'visual', 'toolbar' => 'basic', 'media_upload' => 0),
            array('key' => 'field_as_home_hero_highlight_text', 'label' => 'Highlighted Text', 'name' => 'home_hero_highlight_text', 'type' => 'text', 'instructions' => 'Write the exact word or sentence you want to color. Example: Defined by Value.'),
            array('key' => 'field_as_home_hero_highlight_color', 'label' => 'Highlighted Text Color', 'name' => 'home_hero_highlight_color', 'type' => 'color_picker', 'default_value' => '#f5b400'),
            array('key' => 'field_as_home_hero_description', 'label' => 'Description', 'name' => 'home_hero_description', 'type' => 'textarea', 'rows' => 3),
            array('key' => 'field_as_home_hero_background_image', 'label' => 'Background Image', 'name' => 'home_hero_background_image', 'type' => 'image', 'return_format' => 'array', 'preview_size' => 'medium', 'instructions' => 'Controls the main hero background image. Current static source image is slider.webp.'),
            array('key' => 'field_as_home_hero_primary_text', 'label' => 'Primary Button Text', 'name' => 'home_hero_primary_text', 'type' => 'text'),
            array('key' => 'field_as_home_hero_primary_url', 'label' => 'Primary Button URL', 'name' => 'home_hero_primary_url', 'type' => 'url'),
            array('key' => 'field_as_home_hero_secondary_text', 'label' => 'Secondary Button Text', 'name' => 'home_hero_secondary_text', 'type' => 'text'),
            array('key' => 'field_as_home_hero_secondary_url', 'label' => 'Secondary Button URL', 'name' => 'home_hero_secondary_url', 'type' => 'url'),
            array('key' => 'field_as_home_client_count', 'label' => 'Client Counter Number', 'name' => 'home_client_count', 'type' => 'number'),
            array('key' => 'field_as_home_client_label', 'label' => 'Client Counter Label', 'name' => 'home_client_label', 'type' => 'text'),
            array('key' => 'field_as_home_about_tab', 'label' => 'About Alpha Smart', 'name' => '', 'type' => 'tab'),
            array('key' => 'field_as_home_about_kicker', 'label' => 'Kicker', 'name' => 'home_about_kicker', 'type' => 'text'),
            array('key' => 'field_as_home_about_title', 'label' => 'Title', 'name' => 'home_about_title', 'type' => 'text'),
            array('key' => 'field_as_home_about_copy', 'label' => 'Content', 'name' => 'home_about_copy', 'type' => 'wysiwyg', 'tabs' => 'visual', 'toolbar' => 'basic', 'media_upload' => 0),
            array('key' => 'field_as_home_about_button_text', 'label' => 'Button Text', 'name' => 'home_about_button_text', 'type' => 'text'),
            array('key' => 'field_as_home_about_button_url', 'label' => 'Button URL', 'name' => 'home_about_button_url', 'type' => 'url'),
            array('key' => 'field_as_home_about_muted_copy', 'label' => 'Lower Right / Description Text', 'name' => 'home_about_muted_copy', 'type' => 'textarea', 'rows' => 4),
            array(
                'key' => 'field_as_home_about_checklist',
                'label' => 'Lower Checklist',
                'name' => 'home_about_checklist',
                'type' => 'repeater',
                'button_label' => 'Add Item',
                'sub_fields' => array(
                    array('key' => 'field_as_home_about_checklist_item', 'label' => 'Item', 'name' => 'item', 'type' => 'text'),
                ),
            ),
            array(
                'key' => 'field_as_home_about_slides',
                'label' => 'About Slider',
                'name' => 'home_about_slides',
                'type' => 'repeater',
                'layout' => 'block',
                'button_label' => 'Add Slide',
                'sub_fields' => array(
                    array('key' => 'field_as_home_about_slide_title', 'label' => 'Slide Title', 'name' => 'title', 'type' => 'text'),
                    array('key' => 'field_as_home_about_slide_copy', 'label' => 'Slide Copy', 'name' => 'copy', 'type' => 'textarea', 'rows' => 3),
                    array('key' => 'field_as_home_about_slide_image', 'label' => 'Slide Image', 'name' => 'image', 'type' => 'image', 'return_format' => 'array', 'preview_size' => 'medium', 'instructions' => 'Optional. If empty, about.webp is used.'),
                ),
            ),
            array('key' => 'field_as_home_about_video_file', 'label' => 'Video File', 'name' => 'home_about_video_file', 'type' => 'file', 'return_format' => 'array'),
            array('key' => 'field_as_home_about_video_cover', 'label' => 'Video Cover Image', 'name' => 'home_about_video_cover', 'type' => 'image', 'return_format' => 'array', 'preview_size' => 'medium'),
            array('key' => 'field_as_home_about_video_alt', 'label' => 'Video Cover Alt Text', 'name' => 'home_about_video_alt', 'type' => 'text'),
            array('key' => 'field_as_home_know_more_tab', 'label' => 'Know More About Us', 'name' => '', 'type' => 'tab'),
            array('key' => 'field_as_home_presence_kicker', 'label' => 'Know More Kicker', 'name' => 'home_presence_kicker', 'type' => 'text'),
            array('key' => 'field_as_home_presence_title', 'label' => 'Know More Title', 'name' => 'home_presence_title', 'type' => 'text'),
            array('key' => 'field_as_home_presence_copy', 'label' => 'Know More Description', 'name' => 'home_presence_copy', 'type' => 'textarea', 'rows' => 3),
            array(
                'key' => 'field_as_home_presence_features',
                'label' => 'Know More Features',
                'name' => 'home_presence_features',
                'type' => 'repeater',
                'layout' => 'block',
                'button_label' => 'Add Feature',
                'sub_fields' => array(
                    array('key' => 'field_as_home_presence_feature_icon_type', 'label' => 'Icon Type', 'name' => 'icon_type', 'type' => 'select', 'choices' => array('icon' => 'Font Awesome Icon', 'image' => 'Image Icon'), 'default_value' => 'icon', 'return_format' => 'value', 'allow_null' => 0, 'multiple' => 0, 'ui' => 1, 'wrapper' => array('width' => '25')),
                    array('key' => 'field_as_home_presence_feature_icon', 'label' => 'Font Awesome Icon', 'name' => 'icon', 'type' => 'font-awesome', 'icon_sets' => array('solid', 'regular', 'brands'), 'return_format' => 'class', 'default_value' => '', 'wrapper' => array('width' => '35'), 'conditional_logic' => array(array(array('field' => 'field_as_home_presence_feature_icon_type', 'operator' => '==', 'value' => 'icon')))),
                    array('key' => 'field_as_home_presence_feature_image', 'label' => 'Image Icon', 'name' => 'icon_image', 'type' => 'image', 'return_format' => 'array', 'preview_size' => 'thumbnail', 'wrapper' => array('width' => '35'), 'conditional_logic' => array(array(array('field' => 'field_as_home_presence_feature_icon_type', 'operator' => '==', 'value' => 'image')))),
                    array('key' => 'field_as_home_presence_feature_title', 'label' => 'Title', 'name' => 'title', 'type' => 'text'),
                    array('key' => 'field_as_home_presence_feature_description', 'label' => 'Description', 'name' => 'description', 'type' => 'textarea', 'rows' => 3),
                ),
            ),
            array('key' => 'field_as_home_companies_tab', 'label' => 'Our Companies / Our Group', 'name' => '', 'type' => 'tab'),
            array('key' => 'field_as_home_companies_kicker', 'label' => 'Companies Kicker', 'name' => 'home_companies_kicker', 'type' => 'text'),
            array('key' => 'field_as_home_companies_title', 'label' => 'Companies Title', 'name' => 'home_companies_title', 'type' => 'text'),
            array('key' => 'field_as_home_services_tab', 'label' => 'Services', 'name' => '', 'type' => 'tab'),
            array('key' => 'field_as_home_services_kicker', 'label' => 'Services Kicker', 'name' => 'home_services_kicker', 'type' => 'text'),
            array('key' => 'field_as_home_services_title', 'label' => 'Services Title', 'name' => 'home_services_title', 'type' => 'text'),
            array('key' => 'field_as_home_services_description', 'label' => 'Services Description', 'name' => 'home_services_description', 'type' => 'textarea', 'rows' => 4),
            array('key' => 'field_as_home_value_tab', 'label' => 'Value Banner', 'name' => '', 'type' => 'tab'),
            array('key' => 'field_as_home_value_title', 'label' => 'Title', 'name' => 'home_value_title', 'type' => 'wysiwyg', 'tabs' => 'visual', 'toolbar' => 'basic', 'media_upload' => 0),
            array('key' => 'field_as_home_value_highlight_text', 'label' => 'Highlighted Text', 'name' => 'home_value_highlight_text', 'type' => 'text'),
            array('key' => 'field_as_home_value_highlight_color', 'label' => 'Highlighted Text Color', 'name' => 'home_value_highlight_color', 'type' => 'color_picker', 'default_value' => '#f5b400', 'instructions' => 'Text wrapped in span will use this color.'),
            array('key' => 'field_as_home_value_description', 'label' => 'Description', 'name' => 'home_value_description', 'type' => 'textarea', 'rows' => 4),
            array('key' => 'field_as_home_value_background_image', 'label' => 'Background Image', 'name' => 'home_value_background_image', 'type' => 'image', 'return_format' => 'array', 'preview_size' => 'medium', 'instructions' => 'Controls the Value Banner image. Current static source image is banner-driven.webp.'),
            array('key' => 'field_as_home_value_button_text', 'label' => 'Button Text', 'name' => 'home_value_button_text', 'type' => 'text'),
            array('key' => 'field_as_home_value_button_url', 'label' => 'Button URL', 'name' => 'home_value_button_url', 'type' => 'url'),
            array('key' => 'field_as_home_experience_tab', 'label' => 'Experience / Why Choose Us', 'name' => '', 'type' => 'tab'),
            array('key' => 'field_as_home_experience_word', 'label' => 'Experience Word', 'name' => 'home_experience_word', 'type' => 'text'),
            array('key' => 'field_as_home_growth_kicker', 'label' => 'Growth Section Kicker', 'name' => 'home_growth_kicker', 'type' => 'text'),
            array('key' => 'field_as_home_growth_title', 'label' => 'Growth Section Title', 'name' => 'home_growth_title', 'type' => 'text'),
            array('key' => 'field_as_home_growth_image', 'label' => 'Growth Image', 'name' => 'home_growth_image', 'type' => 'image', 'return_format' => 'array', 'preview_size' => 'medium'),
            array('key' => 'field_as_home_growth_image_alt', 'label' => 'Growth Image Alt Text', 'name' => 'home_growth_image_alt', 'type' => 'text'),
            array(
                'key' => 'field_as_home_growth_items',
                'label' => 'Growth Items',
                'name' => 'home_growth_items',
                'type' => 'repeater',
                'layout' => 'block',
                'button_label' => 'Add Growth Item',
                'sub_fields' => array(
                    array('key' => 'field_as_home_growth_item_number', 'label' => 'Number', 'name' => 'number', 'type' => 'text'),
                    array('key' => 'field_as_home_growth_item_title', 'label' => 'Title', 'name' => 'title', 'type' => 'text'),
                    array('key' => 'field_as_home_growth_item_description', 'label' => 'Description', 'name' => 'description', 'type' => 'textarea', 'rows' => 3),
                ),
            ),
            array('key' => 'field_as_home_cta_tab', 'label' => 'CTA Section', 'name' => '', 'type' => 'tab'),
            array('key' => 'field_as_home_cta_kicker', 'label' => 'Kicker', 'name' => 'home_cta_kicker', 'type' => 'text'),
            array('key' => 'field_as_home_cta_title', 'label' => 'Title', 'name' => 'home_cta_title', 'type' => 'wysiwyg', 'tabs' => 'visual', 'toolbar' => 'basic', 'media_upload' => 0),
            array('key' => 'field_as_home_cta_highlight_text', 'label' => 'Highlighted Text', 'name' => 'home_cta_highlight_text', 'type' => 'text'),
            array('key' => 'field_as_home_cta_highlight_color', 'label' => 'Title / Highlight Color', 'name' => 'home_cta_highlight_color', 'type' => 'color_picker', 'default_value' => '#f5b400'),
            array('key' => 'field_as_home_cta_description', 'label' => 'Description', 'name' => 'home_cta_description', 'type' => 'textarea', 'rows' => 3),
            array('key' => 'field_as_home_cta_button_text', 'label' => 'Button Text', 'name' => 'home_cta_button_text', 'type' => 'text'),
            array('key' => 'field_as_home_cta_button_url', 'label' => 'Button URL', 'name' => 'home_cta_button_url', 'type' => 'url'),
            array('key' => 'field_as_home_orbit_tab', 'label' => 'Orbit Section', 'name' => '', 'type' => 'tab'),
            array('key' => 'field_as_home_orbit_title', 'label' => 'Title', 'name' => 'home_orbit_title', 'type' => 'wysiwyg', 'tabs' => 'visual', 'toolbar' => 'basic', 'media_upload' => 0),
            array('key' => 'field_as_home_orbit_highlight_text', 'label' => 'Highlighted Text', 'name' => 'home_orbit_highlight_text', 'type' => 'text'),
            array('key' => 'field_as_home_orbit_highlight_color', 'label' => 'Highlighted Text Color', 'name' => 'home_orbit_highlight_color', 'type' => 'color_picker', 'default_value' => '#f5b400'),
            array('key' => 'field_as_home_orbit_description', 'label' => 'Description', 'name' => 'home_orbit_description', 'type' => 'textarea', 'rows' => 4),
            array('key' => 'field_as_home_orbit_button_text', 'label' => 'Button Text', 'name' => 'home_orbit_button_text', 'type' => 'text'),
            array('key' => 'field_as_home_orbit_button_url', 'label' => 'Button URL', 'name' => 'home_orbit_button_url', 'type' => 'url'),
            array('key' => 'field_as_home_contact_tab', 'label' => 'Contact Us', 'name' => '', 'type' => 'tab'),
            array('key' => 'field_as_contact_kicker', 'label' => 'Kicker', 'name' => 'contact_kicker', 'type' => 'text'),
            array('key' => 'field_as_contact_title', 'label' => 'Title', 'name' => 'contact_title', 'type' => 'text'),
            array('key' => 'field_as_contact_description', 'label' => 'Description', 'name' => 'contact_description', 'type' => 'textarea', 'rows' => 3),
            array('key' => 'field_as_contact_form_shortcode', 'label' => 'Form Shortcode', 'name' => 'contact_form_shortcode', 'type' => 'text', 'instructions' => 'Optional. If empty, the static form markup is shown.'),
        ),
        'location' => array(
            array(array('param' => 'page_type', 'operator' => '==', 'value' => 'front_page')),
            array(array('param' => 'page', 'operator' => '==', 'value' => '54')),
            array(array('param' => 'options_page', 'operator' => '==', 'value' => 'home-page-settings')),
        ),
        'position' => 'acf_after_title',
        'active' => true,
    ));

    acf_add_local_field_group(array(
        'key' => 'group_alfasmart_company_details',
        'title' => 'Company Details',
        'fields' => array(
            array('key' => 'field_as_company_hero_tab', 'label' => 'Hero', 'name' => '', 'type' => 'tab'),
            array('key' => 'field_as_company_category', 'label' => 'Category', 'name' => 'company_category', 'type' => 'text'),
            array('key' => 'field_as_company_website', 'label' => 'Website URL', 'name' => 'company_website', 'type' => 'url'),
            array('key' => 'field_as_company_show_home', 'label' => 'Show on Home', 'name' => 'show_on_home', 'type' => 'true_false', 'ui' => 1, 'default_value' => 1),
            array('key' => 'field_as_company_hero_title', 'label' => 'Hero Title', 'name' => 'company_hero_title', 'type' => 'text'),
            array('key' => 'field_as_company_hero_description', 'label' => 'Hero Description', 'name' => 'company_hero_description', 'type' => 'textarea', 'rows' => 5),
            array('key' => 'field_as_company_visit_button_text', 'label' => 'Visit Button Text', 'name' => 'company_visit_button_text', 'type' => 'text'),
            array('key' => 'field_as_company_video_tab', 'label' => 'Video', 'name' => '', 'type' => 'tab'),
            array('key' => 'field_as_company_video_file', 'label' => 'Video File', 'name' => 'company_video_file', 'type' => 'file', 'return_format' => 'array'),
            array('key' => 'field_as_company_video_cover', 'label' => 'Video Cover Image', 'name' => 'company_video_cover', 'type' => 'image', 'return_format' => 'array', 'preview_size' => 'medium'),
            array('key' => 'field_as_company_video_cover_alt', 'label' => 'Video Cover Alt Text', 'name' => 'company_video_cover_alt', 'type' => 'text'),
            array('key' => 'field_as_company_services_tab', 'label' => 'Company Services', 'name' => '', 'type' => 'tab'),
            array('key' => 'field_as_company_services_title', 'label' => 'Services Section Title', 'name' => 'company_services_title', 'type' => 'text'),
            array(
                'key' => 'field_as_company_services',
                'label' => 'Services',
                'name' => 'company_services',
                'type' => 'repeater',
                'layout' => 'block',
                'button_label' => 'Add Service',
                'sub_fields' => array(
                    array('key' => 'field_as_company_service_icon_type', 'label' => 'Icon Type', 'name' => 'icon_type', 'type' => 'select', 'choices' => array('icon' => 'Font Awesome Icon', 'image' => 'Image Icon'), 'default_value' => 'icon', 'return_format' => 'value', 'ui' => 1, 'wrapper' => array('width' => '25')),
                    array('key' => 'field_as_company_service_icon', 'label' => 'Font Awesome Icon', 'name' => 'icon', 'type' => 'font-awesome', 'icon_sets' => array('solid', 'regular', 'brands'), 'return_format' => 'class', 'conditional_logic' => array(array(array('field' => 'field_as_company_service_icon_type', 'operator' => '==', 'value' => 'icon'))), 'wrapper' => array('width' => '35')),
                    array('key' => 'field_as_company_service_icon_image', 'label' => 'Image Icon', 'name' => 'icon_image', 'type' => 'image', 'return_format' => 'array', 'preview_size' => 'thumbnail', 'conditional_logic' => array(array(array('field' => 'field_as_company_service_icon_type', 'operator' => '==', 'value' => 'image'))), 'wrapper' => array('width' => '35')),
                    array('key' => 'field_as_company_service_title', 'label' => 'Title', 'name' => 'title', 'type' => 'text'),
                    array('key' => 'field_as_company_service_description', 'label' => 'Description', 'name' => 'description', 'type' => 'textarea', 'rows' => 3),
                ),
            ),
            array('key' => 'field_as_company_solutions_tab', 'label' => 'Smart Solutions', 'name' => '', 'type' => 'tab'),
            array('key' => 'field_as_company_solutions_kicker', 'label' => 'Kicker', 'name' => 'company_solutions_kicker', 'type' => 'text'),
            array('key' => 'field_as_company_solutions_title', 'label' => 'Title', 'name' => 'company_solutions_title', 'type' => 'text'),
            array('key' => 'field_as_company_solutions_description', 'label' => 'Description', 'name' => 'company_solutions_description', 'type' => 'textarea', 'rows' => 4),
            array('key' => 'field_as_company_solutions_image', 'label' => 'Right Image', 'name' => 'company_solutions_image', 'type' => 'image', 'return_format' => 'array', 'preview_size' => 'medium'),
            array('key' => 'field_as_company_solutions_image_alt', 'label' => 'Right Image Alt Text', 'name' => 'company_solutions_image_alt', 'type' => 'text'),
            array(
                'key' => 'field_as_company_solutions_items',
                'label' => 'Solution Items',
                'name' => 'company_solutions_items',
                'type' => 'repeater',
                'layout' => 'block',
                'button_label' => 'Add Solution',
                'sub_fields' => array(
                    array('key' => 'field_as_company_solution_image', 'label' => 'Image', 'name' => 'image', 'type' => 'image', 'return_format' => 'array', 'preview_size' => 'thumbnail'),
                    array('key' => 'field_as_company_solution_title', 'label' => 'Title', 'name' => 'title', 'type' => 'text'),
                    array('key' => 'field_as_company_solution_description', 'label' => 'Description', 'name' => 'description', 'type' => 'textarea', 'rows' => 3),
                ),
            ),
            array('key' => 'field_as_company_growth_tab', 'label' => 'Expansion / Why Choose Us', 'name' => '', 'type' => 'tab'),
            array('key' => 'field_as_company_expansion_title', 'label' => 'Expansion Title', 'name' => 'company_expansion_title', 'type' => 'text'),
            array('key' => 'field_as_company_expansion_description', 'label' => 'Expansion Description', 'name' => 'company_expansion_description', 'type' => 'textarea', 'rows' => 5),
            array('key' => 'field_as_company_why_title', 'label' => 'Why Choose Title', 'name' => 'company_why_title', 'type' => 'text'),
            array(
                'key' => 'field_as_company_why_items',
                'label' => 'Why Choose Items',
                'name' => 'company_why_items',
                'type' => 'repeater',
                'layout' => 'block',
                'button_label' => 'Add Item',
                'sub_fields' => array(
                    array('key' => 'field_as_company_why_icon_type', 'label' => 'Icon Type', 'name' => 'icon_type', 'type' => 'select', 'choices' => array('icon' => 'Font Awesome Icon', 'image' => 'Image Icon'), 'default_value' => 'icon', 'return_format' => 'value', 'ui' => 1, 'wrapper' => array('width' => '25')),
                    array('key' => 'field_as_company_why_icon', 'label' => 'Font Awesome Icon', 'name' => 'icon', 'type' => 'font-awesome', 'icon_sets' => array('solid', 'regular', 'brands'), 'return_format' => 'class', 'conditional_logic' => array(array(array('field' => 'field_as_company_why_icon_type', 'operator' => '==', 'value' => 'icon'))), 'wrapper' => array('width' => '35')),
                    array('key' => 'field_as_company_why_icon_image', 'label' => 'Image Icon', 'name' => 'icon_image', 'type' => 'image', 'return_format' => 'array', 'preview_size' => 'thumbnail', 'conditional_logic' => array(array(array('field' => 'field_as_company_why_icon_type', 'operator' => '==', 'value' => 'image'))), 'wrapper' => array('width' => '35')),
                    array('key' => 'field_as_company_why_text', 'label' => 'Text', 'name' => 'text', 'type' => 'text'),
                ),
            ),
            array('key' => 'field_as_company_cta_tab', 'label' => 'CTA', 'name' => '', 'type' => 'tab'),
            array('key' => 'field_as_company_cta_title', 'label' => 'CTA Title', 'name' => 'company_cta_title', 'type' => 'text'),
            array('key' => 'field_as_company_cta_description', 'label' => 'CTA Description', 'name' => 'company_cta_description', 'type' => 'textarea', 'rows' => 3),
            array('key' => 'field_as_company_cta_primary_text', 'label' => 'Primary Button Text', 'name' => 'company_cta_primary_text', 'type' => 'text'),
            array('key' => 'field_as_company_cta_primary_url', 'label' => 'Primary Button URL', 'name' => 'company_cta_primary_url', 'type' => 'url'),
            array('key' => 'field_as_company_cta_secondary_text', 'label' => 'Secondary Button Text', 'name' => 'company_cta_secondary_text', 'type' => 'text'),
            array('key' => 'field_as_company_cta_secondary_url', 'label' => 'Secondary Button URL', 'name' => 'company_cta_secondary_url', 'type' => 'url'),
        ),
        'location' => array(array(array('param' => 'post_type', 'operator' => '==', 'value' => 'companies'))),
    ));

    acf_add_local_field_group(array(
        'key' => 'group_alfasmart_contact_page',
        'title' => 'Contact Page Settings',
        'fields' => array(
            array('key' => 'field_as_page_contact_kicker', 'label' => 'Kicker', 'name' => 'contact_kicker', 'type' => 'text'),
            array('key' => 'field_as_page_contact_title', 'label' => 'Title', 'name' => 'contact_title', 'type' => 'text'),
            array('key' => 'field_as_page_contact_description', 'label' => 'Description', 'name' => 'contact_description', 'type' => 'textarea', 'rows' => 3),
            array('key' => 'field_as_page_contact_form_shortcode', 'label' => 'Contact Form 7 Shortcode', 'name' => 'contact_form_shortcode', 'type' => 'text'),
        ),
        'location' => array(
            array(array('param' => 'page', 'operator' => '==', 'value' => '15')),
            array(array('param' => 'page', 'operator' => '==', 'value' => '57')),
        ),
        'position' => 'acf_after_title',
        'active' => true,
    ));

    acf_add_local_field_group(array(
        'key' => 'group_alfasmart_about_page',
        'title' => 'About Page Settings',
        'fields' => array(
            array('key' => 'field_as_about_hero_tab', 'label' => 'Hero / Introduction', 'name' => '', 'type' => 'tab'),
            array('key' => 'field_as_about_hero_kicker', 'label' => 'Hero Kicker', 'name' => 'about_hero_kicker', 'type' => 'text'),
            array('key' => 'field_as_about_hero_title', 'label' => 'Hero Title', 'name' => 'about_hero_title', 'type' => 'wysiwyg', 'tabs' => 'visual', 'toolbar' => 'basic', 'media_upload' => 0),
            array('key' => 'field_as_about_hero_highlight_text', 'label' => 'Hero Highlight Text', 'name' => 'about_hero_highlight_text', 'type' => 'text'),
            array('key' => 'field_as_about_hero_highlight_color', 'label' => 'Hero Highlight Color', 'name' => 'about_hero_highlight_color', 'type' => 'color_picker', 'default_value' => '#f5b400'),
            array('key' => 'field_as_about_hero_description', 'label' => 'Hero Description', 'name' => 'about_hero_description', 'type' => 'textarea', 'rows' => 4),
            array('key' => 'field_as_about_who_title', 'label' => 'Who We Are Title', 'name' => 'about_who_title', 'type' => 'text'),
            array('key' => 'field_as_about_who_description', 'label' => 'Who We Are Description', 'name' => 'about_who_description', 'type' => 'wysiwyg', 'tabs' => 'visual', 'toolbar' => 'basic', 'media_upload' => 0),
            array('key' => 'field_as_about_intro_tab', 'label' => 'About Alpha Smart', 'name' => '', 'type' => 'tab'),
            array('key' => 'field_as_about_intro_kicker', 'label' => 'Section Kicker', 'name' => 'about_intro_kicker', 'type' => 'text'),
            array('key' => 'field_as_about_intro_title', 'label' => 'Section Title', 'name' => 'about_intro_title', 'type' => 'text'),
            array('key' => 'field_as_about_intro_copy', 'label' => 'Section Content', 'name' => 'about_intro_copy', 'type' => 'wysiwyg', 'tabs' => 'visual', 'toolbar' => 'basic', 'media_upload' => 0),
            array('key' => 'field_as_about_intro_muted_copy', 'label' => 'Lower Left Text', 'name' => 'about_intro_muted_copy', 'type' => 'textarea', 'rows' => 4),
            array(
                'key' => 'field_as_about_intro_checklist',
                'label' => 'Checklist',
                'name' => 'about_intro_checklist',
                'type' => 'repeater',
                'button_label' => 'Add Item',
                'sub_fields' => array(
                    array('key' => 'field_as_about_intro_checklist_item', 'label' => 'Item', 'name' => 'item', 'type' => 'text'),
                ),
            ),
            array(
                'key' => 'field_as_about_intro_slides',
                'label' => 'About Slider',
                'name' => 'about_intro_slides',
                'type' => 'repeater',
                'layout' => 'block',
                'button_label' => 'Add Slide',
                'sub_fields' => array(
                    array('key' => 'field_as_about_intro_slide_title', 'label' => 'Slide Title', 'name' => 'title', 'type' => 'text'),
                    array('key' => 'field_as_about_intro_slide_copy', 'label' => 'Slide Copy', 'name' => 'copy', 'type' => 'textarea', 'rows' => 3),
                    array('key' => 'field_as_about_intro_slide_image', 'label' => 'Slide Image', 'name' => 'image', 'type' => 'image', 'return_format' => 'array', 'preview_size' => 'medium', 'instructions' => 'Optional. If empty, the current about.webp artwork is used.'),
                ),
            ),
            array('key' => 'field_as_about_video_tab', 'label' => 'Video', 'name' => '', 'type' => 'tab'),
            array('key' => 'field_as_about_video_file', 'label' => 'Video File', 'name' => 'about_video_file', 'type' => 'file', 'return_format' => 'array'),
            array('key' => 'field_as_about_video_cover', 'label' => 'Video Cover Image', 'name' => 'about_video_cover', 'type' => 'image', 'return_format' => 'array', 'preview_size' => 'medium'),
            array('key' => 'field_as_about_overview_tab', 'label' => 'Business Overview', 'name' => '', 'type' => 'tab'),
            array(
                'key' => 'field_as_about_info_cards',
                'label' => 'Mission / Vision Cards',
                'name' => 'about_info_cards',
                'type' => 'repeater',
                'layout' => 'block',
                'button_label' => 'Add Card',
                'sub_fields' => array(
                    array('key' => 'field_as_about_info_icon_type', 'label' => 'Icon Type', 'name' => 'icon_type', 'type' => 'select', 'choices' => array('icon' => 'Font Awesome Icon', 'image' => 'Image Icon'), 'default_value' => 'icon', 'return_format' => 'value', 'ui' => 1, 'wrapper' => array('width' => '25')),
                    array('key' => 'field_as_about_info_icon', 'label' => 'Font Awesome Icon', 'name' => 'icon', 'type' => 'font-awesome', 'icon_sets' => array('solid', 'regular', 'brands'), 'return_format' => 'class', 'conditional_logic' => array(array(array('field' => 'field_as_about_info_icon_type', 'operator' => '==', 'value' => 'icon'))), 'wrapper' => array('width' => '35')),
                    array('key' => 'field_as_about_info_icon_image', 'label' => 'Image Icon', 'name' => 'icon_image', 'type' => 'image', 'return_format' => 'array', 'preview_size' => 'thumbnail', 'conditional_logic' => array(array(array('field' => 'field_as_about_info_icon_type', 'operator' => '==', 'value' => 'image'))), 'wrapper' => array('width' => '35')),
                    array('key' => 'field_as_about_info_title', 'label' => 'Title', 'name' => 'title', 'type' => 'text'),
                    array('key' => 'field_as_about_info_description', 'label' => 'Description', 'name' => 'description', 'type' => 'textarea', 'rows' => 3),
                    array('key' => 'field_as_about_info_style', 'label' => 'Card Style Class', 'name' => 'style_class', 'type' => 'text', 'instructions' => 'Keep existing classes such as as-about-info-card-mission or as-about-info-card-vision.'),
                ),
            ),
            array('key' => 'field_as_about_what_title', 'label' => 'What We Do Title', 'name' => 'about_what_title', 'type' => 'text'),
            array('key' => 'field_as_about_what_description', 'label' => 'What We Do Description', 'name' => 'about_what_description', 'type' => 'textarea', 'rows' => 3),
            array(
                'key' => 'field_as_about_business_areas',
                'label' => 'Business Areas',
                'name' => 'about_business_areas',
                'type' => 'repeater',
                'button_label' => 'Add Area',
                'sub_fields' => array(
                    array('key' => 'field_as_about_business_area_label', 'label' => 'Label', 'name' => 'label', 'type' => 'text'),
                ),
            ),
            array(
                'key' => 'field_as_about_text_cards',
                'label' => 'Business Model / Growth Cards',
                'name' => 'about_text_cards',
                'type' => 'repeater',
                'layout' => 'block',
                'button_label' => 'Add Text Card',
                'sub_fields' => array(
                    array('key' => 'field_as_about_text_card_title', 'label' => 'Title', 'name' => 'title', 'type' => 'text'),
                    array('key' => 'field_as_about_text_card_description', 'label' => 'Description', 'name' => 'description', 'type' => 'textarea', 'rows' => 4),
                ),
            ),
            array('key' => 'field_as_about_cta_tab', 'label' => 'CTA', 'name' => '', 'type' => 'tab'),
            array('key' => 'field_as_about_cta_title', 'label' => 'CTA Title', 'name' => 'about_cta_title', 'type' => 'text'),
            array('key' => 'field_as_about_cta_description', 'label' => 'CTA Description', 'name' => 'about_cta_description', 'type' => 'textarea', 'rows' => 3),
            array('key' => 'field_as_about_cta_primary_text', 'label' => 'Primary Button Text', 'name' => 'about_cta_primary_text', 'type' => 'text'),
            array('key' => 'field_as_about_cta_primary_url', 'label' => 'Primary Button URL', 'name' => 'about_cta_primary_url', 'type' => 'url'),
            array('key' => 'field_as_about_cta_secondary_text', 'label' => 'Secondary Button Text', 'name' => 'about_cta_secondary_text', 'type' => 'text'),
            array('key' => 'field_as_about_cta_secondary_url', 'label' => 'Secondary Button URL', 'name' => 'about_cta_secondary_url', 'type' => 'url'),
            array('key' => 'field_as_about_values_tab', 'label' => 'Core Values', 'name' => '', 'type' => 'tab'),
            array('key' => 'field_as_about_values_title', 'label' => 'Values Section Title', 'name' => 'about_values_title', 'type' => 'text'),
            array(
                'key' => 'field_as_about_values',
                'label' => 'Values',
                'name' => 'about_values',
                'type' => 'repeater',
                'layout' => 'block',
                'button_label' => 'Add Value',
                'sub_fields' => array(
                    array('key' => 'field_as_about_value_title', 'label' => 'Title', 'name' => 'title', 'type' => 'text'),
                    array('key' => 'field_as_about_value_description', 'label' => 'Description', 'name' => 'description', 'type' => 'textarea', 'rows' => 3),
                ),
            ),
        ),
        'location' => array(
            array(array('param' => 'page', 'operator' => '==', 'value' => '14')),
            array(array('param' => 'page', 'operator' => '==', 'value' => '55')),
        ),
        'position' => 'acf_after_title',
        'active' => true,
    ));

    acf_add_local_field_group(array(
        'key' => 'group_alfasmart_service_details',
        'title' => 'Service Details',
        'fields' => array(
            array('key' => 'field_as_service_icon_type', 'label' => 'Icon Type', 'name' => 'icon_type', 'type' => 'select', 'choices' => array('icon' => 'Font Awesome Icon', 'image' => 'Image Icon'), 'default_value' => 'icon', 'return_format' => 'value', 'allow_null' => 0, 'multiple' => 0, 'ui' => 1),
            array('key' => 'field_as_service_icon', 'label' => 'Font Awesome Icon', 'name' => 'service_icon', 'type' => 'font-awesome', 'icon_sets' => array('solid', 'regular', 'brands'), 'return_format' => 'class', 'instructions' => 'Select the service icon.', 'conditional_logic' => array(array(array('field' => 'field_as_service_icon_type', 'operator' => '==', 'value' => 'icon')))),
            array('key' => 'field_as_service_icon_image', 'label' => 'Image Icon', 'name' => 'icon_image', 'type' => 'image', 'return_format' => 'array', 'preview_size' => 'thumbnail', 'instructions' => 'Upload/select an image icon.', 'conditional_logic' => array(array(array('field' => 'field_as_service_icon_type', 'operator' => '==', 'value' => 'image')))),
            array('key' => 'field_as_service_show_home', 'label' => 'Show on Home', 'name' => 'show_on_home', 'type' => 'true_false', 'ui' => 1, 'default_value' => 1),
        ),
        'location' => array(array(array('param' => 'post_type', 'operator' => '==', 'value' => 'services'))),
    ));
});
