<?php
if (!defined('ABSPATH')) {
    exit;
}
?>
<section class="yatra-trip-section" id="included">
    <h2 class="yatra-trip-section-title">
        <?php yatra_render_tab_icon($tab->icon ?? null, 'check', 'yatra-trip-section-title-icon', $tab->label ?? "What's Included & Excluded"); ?>
        <?php echo esc_html(isset($tab->label) ? $tab->label : __("What's Included & Excluded", 'yatra')); ?>
    </h2>
    <div class="yatra-included-excluded">
        <?php 
        $included_items = $trip->getIncludedItems();
        if (!empty($included_items)): 
        ?>
            <div class="yatra-included-section">
                <h3>
                    <?php echo yatra_svg_icon('check', 'yatra-included-icon'); ?>
                    <?php echo esc_html__('Included', 'yatra'); ?>
                </h3>
                <ul class="yatra-included-list">
                    <?php foreach ($included_items as $item): ?>
                        <?php
                        $item_title = is_array($item) ? ($item['title'] ?? '') : (is_object($item) ? ($item->title ?? '') : $item);
                        $item_desc = is_array($item) ? ($item['description'] ?? '') : (is_object($item) ? ($item->description ?? '') : '');
                        ?>
                        <?php if (!empty($item_title)): ?>
                            <li>
                                <?php echo yatra_svg_icon('check', 'yatra-included-icon'); ?>
                                <div class="yatra-item-content">
                                    <div class="yatra-item-title"><?php echo esc_html($item_title); ?></div>
                                    <?php if (!empty($item_desc)): ?>
                                        <div class="yatra-item-desc"><?php echo esc_html($item_desc); ?></div>
                                    <?php endif; ?>
                                </div>
                            </li>
                        <?php endif; ?>
                    <?php endforeach; ?>
                </ul>
            </div>
        <?php endif; ?>
        <?php 
        $excluded_items = $trip->getExcludedItems();
        if (!empty($excluded_items)): 
        ?>
            <div class="yatra-excluded-section">
                <h3>
                    <?php echo yatra_svg_icon('x', 'yatra-excluded-icon'); ?>
                    <?php echo esc_html__('Excluded', 'yatra'); ?>
                </h3>
                <ul class="yatra-excluded-list">
                    <?php foreach ($excluded_items as $item): ?>
                        <?php
                        $item_title = is_array($item) ? ($item['title'] ?? '') : (is_object($item) ? ($item->title ?? '') : $item);
                        $item_desc = is_array($item) ? ($item['description'] ?? '') : (is_object($item) ? ($item->description ?? '') : '');
                        ?>
                        <?php if (!empty($item_title)): ?>
                            <li>
                                <?php echo yatra_svg_icon('x', 'yatra-excluded-icon'); ?>
                                <div class="yatra-item-content">
                                    <div class="yatra-item-title"><?php echo esc_html($item_title); ?></div>
                                    <?php if (!empty($item_desc)): ?>
                                        <div class="yatra-item-desc"><?php echo esc_html($item_desc); ?></div>
                                    <?php endif; ?>
                                </div>
                            </li>
                        <?php endif; ?>
                    <?php endforeach; ?>
                </ul>
            </div>
        <?php endif; ?>
    </div>
</section>