<template>
  <div class="h-full overflow-auto">
    <div class="relative p-2.5 flex flex-col gap-5 h-72">
      <h3>Character details</h3>
      <button @click="toggle" class="btn-cyan px-4 py-1.5 w-24">Edit</button>
      <form class="flex gap-2.5 flex-wrap">
        <div class="form-field-half max-w-[300px]">
          <label for="name">Name</label>
          <input class="input-field" :class="{ inactive: !editCharacter }" type="text" name="name" placeholder="Ethereal" :disabled="!editCharacter" />
        </div>
        <div class="form-field-half max-w-[300px] relative">
          <label for="class">Class</label>
          <select class="input-field" v-model="characterClass" :class="{ inactive: !editCharacter }" name="class" :disabled="!editCharacter">
            <option value="Knight" :selected="characterClass == 'Knight'" :disabled="characterClass == 'Knight'">Knight</option>
            <option value="Paladin" :selected="characterClass == 'Paladin'" :disabled="characterClass == 'Paladin'">Paladin</option>
          </select>
          <span v-if="!editCharacter" class="absolute bottom-[9px] left-[14px] text-sm text-gray-300/50">{{ characterClass }}</span>
        </div>
        <button v-if="editCharacter" @click="toggle" class="btn-cyan px-4 py-1.5 min-w-24" type="submit">Save</button>
      </form>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'

const editCharacter = ref(false)
const characterClass = ref('')

const toggle = () => {
  editCharacter.value = !editCharacter.value
}
</script>
