<?php

namespace Components\Resources;

use Components\Base;

/**
 * TemplateCardSkeleton component for skeleton loading states of TemplateCards
 */
class TemplateCardSkeleton
{
    /**
     * Render multiple skeleton cards
     *
     * @param int $count Number of skeleton cards to render
     * @return string
     */
    public static function render(int $count = 4): string
    {
        $html = '';
        for ($i = 0; $i < $count; $i++) {
            $html .= self::renderSingle();
        }
        return $html;
    }

    /**
     * Render a single skeleton card matching TemplateCard structure
     *
     * @return string
     */
    public static function renderSingle(): string
    {
        $cardHtml = TemplateCardUI::render([
            'card_classes' => 'animate-pulse',
            'preview_content' => '<div class="flex items-center justify-center h-full"><div class="text-secondary ">' . Base::SVG_SPINNER . '</div></div>',
            'preview_classes' => 'bg-gray-100 dark:bg-zinc-800/50',
            'body_header_html' => '<div class="h-4 bg-gray-200 dark:bg-zinc-700/50 rounded w-3/4"></div>',
            'body_footer_html' => '<div class="h-3 bg-gray-100 dark:bg-zinc-700/30 rounded w-1/2 mt-2"></div>',
            'actions_html' => '<div class="size-8 bg-gray-100 dark:bg-zinc-700/30 rounded-full"></div>'
        ]);

        return '<div class="p-3 transition-all duration-500 flex" :class="itemWidthConfigs[columns]">' . $cardHtml . '</div>';
    }
}
