<?php
if (!defined('ABSPATH')) exit;
$user = wp_get_current_user();
$display_name = function_exists('stakmv_get_vendor_display_name') ? stakmv_get_vendor_display_name($user->ID) : (string) $user->display_name;
$bio = function_exists('stakmv_get_vendor_bio') ? stakmv_get_vendor_bio($user->ID) : '';
$location = get_user_meta($user->ID, 'stakmv_location', true);
$rating_label = '';
if ( function_exists('stakmv_get_vendor_rating_summary') ) {
    $summary = stakmv_get_vendor_rating_summary($user->ID);
    $count = (int) ($summary['count'] ?? 0);
    if ($count > 0) {
        $rating_label = '⭐ ' . number_format_i18n((float) ($summary['average'] ?? 0), 1);
    } else {
        $rating_label = __('No feedback yet', 'stak-multivendor');
    }
}
?>

<h2 class="wcmv-section-title">Performer Profile</h2>

<div class="wcmv-profile-grid">

    <div class="wcmv-card wcmv-center">
        <div class="wcmv-avatar">
            <?php echo esc_html(strtoupper(substr($display_name, 0, 1))); ?>
        </div>
        <h3><?php echo esc_html($display_name); ?></h3>
        <p><?php echo esc_html($user->user_email); ?></p>
        <?php if ($rating_label !== '') : ?>
        <p><?php echo esc_html($rating_label); ?></p>
        <?php endif; ?>
        <p>Joined <?php echo date('d/m/Y', strtotime($user->user_registered)); ?></p>
    </div>

    <div class="wcmv-card">
        <h3>Basic Information</h3>
        <p><strong>Display Name:</strong> <?php echo esc_html($display_name); ?></p>
        <p><strong>Bio:</strong> <?php echo $bio !== '' ? esc_html($bio) : esc_html__('No bio added yet', 'stak-multivendor'); ?></p>
        <p><strong>Location:</strong> <?php echo $location !== '' ? esc_html($location) : esc_html__('Not set', 'stak-multivendor'); ?></p>

        <button class="wcmv-btn">Edit Profile</button>
    </div>

</div>
