<?php
/**
 * Template View: Meeting Card
 *
 * Schedule meeting card with calendar link.
 *
 * @package    BoostBot
 * @subpackage Templates/Views
 * @since      1.6.0
 *
 * @var string $title         Meeting title.
 * @var string $description   Meeting description (optional).
 * @var string $duration      Duration (e.g., "30 דקות").
 * @var string $calendar_url  Calendar/booking URL.
 * @var array  $availability  Available slots (optional).
 */

// phpcs:ignoreFile WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-scope variables set by the includer, not true globals.

// Prevent direct access
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

// Validate required data
if ( empty( $title ) || empty( $calendar_url ) ) {
    return;
}
?>

<div class="bb-meeting-card">
    <div class="bb-meeting-header">
        <span class="bb-meeting-icon">📅</span>
        <div class="bb-meeting-info">
            <h4 class="bb-meeting-title"><?php echo esc_html( $title ); ?></h4>
            <?php if ( ! empty( $duration ) ) : ?>
                <span class="bb-meeting-duration">
                    <span class="bb-duration-icon">⏱️</span>
                    <?php echo esc_html( $duration ); ?>
                </span>
            <?php endif; ?>
        </div>
    </div>
    
    <?php if ( ! empty( $description ) ) : ?>
        <div class="bb-meeting-description">
            <?php echo esc_html( $description ); ?>
        </div>
    <?php endif; ?>
    
    <?php if ( ! empty( $availability ) && is_array( $availability ) ) : ?>
        <div class="bb-meeting-slots">
            <div class="bb-slots-label"><?php esc_html_e( 'זמנים זמינים:', 'boostbot' ); ?></div>
            <div class="bb-slots-list">
                <?php foreach ( array_slice( $availability, 0, 4 ) as $slot ) : ?>
                    <span class="bb-slot-item"><?php echo esc_html( $slot ); ?></span>
                <?php endforeach; ?>
                <?php if ( count( $availability ) > 4 ) : ?>
                    <span class="bb-slot-more">+<?php echo esc_html( count( $availability ) - 4 ); ?></span>
                <?php endif; ?>
            </div>
        </div>
    <?php endif; ?>
    
    <a href="<?php echo esc_url( $calendar_url ); ?>" class="bb-meeting-cta" target="_blank" rel="noopener noreferrer">
        <span class="bb-cta-icon">🗓️</span>
        <span class="bb-cta-text"><?php esc_html_e( 'קבע פגישה', 'boostbot' ); ?></span>
    </a>
</div>
