<?php
/**
 * Base Template for HVAC Plugin Pages
 * 
 * Handles 80% of plugin templates with dynamic content loading
 * 
 * @package HVAC_Community_Events
 * @since 2.0.0
 */

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

// Security check
if (!defined('ABSPATH')) {
    exit;
}

get_header();

// Get page configuration
$page_slug = get_post_field('post_name', get_queried_object_id());
$page_config = HVAC_Template_Router::get_page_config($page_slug);

// Security and capability check
if (!HVAC_Template_Security::check_page_access($page_config)) {
    get_template_part('templates/parts/hvac-access-denied');
    get_footer();
    return;
}
?>

<div class="hvac-page-wrapper hvac-<?php echo esc_attr(str_replace('/', '-', $page_slug)); ?>-page">
    <?php
    // Load page header (navigation, breadcrumbs)
    get_template_part('templates/parts/hvac-page-header', null, [
        'page_config' => $page_config,
        'show_navigation' => $page_config['show_navigation'] ?? true,
        'show_breadcrumbs' => $page_config['show_breadcrumbs'] ?? true
    ]);
    ?>
    
    <div class="container">
        <?php
        // Load status messages if any
        get_template_part('templates/parts/hvac-status-messages');
        
        // Load dynamic content based on page configuration
        get_template_part('templates/parts/hvac-content-loader', null, [
            'page_config' => $page_config,
            'page_slug' => $page_slug
        ]);
        ?>
    </div>
</div>

<?php get_footer(); ?>