<template>
  <button 
    class="rotate-button" 
    :class="`rotate-button--${clientType}`"
    @click="handleClick"
    :title="direction === 'cw' ? '顺时针旋转' : '逆时针旋转'"
  >
    <img 
      v-if="direction === 'cw'" 
      :src="rotateClockwiseIcon" 
      class="rotate-button__icon" 
      alt="顺时针旋转" 
    />
    <img 
      v-else 
      :src="rotateCounterclockwiseIcon" 
      class="rotate-button__icon" 
      alt="逆时针旋转" 
    />
  </button>
</template>

<script setup lang="ts">
import rotateClockwiseIcon from '../assets/cw-icon.svg'
import rotateCounterclockwiseIcon from '../assets/ccw-icon.svg'

interface Props {
  direction: 'cw' | 'ccw'
  clientType?: 'pc' | 'mobile' | 'ipad'
}

const props = withDefaults(defineProps<Props>(), {
  clientType: 'pc'
})

const emit = defineEmits<{
  click: []
}>()

const handleClick = () => {
  emit('click')
}
</script>

<style scoped>
.rotate-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.30);
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 999px;
    cursor: pointer;
    user-select: none;
}

.rotate-button:hover {
    background: rgba(0, 0, 0, 0.4);
}

.rotate-button__icon {
    display: block;
}

/* PC 端样式 */
.rotate-button--pc {
    padding: 6px;
}

.rotate-button--pc .rotate-button__icon {
    width: 16px;
    height: 16px;
}

/* iPad 样式 */
.rotate-button--ipad {
    padding: 12px 20px;
}

.rotate-button--ipad .rotate-button__icon {
    width: 24px;
    height: 24px;
}

/* 移动端样式 */
.rotate-button--mobile {
    padding: 12px 20px;
}

.rotate-button--mobile .rotate-button__icon {
    width: 24px;
    height: 24px;
}
</style>
