<script setup>
import { computed } from 'vue'
import { usePhotoboothStore } from '../stores/photoboothStore'
import { STRIP_THEMES } from '../data/stripThemes'

const store = usePhotoboothStore()

const activeTheme = computed(() => store.stripTheme)

function pickTheme(themeId) {
  store.setTheme(themeId)
}
</script>

<template>
  <div class="theme-picker">
    <p class="theme-title">Select strip theme</p>
    <div class="theme-grid">
      <button
        v-for="theme in STRIP_THEMES"
        :key="theme.id"
        class="theme-chip"
        :class="{ active: activeTheme === theme.id }"
        @click="pickTheme(theme.id)"
      >
        <span class="thumb" :style="{ backgroundImage: `url('${theme.image}')` }"></span>
        <span>{{ theme.label }}</span>
      </button>
    </div>
  </div>
</template>

<style scoped>
.theme-picker {
  display: grid;
  gap: 16px;
  padding: 18px 20px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(200, 90, 124, 0.2);
  box-shadow: 0 16px 40px rgba(205, 119, 143, 0.2);
}

.theme-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: #7c3b54;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.theme-chip {
  display: grid;
  grid-template-columns: 40px 1fr;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 16px;
  border: 2px solid transparent;
  background: #fff;
  color: #4b2b38;
  font-weight: 600;
  transition: all 0.2s ease;
  cursor: pointer;
  text-align: left;
}

.thumb {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background-size: cover;
  background-position: center;
  border: 1px solid rgba(124, 59, 84, 0.15);
}

.theme-chip.active {
  border-color: #c85a7c;
  box-shadow: 0 10px 20px rgba(200, 90, 124, 0.2);
}

.theme-chip:hover {
  transform: translateY(-1px);
}
</style>
