<?php
/**
 * Public Booking Confirmation Page
 *
 * @package Freelance_Studio
 */

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

$booking = $data['booking'];
$meeting_type = $data['meeting_type'];
$business = $data['business'];
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
    <meta charset="<?php bloginfo('charset'); ?>">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="robots" content="noindex, nofollow">
    <title><?php esc_html_e('Booking Confirmed', 'freelance-studio'); ?> - <?php echo esc_html($business['business_name']); ?></title>
    <?php include JEEB_FS_PLUGIN_DIR . 'includes/views/public/booking/booking-styles.php'; ?>
</head>
<body class="fs-booking-page fs-confirmation-page">
    <div class="fs-booking-container">
        <header class="fs-booking-header">
            <?php if ($business['business_logo']): ?>
                <img src="<?php echo esc_url($business['business_logo']); ?>" alt="<?php echo esc_attr($business['business_name']); ?>" class="fs-booking-logo">
            <?php endif; ?>
        </header>
        
        <div class="fs-confirmation-card">
            <div class="fs-confirmation-icon">
                <svg width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                    <path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path>
                    <polyline points="22 4 12 14.01 9 11.01"></polyline>
                </svg>
            </div>
            
            <h1><?php esc_html_e('Booking Confirmed!', 'freelance-studio'); ?></h1>
            <p class="fs-confirmation-intro"><?php esc_html_e('Your meeting has been scheduled. A confirmation email has been sent to your inbox.', 'freelance-studio'); ?></p>
            
            <div class="fs-booking-details-card" style="--type-color: <?php echo esc_attr($meeting_type->color); ?>">
                <div class="fs-booking-color-bar"></div>
                
                <h2><?php echo esc_html($meeting_type->name); ?></h2>
                
                <div class="fs-booking-detail">
                    <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                        <rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect>
                        <line x1="16" y1="2" x2="16" y2="6"></line>
                        <line x1="8" y1="2" x2="8" y2="6"></line>
                        <line x1="3" y1="10" x2="21" y2="10"></line>
                    </svg>
                    <span>
                        <?php echo  esc_html( gmdate('l, F j, Y', strtotime($booking->start_datetime)) ); ?>
                    </span>
                </div>
                
                <div class="fs-booking-detail">
                    <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                        <circle cx="12" cy="12" r="10"></circle>
                        <polyline points="12,6 12,12 16,14"></polyline>
                    </svg>
                    <span>
                        <?php echo  esc_html( gmdate('g:i A', strtotime($booking->start_datetime)) ); ?> - 
                        <?php echo  esc_html( gmdate('g:i A', strtotime($booking->end_datetime)) ); ?>
                        <span class="fs-timezone">(<?php echo esc_html($booking->timezone); ?>)</span>
                    </span>
                </div>
                
                <div class="fs-booking-detail">
                    <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                        <path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z"></path>
                        <circle cx="12" cy="10" r="3"></circle>
                    </svg>
                    <span>
                        <?php echo  esc_html( FS_Meeting_Type::get_location_display($meeting_type->location_type, $meeting_type->location_details) ); ?>
                    </span>
                </div>
                
                <?php if ($meeting_type->location_details && $meeting_type->location_type !== 'custom'): ?>
                    <div class="fs-location-details">
                        <?php echo nl2br(esc_html($meeting_type->location_details)); ?>
                    </div>
                <?php endif; ?>
            </div>
            
            <div class="fs-confirmation-actions">
                <p><?php esc_html_e('Need to make changes?', 'freelance-studio'); ?></p>
                <?php 
                $permalink_structure = get_option('permalink_structure');
                if (empty($permalink_structure)) {
                    $cancel_url = add_query_arg('fs_booking_cancel', $booking->confirmation_token, home_url('/'));
                } else {
                    $cancel_url = home_url('/fs-booking/cancel/' . $booking->confirmation_token);
                }
                ?>
                <a href="<?php echo esc_url($cancel_url); ?>" class="fs-btn-secondary">
                    <?php esc_html_e('Cancel Booking', 'freelance-studio'); ?>
                </a>
            </div>
        </div>
        
        <footer class="fs-booking-footer">
            <p><?php echo esc_html($business['business_name']); ?></p>
        </footer>
    </div>
</body>
</html>
