<?php
/**
 * Theme Default Data Setup
 *
 * Sets up default content and settings when theme is activated
 *
 * @package Pawfect
 */

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

if ( ! class_exists( 'Pawfect_Theme_Defaults' ) ) :

    class Pawfect_Theme_Defaults {

        /**
         * Constructor
         */
        public function __construct() {
            add_action( 'after_switch_theme', array( $this, 'setup_default_data_fresh_only' ) );
            add_action( 'after_setup_theme', array( $this, 'add_starter_content_support' ) );
        }

        /**
         * Setup default data only for fresh installations
         */
        public function setup_default_data_fresh_only() {
            // Check if this is a fresh installation
            $theme_setup_done = get_option( 'pawfect_theme_setup_done', false );
            
            if ( ! $theme_setup_done ) {
                $this->setup_default_data();
                update_option( 'pawfect_theme_setup_done', true );
            }
        }

        /**
         * Add starter content support
         */
        public function add_starter_content_support() {
            add_theme_support( 'starter-content', array(
                'widgets' => array(
                    // Default Sidebar
                    'sidebar-1' => array(
                        'search',
                        'recent-posts',
                        'recent-comments',
                        'archives',
                        'categories',
                    ),
                    // Footer Widget Areas
                    'footer-widget-1' => array(
                        'pawfect_shop' => array(
                            'custom_html',
                            array(
                                'title' => 'Shop',
                                'content' => '<ul class="pawfect-text-gray-400 pawfect-space-y-3 pawfect-text-center"><li><a href="#" class="hover:pawfect-text-white pawfect-transition-colors">Dogs</a></li><li><a href="#" class="hover:pawfect-text-white pawfect-transition-colors">Cats</a></li><li><a href="#" class="hover:pawfect-text-white pawfect-transition-colors">Small Pets</a></li><li><a href="#" class="hover:pawfect-text-white pawfect-transition-colors">Bundles</a></li></ul>',
                            ),
                        ),
                    ),
                    'footer-widget-2' => array(
                        'pawfect_company' => array(
                            'custom_html',
                            array(
                                'title' => 'Company',
                                'content' => '<ul class="pawfect-text-gray-400 pawfect-space-y-3 pawfect-text-center"><li><a href="#" class="hover:pawfect-text-white pawfect-transition-colors">About Us</a></li><li><a href="#" class="hover:pawfect-text-white pawfect-transition-colors">Our Ethics</a></li><li><a href="#" class="hover:pawfect-text-white pawfect-transition-colors">Careers</a></li><li><a href="#" class="hover:pawfect-text-white pawfect-transition-colors">Mission</a></li></ul>',
                            ),
                        ),
                    ),
                    'footer-widget-3' => array(
                        'pawfect_help' => array(
                            'custom_html',
                            array(
                                'title' => 'Help',
                                'content' => '<ul class="pawfect-text-gray-400 pawfect-space-y-3 pawfect-text-center"><li><a href="#" class="hover:pawfect-text-white pawfect-transition-colors">Contact</a></li><li><a href="#" class="hover:pawfect-text-white pawfect-transition-colors">Returns</a></li><li><a href="#" class="hover:pawfect-text-white pawfect-transition-colors">Shipping</a></li><li><a href="#" class="hover:pawfect-text-white pawfect-transition-colors">FAQ</a></li></ul>',
                            ),
                        ),
                    ),
                    'footer-widget-4' => array(
                        'pawfect_need_help' => array(
                            'custom_html',
                            array(
                                'title' => 'Need Help?',
                                'content' => '<div class="pawfect-text-gray-400 pawfect-text-center pawfect-space-y-2"><p><a href="mailto:support@pawfectpets.com" class="hover:pawfect-text-white pawfect-transition-colors">support@pawfectpets.com</a></p><p>+1 (555) 555-5555</p><p>1 Park Avenue, NYC</p></div>',
                            ),
                        ),
                    ),
                ),
                'nav_menus' => array(
                    'primary' => array(
                        'name' => __( 'Primary Menu', 'pawfect' ),
                        'items' => array(
                            'link_home',
                            'page_about',
                            'page_blog',
                            'page_contact',
                        ),
                    ),
                ),
            ) );
        }

        /**
         * Setup default theme data
         */
        private function setup_default_data() {
            // Set up basic theme options
            $this->setup_basic_options();
        }

        /**
         * Setup basic theme options
         */
        private function setup_basic_options() {
            // Set default customizer options
            set_theme_mod( 'pawfect_site_title', get_bloginfo( 'name' ) );
            set_theme_mod( 'pawfect_site_tagline', get_bloginfo( 'description' ) );
        }
    }

    new Pawfect_Theme_Defaults();

endif;
