<?php
if (session_status() === PHP_SESSION_NONE) {
    session_start();
}
$currentUser = $_SESSION['username'] ?? 'User';
$basePath = $basePath ?? '';
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Arangan - Billing System</title>

    <link
        href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
        rel="stylesheet"
    >

    <style>
        body {
            background-color: #f8f9fa;
        }

        .navbar-brand {
            font-weight: bold;
        }

        .content-wrapper {
            min-height: calc(100vh - 120px);
        }


        .category-btn {
            margin: 5px;
        }

        .item-card {
            cursor: pointer;
            transition: 0.2s;
            height: 100%;
        }

        .item-card:hover {
            transform: scale(1.03);
        }

        .item-img {
            height: 120px;
            object-fit: cover;
        }

        .cart-table td {
            vertical-align: middle;
        }

        .total-box {
            font-size: 24px;
            font-weight: bold;
            color: green;
        }

        .scroll-area {
            max-height: 600px;
            overflow-y: auto;
        }
    </style>
</head>
<body>

<nav class="navbar navbar-expand-lg navbar-dark bg-dark shadow-sm">
    <div class="container-fluid">

        <a class="navbar-brand" href="<?= $basePath ?>dashboard.php">
            Arangan
        </a>

        <button
            class="navbar-toggler"
            type="button"
            data-bs-toggle="collapse"
            data-bs-target="#navbarNav"
        >
            <span class="navbar-toggler-icon"></span>
        </button>

        <div class="collapse navbar-collapse" id="navbarNav">

            <ul class="navbar-nav me-auto">

                <!-- DASHBOARD -->
                <li class="nav-item">
                    <a class="nav-link" href="<?= $basePath ?>dashboard.php">
                        Dashboard
                    </a>
                </li>

                <!-- POS -->
                <li class="nav-item">
                    <a
                        class="nav-link fw-bold text-warning"
                        href="<?= $basePath ?>modules/pos/index.php"
                    >
                        POS
                    </a>
                </li>

                <!-- ITEMS -->
                <li class="nav-item">
                    <a
                        class="nav-link"
                        href="<?= $basePath ?>modules/items/index.php"
                    >
                        Items
                    </a>
                </li>

                <!-- CATEGORIES -->
                <li class="nav-item">
                    <a
                        class="nav-link"
                        href="<?= $basePath ?>modules/categories/index.php"
                    >
                        Categories
                    </a>
                </li>

                <!-- STOCK -->
                <li class="nav-item dropdown">
                    <a
                        class="nav-link dropdown-toggle"
                        href="#"
                        role="button"
                        data-bs-toggle="dropdown"
                    >
                        Stock
                    </a>

                    <ul class="dropdown-menu">

                        <li>
                            <a
                                class="dropdown-item"
                                href="<?= $basePath ?>modules/stock/index.php"
                            >
                                Stock Dashboard
                            </a>
                        </li>

                        <li>
                            <a
                                class="dropdown-item"
                                href="<?= $basePath ?>modules/stock/stock_in.php"
                            >
                                Stock IN
                            </a>
                        </li>

                        <li>
                            <a
                                class="dropdown-item"
                                href="<?= $basePath ?>modules/stock/stock_out.php"
                            >
                                Stock OUT
                            </a>
                        </li>

                        <li>
                            <a
                                class="dropdown-item"
                                href="<?= $basePath ?>modules/stock/bulk_entry.php"
                            >
                                Bulk Stock Entry
                            </a>
                        </li>

                        <li>
                            <a
                                class="dropdown-item"
                                href="<?= $basePath ?>modules/stock/history.php"
                            >
                                Stock History
                            </a>
                        </li>

                    </ul>
                </li>

                <!-- REPORTS -->
                <li class="nav-item dropdown">
                    <a
                        class="nav-link dropdown-toggle"
                        href="#"
                        role="button"
                        data-bs-toggle="dropdown"
                    >
                        Reports
                    </a>

                    <ul class="dropdown-menu">

                        <li>
                            <a
                                class="dropdown-item"
                                href="<?= $basePath ?>modules/reports/dashboard.php"
                            >
                                Reports Dashboard
                            </a>
                        </li>

                        <li>
                            <a
                                class="dropdown-item"
                                href="<?= $basePath ?>modules/reports/daily_sales.php"
                            >
                                Daily Sales
                            </a>
                        </li>

                        <li>
                            <a
                                class="dropdown-item"
                                href="<?= $basePath ?>modules/reports/item_sales.php"
                            >
                                Item Sales
                            </a>
                        </li>

                        <li>
                            <a
                                class="dropdown-item"
                                href="<?= $basePath ?>modules/reports/category_sales.php"
                            >
                                Category Sales
                            </a>
                        </li>

                        <li>
                            <a
                                class="dropdown-item"
                                href="<?= $basePath ?>modules/reports/stock_report.php"
                            >
                                Stock Movement
                            </a>
                        </li>

                        <li>
                            <a
                                class="dropdown-item"
                                href="<?= $basePath ?>modules/reports/profit_report.php"
                            >
                                Profit Report
                            </a>
                        </li>

                        <li>
                            <a
                                class="dropdown-item"
                                href="<?= $basePath ?>modules/reports/gst_report.php"
                            >
                                GST Report
                            </a>
                        </li>

                    </ul>
                </li>

                <!-- SETTINGS -->
                <li class="nav-item">
                    <a
                        class="nav-link"
                        href="<?= $basePath ?>modules/settings/index.php"
                    >
                        Settings
                    </a>
                </li>

                <!-- INVOICES -->
                <li class="nav-item">
                    <a
                        class="nav-link"
                        href="<?= $basePath ?>modules/reports/daily_sales.php"
                    >
                        Invoices
                    </a>
                </li>

            </ul>

            <!-- USER -->
            <ul class="navbar-nav">

                <li class="nav-item">
                    <span class="navbar-text me-3">
                        Welcome, <?= htmlspecialchars($currentUser) ?>
                    </span>
                </li>

                <li class="nav-item">
                    <a
                        class="btn btn-danger btn-sm"
                        href="<?= $basePath ?>logout.php"
                    >
                        Logout
                    </a>
                </li>

            </ul>

        </div>

    </div>
</nav>

<div class="content-wrapper">