<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{ hotelName() }} - Management System</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        body {
            background-color: #f8f9fa;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            margin: 0;
            padding: 0;
            min-height: 100vh;
        }
        
        .navbar {
            background: linear-gradient(90deg, var(--dark-green) 0%, var(--primary-green) 100%);
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        }
        
        .main-content {
            padding: 30px;
        }
        
        .dashboard-header {
            margin-bottom: 30px;
            text-align: center;
        }
        
        .dashboard-header h1 {
            color: var(--dark-green);
            font-weight: 700;
        }
        
        .dashboard-header p {
            color: #6c757d;
            margin-bottom: 0;
            font-size: 1.1rem;
        }
        
        .modules-container {
            display: flex;
            flex-direction: column;
            gap: 25px;
            max-width: 1200px;
            margin: 0 auto;
        }
        
        .module-row {
            display: flex;
            gap: 20px;
            justify-content: center;
        }
        
        .module-card {
            background-color: white;
            border-radius: 8px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
            padding: 25px 20px;
            transition: all 0.3s;
            text-align: center;
            border-top: 4px solid var(--primary-green);
            cursor: pointer;
            text-decoration: none;
            display: block;
            color: inherit;
            flex: 1;
            min-width: 200px;
            max-width: 220px;
            height: 140px;
            display: flex;
            flex-direction: column;
            justify-content: center;
        }
        
        .module-card:hover {
            transform: translateY(-3px);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
            background-color: #f8f9fa;
            color: inherit;
            text-decoration: none;
        }
        
        .module-title {
            font-size: 1.1rem;
            font-weight: 600;
            color: var(--dark-green);
            margin: 0 0 8px 0;
            line-height: 1.3;
        }
        
        .module-description {
            color: #6c757d;
            font-size: 0.85rem;
            line-height: 1.4;
            margin: 0;
        }
        
        .welcome-banner {
            background: linear-gradient(90deg, var(--dark-green) 0%, var(--primary-green) 100%);
            border-radius: 10px;
            color: white;
            padding: 25px;
            margin-bottom: 30px;
        }
        
        .quick-stats {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 20px;
            margin-bottom: 30px;
            max-width: 900px;
            margin-left: auto;
            margin-right: auto;
        }
        
        .stat-card {
            background-color: white;
            border-radius: 10px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
            padding: 20px;
            text-align: center;
            border-left: 4px solid var(--primary-green);
        }
        
        .stat-value {
            font-size: 2rem;
            font-weight: 700;
            color: var(--dark-green);
            margin-bottom: 5px;
        }
        
        .stat-label {
            font-size: 0.9rem;
            color: #6c757d;
            text-transform: uppercase;
        }
        
        @media (max-width: 992px) {
            .module-row {
                flex-wrap: wrap;
            }
            
            .module-card {
                min-width: 180px;
                max-width: 180px;
                height: 130px;
            }
        }
        
        @media (max-width: 768px) {
            .module-row {
                flex-wrap: wrap;
            }
            
            .module-card {
                min-width: 160px;
                max-width: 160px;
                height: 120px;
                padding: 20px 15px;
            }
            
            .quick-stats {
                grid-template-columns: 1fr 1fr;
            }
        }
        
        @media (max-width: 576px) {
            .module-row {
                flex-wrap: wrap;
            }
            
            .module-card {
                min-width: 140px;
                max-width: 140px;
                height: 110px;
                padding: 15px 10px;
            }
            
            .module-title {
                font-size: 1rem;
            }
            
            .module-description {
                font-size: 0.8rem;
            }
            
            .quick-stats {
                grid-template-columns: 1fr;
            }
        }
    </style>
