<?php
// Default card-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="row g-4 py-2">
    <div class="col-md-4">
        <a href="<?php echo (isLoggedIn() || ALLOW_GUEST_TICKETS) ? getCleanUrl('ticket_create') : getCleanUrl('login'); ?>"
            class="card-link">
            <div class="card h-100">
                <div class="card-body text-center">
                    <i class="bi bi-ticket-detailed text-primary" style="font-size: 3rem;"></i>
                    <h3 class="card-title mt-3">
                        <?php echo $lang_frontend['HOME_SUBMIT_TICKET_TITLE'] ?? 'Submit a Ticket'; ?>
                    </h3>
                    <p class="card-text">
                        <?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): ?>
                            <br><small
                                class="text-muted"><?php echo $lang_frontend['HOME_LOGIN_REQUIRED_NOTE'] ?? '(Login required)'; ?></small>
                        <?php endif; ?>
                    </p>
                </div>
            </div>
        </a>
    </div>

    <div class="col-md-4">
        <a href="<?php echo (isLoggedIn() || ALLOW_GUEST_TICKETS) ? getCleanUrl('tickets') : getCleanUrl('login'); ?>"
            class="card-link">
            <div class="card h-100">
                <div class="card-body text-center">
                    <i class="bi bi-list-check text-primary" style="font-size: 3rem;"></i>
                    <h3 class="card-title mt-3">
                        <?php echo $lang_frontend['HOME_VIEW_TICKETS_TITLE'] ?? 'View Your Tickets'; ?>
                    </h3>
                    <p class="card-text">
                        <?php echo $lang_frontend['HOME_VIEW_TICKETS_DESC'] ?? 'Check the status of your support tickets.'; ?>
                        <?php if (!isLoggedIn() && !ALLOW_GUEST_TICKETS): ?>
                            <br><small
                                class="text-muted"><?php echo $lang_frontend['HOME_LOGIN_REQUIRED_NOTE'] ?? '(Login required)'; ?></small>
                        <?php endif; ?>
                    </p>
                </div>
            </div>
        </a>
    </div>
    <?php if (defined('ENABLE_STORE') && ENABLE_STORE): ?>
        <div class="col-md-4">
            <a href="<?php echo getCleanUrl('store'); ?>" class="card-link">
                <div class="card h-100">
                    <div class="card-body text-center">
                        <i class="bi bi-cart text-primary" style="font-size: 3rem;"></i>
                        <h3 class="card-title mt-3"><?php echo $lang_frontend['PAGE_TITLE_STORE'] ?? 'Store'; ?></h3>
                        <p class="card-text">
                            <?php echo $lang_frontend['STORE_SUBHEADING_DISCOVER'] ?? 'Discover our products and service'; ?>
                        </p>
                    </div>
                </div>
            </a>
        </div>
    <?php endif; ?>
    <?php if (defined('ENABLE_PROJECTS') && ENABLE_PROJECTS): ?>
        <div class="col-md-4">
            <a href="<?php echo getCleanUrl('projects'); ?>" class="card-link">
                <div class="card h-100">
                    <div class="card-body text-center">
                        <i class="bi bi-check-all text-primary" style="font-size: 3rem;"></i>
                        <h3 class="card-title mt-3"><?php echo $lang_frontend['HOME_PROJECTS_TITLE'] ?? 'Projects'; ?></h3>
                        <p class="card-text">
                            <?php echo $lang_frontend['HOME_PROJECTS_DESC'] ?? 'View your active projects and tasks.'; ?>
                        </p>
                    </div>
                </div>
            </a>
        </div>
    <?php endif; ?>

    <?php if (isLoggedIn()): ?>
        <div class="col-md-4">
            <a href="<?php echo getCleanUrl('profile'); ?>" class="card-link">
                <div class="card h-100">
                    <div class="card-body text-center">
                        <i class="bi bi-person-circle text-primary" style="font-size: 3rem;"></i>
                        <h3 class="card-title mt-3"><?php echo $lang_frontend['HOME_PROFILE_TITLE'] ?? 'Your Profile'; ?>
                        </h3>
                        <p class="card-text">
                            <?php echo $lang_frontend['HOME_PROFILE_DESC'] ?? 'Manage your account settings and information.'; ?>
                        </p>
                    </div>
                </div>
            </a>
        </div>
    <?php else: ?>

        <?php if (ALLOW_REGISTER): ?>
            <div class="col-md-4">
                <a href="<?php echo getCleanUrl('register'); ?>" class="card-link">
                    <div class="card h-100">
                        <div class="card-body text-center">
                            <i class="bi bi-person-plus text-primary" style="font-size: 3rem;"></i>
                            <h3 class="card-title mt-3">
                                <?php echo $lang_frontend['HOME_CREATE_ACCOUNT_TITLE'] ?? 'Create an Account'; ?>
                            </h3>
                            <p class="card-text">
                                <?php echo $lang_frontend['HOME_CREATE_ACCOUNT_DESC'] ?? 'Register to access all features.'; ?>
                            </p>
                        </div>
                    </div>
                </a>
            </div>
        <?php else: ?>
            <div class="col-md-4">
                <a href="<?php echo getCleanUrl('login'); ?>" class="card-link">
                    <div class="card h-100">
                        <div class="card-body text-center">
                            <i class="bi bi-person text-primary" style="font-size: 3rem;"></i>
                            <h3 class="card-title mt-3">
                                <?php echo $lang_frontend['HOME_LOGIN_ACCOUNT_TITLE'] ?? 'Login to your Account'; ?>
                            </h3>
                            <p class="card-text">
                                <?php echo $lang_frontend['HOME_LOGIN_ACCOUNT_DESC'] ?? 'The best way to access all features.'; ?>
                            </p>
                        </div>
                    </div>
                </a>
            </div>
        <?php endif; ?>



    <?php endif; ?>

    <?php if (defined('ENABLE_FAQS') && ENABLE_FAQS): ?>
        <div class="col-md-4">
            <a href="<?php echo getCleanUrl('faq'); ?>" class="card-link">
                <div class="card h-100">
                    <div class="card-body text-center">
                        <i class="bi bi-question-circle text-primary" style="font-size: 3rem;"></i>
                        <h3 class="card-title mt-3"><?php echo $lang_frontend['HOME_FAQ_TITLE'] ?? 'FAQ'; ?></h3>
                        <p class="card-text">
                            <?php echo $lang_frontend['HOME_FAQ_DESC'] ?? 'Find answers to frequently asked questions.'; ?>
                        </p>
                    </div>
                </div>
            </a>
        </div>
    <?php endif; ?>

    <?php if (defined('ENABLE_CONTACT') && ENABLE_CONTACT): ?>
        <div class="col-md-4">
            <a href="<?php echo getCleanUrl('contact'); ?>" class="card-link">
                <div class="card h-100">
                    <div class="card-body text-center">
                        <i class="bi bi-envelope text-primary" style="font-size: 3rem;"></i>
                        <h3 class="card-title mt-3"><?php echo $lang_frontend['HOME_CONTACT_US_TITLE'] ?? 'Contact Us'; ?>
                        </h3>
                        <p class="card-text">
                            <?php echo $lang_frontend['HOME_CONTACT_US_DESC'] ?? 'Get in touch with our team.'; ?>
                        </p>
                    </div>
                </div>
            </a>
        </div>
    <?php endif; ?>
</div>
</div>