<template>
    <view v-if="show" class="confirm-dialog-overlay" @click="handleCancel">
        <view class="confirm-dialog-container" @click.stop>
            <!-- 关闭按钮 -->
            <view class="close-btn" @click="handleCancel">
                <text class="close-icon">✕</text>
            </view>
            
            <!-- 标题 -->
            <view class="dialog-title">{{ title }}</view>
            
            <!-- 内容 -->
            <view class="dialog-content">{{ content }}</view>
            
            <!-- 按钮组 -->
            <view class="dialog-buttons">
                <view class="cancel-btn" @click="handleCancel">
                    <text class="cancel-text">{{ cancelText }}</text>
                </view>
                <view class="confirm-btn" @click="handleConfirm">
                    <text class="confirm-text">{{ confirmText }}</text>
                </view>
            </view>
        </view>
    </view>
</template>

<script setup lang="ts">
interface Props {
    show?: boolean
    title?: string
    content?: string
    cancelText?: string
    confirmText?: string
}

const props = withDefaults(defineProps<Props>(), {
    show: false,
    title: '提示',
    content: '',
    cancelText: '取消',
    confirmText: '确认',
})

const emit = defineEmits<{
    (e: 'update:show', value: boolean): void
    (e: 'cancel'): void
    (e: 'confirm'): void
}>()

function handleCancel() {
    emit('update:show', false)
    emit('cancel')
}

function handleConfirm() {
    emit('update:show', false)
    emit('confirm')
}
</script>

<style lang="scss" scoped>
.confirm-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
}

.confirm-dialog-container {
    position: relative;
    width: 600rpx;
    background: linear-gradient(180deg, #E8F5E9 0%, #FFFFFF 30%);
    border-radius: 32rpx;
    padding: 60rpx 48rpx 48rpx;
    box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.1);
}

.close-btn {
    position: absolute;
    top: 24rpx;
    right: 24rpx;
    width: 48rpx;
    height: 48rpx;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.close-icon {
    font-size: 36rpx;
    color: #999999;
    font-weight: 300;
}

.dialog-title {
    font-size: 36rpx;
    font-weight: 600;
    color: #333333;
    text-align: center;
    margin-bottom: 32rpx;
}

.dialog-content {
    font-size: 28rpx;
    color: #666666;
    text-align: center;
    line-height: 40rpx;
    margin-bottom: 48rpx;
}

.dialog-buttons {
    display: flex;
    gap: 24rpx;
}

.cancel-btn,
.confirm-btn {
    flex: 1;
    height: 80rpx;
    border-radius: 40rpx;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.cancel-btn {
    background-color: #FFFFFF;
    border: 2rpx solid #5DB66F;
}

.cancel-text {
    font-size: 28rpx;
    color: #5DB66F;
    font-weight: 500;
}

.confirm-btn {
    background: linear-gradient(135deg, #5DB66F 0%, #4CAF50 100%);
    box-shadow: 0 4rpx 12rpx rgba(93, 182, 111, 0.3);
}

.confirm-text {
    font-size: 28rpx;
    color: #FFFFFF;
    font-weight: 500;
}

.cancel-btn:active {
    opacity: 0.8;
}

.confirm-btn:active {
    opacity: 0.9;
    transform: scale(0.98);
}
</style>
