<template>
  <div id="Fonctionnalites">
    <LayoutContainer>
      <div class="container-green" v-if="!mdAndDown">

        <v-row>
          <v-col cols="12">
            <div class="d-flex justify-center align-center">
              <div class="carousel-button" @click="previousAction">
                <i class="fas fa-chevron-left" />
              </div>
              <div class="carousel-button" @click="nextAction">
                <i class="fas fa-chevron-right" />
              </div>
            </div>
          </v-col>
        </v-row>
        <v-row>
          <v-col cols="12">
            <Carousel
              ref="functionCarousel"
              class="carousel"
              items-to-show="5"
              items-to-scroll="1"
            >
              <Slide
                v-for="(card, index) in cards"
                :key="index"
                :class="{
                  card: true,
                  'active-card': index === activeCardIndex,
                }"
              >
                <v-card>
                  <v-row>
                    <v-img
                      :src="card.logo"
                      alt=""
                      class="justify-center logo-fonctionnalite mt-4 mb-4"
                    />
                  </v-row>

                  <v-card-title>
                    <h4 class="card-title">{{ card.title }}</h4>
                  </v-card-title>

                  <v-card-item>
                    <v-card-text class="review-description">
                      <ul>
                        <li class="list-detail" v-for="item in card.list" :key="item">
                          {{ item }}
                        </li>
                      </ul>
                    </v-card-text>

                    <div class="card-footer">
                      <p class="reviewer-structure">
                        {{ card.option }}
                      </p>
                    </div>
                  </v-card-item>
                </v-card>
              </Slide>
            </Carousel>
          </v-col>
        </v-row>
      </div>
    </LayoutContainer>
  </div>
</template>

<script setup>
import { ref, computed } from 'vue';
import { Carousel, Slide } from 'vue3-carousel';
import 'vue3-carousel/dist/carousel.css';
import { useDisplay } from 'vuetify/lib/framework.mjs';

const props = defineProps({
  cards: Array,
  itemsToScroll: {
    type: Number,
    default: 1,
  },
  itemsToShow: {
    type: Number,
    default: 5,
  },
});


const { width, mdAndDown } = useDisplay();
const functionCarousel = ref(null);
const activeCardIndex = ref(0);

const itemsToShow = computed(() => {
  if (width.value >= 1280 && width.value <= 1920) { 
    return 3; 
  } else if (width.value > 1920) {
    return 6; 
  }
  return props.itemsToShow; 
});

const nextAction = () => {
  functionCarousel.value.next();
};

const previousAction = () => {
  functionCarousel.value.prev();
};

</script>
<style scoped>
.v-card-title-container {
  display: flex;
  flex-direction: row;
}
.logo-fonctionnalite {
  width: 5rem;
  height: 5rem;
}

.list-detail {
  font-weight: 300;
  font-size: 1.2rem;
  line-height: 1.2rem;
  margin-bottom: 1rem;
  color: #000000;
  width: 100%;
}
.card-title {
  white-space: pre-wrap;
  font-size: 1.1rem;
}
.carousel {
  margin-left: 2rem;
  margin-right: 2rem;
}

.card.active-card {
}

.title-container {
  display: flex;
  align-items: center;
}
.subtitle-avantage {
  font-weight: 600;
  font-size: 3rem;
  line-height: 18px;
  color: white;
}
.subtitle {
  color: white;
  font-size: 1rem;
  font-weight: 600;
  line-height: 15px;
  letter-spacing: 1.8px;
  text-transform: uppercase;
}

.icon-title {
  color: rgba(32, 147, 190, 0.6);
  margin-right: 0.5rem;
}
.card {
  font-weight: 300;
  transition: transform 0.3s;
  min-width: 30%;
  max-width: 30%;
}

.card.active-card {
  transform: scale(1.05);
}
.carousel-button {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 4rem;
  height: 4rem;
  background-color: transparent;
  border: 2px solid #fff;
  cursor: pointer;
  margin-right: 1rem;
  margin-top: 1rem;
}

.carousel-button i {
  color: #fff;
  cursor: pointer;
}
.reviewer-name {
  font-weight: 500;
  font-size: 20px;
  line-height: 24px;
  color: rgba(32, 147, 190);
}

.reviewer-status {
  font-weight: 600;
  font-size: 12px;
  line-height: 16px;
  display: flex;
  align-items: center;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.reviewer-structure {
  font-weight: 300;
  font-size: 0.8rem;
  line-height: 14px;
  display: flex;
  align-items: center;
  margin-bottom: 1rem;
  color: #071b1f;
}

.review-description {
  text-align: left;
}
.card-footer {
  position: absolute;
  right: 0;
  margin-right: 2rem;
}

.card-text {
  font-weight: 300;
  font-size: 1rem;
  line-height: 1rem;
  height: 12rem;
}
.reviews-title {
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  line-height: 15px;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  margin-left: 1rem;
  width: 10rem;
}

.card {
  min-height: 35rem;
  max-height: 35rem;
  border-radius: 1rem;
}

.v-card {
  border-radius: 1rem;
  min-height: 25rem;
  max-width: 20rem;
  min-width: 20rem;
}

.card-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 3rem;
  margin-right: 2rem;
}

.container-green {
  background-color: #0e2d32;
}
</style>
