<?php
// addons/verified_sellers/main.php
require_once __DIR__ . '/../../config/db.php';

if (!function_exists('get_user_badges')) {
    function get_user_badges($user_id, $pdo) {
        if (!$user_id) return '';

        try {
            $stmt = $pdo->prepare("SELECT is_verified, is_fast_seller, is_trusted FROM user_verifications WHERE user_id = ? LIMIT 1");
            $stmt->execute([$user_id]);
            $badges = $stmt->fetch(PDO::FETCH_ASSOC);

            $output = '<span class="v-badge-container" style="display: inline-flex; gap: 6px; align-items: center; vertical-align: middle; margin-left: 8px;">';
            
            // --- MEDALLA EXCLUSIVA DE ADMINISTRADOR (SOLO PARA ID 2 - RIZZEN) ---
            if ($user_id == 2) {
                $output .= '<i class="fa-solid fa-crown" 
                               style="color: #ffcc00; font-size: 1.1em; cursor: help; filter: drop-shadow(0 0 5px rgba(255, 204, 0, 0.5));" 
                               title="Official Store: Managed by VVault Administration"></i>';
            }

            if ($badges) {
                // 1. Check Azul (Verified)
                if ($badges['is_verified'] == 1) {
                    $output .= '<i class="fa-solid fa-circle-check" 
                                   style="color: #3897f0; font-size: 0.95em; cursor: help;" 
                                   title="Verified Seller: Identity confirmed by VVault"></i>';
                }
                
                // 2. Rayo Amarillo (Fast Seller)
                if ($badges['is_fast_seller'] == 1) {
                    $output .= '<i class="fa-solid fa-bolt" 
                                   style="color: #ffcc00; font-size: 0.95em; cursor: help;" 
                                   title="Fast Seller: Known for lightning-fast deliveries"></i>';
                }
                
                // 3. Escudo Verde (Trusted Seller)
                if ($badges['is_trusted'] == 1) {
                    $output .= '<i class="fa-solid fa-shield-halved" 
                                   style="color: #00ff88; font-size: 0.95em; cursor: help;" 
                                   title="Trusted Seller: Outstanding sales record and support"></i>';
                }
            }

            $output .= '</span>';
            return $output;

        } catch (Exception $e) {
            return ''; 
        }
    }
}