<?php
session_start();
if (!isset($_SESSION['type'])) {
    header("Location: logout.php");
    exit();
}
require_once 'database/shikanisha.kts.php';
?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title id="shopname">Restaurant Dashboard</title>
    <!-- Favicon -->
    <link rel="icon" type="image/png" sizes="16x16" href="./quixlab/images/favicon.png">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <!-- Custom Stylesheet -->
    <style>
        :root {
            --primary-color: #ff6b6b;
            --secondary-color: #4ecdc4;
            --dark-color: #292f36;
            --light-color: #f7fff7;
            --accent-color: #ff9f1c;
            --glass-color: rgba(255, 255, 255, 0.2);
            --glass-border: 1px solid rgba(255, 255, 255, 0.3);
            --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
            --blur: blur(10px);
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        body {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            background-attachment: fixed;
            min-height: 100vh;
            color: var(--light-color);
            overflow-x: hidden;
        }

        #preloader {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: var(--dark-color);
            z-index: 9999;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .loader {
            width: 50px;
            height: 50px;
            border: 5px solid var(--glass-color);
            border-radius: 50%;
            border-top-color: var(--primary-color);
            animation: spin 1s ease-in-out infinite;
        }

        @keyframes spin {
            to { transform: rotate(360deg); }
        }

        .main-wrapper {
            padding: 2rem;
        }

        .header {
            text-align: center;
            margin-bottom: 2rem;
        }

        .shop-name {
            font-size: 3rem;
            font-weight: 700;
            margin-bottom: 0.5rem;
            text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
            color: white;
        }

        .user-role {
            font-size: 1.2rem;
            opacity: 0.8;
            margin-bottom: 1.5rem;
        }

        .dashboard-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
            gap: 1.5rem;
            margin-top: 2rem;
        }

        .glass-card {
            background: var(--glass-color);
            backdrop-filter: var(--blur);
            -webkit-backdrop-filter: var(--blur);
            border-radius: 15px;
            padding: 1.5rem;
            border: var(--glass-border);
            box-shadow: var(--glass-shadow);
            transition: all 0.3s ease;
            cursor: pointer;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            text-align: center;
            min-height: 200px;
            position: relative;
            overflow: hidden;
            z-index: 1;
        }

        .glass-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
        }

        .glass-card::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(45deg, transparent, rgba(255,255,255,0.1), transparent);
            z-index: -1;
            transition: 0.5s;
        }

        .glass-card:hover::before {
            transform: translateX(100%);
        }

        .card-icon {
            font-size: 2.5rem;
            margin-bottom: 1rem;
            color: white;
        }

        .card-title {
            font-size: 1.3rem;
            font-weight: 600;
            margin-bottom: 0.5rem;
        }

        .card-desc {
            font-size: 0.9rem;
            opacity: 0.8;
        }

        .footer {
            text-align: center;
            margin-top: 3rem;
            padding: 1.5rem;
            font-size: 0.9rem;
            opacity: 0.7;
        }

        /* Color variations for cards */
        .card-pos { background: rgba(231, 76, 60, 0.2); }
        .card-food { background: rgba(46, 204, 113, 0.2); }
        .card-reports { background: rgba(52, 152, 219, 0.2); }
        .card-inventory { background: rgba(155, 89, 182, 0.2); }
        .card-employees { background: rgba(241, 196, 15, 0.2); }
        .card-purchases { background: rgba(230, 126, 34, 0.2); }
        .card-expenses { background: rgba(231, 76, 60, 0.2); }
        .card-logout { background: rgba(149, 165, 166, 0.2); }
        .card-accomodation { background: rgba(26, 188, 156, 0.2); }
        .card-swimming { background: rgba(41, 128, 185, 0.2); }
        .card-accounting { background: rgba(142, 68, 173, 0.2); }

        @media (max-width: 768px) {
            .dashboard-grid {
                grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
            }
            
            .shop-name {
                font-size: 2rem;
            }
        }
    </style>
</head>

