<?php
// ডাটাবেস এবং সেশন লোড
require_once '../config/database.php';

// যদি কেউ লগইন ছাড়া এই পেজে আসার চেষ্টা করে, তাকে লগইন পেজে পাঠিয়ে দেবে
if(!isset($_SESSION['is_admin_logged_in']) || $_SESSION['is_admin_logged_in'] !== true) {
    header("Location: index.php");
    exit();
}

// হেডার এবং সাইডবার ইনক্লুড করা হচ্ছে
require_once '../includes/admin_header.php';
require_once '../includes/admin_sidebar.php';
?>

<!-- Main Content Area -->
<div id="content">
    
    <!-- Welcome Banner -->
    <div class="card border-0 shadow-sm mb-4" style="border-radius: 15px; background: linear-gradient(135deg, #0147C9 0%, #013699 100%); color: white;">
        <div class="card-body p-4 d-flex justify-content-between align-items-center">
            <div>
                <h3 class="fw-bold mb-1">Welcome back, Admin! 👋</h3>
                <p class="mb-0 text-white-50">Here is what's happening with Plexio IT today.</p>
            </div>
            <div class="d-none d-md-block" style="font-size: 40px; opacity: 0.8;">
                <i class="fas fa-chart-line"></i>
            </div>
        </div>
    </div>

    <!-- Dashboard Widgets -->
    <div class="row">
        <!-- Total Users -->
        <div class="col-xl-3 col-md-6 mb-4">
            <div class="card border-0 shadow-sm h-100" style="border-radius: 15px; border-left: 5px solid #0147C9 !important;">
                <div class="card-body d-flex justify-content-between align-items-center p-4">
                    <div>
                        <p class="text-muted fw-bold mb-1" style="font-size: 13px; letter-spacing: 1px;">TOTAL USERS</p>
                        <h2 class="mb-0 fw-bolder" style="color: #2c3e50;">1,245</h2>
                    </div>
                    <div class="bg-light rounded-circle d-flex align-items-center justify-content-center" style="width: 50px; height: 50px; color: #0147C9;">
                        <i class="fas fa-users fa-lg"></i>
                    </div>
                </div>
            </div>
        </div>

        <!-- Active Packages -->
        <div class="col-xl-3 col-md-6 mb-4">
            <div class="card border-0 shadow-sm h-100" style="border-radius: 15px; border-left: 5px solid #10b981 !important;">
                <div class="card-body d-flex justify-content-between align-items-center p-4">
                    <div>
                        <p class="text-muted fw-bold mb-1" style="font-size: 13px; letter-spacing: 1px;">ACTIVE PACKAGES</p>
                        <h2 class="mb-0 fw-bolder" style="color: #2c3e50;">48</h2>
                    </div>
                    <div class="bg-light rounded-circle d-flex align-items-center justify-content-center" style="width: 50px; height: 50px; color: #10b981;">
                        <i class="fas fa-box-open fa-lg"></i>
                    </div>
                </div>
            </div>
        </div>

        <!-- Pending Orders -->
        <div class="col-xl-3 col-md-6 mb-4">
            <div class="card border-0 shadow-sm h-100" style="border-radius: 15px; border-left: 5px solid #f59e0b !important;">
                <div class="card-body d-flex justify-content-between align-items-center p-4">
                    <div>
                        <p class="text-muted fw-bold mb-1" style="font-size: 13px; letter-spacing: 1px;">PENDING ORDERS</p>
                        <h2 class="mb-0 fw-bolder" style="color: #2c3e50;">12</h2>
                    </div>
                    <div class="bg-light rounded-circle d-flex align-items-center justify-content-center" style="width: 50px; height: 50px; color: #f59e0b;">
                        <i class="fas fa-shopping-cart fa-lg"></i>
                    </div>
                </div>
            </div>
        </div>

        <!-- Support Tickets -->
        <div class="col-xl-3 col-md-6 mb-4">
            <div class="card border-0 shadow-sm h-100" style="border-radius: 15px; border-left: 5px solid #ef4444 !important;">
                <div class="card-body d-flex justify-content-between align-items-center p-4">
                    <div>
                        <p class="text-muted fw-bold mb-1" style="font-size: 13px; letter-spacing: 1px;">OPEN TICKETS</p>
                        <h2 class="mb-0 fw-bolder" style="color: #2c3e50;">5</h2>
                    </div>
                    <div class="bg-light rounded-circle d-flex align-items-center justify-content-center" style="width: 50px; height: 50px; color: #ef4444;">
                        <i class="fas fa-headset fa-lg"></i>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Recent Activity Section -->
    <div class="card border-0 shadow-sm" style="border-radius: 15px;">
        <div class="card-header bg-white border-bottom-0 pt-4 pb-2 px-4">
            <h5 class="fw-bold" style="color: #2c3e50;"><i class="fas fa-list-alt me-2 text-primary"></i>Recent Orders</h5>
        </div>
        <div class="card-body px-4 pb-4">
            <div class="table-responsive">
                <table class="table table-hover align-middle">
                    <thead class="table-light">
                        <tr>
                            <th>Order ID</th>
                            <th>Customer</th>
                            <th>Service/Domain</th>
                            <th>Status</th>
                            <th>Date</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td class="fw-bold text-primary">#ORD-001</td>
                            <td>Md. Salman</td>
                            <td>example.com (Domain)</td>
                            <td><span class="badge bg-warning text-dark px-3 py-2 rounded-pill">Pending</span></td>
                            <td class="text-muted">Just now</td>
                        </tr>
                        <tr>
                            <td class="fw-bold text-primary">#ORD-002</td>
                            <td>Rabbi Hasan</td>
                            <td>Premium Hosting - 5GB</td>
                            <td><span class="badge bg-success px-3 py-2 rounded-pill">Active</span></td>
                            <td class="text-muted">2 hours ago</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>

</div> <!-- End of #content -->

<?php
// ফুটার ইনক্লুড করা হচ্ছে
require_once '../includes/admin_footer.php';
?>