<script setup lang="ts">
import { RouterLink, useRoute } from 'vue-router';
import { useAdminLocale } from '../composables/useAdminLocale';

const { t } = useAdminLocale();
const route = useRoute();

withDefaults(
  defineProps<{
    embedded?: boolean;
  }>(),
  { embedded: false },
);

const tabs = [
  { path: '/matches', labelKey: 'nav.matches.fixtures' },
  { path: '/matches/outrights', labelKey: 'nav.matches.outrights' },
];

function isActive(path: string) {
  if (path === '/matches/outrights') {
    return route.path === '/matches/outrights';
  }
  return (
    route.path === '/matches' ||
    (route.path.startsWith('/matches/') &&
      !route.path.startsWith('/matches/outrights'))
  );
}
</script>

<template>
  <nav
    class="matches-subnav"
    :class="{ 'matches-subnav--embedded': embedded }"
    aria-label="Matches sections"
  >
    <RouterLink
      v-for="tab in tabs"
      :key="tab.path"
      :to="tab.path"
      class="matches-subnav__item"
      :class="{ 'matches-subnav__item--active': isActive(tab.path) }"
    >
      {{ t(tab.labelKey) }}
    </RouterLink>
  </nav>
</template>

<style scoped>
.matches-subnav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 16px;
  padding: 4px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}
.matches-subnav--embedded {
  margin-bottom: 0;
  padding: 0 12px 0 0;
  border: none;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background: transparent;
  flex-shrink: 0;
  height: 32px;
  box-sizing: border-box;
}
.matches-subnav__item {
  padding: 0 12px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #888;
  transition: color 0.15s, background 0.15s;
}
.matches-subnav__item:hover {
  color: #ccc;
  background: rgba(255, 255, 255, 0.04);
}
.matches-subnav__item--active {
  color: var(--green-text);
  background: rgba(0, 200, 83, 0.1);
}
</style>
