<?php
// List-based homepage layout
?>

<div class="container py-2">
    <div class="jumbotron">
        <h4 class="display-6"><?php echo htmlspecialchars(SITE_WELCOME, ENT_QUOTES, 'UTF-8'); ?></h4>

        <hr class="my-4">
        <p><?php echo htmlspecialchars(SITE_WELCOME_DETAILS, ENT_QUOTES, 'UTF-8'); ?></p>
        <?php if (defined('ALERT_MESSAGE') && ALERT_MESSAGE !== ''): ?>
            <div class="alert alert-warning" role="alert">
                <?php echo htmlspecialchars(ALERT_MESSAGE, ENT_QUOTES, 'UTF-8'); ?></div>
        <?php endif; ?>
    </div>
</div>

<div class="container py-3">
    <div class="row">
        <div class="col-lg-8 mx-auto">
            <div class="list-group">
                <a href="<?php echo (isLoggedIn() || ALLOW_GUEST_TICKETS) ? getCleanUrl('ticket_create') : getCleanUrl('login'); ?>"
                    class="list-group-item list-group-item-action py-3">
                    <div class="d-flex w-100 justify-content-between align-items-center">
                        <div class="d-flex align-items-center">
                            <i class="bi bi-ticket-detailed text-primary me-3" style="font-size: 1.5rem;"></i>
                            <div>
                                <h5 class="mb-1">
                                    <?php echo $lang_frontend['HOME_SUBMIT_TICKET_TITLE'] ?? 'Submit a Ticket'; ?>
                                </h5>
                                <p class="mb-0 text-muted">
                                    <?php echo $lang_frontend['HOME_SUBMIT_TICKET_DESC'] ?? "Submit a support ticket and we'll get back to you."; ?>
                                    <?php if (!isLoggedIn() && !ALLOW_GUEST_TICKETS): ?>
                                        <small
                                            class="text-muted"><?php echo $lang_frontend['HOME_LOGIN_REQUIRED_NOTE'] ?? '(Login required)'; ?></small>
                                    <?php endif; ?>
                                </p>
                            </div>
                        </div>
                        <i class="bi bi-chevron-right text-muted"></i>
                    </div>
                </a>

                <a href="<?php echo (isLoggedIn() || ALLOW_GUEST_TICKETS) ? getCleanUrl('tickets') : getCleanUrl('login'); ?>"
                    class="list-group-item list-group-item-action py-3">
                    <div class="d-flex w-100 justify-content-between align-items-center">
                        <div class="d-flex align-items-center">
                            <i class="bi bi-list-check text-primary me-3" style="font-size: 1.5rem;"></i>
                            <div>
                                <h5 class="mb-1">
                                    <?php echo $lang_frontend['HOME_VIEW_TICKETS_TITLE'] ?? 'View Your Tickets'; ?>
                                </h5>
                                <p class="mb-0 text-muted">
                                    <?php echo $lang_frontend['HOME_VIEW_TICKETS_DESC'] ?? 'Check the status of your support tickets.'; ?>
                                    <?php if (!isLoggedIn() && !ALLOW_GUEST_TICKETS): ?>
                                        <small
                                            class="text-muted"><?php echo $lang_frontend['HOME_LOGIN_REQUIRED_NOTE'] ?? '(Login required)'; ?></small>
                                    <?php endif; ?>
                                </p>
                            </div>
                        </div>
                        <i class="bi bi-chevron-right text-muted"></i>
                    </div>
                </a>
                <?php if (defined('ENABLE_STORE') && ENABLE_STORE): ?>
                    <a href="<?php echo getCleanUrl('store'); ?>" class="list-group-item list-group-item-action py-3">
                        <div class="d-flex w-100 justify-content-between align-items-center">
                            <div class="d-flex align-items-center">
                                <i class="bi bi-cart text-primary me-3" style="font-size: 1.5rem;"></i>
                                <div>
                                    <h5 class="mb-1"><?php echo $lang_frontend['PAGE_TITLE_STORE'] ?? 'Store'; ?></h5>
                                    <p class="mb-0 text-muted">
                                        <?php echo $lang_frontend['STORE_SUBHEADING_DISCOVER'] ?? 'Discover our products and services'; ?>
                                    </p>
                                </div>
                            </div>
                            <i class="bi bi-chevron-right text-muted"></i>
                        </div>
                    </a>
                <?php endif; ?>
                <?php if (defined('ENABLE_PROJECTS') && ENABLE_PROJECTS): ?>
                    <a href="<?php echo getCleanUrl('projects'); ?>" class="list-group-item list-group-item-action py-3">
                        <div class="d-flex w-100 justify-content-between align-items-center">
                            <div class="d-flex align-items-center">
                                <i class="bi bi-check-all text-primary me-3" style="font-size: 1.5rem;"></i>
                                <div>
                                    <h5 class="mb-1"><?php echo $lang_frontend['HOME_PROJECTS_TITLE'] ?? 'Projects'; ?></h5>
                                    <p class="mb-0 text-muted">
                                        <?php echo $lang_frontend['HOME_PROJECTS_DESC'] ?? 'View your active projects and tasks.'; ?>
                                    </p>
                                </div>
                            </div>
                            <i class="bi bi-chevron-right text-muted"></i>
                        </div>
                    </a>
                <?php endif; ?>

                <?php if (isLoggedIn()): ?>
                    <a href="<?php echo getCleanUrl('profile'); ?>" class="list-group-item list-group-item-action py-3">
                        <div class="d-flex w-100 justify-content-between align-items-center">
                            <div class="d-flex align-items-center">
                                <i class="bi bi-person-circle text-primary me-3" style="font-size: 1.5rem;"></i>
                                <div>
                                    <h5 class="mb-1"><?php echo $lang_frontend['HOME_PROFILE_TITLE'] ?? 'Your Profile'; ?>
                                    </h5>
                                    <p class="mb-0 text-muted">
                                        <?php echo $lang_frontend['HOME_PROFILE_DESC'] ?? 'Manage your account settings and information.'; ?>
                                    </p>
                                </div>
                            </div>
                            <i class="bi bi-chevron-right text-muted"></i>
                        </div>
                    </a>
                <?php else: ?>

                    <?php if (ALLOW_REGISTER): ?>
                        <a href="<?php echo getCleanUrl('register'); ?>" class="list-group-item list-group-item-action py-3">
                            <div class="d-flex w-100 justify-content-between align-items-center">
                                <div class="d-flex align-items-center">
                                    <i class="bi bi-person-plus text-primary me-3" style="font-size: 1.5rem;"></i>
                                    <div>
                                        <h5 class="mb-1">
                                            <?php echo $lang_frontend['HOME_CREATE_ACCOUNT_TITLE'] ?? 'Create an Account'; ?>
                                        </h5>
                                        <p class="mb-0 text-muted">
                                            <?php echo $lang_frontend['HOME_CREATE_ACCOUNT_DESC'] ?? 'Register to access all features.'; ?>
                                        </p>
                                    </div>
                                </div>
                                <i class="bi bi-chevron-right text-muted"></i>
                            </div>
                        </a>
                    <?php else: ?>
                        <a href="<?php echo getCleanUrl('login'); ?>" class="list-group-item list-group-item-action py-3">
                            <div class="d-flex w-100 justify-content-between align-items-center">
                                <div class="d-flex align-items-center">
                                    <i class="bi bi-person text-primary me-3" style="font-size: 1.5rem;"></i>
                                    <div>
                                        <h5 class="mb-1">
                                            <?php echo $lang_frontend['HOME_LOGIN_ACCOUNT_TITLE'] ?? 'Login to your Account'; ?>
                                        </h5>
                                        <p class="mb-0 text-muted">
                                            <?php echo $lang_frontend['HOME_LOGIN_ACCOUNT_DESC'] ?? 'The best way to access all features.'; ?>
                                        </p>
                                    </div>
                                </div>
                                <i class="bi bi-chevron-right text-muted"></i>
                            </div>
                        </a>
                    <?php endif; ?>

                <?php endif; ?>

                <?php if (defined('ENABLE_FAQS') && ENABLE_FAQS): ?>
                    <a href="<?php echo getCleanUrl('faq'); ?>" class="list-group-item list-group-item-action py-3">
                        <div class="d-flex w-100 justify-content-between align-items-center">
                            <div class="d-flex align-items-center">
                                <i class="bi bi-question-circle text-primary me-3" style="font-size: 1.5rem;"></i>
                                <div>
                                    <h5 class="mb-1"><?php echo $lang_frontend['HOME_FAQ_TITLE'] ?? 'FAQs'; ?></h5>
                                    <p class="mb-0 text-muted">
                                        <?php echo $lang_frontend['HOME_FAQ_DESC'] ?? 'Find answers to frequently asked questions.'; ?>
                                    </p>
                                </div>
                            </div>
                            <i class="bi bi-chevron-right text-muted"></i>
                        </div>
                    </a>
                <?php endif; ?>

                <?php if (defined('ENABLE_CONTACT') && ENABLE_CONTACT): ?>
                    <a href="<?php echo getCleanUrl('contact'); ?>" class="list-group-item list-group-item-action py-3">
                        <div class="d-flex w-100 justify-content-between align-items-center">
                            <div class="d-flex align-items-center">
                                <i class="bi bi-envelope text-primary me-3" style="font-size: 1.5rem;"></i>
                                <div>
                                    <h5 class="mb-1"><?php echo $lang_frontend['HOME_CONTACT_US_TITLE'] ?? 'Contact Us'; ?>
                                    </h5>
                                    <p class="mb-0 text-muted">
                                        <?php echo $lang_frontend['HOME_CONTACT_US_DESC'] ?? 'Get in touch with our team.'; ?>
                                    </p>
                                </div>
                            </div>
                            <i class="bi bi-chevron-right text-muted"></i>
                        </div>
                    </a>
                <?php endif; ?>
            </div>
        </div>
    </div>
</div>