<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Project Gantt Chart</title>
    <style>
        /* Basic styling for the chart container */
        body, html {
            margin: 0;
            padding: 0;
            height: 100%;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
        }
        #container {
            width: 100%;
            height: 100%;
        }
    </style>
</head>
<body>

    <!-- The container where the Gantt chart will be rendered -->
    <div id="container"></div>

    <!-- Highcharts library scripts -->
    <script src="https://code.highcharts.com/gantt/gantt.js"></script>
    <script src="https://code.highcharts.com/gantt/modules/exporting.js"></script>

    <script>
        // FIX: Wrap the chart initialization in a DOMContentLoaded event listener.
        // This ensures the Highcharts library is fully loaded before the script runs.
        document.addEventListener('DOMContentLoaded', function () {
            Highcharts.ganttChart('container', {
                title: {
                    text: 'Gantt Chart'
                },
                yAxis: {
                    // Defines the tasks listed on the Y-axis
                    categories: [
                        'Literature Review & Component Procurement',
                        'Mechanical Assembly',
                        'Basic System Integration',
                        'SLAM Implementation',
                        'Fall Detection Model Training',
                        'Vision System Deployment & Testing',
                        'Conversational AI Development',
                        'Full System Integration',
                        'User Study Protocol & Ethics Approval',
                        'Participant Recruitment & User Studies',
                        'Data Analysis',
                        'Thesis Writing & Journal Publication'
                    ],
                    reversed: true, // Puts the first task at the top
                    labels: {
                        style: {
                            fontSize: '14px'
                        }
                    }
                },
                xAxis: [{
                    // Primary X-axis showing years
                    currentDateIndicator: true,
                    min: Date.UTC(2025, 10, 1), // Start date: November 2025
                    max: Date.UTC(2027, 11, 31), // End date: December 2027
                    labels: {
                        format: '{value:%Y}',
                        style: {
                            fontSize: '14px'
                        }
                    },
                    tickInterval: 1000 * 60 * 60 * 24 * 365 // One year in milliseconds
                }, {
                    // Secondary X-axis showing months
                    labels: {
                        format: '{value:%b}',
                        style: {
                            fontSize: '12px'
                        }
                    },
                    min: Date.UTC(2025, 10, 1),
                    max: Date.UTC(2027, 11, 31),
                    tickInterval: 1000 * 60 * 60 * 24 * 30.44 // Average month in milliseconds
                }],
                series: [{
                    name: 'Project Tasks',
                    data: [
                        // Each object represents a task bar with a start and end date
                        {
                            name: 'Literature Review & Component Procurement',
                            start: Date.UTC(2025, 11, 1), // Dec 2025
                            end: Date.UTC(2026, 1, 28),   // Feb 2026
                            y: 0 // Corresponds to the first category in yAxis
                        },
                        {
                            name: 'Mechanical Assembly',
                            start: Date.UTC(2026, 2, 1),   // Mar 2026
                            end: Date.UTC(2026, 3, 30),   // Apr 2026
                            y: 1
                        },
                        {
                            name: 'Basic System Integration',
                            start: Date.UTC(2026, 4, 1),   // May 2026
                            end: Date.UTC(2026, 4, 31),   // May 2026
                            y: 2
                        },
                        {
                            name: 'SLAM Implementation',
                            start: Date.UTC(2026, 5, 1),   // Jun 2026
                            end: Date.UTC(2026, 5, 30),   // Jun 2026
                            y: 3
                        },
                        {
                            name: 'Fall Detection Model Training',
                            start: Date.UTC(2026, 6, 1),   // Jul 2026
                            end: Date.UTC(2026, 7, 31),   // Aug 2026
                            y: 4
                        },
                        {
                            name: 'Vision System Deployment & Testing',
                            start: Date.UTC(2026, 8, 1),   // Sep 2026
                            end: Date.UTC(2026, 9, 31),   // Oct 2026
                            y: 5
                        },
                        {
                            name: 'Conversational AI Development',
                            start: Date.UTC(2026, 10, 1),  // Nov 2026
                            end: Date.UTC(2026, 11, 31),  // Dec 2026
                            y: 6
                        },
                        {
                            name: 'Full System Integration',
                            start: Date.UTC(2027, 0, 1),   // Jan 2027
                            end: Date.UTC(2027, 1, 28),   // Feb 2027
                            y: 7
                        },
                        {
                            name: 'User Study Protocol & Ethics Approval',
                            start: Date.UTC(2027, 2, 1),   // Mar 2027
                            end: Date.UTC(2027, 3, 30),   // Apr 2027
                            y: 8
                        },
                        {
                            name: 'Participant Recruitment & User Studies',
                            start: Date.UTC(2027, 4, 1),   // May 2027
                            end: Date.UTC(2027, 6, 31),   // Jul 2027
                            y: 9
                        },
                        {
                            name: 'Data Analysis',
                            start: Date.UTC(2027, 7, 1),   // Aug 2027
                            end: Date.UTC(2027, 9, 31),   // Oct 2027
                            y: 10
                        },
                        {
                            name: 'Thesis Writing & Journal Publication',
                            start: Date.UTC(2027, 10, 1),  // Nov 2027
                            end: Date.UTC(2027, 11, 31),  // Dec 2027
                            y: 11
                        }
                    ],
                    dataLabels: {
                        enabled: true,
                        format: '{point.name}',
                        style: {
                            fontSize: '12px',
                            fontWeight: 'normal',
                            textOutline: 'none'
                        },
                        align: 'left',
                        x: 10
                    }
                }],
                tooltip: {
                    pointFormat: '<span>Task: {point.name}</span><br/><span>From: {point.start:%d %b %Y}</span><br/><span>To: {point.end:%d %b %Y}</span>'
                },
                // Enable exporting options, including printing
                exporting: {
                    enabled: true
                }
            });
        });
    </script>

</body>
</html>