<?php
/**
 * Public Booking Cancel 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('Cancel Booking', '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">
    <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-cancel-card">
            <h1><?php esc_html_e('Cancel Booking', 'freelance-studio'); ?></h1>
            
            <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>
                </div>
            </div>
            
            <form method="post" class="fs-cancel-form">
                <p><?php esc_html_e('Are you sure you want to cancel this booking?', 'freelance-studio'); ?></p>
                
                <div class="fs-form-group">
                    <label for="reason"><?php esc_html_e('Reason for cancellation (optional)', 'freelance-studio'); ?></label>
                    <textarea name="reason" id="reason" rows="3" placeholder="<?php esc_attr_e('Let us know why you\'re cancelling...', 'freelance-studio'); ?>"></textarea>
                </div>
                
                <div class="fs-form-actions">
                    <?php 
                    $permalink_structure = get_option('permalink_structure');
                    if (empty($permalink_structure)) {
                        $keep_url = add_query_arg('fs_booking_confirm', $booking->confirmation_token, home_url('/'));
                    } else {
                        $keep_url = home_url('/fs-booking/confirm/' . $booking->confirmation_token);
                    }
                    ?>
                    <a href="<?php echo esc_url($keep_url); ?>" class="fs-btn-secondary">
                        <?php esc_html_e('Keep Booking', 'freelance-studio'); ?>
                    </a>
                    <button type="submit" name="confirm_cancel" class="fs-btn-danger">
                        <?php esc_html_e('Cancel Booking', 'freelance-studio'); ?>
                    </button>
                </div>
            </form>
        </div>
        
        <footer class="fs-booking-footer">
            <p><?php echo esc_html($business['business_name']); ?></p>
        </footer>
    </div>
</body>
</html>
