<template>
  <div class="kole-card" :class="classes" :style="{ padding: paddingPx }">
    <div v-if="title || $slots.extra" class="kole-card__header">
      <div class="kole-card__title">
        <slot name="title">{{ title }}</slot>
      </div>
      <div v-if="$slots.extra" class="kole-card__extra"><slot name="extra" /></div>
    </div>
    <div class="kole-card__body"><slot /></div>
    <div v-if="$slots.actions" class="kole-card__actions"><slot name="actions" /></div>
  </div>
</template>

<script setup>
import { computed } from 'vue';

const props = defineProps({
  title: { type: String, default: '' },
  bordered: { type: Boolean, default: false },
  shadowed: { type: Boolean, default: false },
  padding: { type: [Number, String], default: 16 }   // 16 | 24
});

const classes = computed(() => [
  props.bordered ? 'kole-card--bordered' : '',
  props.shadowed ? 'kole-card--shadowed' : ''
]);
const paddingPx = computed(() =>
  typeof props.padding === 'number' ? `${props.padding}px` : props.padding
);
</script>

<!-- 样式对齐 components.css 与 card.json 契约 -->
<style scoped>
.kole-card {
  background: #fff; border-radius: 8px; box-sizing: border-box;
  min-width: 280px; max-width: 360px;
}
.kole-card--bordered { border: 1px solid #E8ECF1; }
.kole-card--shadowed { box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.kole-card__header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-weight: 600; color: #1F2329;
}
.kole-card__title { font-size: 16px; }
.kole-card__extra { color: #2F54EB; font-size: 14px; cursor: pointer; }
.kole-card__body { color: #262626; font-size: 14px; line-height: 22px; }
.kole-card__actions { display: flex; justify-content: flex-end; gap: 8px; }
</style>
