// ==========================================
// ResultModal Component
// ==========================================

const ResultModal = ({ resultBlob, packBlob, onClose, t }) => {
    const { CheckIcon } = window.Icons;

    if (!resultBlob) return null;

    return (
        <div className="fixed inset-0 z-[100] bg-slate-950/98 backdrop-blur-2xl flex items-center justify-center p-6 animate-in fade-in zoom-in duration-500">
            <div className="bg-slate-900 rounded-[3rem] border border-slate-800 p-12 max-w-xl w-full text-center space-y-10 relative shadow-3xl">
                <button onClick={onClose} className="absolute top-10 right-10 text-slate-500 hover:text-white transition-colors p-2 bg-slate-800 rounded-full hover:rotate-90 duration-300">✕</button>
                <div className="w-20 h-20 bg-emerald-500/10 text-emerald-400 rounded-full flex items-center justify-center mx-auto border border-emerald-500/20 shadow-xl">
                    <CheckIcon />
                </div>
                <div>
                    <h3 className="text-4xl font-black uppercase tracking-tight">{t('Generation Complete', '生成完成')}</h3>
                    <p className="text-slate-500 text-xs font-bold uppercase tracking-widest mt-2">{t('Package includes: Transparent/Original GIFs & PNG Frames', '压缩包包含：透明/白底 GIF 及所有 PNG 分帧文件')}</p>
                </div>
                <div className="bg-black rounded-3xl p-10 border border-slate-800 flex justify-center shadow-inner overflow-hidden relative">
                    <div className="absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ib3BhY2l0eSI+PHJlY3Qgd2lkdGg9IjEwIiBoZWlnaHQ9IjEwIiBmaWxsPSIjMWUyOTNiIiAvPjwvc3ZnPg==')] opacity-10" />
                    <img src={URL.createObjectURL(resultBlob)} className="max-h-[300px] object-contain scale-150 z-10" style={{ imageRendering: 'pixelated' }} alt="GIF Preview" />
                </div>

                <div className="grid grid-cols-2 gap-4">
                    <button
                        onClick={() => saveAs(resultBlob, 'pixel_anim.gif')}
                        className="w-full py-4 bg-slate-800 text-white font-bold rounded-2xl uppercase tracking-[0.1em] text-xs hover:bg-slate-700 transition-all shadow-lg active:scale-95 border border-slate-700"
                    >
                        {t('Download GIF', '下载 GIF 动图')}
                    </button>
                    <button
                        onClick={() => saveAs(packBlob, 'pixel_assets_pack.zip')}
                        className="w-full py-4 bg-white text-slate-950 font-black rounded-2xl uppercase tracking-[0.1em] text-xs hover:bg-slate-200 transition-all shadow-xl active:scale-95"
                    >
                        {t('Download ZIP', '下载 ZIP 素材包')}
                    </button>
                </div>

            </div>
        </div>
    );
};

window.ResultModal = ResultModal;
