<h1><?= ($isSelf ?? false) ? 'Můj profil' : 'Upravit uživatele' ?></h1>

<form method="post" action="">
    <div class="mb-3">
        <label class="form-label">Uživatelské jméno *</label>
        <input type="text" name="uzivatelske_jmeno" class="form-control" value="<?= htmlspecialchars($user['uzivatelske_jmeno']) ?>" required>
    </div>

    <div class="mb-3">
        <label class="form-label">Jméno *</label>
        <input type="text" name="jmeno" class="form-control" value="<?= htmlspecialchars($user['jmeno']) ?>" required>
    </div>

    <div class="mb-3">
        <label class="form-label">Příjmení *</label>
        <input type="text" name="prijmeni" class="form-control" value="<?= htmlspecialchars($user['prijmeni']) ?>" required>
    </div>

    <div class="mb-3">
        <label class="form-label">Nové heslo (ponechte prázdné, pokud nechcete měnit)</label>
        <input type="password" name="heslo" class="form-control" minlength="8">
    </div>

    <?php if ($userRole === 'admin'): ?>
        <div class="mb-3">
            <label class="form-label">Role *</label>
            <select name="role" class="form-select" required>
                <option value="sportovec" <?= $user['role'] === 'sportovec' ? 'selected' : '' ?>>Sportovec</option>
                <option value="trener" <?= $user['role'] === 'trener' ? 'selected' : '' ?>>Trenér</option>
                <option value="admin" <?= $user['role'] === 'admin' ? 'selected' : '' ?>>Správce</option>
            </select>
        </div>
    <?php else: ?>
        <p class="text-muted">Role: <strong>
            <?php 
                $roleLabel = [
                    'admin' => 'Správce',
                    'trener' => 'Trenér',
                    'sportovec' => 'Sportovec'
                ];
                echo $roleLabel[$user['role']] ?? $user['role'];
            ?>
        </strong></p>
    <?php endif; ?>

    <button title="Uložit" class="btn btn-success"><i class="ti ti-device-floppy fs-4"></i></button>
    <a href="<?= BASE_URL ?>/user/show?id=<?= $user['id'] ?>" class="btn btn-outline-secondary" title="Zpět"><i class="ti ti-arrow-back-up fs-4"></i></a>
</form>
