<template>
  <component
    :is="url ? 'a' : 'div'"
    v-bind="url ? { href: url, target: '_blank', rel: 'noopener noreferrer' } : {}"
    class="simu-feature"
    :class="{ 'simu-feature--link': !!url }"
  >
    <div class="simu-feature__inner">
      <div class="simu-feature__left">
        <span class="simu-feature__icon" aria-hidden="true">{{ icon }}</span>
        <div class="simu-feature__body">
          <div class="simu-feature__header">
            <h3 class="simu-feature__titre">{{ titre }}</h3>
            <span v-if="tag" :class="['simu-feature__badge', `simu-feature__badge--${tag}`]">{{ tagLabel }}</span>
          </div>
          <p class="simu-feature__desc">{{ description }}</p>
        </div>
      </div>
      <span v-if="cta && url" class="simu-feature__cta">{{ cta }}</span>
    </div>
  </component>
</template>

<script setup lang="ts">
const props = defineProps<{
  icon?: string
  titre: string
  url?: string | null
  description?: string
  cta?: string
  tag?: string
}>()

const tagLabels: Record<string, string> = {
  'outil-aep': 'Outil AEP',
  'inspiration-externe': 'Inspiration externe',
  'disponible': 'Disponible',
  'recommande': 'Recommandé',
  'a-venir': 'À venir',
}

const tagLabel = computed(() => props.tag ? (tagLabels[props.tag] ?? props.tag) : '')
</script>

<style scoped>
.simu-feature {
  display: block;
  padding: 1.5rem 1.75rem;
  border-radius: 14px;
  border: 1.5px solid var(--nav-bg-alt);
  background: var(--nav-surface);
  text-decoration: none;
  color: var(--nav-text);
  transition: box-shadow 0.2s, border-color 0.2s, transform 0.15s;
}

.simu-feature--link:hover {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  border-color: var(--nav-primary-solid);
  transform: translateY(-2px);
}

.simu-feature__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.simu-feature__left {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  flex: 1;
  min-width: 0;
}

.simu-feature__icon {
  font-size: 2rem;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 2px;
}

.simu-feature__body {
  flex: 1;
  min-width: 0;
}

.simu-feature__header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}

.simu-feature__titre {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--nav-text);
  margin: 0;
  line-height: 1.3;
}

.simu-feature__badge {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  background: #d1fae5;
  color: #065f46;
}

.simu-feature__badge--inspiration-externe {
  background: #fef3c7;
  color: #92400e;
}

.simu-feature__desc {
  font-size: 0.88rem;
  color: var(--nav-text-muted);
  margin: 0;
  line-height: 1.55;
}

.simu-feature__cta {
  display: inline-flex;
  align-items: center;
  padding: 0.6rem 1.25rem;
  background: var(--nav-primary-solid);
  color: var(--nav-text-on-primary);
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  transition: opacity 0.15s;
  flex-shrink: 0;
}

.simu-feature--link:hover .simu-feature__cta {
  opacity: 0.88;
}

:global(.dark) .simu-feature__badge {
  background: #064e3b;
  color: #a7f3d0;
}
:global(.dark) .simu-feature__badge--inspiration-externe {
  background: #78350f;
  color: #fde68a;
}
</style>
