<script setup lang="ts">
import { Aircraft } from "@/Types/types";
import GlassTooltip from "@/Components/FlightsGoneBy/GlassTooltip.vue";
import InlineBadge from "@/Components/FlightsGoneBy/InlineBadge.vue";

defineProps<{
    aircraft: Aircraft
}>()

function formatWtc(wtc: string): string {
    switch (wtc.toUpperCase()) {
        case 'L': return 'Light'
        case 'M': return 'Medium'
        case 'H': return 'Heavy'
        case 'J': return 'Super'
        default:  return wtc
    }
}

function formatEngineType(type: string): string {
    return type.replace(/_/g, ' ').replace(/\b\w/g, c => c.toUpperCase())
}
</script>

<template>
    <GlassTooltip>
        <template #activator="{ props: tooltipProps }">
            <div style="cursor:pointer" v-bind="tooltipProps">
                <slot />
            </div>
        </template>

        <div class="tooltip-header">
            <span class="designator">{{ aircraft.manufacturer_code }} {{ aircraft.model_full_name }}</span>

        </div>

        <div class="tooltip-name">
            <InlineBadge variant="generic">
                {{aircraft.designator }}
            </InlineBadge>
            <InlineBadge variant="generic">
                {{ formatWtc(aircraft.wtc) }}
            </InlineBadge>
        </div>

        <div class="tooltip-divider" />

        <div class="tooltip-rows">
            <div class="tooltip-row">
                <span class="tooltip-label">Engines</span>
                <span class="tooltip-value">{{ aircraft.engine_count }}x {{ formatEngineType(aircraft.engine_type) }}</span>
            </div>
        </div>
    </GlassTooltip>
</template>

<style scoped>
.tooltip-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.designator {
    color: #e8eaf0;
    letter-spacing: 0.06em;
    line-height: 1;
}

.badges {
    display: flex;
    gap: 0.3rem;
}

.tooltip-name {
    display:flex;
    gap: 4px;
    margin-top: 0.2rem;
    line-height: 1.3;
}


.tooltip-divider {
    height: 1px;
    background: var(--table-border, rgba(255,255,255,0.08));
}

.tooltip-rows {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.tooltip-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}

.tooltip-label {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.6rem;
    letter-spacing: 0.15em;
    color: var(--muted, #445566);
    flex-shrink: 0;
}

.tooltip-value {
    font-size: 0.78rem;
    color: var(--text, #c8cdd8);
    text-align: right;
}
</style>
