<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Coach Vault</title>
    <meta name="description" content="Professional coaching management platform" />
    <meta name="author" content="Coach Vault" />

    <meta property="og:title" content="Coach Vault" />
    <meta property="og:description" content="Professional coaching management platform" />
    <meta property="og:type" content="website" />
    <meta property="og:image" content="/lovable-uploads/f2df824b-d722-4548-a26c-7d738f754338.png" />

    <meta name="twitter:card" content="summary_large_image" />
    <meta name="twitter:site" content="@coachvault" />
    <meta name="twitter:image" content="/lovable-uploads/f2df824b-d722-4548-a26c-7d738f754338.png" />
    
    <link rel="icon" href="/lovable-uploads/f2df824b-d722-4548-a26c-7d738f754338.png" type="image/png" />
    
    <!-- Token debugging for password reset functionality -->
    <script src="/token-debug.js"></script>
    
    <!-- Early routing fix for hash-based routes -->
    <script>
      // Fix hash-based routes like #/reset-password
      (function() {
        var hash = window.location.hash;
        
        // Check if we have a hash route (e.g., #/reset-password)
        if (hash && hash.startsWith('#/')) {
          console.log('Detected hash-based route:', hash);
          
          // Extract the path and any parameters
          var path = hash.substring(1); // Remove the # character
          var pathParts = path.split('?');
          var cleanPath = pathParts[0];
          var params = pathParts.length > 1 ? '?' + pathParts[1] : '';
          
          // Check for reset-password path specifically
          if (cleanPath === '/reset-password' || cleanPath.startsWith('/reset-password/')) {
            console.log('Detected reset-password hash route, fixing navigation');
            
            // Redirect to the proper path
            window.location.href = window.location.origin + cleanPath + params;
          }
        }
        
        // Also handle password reset tokens in the URL hash
        if (hash && hash.includes('access_token=') && hash.includes('type=recovery')) {
          console.log('Detected password reset token in URL hash');
          
          // Ensure we're on the reset-password page
          if (!window.location.pathname.includes('/reset-password')) {
            console.log('Redirecting to reset-password page with token');
            window.location.href = window.location.origin + '/reset-password' + hash;
          }
        }
      })();
    </script>
    
    <!-- Stripe configuration for checkout pages -->
    <meta name="stripe-key" content="%VITE_STRIPE_PUBLISHABLE_KEY%" />
    
    <!-- Early password reset error detection script -->
    <script>
      (function() {
        // Immediately check if we're on lovable.app domain with reset error in URL
        if (window.location.href.includes('lovable.app') && 
            window.location.hash && 
            (window.location.hash.includes('error=access_denied') || 
             window.location.hash.includes('error_code=otp_expired'))) {
          
          // Log the detection
          console.log('Password reset error detected on lovable.app domain');
          
          // Get the correct production URL
          const correctProductionURL = 'https://coachvault.co.uk';
          const path = '/reset-password';
          
          // Create the redirect URL with original error params for debugging
          const redirectURL = correctProductionURL + path + 
                            '?source_domain=' + encodeURIComponent(window.location.origin) + 
                            window.location.hash;
          
          console.log('Redirecting to correct domain:', redirectURL);
          
          // Perform the redirect before the page even loads
          window.location.href = redirectURL;
        }
      })();
    </script>
    <script type="module" crossorigin src="/assets/js/index-DIV9npHG.js"></script>
    <link rel="modulepreload" crossorigin href="/assets/js/react-vendor-D8q6SJRB.js">
    <link rel="modulepreload" crossorigin href="/assets/js/ui-vendor-guczrwyU.js">
    <link rel="stylesheet" crossorigin href="/assets/css/index-BgEpnCMK.css">
  </head>

  <body>
    <div id="root"></div>
    <script src="https://cdn.gpteng.co/gptengineer.js" type="module"></script>
  </body>
</html>