</head>
<body>
    <!-- Navbar -->
    <nav class="navbar navbar-expand-lg navbar-dark">
        <div class="container-fluid">
            <a class="navbar-brand" href="{{ url('/home') }}">
                {{ hotelName() }}
            </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 ms-auto">
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-bs-toggle="dropdown">
                            <i class="fas fa-user-circle me-1"></i> <span id="userName">{{ Auth::user()->name ?? 'User' }}</span>
                        </a>
                        <ul class="dropdown-menu dropdown-menu-end">
                            <li><a class="dropdown-item" href="{{ url('/profile') }}"><i class="fas fa-user me-2"></i> Profile</a></li>
                            <li><a class="dropdown-item" href="{{ url('/settings') }}"><i class="fas fa-cog me-2"></i> Settings</a></li>
                            <li><hr class="dropdown-divider"></li>
                            <li>
                                <a class="dropdown-item" href="{{ route('logout') }}" 
                                   onclick="event.preventDefault(); document.getElementById('logout-form').submit();">
                                    <i class="fas fa-sign-out-alt me-2"></i> Logout
                                </a>
                                <form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
                                    @csrf
                                </form>
                            </li>
                        </ul>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

    <!-- Main Content Area -->
    <div class="main-content">
        <!-- Welcome Banner -->
        <div class="welcome-banner">
            <div class="row align-items-center">
                <div class="col-md-8">
                    <h2>Welcome back, <span id="welcomeUserName">{{ Auth::user()->name ?? 'Admin' }}</span>!</h2>
                    <p class="mb-0">Access all hotel management functions from one central location.</p>
                </div>
                <div class="col-md-4 text-md-end">
                    <p class="mb-0" id="currentDate">{{ date('l, F j, Y') }}</p>
                    <p class="mb-0" id="currentTime">{{ date('h:i A') }}</p>
                </div>
            </div>
        </div>

        <!-- Quick Stats -->
        <div class="quick-stats">
            <div class="stat-card">
                <div class="stat-value">{{ $totalRooms ?? '42' }}</div>
                <div class="stat-label">Total Rooms</div>
            </div>
            <div class="stat-card">
                <div class="stat-value">{{ $occupiedRooms ?? '24' }}</div>
                <div class="stat-label">Occupied Rooms</div>
            </div>
            <div class="stat-card">
                <div class="stat-value">{{ $todayCheckins ?? '5' }}</div>
                <div class="stat-label">Today's Check-ins</div>
            </div>
            <div class="stat-card">
                <div class="stat-value">UGX {{ number_format($dailyRevenue ?? '2450000', 0) }}</div>
                <div class="stat-label">Today's Revenue</div>
            </div>
        </div>

        <!-- Dashboard Header -->
        <div class="dashboard-header">
            <h1>{{ hotelName() }}</h1>
            <p>Select a module to manage different aspects of your hotel operations</p>
        </div>
        
        <!-- Modules arranged like the image -->
        <div class="modules-container">
            <!-- Row 1 -->
            <div class="module-row">
                <a href="{{ url('/rooms') }}" class="module-card">
                    <p class="module-title">Room Management</p>
                    <p class="module-description">Manage room availability, types, and status</p>
                </a>
                <a href="{{ url('/reservations') }}" class="module-card">
                    <p class="module-title">Reservations</p>
                    <p class="module-description">View and manage all bookings</p>
                </a>
                <a href="{{ url('/guests') }}" class="module-card">
                    <p class="module-title">Guests</p>
                    <p class="module-description">Manage guest profiles and history</p>
                </a>
                <a href="{{ url('/inout') }}" class="module-card">
                    <p class="module-title">In/Out Log</p>
                    <p class="module-description">Track guest check-ins and check-outs</p>
                </a>
                <a href="{{ url('/services') }}" class="module-card">
                    <p class="module-title">Services</p>
                    <p class="module-description">Manage hotel services and amenities</p>
                </a>
            </div>
            
            <!-- Row 2 -->
            <div class="module-row">
                <a href="{{ url('/pos') }}" class="module-card">
                    <p class="module-title">Point of Sale</p>
                    <p class="module-description">Process restaurant and bar orders</p>
                </a>
                <a href="{{ url('/housekeeping') }}" class="module-card">
                    <p class="module-title">Housekeeping</p>
                    <p class="module-description">Track room cleaning status</p>
                </a>
                <a href="{{ url('/maintenance') }}" class="module-card">
                    <p class="module-title">Maintenance</p>
                    <p class="module-description">Manage maintenance requests</p>
                </a>
                <a href="{{ url('/inventory') }}" class="module-card">
                    <p class="module-title">Inventory</p>
                    <p class="module-description">Track supplies and stock levels</p>
                </a>
                <a href="{{ url('/Accounts') }}" class="module-card">
                    <p class="module-title">Accounts</p>
                    <p class="module-description">Manage financial transactions</p>
                </a>
            </div>
            
            <!-- Row 3 -->
            <div class="module-row">
                <a href="{{ url('/staff') }}" class="module-card">
                    <p class="module-title">Staff Management</p>
                    <p class="module-description">Manage assistance schedules and</p>
                </a>
                <a href="{{ url('/contacts') }}" class="module-card">
                    <p class="module-title">Contacts</p>
                    <p class="module-description">Manage conduct and actions</p>
                </a>
                <a href="{{ url('/documents') }}" class="module-card">
                    <p class="module-title">Documents</p>
                    <p class="module-description">Across important tasks</p>
                </a>
                <a href="{{ url('/reports') }}" class="module-card">
                    <p class="module-title">Reports</p>
                    <p class="module-description">Access detailed operational reports</p>
                </a>
                <a href="{{ url('/surveys') }}" class="module-card">
                    <p class="module-title">Surveys</p>
                    <p class="module-description">View guest feedback and surveys</p>
                </a>
            </div>
            
            <!-- Row 4 -->
            <div class="module-row">
                <a href="{{ url('/settings') }}" class="module-card">
                    <p class="module-title">Settings</p>
                    <p class="module-description">Configure system preferences</p>
                </a>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <script>
        // Update date and time
        function updateDateTime() {
            const now = new Date();
            const options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
            document.getElementById('currentDate').textContent = now.toLocaleDateString('en-US', options);
            document.getElementById('currentTime').textContent = now.toLocaleTimeString('en-US', {
                hour: '2-digit',
                minute: '2-digit'
            });
        }

        // Initialize on page load
        document.addEventListener('DOMContentLoaded', function() {
            updateDateTime();
            setInterval(updateDateTime, 60000); // Update every minute
            
            // Add click animation to module cards
            const moduleCards = document.querySelectorAll('.module-card');
            
            moduleCards.forEach(card => {
                card.addEventListener('click', function() {
                    // Add a temporary active class for visual feedback
                    this.classList.add('active');
                    setTimeout(() => {
                        this.classList.remove('active');
                    }, 300);
                });
            });
        });
    </script>
</body>
</html>
