<?php
session_start();
if (!isset($_SESSION['user_id']) || $_SESSION['role'] !== 'admin') {
    header("Location: ../auth/login.php");
    exit();
}
?>
<!DOCTYPE html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <title>Admin Dashboard - Glado</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" rel="stylesheet">
    <style>
        body {
            background-color: #f8f9fa;
        }
        .sidebar {
            background-color: #343a40;
            color: white;
            height: 100vh;
        }
        .sidebar a {
            color: white;
            text-decoration: none;
        }
        .sidebar a:hover {
            background-color: #495057;
        }
        .card-icon {
            font-size: 3rem;
            opacity: 0.5;
        }
    </style>
</head>
<body>
    <div class="d-flex">
        <!-- Sidebar -->
        <div class="sidebar p-3 d-flex flex-column">
            <h2 class="text-center">Glado Admin</h2>
            <hr>
            <ul class="nav nav-pills flex-column mb-auto">
                <li class="nav-item"><a href="dashboard.php" class="nav-link active"><i class="fas fa-tachometer-alt"></i> Dashboard</a></li>
                <li class="nav-item"><a href="users.php" class="nav-link"><i class="fas fa-users"></i> Gestionar Usuarios</a></li>
                <li class="nav-item"><a href="products.php" class="nav-link"><i class="fas fa-ice-cream"></i> Gestionar Productos</a></li>
                <li class="nav-item"><a href="suppliers.php" class="nav-link"><i class="fas fa-truck"></i> Gestionar Proveedores</a></li>
                <li class="nav-item"><a href="branches.php" class="nav-link"><i class="fas fa-store"></i> Gestionar Sucursales</a></li>
                <li class="nav-item"><a href="transfer_products.php" class="nav-link"><i class="fas fa-exchange-alt"></i> Trasladar Productos</a></li>
                <li class="nav-item"><a href="sales_by_seller.php" class="nav-link"><i class="fas fa-chart-bar"></i> Reporte de Ventas</a></li>
                <li class="nav-item"><a href="top_products.php" class="nav-link"><i class="fas fa-chart-pie"></i> Top 5 Productos</a></li>
                <li class="nav-item"><a href="season_analysis.php" class="nav-link"><i class="fas fa-chart-line"></i> Análisis de Temporada</a></li>
                <li class="nav-item"><a href="gifts.php" class="nav-link"><i class="fas fa-gift"></i> Gestionar Regalos</a></li>
                <li class="nav-item"><a href="inactive_customers.php" class="nav-link"><i class="fas fa-user-clock"></i> Clientes Inactivos</a></li>
            </ul>
            <hr>
            <a href="../../controllers/AuthController.php?action=logout" class="btn btn-danger"><i class="fas fa-sign-out-alt"></i> Cerrar Sesión</a>
        </div>

        <!-- Main Content -->
        <div class="container-fluid p-4">
            <h1 class="mb-4">Dashboard</h1>
            <div class="row">
                <!-- Ejemplo de Widget -->
                <div class="col-md-4 mb-3">
                    <div class="card text-white bg-primary">
                        <div class="card-body d-flex justify-content-between align-items-center">
                            <div>
                                <h3>Ventas Hoy</h3>
                                <h4>Q 1,234.56</h4>
                            </div>
                            <i class="fas fa-dollar-sign card-icon"></i>
                        </div>
                    </div>
                </div>
                 <div class="col-md-4 mb-3">
                    <div class="card text-white bg-success">
                        <div class="card-body d-flex justify-content-between align-items-center">
                            <div>
                                <h3>Clientes Nuevos</h3>
                                <h4>15</h4>
                            </div>
                            <i class="fas fa-user-plus card-icon"></i>
                        </div>
                    </div>
                </div>
                 <div class="col-md-4 mb-3">
                    <div class="card text-white bg-warning">
                        <div class="card-body d-flex justify-content-between align-items-center">
                            <div>
                                <h3>Bajo Stock</h3>
                                <h4>3 Productos</h4>
                            </div>
                            <i class="fas fa-exclamation-triangle card-icon"></i>
                        </div>
                    </div>
                </div>
            </div>
            <!-- Aquí se pueden añadir más gráficos y tablas -->
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>