<?php
/*
Template Name: Todas las Etiquetas
*/

get_header(); ?>

<div class="container tags-page-container">
    <div class="tags-page-header">
        <h1 class="tags-page-title">Todas las Etiquetas</h1>
        <p class="tags-page-description">Explora todo el contenido por etiquetas</p>
    </div>

    <div class="tags-cloud-wrapper">
        <?php
        $tags = get_tags(array(
            'orderby' => 'count',
            'order' => 'DESC',
            'hide_empty' => true
        ));

        if ($tags) :
            echo '<div class="tags-cloud-grid">';
            foreach ($tags as $tag) :
                $tag_link = get_tag_link($tag->term_id);
                $tag_count = $tag->count;
                
                // Calcular tamaño basado en la cantidad de posts
                $size_class = '';
                if ($tag_count >= 20) {
                    $size_class = 'tag-xl';
                } elseif ($tag_count >= 10) {
                    $size_class = 'tag-lg';
                } elseif ($tag_count >= 5) {
                    $size_class = 'tag-md';
                } else {
                    $size_class = 'tag-sm';
                }
                ?>
                <a href="<?php echo esc_url($tag_link); ?>" class="tag-item <?php echo $size_class; ?>" data-count="<?php echo $tag_count; ?>">
                    <span class="tag-name"><?php echo esc_html($tag->name); ?></span>
                    <span class="tag-count"><?php echo $tag_count; ?></span>
                </a>
            <?php endforeach;
            echo '</div>';
        else : ?>
            <p class="no-tags">No hay etiquetas disponibles.</p>
        <?php endif; ?>
    </div>
</div>

<?php get_footer(); ?>
