<?php
/**
 * Template Name: Manage Event
 * Description: Template for managing events (uses The Events Calendar)
 */

// Define constant to indicate we are in a page template
define('HVAC_IN_PAGE_TEMPLATE', true);

get_header();

// The Events Calendar handles the event creation/editing interface
// This template ensures proper WordPress theme integration
?>

<style>
/* Hide duplicate headers and fix layout for event manage page */
.hvac-event-manage-wrapper .tribe-community-events #tribe-bar-form,
.hvac-event-manage-wrapper #tribe-bar-views,
.hvac-event-manage-wrapper .tribe-events-page-title {
    display: none !important;
}

.hvac-event-manage-wrapper {
    max-width: 1200px; 
    margin: 0 auto;
    padding: 20px;
}

/* Fix The Events Calendar layout issues */
.hvac-event-manage-wrapper #tribe-community-events,
.hvac-event-manage-wrapper .tribe-community-events {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    margin-top: 0 !important;
}

/* Hide any duplicate site headers within the community events content */
.hvac-event-manage-wrapper .site-header,
.hvac-event-manage-wrapper .ast-header,
.hvac-event-manage-wrapper header {
    display: none !important;
}
</style>

<div class="hvac-event-manage-wrapper">
    <?php
    // Display trainer navigation menu
    if (class_exists('HVAC_Menu_System')) {
        HVAC_Menu_System::instance()->render_trainer_menu();
    }
    ?>
    
    <div class="hvac-page-content">
        <?php
        // TEC Community Events 5.x uses its own URL structure
        // Redirect to the proper TEC Community Events pages
        ?>
        <h2>Event Management</h2>
        <p>Manage your events using the links below:</p>
        
        <div class="hvac-event-actions">
            <a href="/events/network/add/" class="button button-primary">Add New Event</a>
            <a href="/events/network/" class="button">View My Events</a>
        </div>
        
        <?php
        // Try the shortcode in case it works
        if (shortcode_exists('tribe_community_events')) {
            echo do_shortcode('[tribe_community_events]');
        }
        ?>
    </div>
</div>

<?php
get_footer();
