<?php
include "classes/app.class.php";
$username = $_SESSION['username'] ?? 'User'; // Fallback to 'User' if not set
?>

<div class="app-content-wrapper">
    <div class="page-header">
        <div class="greeting-container">
            <h2 class="main-title">Welcome back, <?php echo htmlspecialchars($username); ?>!</h2>
            <p class="sub-text"><?php echo date('l, jS F Y'); ?></p>
        </div>
    </div>

    <div class="stats-grid">
        <div class="stat-card">
            <div class="stat-icon icon-blue">
                <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
                    stroke-linecap="round" stroke-linejoin="round">
                    <path d="M12 2.69l5.66 5.66a8 8 0 1 1-11.31 0z"></path>
                </svg>
            </div>
            <div class="stat-info">
                <span class="stat-label">Total Tanks</span>
                <?php
                if ($_SESSION['client_id'] != 0) { ?>
                    <span
                        class="stat-value"><?php echo $functions->get_total_tanks_for_client($_SESSION['client_id']); ?></span>

                <?php } else { ?>
                    <span class="stat-value"><?php echo $functions->get_total_tanks(); ?></span>

                <?php } ?>
            </div>
        </div>
        <?php if ($_SESSION['client_id'] == 0) { ?>
            <div class="stat-card">
                <div class="stat-icon icon-green">
                    <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
                        stroke-linecap="round" stroke-linejoin="round">
                        <path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path>
                        <circle cx="9" cy="7" r="4"></circle>
                    </svg>
                </div>
                <div class="stat-info">
                    <span class="stat-label">Total Clients</span>
                    <span class="stat-value"><?php echo $functions->get_total_clients(); ?></span>
                </div>
            </div>
        <?php } ?>
        <!-- <div class="stat-card">
            <div class="stat-icon icon-orange">
                <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
                    stroke-linecap="round" stroke-linejoin="round">
                    <path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z">
                    </path>
                    <line x1="12" y1="9" x2="12" y2="13"></line>
                    <line x1="12" y1="17" x2="12.01" y2="17"></line>
                </svg>
            </div>
            <div class="stat-info">
                <span class="stat-label">Offline Tanks</span>
                <span class="stat-value">8</span>
            </div>
        </div>

        <div class="stat-card">
            <div class="stat-icon icon-red">
                <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
                    stroke-linecap="round" stroke-linejoin="round">
                    <path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"></path>
                    <path d="M13.73 21a2 2 0 0 1-3.46 0"></path>

                    <circle cx="18" cy="5" r="3" fill="#FF3B30" stroke="white" stroke-width="1.5"></circle>
                </svg>
            </div>
            <div class="stat-info">
                <span class="stat-label">Unread Notifications</span>
                <span class="stat-value">3</span>
            </div>
        </div> -->
    </div>
    <br>

</div>