<?php if (!defined('ABSPATH')) exit; ?>
<?php
/**
 * Classic - Archive Card Template
 *
 * Traditional real estate style. Horizontal card with image on left (40%),
 * details on right (60%). Prominent price. Clean lines.
 *
 * @package Integrate_Palace_Properties
 */

$prop      = new IPP_Property_Helper();
$featured  = $prop->featured_image('large');
$permalink = get_permalink();
?>
<article class="ipp-card ipp-card--classic" style="display:flex;flex-direction:row;overflow:hidden;" aria-label="<?php echo esc_attr($prop->name()); ?>">

    <a href="<?php echo esc_url($permalink); ?>" class="ipp-card__image" style="flex:0 0 40%;min-height:220px;position:relative;display:block;">
        <?php if ($featured) : ?>
            <img src="<?php echo esc_url($featured['url']); ?>"
                 alt="<?php echo esc_attr($featured['alt'] ?: $prop->name()); ?>"
                 loading="lazy"
                 style="width:100%;height:100%;object-fit:cover;">
        <?php else : ?>
            <span style="display:block;width:100%;height:100%;background:var(--ipp-color-gray-100,#f3f4f6);"></span>
        <?php endif; ?>

        <?php if ($prop->show('status') && $prop->status()) : ?>
            <span class="ipp-card__badge ipp-badge <?php echo strtolower($prop->status()) === 'active' ? 'ipp-badge--active' : 'ipp-badge--inactive'; ?>">
                <?php echo esc_html($prop->status()); ?>
            </span>
        <?php endif; ?>
    </a>

    <div style="flex:1;display:flex;flex-direction:column;padding:1.25rem;">
        <div class="ipp-card__body" style="flex:1;">
            <?php if ($prop->show('rent') && $prop->formatted_rent()) : ?>
                <p class="ipp-card__price" style="font-size:1.25rem;font-weight:700;color:var(--ipp-color-primary,#2563eb);margin:0 0 0.5rem;">
                    <?php echo esc_html($prop->formatted_rent()); ?>
                    <?php if ($prop->rental_period()) : ?>
                        <span style="font-size:0.75rem;font-weight:400;color:var(--ipp-color-gray-500,#6b7280);">/ <?php echo esc_html($prop->rental_period()); ?></span>
                    <?php endif; ?>
                </p>
            <?php endif; ?>

            <h3 class="ipp-card__title" style="margin:0 0 0.375rem;">
                <a href="<?php echo esc_url($permalink); ?>"><?php echo esc_html(get_the_title()); ?></a>
            </h3>

            <?php if ($prop->show('address') && $prop->short_address()) : ?>
                <p class="ipp-card__address" style="margin:0 0 0.75rem;">
                    <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z"/><circle cx="12" cy="10" r="3"/></svg>
                    <?php echo esc_html($prop->short_address()); ?>
                </p>
            <?php endif; ?>

            <div class="ipp-card__meta">
                <?php if ($prop->show('bedrooms') && $prop->bedrooms()) : ?>
                    <span class="ipp-card__meta-item" aria-label="<?php echo esc_attr($prop->bedrooms()); ?> bedrooms">
                        <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 7v11a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V7"/><path d="M21 11H3V9a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v2z"/><path d="M7 7V5a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v2"/></svg>
                        <?php echo esc_html($prop->bedrooms()); ?> Bed
                    </span>
                <?php endif; ?>
                <?php if ($prop->show('bathrooms') && $prop->bathrooms()) : ?>
                    <span class="ipp-card__meta-item" aria-label="<?php echo esc_attr($prop->bathrooms()); ?> bathrooms">
                        <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 12h16a1 1 0 0 1 1 1v3a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4v-3a1 1 0 0 1 1-1z"/><path d="M6 12V5a2 2 0 0 1 2-2h1"/></svg>
                        <?php echo esc_html($prop->bathrooms()); ?> Bath
                    </span>
                <?php endif; ?>
                <?php if ($prop->show('cars') && $prop->cars()) : ?>
                    <span class="ipp-card__meta-item" aria-label="<?php echo esc_attr($prop->cars()); ?> car spaces">
                        <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 17h14M5 17a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1l2-3h8l2 3h1a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2"/><circle cx="7.5" cy="15.5" r="1.5"/><circle cx="16.5" cy="15.5" r="1.5"/></svg>
                        <?php echo esc_html($prop->cars()); ?> Car
                    </span>
                <?php endif; ?>
            </div>

            <?php if ($prop->show('property_class') && $prop->property_class()) : ?>
                <p style="margin:0.5rem 0 0;font-size:0.8125rem;color:var(--ipp-color-gray-500,#6b7280);">
                    <?php echo esc_html($prop->property_class()); ?>
                </p>
            <?php endif; ?>
        </div>

        <div class="ipp-card__footer" style="border-top:1px solid var(--ipp-color-gray-200,#e5e7eb);padding-top:0.75rem;margin-top:0.75rem;">
            <?php if ($prop->show('date_available') && $prop->formatted_date_available()) : ?>
                <span style="font-size:0.8125rem;color:var(--ipp-color-gray-500,#6b7280);">
                    Available <?php echo esc_html($prop->formatted_date_available()); ?>
                </span>
            <?php endif; ?>
            <a href="<?php echo esc_url($permalink); ?>" class="ipp-btn ipp-btn--primary">View Details</a>
        </div>
    </div>

</article>
