<?php

namespace GriffinForms\Admin\Html\Elements;

class ProBadge extends \GriffinForms\Admin\Html\Format
{
    protected string $label;
    protected string $variant;

    public function html(): void
    {
        $styles = $this->getVariantStyles($this->variant);

        echo '<span class="gf-pro-badge gf-pro-badge-' . esc_attr($this->variant) . '" style="' . esc_attr($styles) . '">';
        echo esc_html($this->label);
        echo '</span>';
    }

    protected function getVariantStyles(string $variant): string
    {
        if ($variant === 'gradient') {
            return 'display:inline-flex;align-items:center;border-radius:999px;padding:4px 9px;background:linear-gradient(135deg,#7c3aed 0%,#ec4899 100%);color:#fff;border:0;font-size:10px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;line-height:1;box-shadow:none;';
        }

        if ($variant === 'dark') {
            return 'display:inline-flex;align-items:center;border-radius:999px;padding:5px 11px;background:#111827;color:#fff;border:1px solid #111827;font-size:11px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;line-height:1;';
        }

        return 'display:inline-flex;align-items:center;border-radius:999px;padding:5px 11px;background:#fff;color:#111827;border:1px solid #d1d5db;font-size:11px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;line-height:1;box-shadow:0 1px 2px rgba(15,23,42,.06);';
    }

    public function __construct(string $label = 'Pro', string $variant = 'light')
    {
        $this->label = trim($label) !== '' ? $label : 'Pro';
        $this->variant = in_array($variant, ['light', 'dark', 'gradient'], true) ? $variant : 'light';
    }
}
