<script setup>
import { transl } from './Module';

import Modal      from '@Holos/Modal.vue';
import GoogleIcon from '@Shared/GoogleIcon.vue';

/** Propiedades */
const props = defineProps({
    show: {
        type: Boolean,
        default: false
    },
    bill: {
        type: Object,
        default: null
    }
});

/** Eventos */
const emit = defineEmits(['close', 'confirm']);

/** Métodos */
const handleConfirm = () => emit('confirm', props.bill.id);
const handleClose   = () => emit('close');
</script>

<template>
    <Modal :show="show" max-width="md" @close="handleClose">
        <div class="p-6">
            <!-- Header -->
            <div class="flex items-center justify-between mb-6">
                <div class="flex items-center gap-3">
                    <div class="flex items-center justify-center w-12 h-12 rounded-full bg-red-100 dark:bg-red-900/30">
                        <GoogleIcon name="delete_forever" class="text-2xl text-red-600 dark:text-red-400" />
                    </div>
                    <h3 class="text-lg font-bold text-gray-900 dark:text-gray-100">
                        {{ transl('delete.title') }}
                    </h3>
                </div>
                <button
                    @click="handleClose"
                    class="text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors"
                >
                    <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>
                    </svg>
                </button>
            </div>

            <!-- Contenido -->
            <div class="space-y-5">
                <p class="text-gray-700 dark:text-gray-300 text-base">
                    {{ transl('delete.confirm') }}
                </p>

                <div
                    v-if="bill"
                    class="bg-gradient-to-br from-gray-50 to-gray-100 dark:from-gray-800 dark:to-gray-900 border border-gray-200 dark:border-gray-700 rounded-xl p-5 space-y-1"
                >
                    <p class="text-base font-bold text-gray-900 dark:text-gray-100">
                        {{ bill.name }}
                    </p>
                    <p class="text-sm text-gray-500 dark:text-gray-400">
                        ${{ Number(bill.cost).toFixed(2) }}
                    </p>
                </div>

                <div class="flex items-start gap-2 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4">
                    <GoogleIcon name="info" class="text-red-600 dark:text-red-400 text-xl flex-shrink-0 mt-0.5" />
                    <p class="text-sm text-red-800 dark:text-red-300 font-medium">
                        {{ transl('delete.warning') }}
                    </p>
                </div>
            </div>

            <!-- Footer -->
            <div class="flex items-center justify-end gap-3 mt-8 pt-6 border-t border-gray-200 dark:border-gray-700">
                <button
                    type="button"
                    @click="handleClose"
                    class="px-5 py-2.5 text-sm font-semibold text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500 transition-colors"
                >
                    {{ $t('cancel') }}
                </button>
                <button
                    type="button"
                    @click="handleConfirm"
                    class="flex items-center gap-2 px-5 py-2.5 bg-red-600 hover:bg-red-700 text-white text-sm font-semibold rounded-lg focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-600 shadow-lg shadow-red-600/30 transition-all"
                >
                    <GoogleIcon name="delete" class="text-xl" />
                    {{ transl('delete.title') }}
                </button>
            </div>
        </div>
    </Modal>
</template>
