<?php
/**
 * Admin Notice - Dismissible Welcome Notice
 *
 * @package Paws_And_Care
 * @since 0.0.1
 */

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

/**
 * Display admin notice on theme activation
 */
function paws_and_care_admin_notice() {
    // Check if already dismissed
    $user_id = get_current_user_id();
    if (get_user_meta($user_id, 'paws_and_care_notice_dismissed', true)) {
        return;
    }
    
    // Only show on dashboard and themes pages (not on Theme Info page)
    $screen = get_current_screen();
    if (!in_array($screen->id, array('dashboard', 'themes'))) {
        return;
    }
    
    ?>
    <div class="notice notice-info is-dismissible paws-welcome-notice">
        <div style="display: flex; align-items: center; gap: 15px; flex-wrap: wrap;">
            <div style="flex: 1; min-width: 250px;">
                <h3><?php esc_html_e('Welcome to Paws & Care!', 'paws-and-care'); ?></h3>
                <p><?php esc_html_e('Thank you for choosing Paws & Care. Get started by customizing your theme or explore premium features.', 'paws-and-care'); ?></p>
            </div>
            <div style="display: flex; gap: 10px; flex-wrap: wrap;">
                <a href="<?php echo esc_url(admin_url('customize.php')); ?>" class="button paws-notice-btn">
                    <?php esc_html_e('Customize', 'paws-and-care'); ?>
                </a>
                <a href="<?php echo esc_url(admin_url('themes.php?page=paws-and-care-info')); ?>" class="button">
                    <?php esc_html_e('Theme Info', 'paws-and-care'); ?>
                </a>
                <a href="<?php echo esc_url('https://wpfrank.com/wordpress-themes/paws-and-care-premium/'); ?>" target="_blank" class="button paws-notice-btn-outline">
                    <?php esc_html_e('★ Go Pro', 'paws-and-care'); ?>
                </a>
            </div>
        </div>
    </div>
    <?php
}
add_action('admin_notices', 'paws_and_care_admin_notice');

/**
 * AJAX handler to dismiss notice
 */
function paws_and_care_dismiss_notice() {
    // Verify nonce
    if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'paws_dismiss_notice')) {
        wp_die();
    }
    
    $user_id = get_current_user_id();
    update_user_meta($user_id, 'paws_and_care_notice_dismissed', true);
    
    wp_die();
}
add_action('wp_ajax_paws_and_care_dismiss_notice', 'paws_and_care_dismiss_notice');
