<?php
/**
 * Meeting Types List View
 *
 * @package Freelance_Studio
 */

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

$meeting_types = $data['meeting_types'];
?>

<div class="wrap fs-wrap">
    <h1 class="fs-page-title"><?php esc_html_e('Bookings', 'freelance-studio'); ?></h1>
    
    <?php if (isset($_GET['saved'])): ?>
        <div class="notice notice-success is-dismissible">
            <p><?php esc_html_e('Meeting type saved successfully.', 'freelance-studio'); ?></p>
        </div>
    <?php endif; ?>
    
    <?php if (isset($_GET['deleted'])): ?>
        <div class="notice notice-success is-dismissible">
            <p><?php esc_html_e('Meeting type deleted.', 'freelance-studio'); ?></p>
        </div>
    <?php endif; ?>
    
    <!-- Mobile Tab Dropdown Navigation -->
    <div class="fs-tab-nav fs-bookings-tab-nav fs-mobile-only">
        <a href="<?php echo  esc_url( admin_url('admin.php?page=fs-bookings') ); ?>" class="fs-tab"><?php esc_html_e('Bookings', 'freelance-studio'); ?></a>
        <a href="<?php echo  esc_url( admin_url('admin.php?page=fs-bookings&tab=meeting-types') ); ?>" class="fs-tab active"><?php esc_html_e('Meeting Types', 'freelance-studio'); ?></a>
        <a href="<?php echo  esc_url( admin_url('admin.php?page=fs-bookings&tab=availability') ); ?>" class="fs-tab"><?php esc_html_e('Availability', 'freelance-studio'); ?></a>
        <a href="<?php echo  esc_url( admin_url('admin.php?page=fs-bookings&tab=settings') ); ?>" class="fs-tab"><?php esc_html_e('Settings', 'freelance-studio'); ?></a>
    </div>
    
    <div class="fs-settings-layout">
        <nav class="fs-settings-sidebar">
            <a href="<?php echo  esc_url( admin_url('admin.php?page=fs-bookings') ); ?>" class="fs-settings-nav-item">
                <span class="dashicons dashicons-calendar-alt"></span> <?php esc_html_e('Bookings', 'freelance-studio'); ?>
            </a>
            <a href="<?php echo  esc_url( admin_url('admin.php?page=fs-bookings&tab=meeting-types') ); ?>" class="fs-settings-nav-item active">
                <span class="dashicons dashicons-screenoptions"></span> <?php esc_html_e('Meeting Types', 'freelance-studio'); ?>
            </a>
            <a href="<?php echo  esc_url( admin_url('admin.php?page=fs-bookings&tab=availability') ); ?>" class="fs-settings-nav-item">
                <span class="dashicons dashicons-clock"></span> <?php esc_html_e('Availability', 'freelance-studio'); ?>
            </a>
            <a href="<?php echo  esc_url( admin_url('admin.php?page=fs-bookings&tab=settings') ); ?>" class="fs-settings-nav-item">
                <span class="dashicons dashicons-admin-generic"></span> <?php esc_html_e('Settings', 'freelance-studio'); ?>
            </a>
        </nav>
        
        <div class="fs-settings-content">
    
    <div class="fs-list-header">
        <a href="<?php echo  esc_url( admin_url('admin.php?page=fs-bookings&action=new-meeting-type') ); ?>" class="fs-btn fs-btn-primary">
            <?php esc_html_e('New meeting type', 'freelance-studio'); ?>
        </a>
    </div>
    
    <p><?php esc_html_e('Create different meeting types for clients to book. Each type can have its own duration, price, and settings.', 'freelance-studio'); ?></p>
    
    <?php if (empty($meeting_types)): ?>
        <div class="fs-empty-state">
            <span class="dashicons dashicons-clock"></span>
            <h3><?php esc_html_e('No meeting types yet', 'freelance-studio'); ?></h3>
            <p><?php esc_html_e('Create your first meeting type to start accepting bookings.', 'freelance-studio'); ?></p>
            <a href="<?php echo  esc_url( admin_url('admin.php?page=fs-bookings&action=new-meeting-type') ); ?>" class="button button-primary">
                <?php esc_html_e('Create Meeting Type', 'freelance-studio'); ?>
            </a>
        </div>
    <?php else: ?>
        <div class="fs-meeting-types-grid">
            <?php foreach ($meeting_types as $type): ?>
                <div class="fs-meeting-type-card <?php echo !$type->is_active ? 'fs-inactive' : ''; ?>">
                    <div class="fs-meeting-type-header" style="border-left-color: <?php echo esc_attr($type->color); ?>;">
                        <h3><?php echo esc_html($type->name); ?></h3>
                        <?php if (!$type->is_active): ?>
                            <span class="fs-badge fs-badge-warning"><?php esc_html_e('Inactive', 'freelance-studio'); ?></span>
                        <?php elseif (!$type->is_public): ?>
                            <span class="fs-badge fs-badge-info"><?php esc_html_e('Private', 'freelance-studio'); ?></span>
                        <?php endif; ?>
                    </div>
                    
                    <div class="fs-meeting-type-body">
                        <?php if ($type->description): ?>
                            <p class="fs-description"><?php echo esc_html($type->description); ?></p>
                        <?php endif; ?>
                        
                        <div class="fs-meeting-type-meta">
                            <div class="fs-meta-item">
                                <span class="dashicons dashicons-clock"></span>
                                <?php echo  esc_html( FS_Meeting_Type::get_duration_display($type->duration) ); ?>
                            </div>
                            
                            <div class="fs-meta-item">
                                <span class="dashicons dashicons-location"></span>
                                <?php echo  esc_html( FS_Meeting_Type::get_location_display($type->location_type) ); ?>
                            </div>
                            
                            <?php if ($type->price): ?>
                                <div class="fs-meta-item">
                                    <span class="dashicons dashicons-money-alt"></span>
                                    $<?php echo number_format($type->price, 2); ?>
                                </div>
                            <?php endif; ?>
                        </div>
                    </div>
                    
                    <div class="fs-meeting-type-footer">
                        <a href="<?php echo  esc_url( admin_url('admin.php?page=fs-bookings&action=edit-meeting-type&id=' . $type->id) ); ?>" class="fs-btn fs-btn-secondary fs-btn-small">
                            <?php esc_html_e('Edit', 'freelance-studio'); ?>
                        </a>
                        <a href="<?php echo  esc_url( home_url('/book/' . $type->slug) ); ?>" target="_blank" class="fs-btn fs-btn-secondary fs-btn-small">
                            <span class="dashicons dashicons-external"></span>
                            <?php esc_html_e('View Page', 'freelance-studio'); ?>
                        </a>
                        <a href="<?php echo esc_url( wp_nonce_url( admin_url('admin.php?page=fs-bookings&tab=meeting-types&delete=' . $type->id), 'fs_delete_meeting_type') ); ?>" 
                           class="fs-btn fs-btn-danger fs-btn-small" 
                           onclick="return confirm('<?php esc_attr_e('Are you sure you want to delete this meeting type?', 'freelance-studio'); ?>');">
                            <?php esc_html_e('Delete', 'freelance-studio'); ?>
                        </a>
                    </div>
                </div>
            <?php endforeach; ?>
        </div>
    <?php endif; ?>
        </div><!-- /.fs-settings-content -->
    </div><!-- /.fs-settings-layout -->
</div>
