// components/StartupLoader.tsx
'use client'

import { motion, AnimatePresence } from 'framer-motion';
import { useState, useEffect } from 'react';

export default function StartupLoader() {
    const [showLoader, setShowLoader] = useState(true);

    useEffect(() => {
        const timer = setTimeout(() => setShowLoader(false), 500);
        return () => clearTimeout(timer);
    }, []);

    return (
        <AnimatePresence>
            {showLoader && (
                <motion.div
                    initial={{ opacity: 1 }}
                    animate={{ opacity: 1 }}
                    exit={{ opacity: 0 }}
                    transition={{ duration: 0.6 }}
                    style={{
                        position: 'fixed',
                        inset: 0,
                        zIndex: 9999,
                        backgroundColor: 'black',
                        color: 'white',
                        display: 'flex',
                        justifyContent: 'center',
                        alignItems: 'center',
                    }}
                >
                    <motion.h1
                        initial={{ scale: 1.2 }}
                        animate={{ scale: 1 }}
                        exit={{ scale: 0.8 }}
                        transition={{ duration: 0.6 }}
                        style={{ fontSize: '32px' }}
                    >
                        Загрузка...
                    </motion.h1>
                </motion.div>
            )}
        </AnimatePresence>
    );
}
