<template>
  <view class="ui-section-card" :class="{ 'no-margin-top': isFirst }">
    <view class="section-header" v-if="title">
      <text class="title-icon"></text>
      <text class="title-text">{{ title }}</text>
      <view class="header-extra">
        <slot name="extra"></slot>
      </view>
    </view>
    <view class="section-body">
      <slot></slot>
    </view>
  </view>
</template>

<script setup lang="ts">
/**
 * UI 通用组件 - 区块容器
 * 封装统一的卡片外观、带蓝色竖条的标题栏
 */
defineProps<{
  /** 标题文字 */
  title?: string;
  /** 是否为页面第一个区块（移除顶部外边距） */
  isFirst?: boolean;
}>();
</script>

<style lang="scss" scoped>
.ui-section-card {
  background-color: #ffffff;
  border-radius: 20rpx;
  padding: 30rpx;
  margin-top: 24rpx;
  box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.03);
  overflow: hidden;

  &.no-margin-top {
    margin-top: 0;
  }

  .section-header {
    display: flex;
    align-items: center;
    margin-bottom: 24rpx;
    position: relative;

    .title-icon {
      width: 8rpx;
      height: 32rpx;
      background: linear-gradient(180deg, #1c9bfd 0%, #007aff 100%);
      border-radius: 4rpx;
      margin-right: 16rpx;
    }

    .title-text {
      font-size: 32rpx;
      font-weight: 600;
      color: #343a3f;
      flex: 1;
    }

    .header-extra {
      flex-shrink: 0;
    }
  }

  .section-body {
    width: 100%;
  }
}
</style>
