<template>
  <v-card tile outlined :class="{ 'card--reduced': isCardReduced }">
    <v-card-title class="card__title primary" @click="toggleCardSize">
      <v-icon left class="white--text pr-5 pl-2" size="40">mdi-calculator-variant</v-icon>
      Gestion des scores
    </v-card-title>
    <v-container class="text-center">
      <v-row justify="center">
        <v-col cols="4" sm="6" md="3">
          <mqtt-button width="120" height="60" class="btn red xs12 sm6 md3" topic="game/score/update" message='{"Red": "-2"}'>
            <v-icon left size="40">mdi-minus-box-multiple</v-icon>
          </mqtt-button>
        </v-col>
        <v-col cols="4" sm="6" md="3">
          <mqtt-button width="120" height="60" class="btn red card xs12 sm6 md3" topic="game/score/update" message='{"Red": "-1"}'>
            <v-icon left size="40">mdi-minus-box</v-icon>
          </mqtt-button>
        </v-col>
        <v-col cols="4" sm="6" md="3">
          <mqtt-button width="120" height="60" class="btn red card xs12 sm6 md3" topic="game/score/update" message='{"Red": "+1"}'>
            <v-icon left size="40">mdi-plus-box</v-icon>
          </mqtt-button>
        </v-col>
        <v-col cols="4" sm="6" md="3">
          <mqtt-button width="120" height="60" class="btn red card xs12 sm6 md3 " topic="game/score/update" message='{"Red": "+2"}'>
            <v-icon left size="40">mdi-plus-box-multiple</v-icon>
          </mqtt-button>
        </v-col>
        <v-col cols="4" sm="6" md="3">
          <mqtt-button width="120" height="60" class="btn blue card xs12 sm6 md3 " topic="game/score/update" message='{"Blue": "-2"}'>
            <v-icon left size="40">mdi-minus-box-multiple</v-icon>
          </mqtt-button>
        </v-col>
        <v-col cols="12" sm="6" md="3">
          <mqtt-button width="120" height="60" class="btn blue card xs12 sm6 md3 " topic="game/score/update" message='{"Blue": "-1"}'>
            <v-icon left size="40">mdi-minus-box</v-icon>
          </mqtt-button>
        </v-col>
        <v-col cols="4" sm="6" md="3">
          <mqtt-button width="120" height="60" class="btn blue card xs12 sm6 md3 " topic="game/score/update" message='{"Blue": "+1"}'>
            <v-icon left size="40">mdi-plus-box</v-icon>
          </mqtt-button>
        </v-col>
        <v-col cols="12" sm="6" md="3">
          <mqtt-button width="120" height="60" class="btn blue card xs12 sm6 md3 " topic="game/score/update" message='{"Blue": "+2"}'>
            <v-icon left size="40">mdi-plus-box-multiple</v-icon>
          </mqtt-button>
        </v-col>
        <v-col cols="4" sm="6" md="3">
          <mqtt-button width="120" height="60" class="btn yellow card xs12 sm6 md3 " topic="game/score/update" message='{"Yellow": "-2"}'>
            <v-icon left size="40">mdi-minus-box-multiple</v-icon>
          </mqtt-button>
        </v-col>
        <v-col cols="12" sm="6" md="3">
          <mqtt-button width="120" height="60" class="btn yellow card xs12 sm6 md3 " topic="game/score/update" message='{"Yellow": "-1"}'>
            <v-icon left size="40">mdi-minus-box</v-icon>
          </mqtt-button>
        </v-col>
        <v-col cols="4" sm="6" md="3">
          <mqtt-button width="120" height="60" class="btn yellow card xs12 sm6 md3 " topic="game/score/update" message='{"Yellow": "+1"}'>
            <v-icon left size="40">mdi-plus-box</v-icon>
          </mqtt-button>
        </v-col>
        <v-col cols="12" sm="6" md="3">
          <mqtt-button width="120" height="60" class="btn yellow card xs12 sm6 md3 " topic="game/score/update" message='{"Yellow": "+2"}'>
            <v-icon left size="40">mdi-plus-box-multiple</v-icon>
          </mqtt-button>
        </v-col>
        <v-col cols="4" sm="6" md="3">
          <mqtt-button width="120" height="60" class="btn green card xs12 sm6 md3 " topic="game/score/update" message='{"Green": "-2"}'>
            <v-icon left size="40">mdi-minus-box-multiple</v-icon>
          </mqtt-button>
        </v-col>
        <v-col cols="12" sm="6" md="3">
          <mqtt-button width="120" height="60" class="btn green card xs12 sm6 md3 " topic="game/score/update" message='{"Green": "-1"}'>
            <v-icon left size="40">mdi-minus-box</v-icon>
          </mqtt-button>
        </v-col>
        <v-col cols="4" sm="6" md="3">
          <mqtt-button width="120" height="60" class="btn green card xs12 sm6 md3 " topic="game/score/update" message='{"Green": "+1"}'>
            <v-icon left size="40">mdi-plus-box</v-icon>
          </mqtt-button>
        </v-col>
        <v-col cols="12" sm="6" md="3">
          <mqtt-button width="120" height="60" class="btn green card xs12 sm6 md3 " topic="game/score/update" message='{"Green": "2"}'>
            <v-icon left size="40">mdi-plus-box-multiple</v-icon>
          </mqtt-button>
        </v-col>
      </v-row>
    </v-container>
  </v-card>
</template>

<script setup>
  import MqttButton from './MqttButton.vue';
  import { ref } from 'vue';

  // Variable pour contrôler l'état de la carte
  const isCardReduced = ref(false);

  // Méthode pour basculer l'état de la carte
  function toggleCardSize() {
    isCardReduced.value = !isCardReduced.value;
  }
</script>

<style>
  .card--reduced {
    height: 56px; /* Réglez la hauteur réduite selon vos besoins */
    width: 170px;
    overflow: hidden;
    transition: height 0.3s ease-in-out;
  }
</style>