<body>

    <!-- Preloader -->
    <div id="preloader">
        <div class="loader"></div>
    </div>

    <!-- Main Content -->
    <div class="main-wrapper">
        <div class="header">
            <h1 class="shop-name" id="shopname1"></h1>
            <div class="user-role">Welcome, <?php echo $_SESSION['type']; ?></div>
        </div>

        <div class="dashboard-grid">
            <?php 
            if ($_SESSION['type'] == 'Cashier') {
                echo '
                <div class="glass-card card-pos" onclick="redirectToPage(\'menu.php\')">
                    <i class="fas fa-cash-register card-icon"></i>
                    <h3 class="card-title">Point of Sale</h3>
                    <p class="card-desc">Process customer orders</p>
                </div>
                <div class="glass-card card-pos" onclick="redirectToPage(\'shift.php\')">
    <i class="fas fa-clock card-icon"></i>
    <h3 class="card-title">Shift Management</h3>
    <p class="card-desc">Start or manage cashier shifts</p>
</div>

                
               
                <div class="glass-card card-reports" onclick="redirectToPage(\'request.php\')">
                    <i class="fas fa-recycle card-icon"></i>
                    <h3 class="card-title">Dispose/Request</h3>
                    <p class="card-desc">Manage inventory requests</p>
                </div>
                
                <div class="glass-card card-accounting" onclick="redirectToPage(\'payments.php\')">
                    <i class="fas fa-money-bill-wave card-icon"></i>
                    <h3 class="card-title">Add Payment</h3>
                    <p class="card-desc">Process payments</p>
                </div>
                
                <div class="glass-card card-reports" onclick="redirectToPage(\'reports.php\')">
                    <i class="fas fa-chart-bar card-icon"></i>
                    <h3 class="card-title">Reports</h3>
                    <p class="card-desc">View sales reports</p>
                </div>
                
               
               
                <div class="glass-card card-logout" onclick="redirectToPage(\'logout.php\')">
                    <i class="fas fa-sign-out-alt card-icon"></i>
                    <h3 class="card-title">Logout</h3>
                    <p class="card-desc">End your session</p>
                </div>';
            } elseif ($_SESSION['type'] == 'Waiter') {
                echo '
                <div class="glass-card card-pos" onclick="redirectToPage(\'menu.php\')">
                    <i class="fas fa-cash-register card-icon"></i>
                    <h3 class="card-title">Point of Sale</h3>
                    <p class="card-desc">Take customer orders</p>
                </div>
                
                <div class="glass-card card-accounting" onclick="redirectToPage(\'payments.php\')">
                    <i class="fas fa-money-bill-wave card-icon"></i>
                    <h3 class="card-title">Payments</h3>
                    <p class="card-desc">Process payments</p>
                </div>
                
              
                
                <div class="glass-card card-logout" onclick="redirectToPage(\'logout.php\')">
                    <i class="fas fa-sign-out-alt card-icon"></i>
                    <h3 class="card-title">Logout</h3>
                    <p class="card-desc">End your session</p>
                </div>';
            } elseif ($_SESSION['type'] == 'Receptionist') {
                echo '
                <div class="glass-card card-reports" onclick="redirectToPage(\'request.php\')">
                    <i class="fas fa-recycle card-icon"></i>
                    <h3 class="card-title">Dispose/Request</h3>
                    <p class="card-desc">Manage inventory requests</p>
                </div>
                
                <div class="glass-card card-accounting" onclick="redirectToPage(\'payments.php\')">
                    <i class="fas fa-money-bill-wave card-icon"></i>
                    <h3 class="card-title">Add Payment</h3>
                    <p class="card-desc">Process payments</p>
                </div>
                
                <div class="glass-card card-accomodation" onclick="redirectToPage(\'accomodation.php\')">
                    <i class="fas fa-hotel card-icon"></i>
                    <h3 class="card-title">Accomodation</h3>
                    <p class="card-desc">Manage rooms</p>
                </div>
                
                <div class="glass-card card-swimming" onclick="redirectToPage(\'swimming.php\')">
                    <i class="fas fa-swimming-pool card-icon"></i>
                    <h3 class="card-title">Swimming Arena</h3>
                    <p class="card-desc">Manage pool area</p>
                </div>
                
                <div class="glass-card card-pos" onclick="redirectToPage(\'menu.php\')">
                    <i class="fas fa-cash-register card-icon"></i>
                    <h3 class="card-title">Point of Sale</h3>
                    <p class="card-desc">Process orders</p>
                </div>
                
                <div class="glass-card card-logout" onclick="redirectToPage(\'logout.php\')">
                    <i class="fas fa-sign-out-alt card-icon"></i>
                    <h3 class="card-title">Logout</h3>
                    <p class="card-desc">End your session</p>
                </div>';
            } elseif ($_SESSION['type'] == 'CEO') {
                echo '
                <div class="glass-card card-inventory" onclick="redirectToPage(\'stock-management.php\')">
                    <i class="fas fa-boxes card-icon"></i>
                    <h3 class="card-title">Inventory</h3>
                    <p class="card-desc">Manage stock levels</p>
                </div>
                
                <div class="glass-card card-reports" onclick="redirectToPage(\'reports.php\')">
                    <i class="fas fa-chart-pie card-icon"></i>
                    <h3 class="card-title">Reports</h3>
                    <p class="card-desc">Business analytics</p>
                </div>
                
                <div class="glass-card card-reports" onclick="redirectToPage(\'dashboard.php\')">
                    <i class="fas fa-tachometer-alt card-icon"></i>
                    <h3 class="card-title">Dashboard Analytics</h3>
                    <p class="card-desc">Business overview</p>
                </div>';
            } elseif ($_SESSION['type'] == 'Manager') {
                echo '
                <div class="glass-card card-reports" onclick="redirectToPage(\'reports.php\')">
                    <i class="fas fa-chart-pie card-icon"></i>
                    <h3 class="card-title">Reports</h3>
                    <p class="card-desc">Business analytics</p>
                </div>
                <div class="glass-card card-reports" onclick="redirectToPage(\'backdating.php\')">
    <i class="fas fa-calendar-check card-icon"></i>
    <h3 class="card-title">Backdating</h3>
    <p class="card-desc">Date adjustment records</p>
</div>
                <div class="glass-card card-pos" onclick="redirectToPage(\'shift.php\')">
    <i class="fas fa-clock card-icon"></i>
    <h3 class="card-title">Shift Management</h3>
    <p class="card-desc">Start or manage cashier shifts</p>
</div>
             <div class="glass-card card-reports" onclick="redirectToPage(\'dashboard.php\')">
                    <i class="fas fa-tachometer-alt card-icon"></i>
                    <h3 class="card-title">Dashboard Analytics</h3>
                    <p class="card-desc">Business overview</p>
                </div>  
             
                <div class="glass-card card-employees" onclick="redirectToPage(\'employee.php\')">
                    <i class="fas fa-users card-icon"></i>
                    <h3 class="card-title">Employees</h3>
                    <p class="card-desc">Staff management</p>
                </div>
                
                <div class="glass-card card-purchases" onclick="redirectToPage(\'purchases.php\')">
                    <i class="fas fa-shopping-cart card-icon"></i>
                    <h3 class="card-title">Purchases</h3>
                    <p class="card-desc">Manage supplies</p>
                </div>
                
                <div class="glass-card card-inventory" onclick="redirectToPage(\'stock-management.php\')">
                    <i class="fas fa-box-open card-icon"></i>
                    <h3 class="card-title">Inventory</h3>
                    <p class="card-desc">Stock control</p>
                </div>
                
                <div class="glass-card card-accounting" onclick="redirectToPage(\'payments.php\')">
                    <i class="fas fa-money-bill-wave card-icon"></i>
                    <h3 class="card-title">Add Payment</h3>
                    <p class="card-desc">Process payments</p>
                </div>
                
                <div class="glass-card card-expenses" onclick="redirectToPage(\'expenses.php\')">
                    <i class="fas fa-file-invoice-dollar card-icon"></i>
                    <h3 class="card-title">Expenses</h3>
                    <p class="card-desc">Track costs</p>
                </div>
                
                <div class="glass-card card-reports" onclick="redirectToPage(\'request.php\')">
                    <i class="fas fa-exchange-alt card-icon"></i>
                    <h3 class="card-title">Dispose/Request</h3>
                    <p class="card-desc">Inventory requests</p>
                </div>
                
                <div class="glass-card card-pos" onclick="redirectToPage(\'menu.php\')">
                    <i class="fas fa-cash-register card-icon"></i>
                    <h3 class="card-title">Point of Sale</h3>
                    <p class="card-desc">Sales terminal</p>
                </div>
                
                <div class="glass-card card-logout" onclick="redirectToPage(\'logout.php\')">
                    <i class="fas fa-sign-out-alt card-icon"></i>
                    <h3 class="card-title">Logout</h3>
                    <p class="card-desc">End your session</p>
                </div>
                <div class="glass-card card-reports" onclick="redirectToPage(\'cashier.php\')">
                    <i class="fas fa-user-shield"></i>
                    <h3 class="card-title">Reports</h3>
                    <p class="card-desc">Manage inventory requests</p>
                </div>
                ';
            } elseif ($_SESSION['type'] == 'SuperCashier') {
                echo '
                <div class="glass-card card-reports" onclick="redirectToPage(\'cashier.php\')">
                    <i class="fas fa-user-shield"></i>
                    <h3 class="card-title">Reports</h3>
                    <p class="card-desc">Manage inventory requests</p>
                </div>
                
                 <div class="glass-card card-expenses" onclick="redirectToPage(\'expenses.php\')">
                    <i class="fas fa-file-invoice-dollar card-icon"></i>
                    <h3 class="card-title">Expenses</h3>
                    <p class="card-desc">Track costs</p>
                </div>
                
               ';
            } else {
                header("location:logout.php");
            }
            ?>
        </div>

        <div class="footer">
            <p>Copyright &copy; <?php echo date("Y"); ?> Designed by <a href="https://kakashitech.com" style="color: var(--accent-color);">Kakashi Tech</a></p>
        </div>
    </div>

    <script>
        // Hide preloader when page loads
        window.addEventListener('load', function() {
            document.getElementById('preloader').style.display = 'none';
        });

        function redirectToPage(url) {
            window.location.href = url;
        }

        // Fetch business details
        function fetchBusinessDetails() {
            fetch('./database/fetch_business.kts.php')
                .then(response => response.json())
                .then(data => {
                    if (!data.error) {
                        document.getElementById('shopname').innerText = data.shop_name || 'Restaurant Dashboard';
                        document.getElementById('shopname1').innerText = data.shop_name || 'Restaurant Dashboard';
                    }
                })
                .catch(error => console.error('Error:', error));
        }

        document.addEventListener('DOMContentLoaded', fetchBusinessDetails);
    </script>
</body>
</html>