<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit;
$currentAvatar = Mirai_getUserAvatar($this->user->uid);
$currentCover = !empty($this->user->cover) ? $this->user->cover : '';
?>
<div class="uc-page">
    <div class="uc-page-header">
        <h2 class="uc-page-title">个人资料</h2>
    </div>

    <?php if (!empty($message)): ?>
        <div class="uc-alert uc-alert-<?php echo $messageType; ?>"><?php echo $message; ?></div>
    <?php endif; ?>

    <form method="post" action="" class="uc-form" enctype="multipart/form-data">
        <input type="hidden" name="action" value="update_profile">

        <div class="uc-form-group uc-avatar-upload">
            <label class="uc-label">头像</label>
            <div class="uc-avatar-row">
                <div class="uc-avatar-preview">
                    <img src="<?php echo $currentAvatar; ?>" alt="当前头像" id="avatarPreview">
                </div>
                <div class="uc-avatar-input">
                    <input type="file" name="avatar" id="avatarInput" accept="image/jpeg,image/png,image/gif,image/webp" class="uc-file-input">
                    <p class="uc-hint">支持 JPG、PNG、GIF、WebP，不超过 2MB</p>
                </div>
            </div>
        </div>

        <div class="uc-form-group">
            <label class="uc-label">昵称</label>
            <input type="text" name="screenName" value="<?php $this->user->screenName(); ?>" required class="uc-input">
        </div>

        <div class="uc-form-group">
            <label class="uc-label">邮箱</label>
            <input type="email" name="mail" value="<?php $this->user->mail(); ?>" required class="uc-input">
        </div>

        <div class="uc-form-group">
            <label class="uc-label">个人网站</label>
            <input type="url" name="url" value="<?php echo htmlspecialchars($this->user->url ?? '', ENT_QUOTES, 'UTF-8'); ?>" class="uc-input" placeholder="你的个人网站">
        </div>

        <div class="uc-form-group">
            <label class="uc-label">个人简介</label>
            <input type="text" name="motto" value="<?php echo htmlspecialchars($this->user->motto ?? '', ENT_QUOTES, 'UTF-8'); ?>" class="uc-input" placeholder="介绍你自己，最多100字符" maxlength="100">
        </div>

        <div class="uc-form-group">
            <label class="uc-label">主页背景图</label>
            <input type="text" name="cover" value="<?php echo htmlspecialchars($currentCover, ENT_QUOTES, 'UTF-8'); ?>" class="uc-input" placeholder="输入图片URL，留空使用默认">
        </div>

        <button type="submit" class="uc-btn uc-btn-primary uc-btn-block">保存修改</button>
    </form>
</div>


