<?php
/**
 * HVAC Event Navigation Shortcode
 * 
 * Provides a shortcode for adding navigation to event-related pages
 * 
 * @package HVAC_Community_Events
 * @since 1.0.0
 */

if (!defined('ABSPATH')) {
    exit;
}

class HVAC_Event_Navigation {
    
    /**
     * Constructor - DISABLED: Replaced with HVAC_Menu_System
     */
    public function __construct() {
        // Old event navigation disabled to prevent conflicts with new WordPress menu system
        // All functionality moved to HVAC_Menu_System class
        
        // // Register the shortcode
        // add_shortcode('hvac_event_navigation', array($this, 'render_navigation'));
    }
    
    /**
     * Render the navigation shortcode
     */
    public function render_navigation($atts = array()) {
        // Parse attributes
        $atts = shortcode_atts(array(
            'page_title' => '',
            'show_instructions' => 'no'
        ), $atts);
        
        // Start output buffering
        ob_start();
        
        // Check if Help System is available for tooltips
        $help_available = class_exists('HVAC_Help_System');
        
        ?>
        <div class="hvac-dashboard-header">
            <?php if (!empty($atts['page_title'])) : ?>
                <h1 class="entry-title"><?php echo esc_html($atts['page_title']); ?></h1>
            <?php endif; ?>
            <div class="hvac-dashboard-nav">
                <?php
                // Dashboard link
                if ($help_available) {
                    echo HVAC_Help_System::add_tooltip(
                        '<a href="' . esc_url(home_url('/hvac-dashboard/')) . '" class="ast-button ast-button-secondary">Dashboard</a>',
                        'Return to your main dashboard to view stats and manage events'
                    );
                } else {
                    echo '<a href="' . esc_url(home_url('/hvac-dashboard/')) . '" class="ast-button ast-button-secondary">Dashboard</a>';
                }
                
                // Generate Certificates link
                if ($help_available) {
                    echo HVAC_Help_System::add_tooltip(
                        '<a href="' . esc_url(home_url('/generate-certificates/')) . '" class="ast-button ast-button-primary">Generate Certificates</a>',
                        'Create professional certificates for attendees who completed your training'
                    );
                } else {
                    echo '<a href="' . esc_url(home_url('/generate-certificates/')) . '" class="ast-button ast-button-primary">Generate Certificates</a>';
                }
                
                // Certificate Reports link
                if ($help_available) {
                    echo HVAC_Help_System::add_tooltip(
                        '<a href="' . esc_url(home_url('/certificate-reports/')) . '" class="ast-button ast-button-primary">Certificate Reports</a>',
                        'View and manage all certificates you\'ve issued to attendees'
                    );
                } else {
                    echo '<a href="' . esc_url(home_url('/certificate-reports/')) . '" class="ast-button ast-button-primary">Certificate Reports</a>';
                }
                
                // Trainer Profile link
                if ($help_available) {
                    echo HVAC_Help_System::add_tooltip(
                        '<a href="' . esc_url(home_url('/trainer-profile/')) . '" class="ast-button ast-button-secondary">View Profile</a>',
                        'Update your professional credentials, business information, and training specialties'
                    );
                } else {
                    echo '<a href="' . esc_url(home_url('/trainer-profile/')) . '" class="ast-button ast-button-secondary">View Profile</a>';
                }
                
                // Help and Logout links
                ?>
                <a href="<?php echo esc_url(home_url('/hvac-documentation/')); ?>" class="ast-button ast-button-secondary">Help</a>
                <a href="<?php echo esc_url(wp_logout_url(home_url('/community-login/'))); ?>" class="ast-button ast-button-secondary">Logout</a>
            </div>
        </div>
        
        <?php if ($atts['show_instructions'] === 'yes') : ?>
        <div class="hvac-info-section">
            <div class="hvac-instruction-text">
                <p><strong>📝 Create Your Training Event:</strong> Fill in the required fields below including event title, dates, and pricing. All fields marked with an asterisk (*) are required for publication.</p>
                <p><strong>🎯 Event Visibility:</strong> Your published events will appear in the main events directory and your trainer dashboard, where attendees can register and make payments.</p>
                <p><strong>💼 Professional Features:</strong> Each event includes automatic attendee management, certificate generation capabilities, and integrated payment processing through PayPal.</p>
            </div>
        </div>
        <?php endif; ?>
        
        <style>
        .hvac-dashboard-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            flex-wrap: wrap;
        }
        
        .hvac-dashboard-nav {
            display: flex;
            gap: 10px;
            flex-wrap: wrap;
        }
        
        .hvac-info-section {
            background: #f8f9fa;
            border: 1px solid #e9ecef;
            border-radius: 8px;
            padding: 20px;
            margin: 20px 0 30px 0;
            box-shadow: 0 1px 3px rgba(0,0,0,0.1);
        }
        
        .hvac-instruction-text {
            font-size: 0.95rem;
            line-height: 1.6;
            color: #495057;
        }
        
        .hvac-instruction-text p {
            margin: 0 0 12px 0;
        }
        
        .hvac-instruction-text p:last-child {
            margin-bottom: 0;
        }
        
        .hvac-instruction-text strong {
            color: #212529;
            font-weight: 600;
        }
        
        @media (max-width: 768px) {
            .hvac-dashboard-header {
                flex-direction: column;
                align-items: flex-start;
            }
            
            .hvac-dashboard-nav {
                margin-top: 15px;
                width: 100%;
            }
        }
        </style>
        <?php
        
        return ob_get_clean();
    }
}