<%# Firebase logout page - signs out from Firebase client-side %>
<!DOCTYPE html>
<html>
<head>
  <title>Signing out...</title>
  <meta charset="utf-8">
  <style>
    body {
      display: flex;
      justify-content: center;
      align-items: center;
      height: 100vh;
      margin: 0;
      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
      background-color: #f5f5f5;
    }
    .logout-message {
      text-align: center;
      padding: 40px;
      background: white;
      border-radius: 8px;
      box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    }
    .spinner {
      width: 40px;
      height: 40px;
      margin: 0 auto 20px;
      border: 4px solid #f3f3f3;
      border-top: 4px solid #3498db;
      border-radius: 50%;
      animation: spin 1s linear infinite;
    }
    @keyframes spin {
      0% { transform: rotate(0deg); }
      100% { transform: rotate(360deg); }
    }
  </style>
</head>
<body>
  <div class="logout-message">
    <div class="spinner"></div>
    <p>Signing out...</p>
  </div>

  <script src="https://www.gstatic.com/firebasejs/9.22.0/firebase-app-compat.js"></script>
  <script src="https://www.gstatic.com/firebasejs/9.22.0/firebase-auth-compat.js"></script>
  <script>
    // Initialize Firebase with config
    const firebaseConfig = {
      apiKey: "<%= ENV['FIREBASE_API_KEY'] %>",
      authDomain: "<%= ENV['FIREBASE_PROJECT_ID'] %>.firebaseapp.com",
      projectId: "<%= ENV['FIREBASE_PROJECT_ID'] %>",
    };

    firebase.initializeApp(firebaseConfig);

    // Sign out from Firebase and redirect to home
    firebase.auth().signOut().then(() => {
      window.location.assign('/');
    }).catch((error) => {
      console.error('Firebase sign out error:', error);
      // Still redirect even if Firebase signout fails
      // (user is already signed out from Rails session)
      window.location.assign('/');
    });
  </script>
</body>
</html>
