<template>
  <section class="planning-lane" @dragover.prevent @drop="$emit('drop-member', laneId)">
    <div class="planning-lane-header">
      <div>
        <strong>{{ title }}</strong>
        <div class="planning-lane-subtitle">{{ subtitle }}</div>
      </div>
      <span class="planning-lane-count">{{ members.length }}</span>
    </div>
    <div class="planning-lane-list">
      <TeamPlanningMemberRow
        v-for="(member, index) in members"
        :key="member.id"
        :member="member"
        :show-actions="showActions"
        :can-move-up="index > 0"
        :can-move-down="index < members.length - 1"
        @drag-start="$emit('drag-start', $event)"
        @move-up="$emit('move-member', { laneId, memberId: $event.id, direction: 'up' })"
        @move-down="$emit('move-member', { laneId, memberId: $event.id, direction: 'down' })"
        @remove="$emit('remove-member', { laneId, memberId: $event.id })"
      />
      <div v-if="!members.length" class="planning-lane-empty">{{ emptyLabel }}</div>
    </div>
  </section>
</template>

<script>
import TeamPlanningMemberRow from './TeamPlanningMemberRow.vue';

export default {
  name: 'TeamPlanningLane',
  components: { TeamPlanningMemberRow },
  props: {
    laneId: { type: [String, Number], required: true },
    title: { type: String, required: true },
    subtitle: { type: String, default: '' },
    members: { type: Array, required: true },
    showActions: { type: Boolean, default: true },
    emptyLabel: { type: String, required: true }
  },
  emits: ['drop-member', 'drag-start', 'move-member', 'remove-member']
};
</script>

<style scoped>
.planning-lane {
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--background-light);
  padding: 0.7rem;
  min-height: 180px;
}

.planning-lane-header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
  margin-bottom: 0.65rem;
}

.planning-lane-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.planning-lane-count {
  display: inline-flex;
  min-width: 1.8rem;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: white;
  padding: 0.1rem 0.45rem;
  font-size: 0.78rem;
}

.planning-lane-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.planning-lane-empty {
  color: var(--text-muted);
  font-size: 0.88rem;
  padding: 0.45rem 0.2rem;
}
</style>
