<?php
session_start();
include 'layouts/main.php';
include 'layouts/dbconn.php';

// Check if user is logged in
if (!isset($_SESSION['user_id'])) {
    header('Location: login.php');
    exit();
}
?>

<!DOCTYPE html>
<html>

<head>
    <?php includeFileWithVariables('layouts/title-meta.php', array('title' => 'Help & Support')); ?>
    <?php include 'layouts/head-css.php'; ?>
</head>

<body>
    <div id="layout-wrapper">
        <?php include 'layouts/menu.php'; ?>

        <div class="main-content">
            <div class="page-content">
                <div class="container-fluid">
                    <!-- Page Title -->
                    <div class="row">
                        <div class="col-12">
                            <div class="page-title-box d-sm-flex align-items-center justify-content-between">
                                <h4 class="mb-sm-0">Help & Support</h4>
                                <div class="page-title-right">
                                    <ol class="breadcrumb m-0">
                                        <li class="breadcrumb-item"><a href="index.php">Dashboard</a></li>
                                        <li class="breadcrumb-item active">Help & Support</li>
                                    </ol>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-xl-4">
                            <div class="card">
                                <div class="card-header">
                                    <h5 class="card-title mb-0">Contact Support</h5>
                                </div>
                                <div class="card-body">
                                    <div class="d-flex align-items-center mb-4">
                                        <div class="flex-shrink-0">
                                            <div class="avatar-xs">
                                                <span
                                                    class="avatar-title bg-primary-subtle text-primary rounded-circle fs-16">
                                                    <i class="ri-phone-line"></i>
                                                </span>
                                            </div>
                                        </div>
                                        <div class="flex-grow-1 ms-3">
                                            <h5 class="mb-1">Phone Support</h5>
                                            <p class="text-muted mb-0">+254 700 000 000</p>
                                        </div>
                                    </div>

                                    <div class="d-flex align-items-center mb-4">
                                        <div class="flex-shrink-0">
                                            <div class="avatar-xs">
                                                <span
                                                    class="avatar-title bg-success-subtle text-success rounded-circle fs-16">
                                                    <i class="ri-mail-line"></i>
                                                </span>
                                            </div>
                                        </div>
                                        <div class="flex-grow-1 ms-3">
                                            <h5 class="mb-1">Email Support</h5>
                                            <p class="text-muted mb-0">support@polakis360.com</p>
                                        </div>
                                    </div>

                                    <div class="d-flex align-items-center">
                                        <div class="flex-shrink-0">
                                            <div class="avatar-xs">
                                                <span
                                                    class="avatar-title bg-warning-subtle text-warning rounded-circle fs-16">
                                                    <i class="ri-map-pin-line"></i>
                                                </span>
                                            </div>
                                        </div>
                                        <div class="flex-grow-1 ms-3">
                                            <h5 class="mb-1">Location</h5>
                                            <p class="text-muted mb-0">Main Hospital Branch, Nairobi</p>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="card">
                                <div class="card-header">
                                    <h5 class="card-title mb-0">System Information</h5>
                                </div>
                                <div class="card-body">
                                    <div class="table-responsive">
                                        <table class="table table-borderless table-sm mb-0">
                                            <tbody>
                                                <tr>
                                                    <th scope="row" style="width: 40%;">Version</th>
                                                    <td class="text-muted">v2.5.0</td>
                                                </tr>
                                                <tr>
                                                    <th scope="row">Last Updated</th>
                                                    <td class="text-muted">Dec 2025</td>
                                                </tr>
                                                <tr>
                                                    <th scope="row">PHP Version</th>
                                                    <td class="text-muted"><?php echo phpversion(); ?></td>
                                                </tr>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="col-xl-8">
                            <div class="card">
                                <div class="card-header">
                                    <h5 class="card-title mb-0">Frequently Asked Questions</h5>
                                </div>
                                <div class="card-body">
                                    <div class="accordion accordion-flush" id="faqAccordion">
                                        <div class="accordion-item">
                                            <h2 class="accordion-header" id="flush-headingOne">
                                                <button class="accordion-button collapsed" type="button"
                                                    data-bs-toggle="collapse" data-bs-target="#flush-collapseOne">
                                                    How do I reset my password?
                                                </button>
                                            </h2>
                                            <div id="flush-collapseOne" class="accordion-collapse collapse show"
                                                data-bs-parent="#faqAccordion">
                                                <div class="accordion-body">
                                                    You can change your password by navigating to <b>My Account > Change
                                                        Password</b>. If you cannot log in, please contact the system
                                                    administrator to reset your credentials.
                                                </div>
                                            </div>
                                        </div>
                                        <div class="accordion-item">
                                            <h2 class="accordion-header" id="flush-headingTwo">
                                                <button class="accordion-button collapsed" type="button"
                                                    data-bs-toggle="collapse" data-bs-target="#flush-collapseTwo">
                                                    How do I report a system error?
                                                </button>
                                            </h2>
                                            <div id="flush-collapseTwo" class="accordion-collapse collapse"
                                                data-bs-parent="#faqAccordion">
                                                <div class="accordion-body">
                                                    If you encounter an error, please take a screenshot and email it to
                                                    support@polakis360.com or use the 'Submit Ticket' form below.
                                                </div>
                                            </div>
                                        </div>
                                        <div class="accordion-item">
                                            <h2 class="accordion-header" id="flush-headingThree">
                                                <button class="accordion-button collapsed" type="button"
                                                    data-bs-toggle="collapse" data-bs-target="#flush-collapseThree">
                                                    Can I access the system from home?
                                                </button>
                                            </h2>
                                            <div id="flush-collapseThree" class="accordion-collapse collapse"
                                                data-bs-parent="#faqAccordion">
                                                <div class="accordion-body">
                                                    Yes, the system is web-based and can be accessed securely from
                                                    anywhere using your login credentials. However, some sensitive
                                                    actions may be restricted to hospital networks only.
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="card">
                                <div class="card-header">
                                    <h5 class="card-title mb-0">Submit a Support Ticket</h5>
                                </div>
                                <div class="card-body">
                                    <form action="submit_ticket.php" method="POST">
                                        <div class="row">
                                            <div class="col-md-6 mb-3">
                                                <label class="form-label">Subject</label>
                                                <input type="text" class="form-control" name="subject" required>
                                            </div>
                                            <div class="col-md-6 mb-3">
                                                <label class="form-label">Priority</label>
                                                <select class="form-select" name="priority">
                                                    <option value="LOW">Low</option>
                                                    <option value="MEDIUM" selected>Medium</option>
                                                    <option value="HIGH">High</option>
                                                    <option value="CRITICAL">Critical</option>
                                                </select>
                                            </div>
                                            <div class="col-12 mb-3">
                                                <label class="form-label">Description</label>
                                                <textarea class="form-control" name="description" rows="4"
                                                    required></textarea>
                                            </div>
                                        </div>
                                        <div class="text-end">
                                            <button type="submit" class="btn btn-primary">Submit Ticket</button>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
            <?php include 'layouts/footer.php'; ?>
        </div>
    </div>
    <?php include 'layouts/vendor-scripts.php'; ?>
</body>

</html>