<template>
  <div class="tabs-panel">
    <button 
      v-for="tab in tabs" 
      :key="tab.id"
      class="tab" 
      :class="{ active: modelValue === tab.id }"
      @click="$emit('update:modelValue', tab.id)"
      :title="tab.title || tab.label"
    >
      <i v-if="tab.icon" :data-lucide="tab.icon"></i>
      <span v-if="tab.label && showLabels" class="tab-label">{{ tab.label }}</span>
      <span v-if="tab.badge" class="tab-badge">{{ tab.badge }}</span>
    </button>
  </div>
</template>

<script setup>
import { onMounted, onUpdated } from 'vue'

defineProps({
  modelValue: {
    type: [String, Number],
    required: true
  },
  tabs: {
    type: Array,
    required: true
    // { id, icon?, label?, title?, badge? }
  },
  showLabels: {
    type: Boolean,
    default: false
  }
})

defineEmits(['update:modelValue'])

const refreshIcons = () => {
  if (window.lucide) {
    window.lucide.createIcons()
  }
}

onMounted(refreshIcons)
onUpdated(refreshIcons)
</script>

<style scoped>
.tabs-panel {
  display: flex;
  gap: 2px;
  background: rgba(255, 255, 255, 0.04);
  padding: 3px;
  border-radius: 8px;
}

.tab {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 10px;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  font-size: 13px;
}

.tab:hover {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.04);
}

.tab.active {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.tab i,
.tab :deep(svg) {
  width: 25px;
  height: 25px;
  pointer-events: none;
}

.tab-label {
  white-space: nowrap;
  pointer-events: none;
}

.tab-badge {
  pointer-events: none;
  background: var(--accent);
  color: #000;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 8px;
  min-width: 16px;
  text-align: center;
}
</style>
