<?php
session_start();
include 'koneksi.php';

// Cek apakah user sudah login
if (!isset($_SESSION['user_id'])) {
    // Jika belum login, langsung ke login
    header("Location: login.php");
    exit;
}

// Set session logout
session_unset();
session_destroy();

// Tampilkan halaman loading
?>
<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Logging Out...</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Inter', sans-serif;
            height: 100vh;
            width: 100%;
            overflow: hidden;
            position: relative;
        }

        /* Background Foto */
        .background-image {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: url('SILAKU.png') center/cover no-repeat;
            z-index: 1;
        }



        /* Loading Container */
        .loading-container {
            text-align: center;
            animation: fadeIn 0.5s ease;
        }

        /* Avatar Foto */
        .avatar {
            width: 80px;
            height: 80px;
            border-radius: 50%;
            border: 4px solid rgba(255, 255, 255, 0.3);
            margin-bottom: 20px;
            overflow: hidden;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
        }

        .avatar img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        /* Spinner */
        .spinner {
            width: 50px;
            height: 50px;
            border: 5px solid rgba(255, 255, 255, 0.1);
            border-top: 5px solid #4f46e5;
            border-radius: 50%;
            animation: spin 1s linear infinite;
            margin: 0 auto 20px;
        }

        /* Loading Text */
        .loading-text {
            color: white;
            font-size: 18px;
            font-weight: 600;
            letter-spacing: 1px;
            margin-bottom: 10px;
        }

        .loading-subtext {
            color: rgba(255, 255, 255, 0.6);
            font-size: 13px;
        }

        /* Animations */
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: translateY(20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
    </style>
</head>
<body>

    <!-- Background Foto -->
    <div class="background-image"></div>

    <!-- Overlay Loading -->
    <div class="overlay">
        <div class="loading-container">
            <!-- Foto Profil -->
            <div class="avatar">
                <img src="silakumanagefinance_-removebg-preview.png" alt="Profile">
            </div>
            
            <!-- Spinner -->
            <div class="spinner"></div>
            
            <!-- Text -->
         
            <div class="loading-subtext">Sampai jumpa lagi!</div>
        </div>
    </div>

    <script>
        // Redirect setelah 1.5 detik (1500 milidetik)
        setTimeout(function() {
            window.location.href = 'login.php';
        }, 1500);
    </script>

</body>
</html>

