<template>
  <div class="profile-card">
    <div class="card-header">
      <h3 class="card-title">个人资料</h3>
    </div>
    <div class="card-content">
      <div class="avatar-section">
        <el-avatar :size="100" :src="userInfo?.avatar || ''">
          {{ userInfo?.account?.charAt(0)?.toUpperCase() || "U" }}
        </el-avatar>
        <el-button
          type="primary"
          link
          size="small"
          @click="$emit('change-avatar')"
        >
          更换头像
        </el-button>
      </div>
      <div class="info-list">
        <div class="info-item">
          <span class="info-label">账号</span>
          <span class="info-value">{{ userInfo?.account || "-" }}</span>
        </div>
        <div class="info-item">
          <span class="info-label">邮箱</span>
          <span class="info-value">{{ userInfo?.email || "-" }}</span>
        </div>
        <div class="info-item">
          <span class="info-label">手机号</span>
          <span class="info-value">{{ userInfo?.phone || "-" }}</span>
        </div>
        <div class="info-item">
          <span class="info-label">状态</span>
          <el-tag :type="userInfo?.status === 1 ? 'success' : 'danger'" size="small">
            {{ userInfo?.status === 1 ? "正常" : "禁用" }}
          </el-tag>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
defineProps({
  userInfo: {
    type: Object,
    default: null
  }
});

defineEmits(["change-avatar"]);
</script>

<style scoped lang="less">
.profile-card {
  background: var(--el-bg-color);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 16px;
  border: 1px solid var(--el-border-color-lighter);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: all 0.3s;

  &:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  }
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--el-border-color-lighter);

  .card-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--el-text-color-primary);
  }
}

.card-content {
  .avatar-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;

    .el-avatar {
      background: linear-gradient(135deg, #3973ff 0%, #4f84ff 100%);
    }
  }

  .info-list {
    .info-item {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 12px 0;
      border-bottom: 1px solid var(--el-border-color-lighter);

      &:last-child {
        border-bottom: none;
      }

      .info-label {
        font-size: 14px;
        color: var(--el-text-color-regular);
      }

      .info-value {
        font-size: 14px;
        color: var(--el-text-color-primary);
        font-weight: 500;
      }
    }
  }
}

@media (max-width: 768px) {
  .profile-card {
    padding: 16px;
  }
}
</style>
