import { chromium } from 'playwright';
import { config } from 'dotenv';
import path from 'path';
config({ path: path.resolve(process.cwd(), '.env.local') });

(async () => {
  const browser = await chromium.launch({ headless: true });
  const page = await browser.newPage();
  await page.goto('https://skyslope.com/forms-login/');
  await page.waitForLoadState('networkidle');

  const inputs = await page.locator('input').all();
  console.log('Input count:', inputs.length);
  for (const input of inputs) {
    const attrs = await input.evaluate((el: HTMLInputElement) => ({
      type: el.type, name: el.name, id: el.id, placeholder: el.placeholder
    }));
    console.log('Input:', attrs);
  }

  const links = await page.locator('a[href*="login"], a[href*="signin"], a[href*="forms.skyslope"]').all();
  for (const link of links) {
    const text = await link.textContent();
    const href = await link.getAttribute('href');
    console.log('Link:', text?.trim().slice(0, 60), '→', href);
  }

  await page.screenshot({ path: 'scripts/debug-inspect.png', fullPage: false });
  await browser.close();
})();
