<?php

/**
 * Guard Dog Appearance Page
 *
 * Hub page for visual customizers including the Access Denied page,
 * Email Templates, and WordPress Login Screen customizer. Each feature
 * links to the WordPress Customizer with the appropriate section
 * auto-focused.
 *
 * @package GuardDog
 * @since 1.6.0
 */

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

class Guard_Dog_Appearance_Page {

    /**
     * Feature instances
     * @var array
     */
    private $features;

    /**
     * Constructor
     *
     * @param array $features Feature class instances
     */
    public function __construct(array $features = []) {
        $this->features = $features;
    }

    /**
     * Render the appearance hub page
     */
    public function render(): void {
        ?>
        <div class="wrap guard-dog-admin">
            <h1 class="guard-dog-page-title">
                <span class="dashicons dashicons-art"></span>
                <?php esc_html_e('Appearance', 'guard-dog'); ?>
            </h1>

            <p class="guard-dog-page-subtitle">
                <?php esc_html_e('Customize the visual appearance of your security pages and email templates.', 'guard-dog'); ?>
            </p>

            <div class="guard-dog-appearance-grid">
                <?php $this->render_access_denied_card(); ?>
                <?php $this->render_email_templates_card(); ?>
                <?php $this->render_login_page_card(); ?>
            </div>
        </div>
        <?php
    }

    /**
     * Render the Access Denied Page customizer card
     */
    private function render_access_denied_card(): void {
        $page_url = admin_url('admin.php?page=guard-dog-access-denied-customizer');
        ?>
        <div class="guard-dog-appearance-card">
            <div class="guard-dog-appearance-card-icon">
                <span class="dashicons dashicons-dismiss"></span>
            </div>
            <h3><?php esc_html_e('Access Denied Page', 'guard-dog'); ?></h3>
            <p><?php esc_html_e('Customize the page shown to visitors when access is blocked.', 'guard-dog'); ?></p>
            <a href="<?php echo esc_url($page_url); ?>" class="button button-primary">
                <?php esc_html_e('Customize', 'guard-dog'); ?>
            </a>
        </div>
        <?php
    }

    /**
     * Render the Email Templates customizer card
     */
    private function render_email_templates_card(): void {
        $page_url = admin_url('admin.php?page=guard-dog-email-customizer');
        ?>
        <div class="guard-dog-appearance-card">
            <div class="guard-dog-appearance-card-icon">
                <span class="dashicons dashicons-email"></span>
            </div>
            <h3><?php esc_html_e('Email Templates', 'guard-dog'); ?></h3>
            <p><?php esc_html_e('Customize the email templates for two-factor authentication and password expiration notifications.', 'guard-dog'); ?></p>
            <a href="<?php echo esc_url($page_url); ?>" class="button button-primary">
                <?php esc_html_e('Customize', 'guard-dog'); ?>
            </a>
        </div>
        <?php
    }

    /**
     * Render the WordPress Login Screen customizer card
     */
    private function render_login_page_card(): void {
        $page_url = admin_url('admin.php?page=guard-dog-login-customizer');
        $frontend_form_url = admin_url('admin.php?page=guard-dog-authentication&authentication_tab=login-form');
        ?>
        <div class="guard-dog-appearance-card">
            <div class="guard-dog-appearance-card-icon">
                <span class="dashicons dashicons-admin-network"></span>
            </div>
            <h3><?php esc_html_e('WordPress Login Screen', 'guard-dog'); ?></h3>
            <p><?php esc_html_e('Customize the native WordPress login experience used by wp-login.php, your custom login URL, password reset, and security screens.', 'guard-dog'); ?></p>
            <p class="guard-dog-appearance-card-note">
                <strong><?php esc_html_e('Applies to:', 'guard-dog'); ?></strong>
                <?php esc_html_e('the default WordPress login flow. For embedded page forms, use', 'guard-dog'); ?>
                <a href="<?php echo esc_url($frontend_form_url); ?>"><?php esc_html_e('Authentication > Frontend Login Form', 'guard-dog'); ?></a>.
            </p>
            <a href="<?php echo esc_url($page_url); ?>" class="button button-primary">
                <?php esc_html_e('Customize Login Screen', 'guard-dog'); ?>
            </a>
        </div>
        <?php
    }
}
