<template>
  <UiContainer>
    <div class="space-25-55">
      <h2 class="h2-bold-bounded">{{ component.front_section_lang[0].data.title }}</h2>

      <div class="flex flex-col gap-10">
        <div v-for="(item, index) in component.front_section_lang[0].data.faq" :key="index"
          @click="active = active === index ? 0 : index"
          class="flex gap-8 sm:gap-20 md:gap-40 xl:gap-60 cursor-pointer">
          <h4 class="h4-uppercase-bold-inter">
            <span v-if="index + 1 < 10">0</span>{{ index + 1 }}
          </h4>
          <div :class="[
            'flex justify-between w-full transition-all duration-300 gap-2 sm:gap-10 md:gap-2',
            active === index && 'pb-10 border-b border-bg-dark dark:border-bg-light',
          ]">
            <div class="max-w-[1200px] flex flex-col gap-6">
              <h4 :class="[
                'h4-uppercase-bold-inter transition-colors duration-300',
                active === index &&
                'text-accent-green-light dark:text-accent-green-dark',
              ]">
                {{ item.label }}
              </h4>

              <transition name="fade-slide">
                <p v-if="active === index">
                  {{ item.content }}
                </p>
              </transition>
            </div>

            <svg class="min-w-5 h-5 dark:text-bg-light" viewBox="0 0 20 21" fill="none"
              xmlns="http://www.w3.org/2000/svg">
              <path :d="active === index
                ? 'M1.29289 17.4628L0.585786 18.1699L2 19.5841L2.70711 18.877L1.29289 17.4628ZM19.9706 1.19936C19.9706 0.647074 19.5228 0.199359 18.9706 0.199359L9.97056 0.19936C9.41828 0.199359 8.97056 0.647075 8.97056 1.19936C8.97056 1.75164 9.41828 2.19936 9.97056 2.19936L17.9706 2.19936L17.9706 10.1994C17.9706 10.7516 18.4183 11.1994 18.9706 11.1994C19.5228 11.1994 19.9706 10.7516 19.9706 10.1994L19.9706 1.19936ZM2 18.1699L2.70711 18.877L19.6777 1.90647L18.9706 1.19936L18.2635 0.492253L1.29289 17.4628L2 18.1699Z'
                : 'M2.7364 1.49211L2.0293 0.785005L0.615083 2.19922L1.32219 2.90633L2.7364 1.49211ZM18.9999 20.1698C19.5521 20.1698 19.9999 19.7221 19.9999 19.1698L19.9999 10.1698C19.9999 9.6175 19.5521 9.16978 18.9999 9.16978C18.4476 9.16978 17.9999 9.6175 17.9999 10.1698L17.9999 18.1698L9.99986 18.1698C9.44758 18.1698 8.99986 18.6175 8.99986 19.1698C8.99986 19.7221 9.44757 20.1698 9.99986 20.1698L18.9999 20.1698ZM2.0293 2.19922L1.32219 2.90633L18.2928 19.8769L18.9999 19.1698L19.707 18.4627L2.7364 1.49211L2.0293 2.19922Z'
                " fill="currentColor" />
            </svg>
          </div>
        </div>
      </div>
      <h4 class="h4-uppercase-bold-inter sm:text-start md:text-center xl:text-start xl:ml-66">
        <span v-for="(item, index) in component.front_section_lang [0].data.sub_title" :key="index" :class="{
          'text-accent-green-light dark:text-accent-green-dark':
            item.highlight,
        }">
          {{ item.text }}
        </span>
      </h4>
    </div>
  </UiContainer>
</template>

<script lang="ts" setup>
defineProps<{
  component: {
    id: number
    name: string
    img: string[]
    component_name: string
    is_no_lang: boolean
    page_name: string
    front_section_lang: {
      data: {
        title: string;
        faq: [
          {
            label: string;
            content: string;
          }
        ];
        sub_title: [
          {
            text: string;
            highlight: boolean;
          }
        ];
      }
      id_front_section: number
      id_lang: number
    }[]
  }
}>();


const active = ref<number>(0);
</script>
