<?php

/**
 * Access Denied Template
 *
 * Default template for displaying access denied messages.
 *
 * @package ArraySubs\Features\MembersAccess\views
 * @since 1.0.0
 *
 * @var string $arraysubs_restricted_message The message to display.
 */

defined('ABSPATH') || exit;

// Get message from global or use default
$arraysubs_message = isset($arraysubs_restricted_message) ? $arraysubs_restricted_message : __('You do not have permission to access this page.', 'arraysubs');
$arraysubs_pricing_url = home_url(arraysubs_get_setting('members_access.default_redirect_url', '/pricing'));
$arraysubs_request_uri = isset($_SERVER['REQUEST_URI'])
    ? sanitize_text_field(wp_unslash($_SERVER['REQUEST_URI']))
    : '/';
$arraysubs_login_url = wp_login_url(home_url($arraysubs_request_uri));
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>

<head>
    <meta charset="<?php bloginfo('charset'); ?>">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php esc_html_e('Access Denied', 'arraysubs'); ?> - <?php bloginfo('name'); ?></title>
    <?php wp_head(); ?>
</head>

<body class="arraysubs-access-denied-page">
    <div class="arraysubs-access-denied">
        <div class="arraysubs-access-denied__icon">
            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                <rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect>
                <path d="M7 11V7a5 5 0 0 1 10 0v4"></path>
            </svg>
        </div>

        <h1 class="arraysubs-access-denied__title">
            <?php esc_html_e('Access Restricted', 'arraysubs'); ?>
        </h1>

        <p class="arraysubs-access-denied__message">
            <?php echo wp_kses_post($arraysubs_message); ?>
        </p>

        <div class="arraysubs-access-denied__actions">
            <a href="<?php echo esc_url($arraysubs_pricing_url); ?>" class="arraysubs-access-denied__button arraysubs-access-denied__button--primary">
                <?php esc_html_e('View Plans & Pricing', 'arraysubs'); ?>
            </a>

            <?php if (!is_user_logged_in()) : ?>
                <a href="<?php echo esc_url($arraysubs_login_url); ?>" class="arraysubs-access-denied__button arraysubs-access-denied__button--secondary">
                    <?php esc_html_e('Log In', 'arraysubs'); ?>
                </a>
            <?php endif; ?>
        </div>

        <div class="arraysubs-access-denied__links">
            <a href="<?php echo esc_url(home_url()); ?>" class="arraysubs-access-denied__link">
                &larr; <?php esc_html_e('Return to Home', 'arraysubs'); ?>
            </a>
        </div>
    </div>

    <?php wp_footer(); ?>
</body>

</html>