<?php

use WoWPress\Models\Character;

?>
<div class="bg-glass shadow p-auto order-last flex flex-col gap-1">
    <h1 class="text-xl font-bold text-center">Klassensuche</h1>
    <div class="grid grid-cols-5 gap-2">
        <?php if ($instance['text']) : ?>
            <div class="p-auto col-span-5 text-center">
                <?= $instance['text'] ?>
            </div>
        <?php endif; ?>
        <?php foreach ($instance['classes'] as $class => $specs) : ?>
            <?php if ($this->hasSpec($specs)) : ?>
                <div class="col-span-1"><img src="<?= Character::classIconLink($class) ?>" title="<?= translate_string($class) ?>" alt="" class="h-8"></div>
                <div class="col-span-4 grid grid-cols-subgrid">
                    <?php foreach ($specs as $spec => $search) :
                        switch ($search) {
                            case 3:
                                $classes = "border border-red-500";
                                $text = "Hoch";
                                break;
                            case 2:
                                $classes = "border border-yellow-500 opacity-70";
                                $text = "Mittel";
                                break;
                            case 1:
                                $classes = "border border-green-500 opacity-50";
                                $text = "Niedrig";
                                break;
                            case 0:
                            default:
                                $classes = "opacity-10";
                                $text = "Suche geschlossen";
                                break;
                        } ?>
                        <div><img src="<?= Character::specIconLink($class, $spec) ?>" alt="" class="h-8 <?= $classes ?>" title="<?= translate_string($spec) ?>: <?= $text ?>"></div>
                    <?php endforeach; ?>
                </div>
            <?php endif; ?>
        <?php endforeach; ?>
    </div>
</div>