<template>
    <div class="alert-modal-overlay" :class="{ 'is-open': isOpen }" @click.self="close">
        <div class="alert-modal-card" :class="{ 'is-open': isOpen }">
            <!-- Top Close Icon Button (Micro-interaction) -->
            <button class="alert-modal-close-btn" @click="close" aria-label="Close">
                <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor">
                    <path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" />
                </svg>
            </button>

            <div class="alert-modal-body">
                <!-- Icon container with glowing gradient and drop-shadow -->
                <div class="alert-icon-wrapper">
                    <div class="alert-icon-glow"></div>
                    <div class="alert-icon-circle">
                        <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" class="icon-svg">
                            <path stroke-linecap="round" stroke-linejoin="round" d="M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
                        </svg>
                    </div>
                </div>

                <!-- Text Header & Content -->
                <div class="alert-text-container">
                    <h3 class="alert-modal-title">{{ title }}</h3>
                    <p class="alert-modal-message">{{ message }}</p>
                </div>
            </div>

            <!-- Action buttons with custom styles and animations -->
            <div class="alert-modal-footer">
                <button class="alert-btn alert-btn-primary" @click="close">OK</button>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    props: {
        message: {
            type: String,
            required: true
        },
        title: {
            type: String,
            default: 'Notification'
        }
    },
    data() {
        return {
            isOpen: false
        };
    },
    mounted() {
        setTimeout(() => {
            this.isOpen = true;
        }, 10);
    },
    methods: {
        close() {
            this.isOpen = false;
            setTimeout(() => {
                this.$emit('close');
            }, 250);
        }
    }
}
</script>

<style scoped>
/* ─────────────────────────────────────────────
   Modal Overlay (Backdrop)
   ───────────────────────────────────────────── */
.alert-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.alert-modal-overlay.is-open {
    opacity: 1;
    pointer-events: all;
}

/* ─────────────────────────────────────────────
   Modal Card
   ───────────────────────────────────────────── */
.alert-modal-card {
    background: var(--bg-surface, #ffffff);
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.06));
    border-radius: 20px;
    box-shadow: 
        0 10px 15px -3px rgba(0, 0, 0, 0.05),
        0 25px 40px -12px rgba(0, 0, 0, 0.12),
        0 0 0 1px rgba(0, 0, 0, 0.02);
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    position: relative;
    transform: translateY(24px) scale(0.95);
    opacity: 0;
    transition: 
        transform 0.4s cubic-bezier(0.16, 1, 0.3, 1),
        opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
    padding: 32px 28px 24px;
}

.alert-modal-card.is-open {
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* Dark Mode Overrides */
:global(.dark) .alert-modal-card {
    background: #1e293b;
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 
        0 20px 25px -5px rgba(0, 0, 0, 0.3),
        0 35px 60px -15px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* ─────────────────────────────────────────────
   Close Button
   ───────────────────────────────────────────── */
.alert-modal-close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-muted, #94a3b8);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.alert-modal-close-btn:hover {
    background: var(--bg-hover, rgba(0, 0, 0, 0.04));
    color: var(--text-primary, #1e293b);
    transform: rotate(90deg);
}

:global(.dark) .alert-modal-close-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #f8fafc;
}

.alert-modal-close-btn svg {
    width: 16px;
    height: 16px;
}

/* ─────────────────────────────────────────────
   Body Content
   ───────────────────────────────────────────── */
.alert-modal-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 20px;
    margin-bottom: 24px;
}

/* ─────────────────────────────────────────────
   Glowing Icon Styles
   ───────────────────────────────────────────── */
.alert-icon-wrapper {
    position: relative;
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.alert-icon-circle {
    position: relative;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    transition: transform 0.3s ease;
    background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
    color: #0284c7;
    border: 1px solid rgba(186, 230, 253, 0.4);
}

.alert-icon-wrapper:hover .alert-icon-circle {
    transform: scale(1.08);
}

.alert-icon-glow {
    position: absolute;
    inset: 4px;
    border-radius: 50%;
    filter: blur(12px);
    opacity: 0.5;
    z-index: 1;
    transition: opacity 0.3s ease;
    background: #0284c7;
}

.alert-icon-wrapper:hover .alert-icon-glow {
    opacity: 0.8;
}

:global(.dark) .alert-icon-wrapper .alert-icon-circle {
    background: linear-gradient(135deg, rgba(2, 132, 199, 0.15) 0%, rgba(2, 132, 199, 0.3) 100%);
    color: #38bdf8;
    border-color: rgba(56, 189, 248, 0.2);
}

.icon-svg {
    width: 24px;
    height: 24px;
}

/* ─────────────────────────────────────────────
   Text Styles
   ───────────────────────────────────────────── */
.alert-text-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.alert-modal-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary, #0f172a);
    margin: 0;
    letter-spacing: -0.02em;
}

:global(.dark) .alert-modal-title {
    color: #f8fafc;
}

.alert-modal-message {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-secondary, #64748b);
    margin: 0;
    padding: 0 10px;
    word-break: break-word;
    white-space: pre-wrap;
}

:global(.dark) .alert-modal-message {
    color: #94a3b8;
}

/* ─────────────────────────────────────────────
   Footer & Buttons
   ───────────────────────────────────────────── */
.alert-modal-footer {
    display: flex;
    justify-content: center;
}

.alert-btn {
    width: 100%;
    max-width: 140px;
    height: 42px;
    border-radius: 12px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    border: none;
    outline: none;
}

.alert-btn:active {
    transform: scale(0.96);
}

/* Primary Alert Button (Blue Gradient) */
.alert-btn-primary {
    background: linear-gradient(135deg, #4f46e5 0%, #3b82f6 100%);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

.alert-btn-primary:hover {
    background: linear-gradient(135deg, #4338ca 0%, #2563eb 100%);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.35);
}
</style>
