<?php

/**
 * Administrator login notification template.
 *
 * Variables via $data array:
 * - $data['site_name'], $data['site_url'], $data['label']
 * - $data['username'] (string)
 * - $data['ip_address'] (string)
 * - $data['browser'] (string)
 * - $data['login_time'] (string)
 * - $data['details'] (array, optional fallback values)
 */

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

$securwp_username = isset( $data['username'] ) && is_scalar( $data['username'] )
    ? (string) $data['username']
    : (string) ( $data['details']['User'] ?? 'Unknown' );
$securwp_ip = isset( $data['ip_address'] ) && is_scalar( $data['ip_address'] )
    ? (string) $data['ip_address']
    : (string) ( $data['details']['IP Address'] ?? 'Unavailable' );
$securwp_browser = isset( $data['browser'] ) && is_scalar( $data['browser'] )
    ? (string) $data['browser']
    : (string) ( $data['details']['Browser'] ?? 'Unavailable' );
$securwp_login_time = isset( $data['login_time'] ) && is_scalar( $data['login_time'] )
    ? (string) $data['login_time']
    : (string) ( $data['details']['Time'] ?? 'Unavailable' );
?>
<h1>Administrator Login</h1>

<div class="alert-info">
    An administrator account signed in to <?php echo esc_html( $data['site_name'] ?? 'your site' ); ?>.
</div>

<p>
    If this activity was expected, no action is required. If you do not recognize it,
    review active sessions, reset the account password, and confirm no other privileged
    changes were made.
</p>

<div class="detail-box">
    <strong>Site:</strong> <?php echo esc_html( $data['site_url'] ?? '' ); ?><br>
    <strong>Administrator:</strong> <?php echo esc_html( $securwp_username ); ?><br>
    <strong>IP Address:</strong> <?php echo esc_html( $securwp_ip ); ?><br>
    <strong>Browser:</strong> <?php echo esc_html( $securwp_browser ); ?><br>
    <strong>Time:</strong> <?php echo esc_html( $securwp_login_time ); ?>
</div>
