<?php
/**
 * Goodmeet access-denied partial.
 *
 * Rendered inside theme header/footer when the visibility check denies a viewer.
 * Expects $goodmeet_visibility_check (array { allowed, reason }) in scope.
 *
 * @package goodmeet
 */

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

$goodmeet_reason = isset( $goodmeet_visibility_check['reason'] ) ? $goodmeet_visibility_check['reason'] : '';

if ( 'login_required' === $goodmeet_reason ) {
	$goodmeet_denied_title   = __( 'Login Required', 'goodmeet' );
	$goodmeet_denied_message = __( 'You must be logged in to access this meeting.', 'goodmeet' );
	$goodmeet_login_url      = wp_login_url( get_permalink() );
} else {
	$goodmeet_denied_title   = __( 'Access Denied', 'goodmeet' );
	$goodmeet_denied_message = __( 'You do not have permission to access this meeting.', 'goodmeet' );
	$goodmeet_login_url      = '';
}
?>

<div class="goodmeet-wrapper goodmeet-access-denied">
	<div class="goodmeet-access-denied__inner">
		<h2 class="goodmeet-access-denied__title"><?php echo esc_html( $goodmeet_denied_title ); ?></h2>
		<p class="goodmeet-access-denied__message"><?php echo esc_html( $goodmeet_denied_message ); ?></p>

		<?php if ( ! empty( $goodmeet_login_url ) ) : ?>
			<p class="goodmeet-access-denied__action">
				<a class="goodmeet-google-meet-button" href="<?php echo esc_url( $goodmeet_login_url ); ?>">
					<?php esc_html_e( 'Log in', 'goodmeet' ); ?>
				</a>
			</p>
		<?php endif; ?>
	</div>
</div>
