<?php
// Prevent direct access.
defined( 'ABSPATH' ) || exit;
?>
<div class="wrap lsc-admin-wrap">
    <h1 class="lsc-page-title">
        <span class="dashicons dashicons-format-chat"></span>
        <?php esc_html_e( 'Live Support Chat — Dashboard', 'live-support-chat' ); ?>
    </h1>

    <!-- Status card -->
    <div class="lsc-card lsc-status-card">
        <h2><?php esc_html_e( 'Chat Status', 'live-support-chat' ); ?></h2>
        <div class="lsc-status-row">
            <span class="lsc-status-indicator <?php echo 'online' === $status ? 'lsc-indicator-online' : 'lsc-indicator-offline'; ?>" id="lsc-status-indicator"></span>
            <strong id="lsc-status-label">
                <?php echo 'online' === $status ? esc_html__( 'Online', 'live-support-chat' ) : esc_html__( 'Offline', 'live-support-chat' ); ?>
            </strong>
            <div class="lsc-status-toggle-btns">
                <button class="button button-primary <?php echo 'online' === $status ? 'button-disabled' : ''; ?>"
                        id="lsc-set-online"
                        data-status="online"
                        <?php echo 'online' === $status ? 'disabled' : ''; ?>>
                    <?php esc_html_e( 'Set Online', 'live-support-chat' ); ?>
                </button>
                <button class="button <?php echo 'offline' === $status ? 'button-disabled' : ''; ?>"
                        id="lsc-set-offline"
                        data-status="offline"
                        <?php echo 'offline' === $status ? 'disabled' : ''; ?>>
                    <?php esc_html_e( 'Set Offline', 'live-support-chat' ); ?>
                </button>
            </div>
        </div>
    </div>

    <!-- Stats row -->
    <div class="lsc-stats-row">
        <div class="lsc-stat-card">
            <div class="lsc-stat-number"><?php echo esc_html( $open_chats ); ?></div>
            <div class="lsc-stat-label"><?php esc_html_e( 'Open Chats', 'live-support-chat' ); ?></div>
        </div>
        <div class="lsc-stat-card">
            <div class="lsc-stat-number"><?php echo esc_html( $total_chats ); ?></div>
            <div class="lsc-stat-label"><?php esc_html_e( 'Total Chats', 'live-support-chat' ); ?></div>
        </div>
        <div class="lsc-stat-card <?php echo $unread > 0 ? 'lsc-stat-alert' : ''; ?>">
            <div class="lsc-stat-number"><?php echo esc_html( $unread ); ?></div>
            <div class="lsc-stat-label"><?php esc_html_e( 'Unread Messages', 'live-support-chat' ); ?></div>
        </div>
    </div>

    <!-- Quick links -->
    <div class="lsc-card">
        <h2><?php esc_html_e( 'Quick Links', 'live-support-chat' ); ?></h2>
        <p>
            <a href="<?php echo esc_url( admin_url( 'admin.php?page=lsc-chats' ) ); ?>" class="button button-primary">
                <?php esc_html_e( 'Manage Chats', 'live-support-chat' ); ?>
            </a>
            &nbsp;
            <a href="<?php echo esc_url( admin_url( 'admin.php?page=lsc-users' ) ); ?>" class="button">
                <?php esc_html_e( 'Manage Chatters', 'live-support-chat' ); ?>
            </a>
            &nbsp;
            <a href="<?php echo esc_url( admin_url( 'admin.php?page=lsc-settings' ) ); ?>" class="button">
                <?php esc_html_e( 'Settings', 'live-support-chat' ); ?>
            </a>
        </p>
    </div>
</div>
