<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Insurance Quote Form</title>
    <style>
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            margin: 0;
            padding: 20px;
        }
        .container {
            max-width: 600px;
            margin: 50px auto;
            background: white;
            border-radius: 12px;
            box-shadow: 0 10px 40px rgba(0,0,0,0.2);
            overflow: hidden;
        }
        .header {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 30px;
            text-align: center;
        }
        .wizard {
            padding: 30px;
        }
        .step-indicator {
            display: flex;
            margin-bottom: 30px;
            gap: 10px;
        }
        .step-dot {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background: #e0e0e0;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            cursor: pointer;
        }
        .step-dot.active {
            background: #667eea;
            color: white;
        }
        .step-dot.completed {
            background: #4caf50;
            color: white;
        }
        iframe {
            width: 100%;
            border: none;
            margin: 20px 0;
            min-height: 300px;
        }
        button {
            padding: 12px 24px;
            background: #667eea;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
            font-weight: 600;
            margin-top: 20px;
        }
        button:hover { background: #5568d3; }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <h1>Insurance Quote</h1>
            <p>Get your personalized quote in 4 steps</p>
        </div>
        <div id="wizard" class="wizard">
            <div class="step-indicator">
                <div class="step-dot active" data-step="1">1</div>
                <div class="step-dot" data-step="2">2</div>
                <div class="step-dot" data-step="3">3</div>
                <div class="step-dot" data-step="4">4</div>
            </div>
            
            <iframe id="step-frame" src="step1.html" style="display:block;"></iframe>
            
            <button onclick="prevStep()">← Back</button>
            <button onclick="nextStep()" style="float:right;">Next →</button>
            <div style="clear:both;"></div>
        </div>
    </div>

    <script>
        let currentStep = 1;
        window.formData = {};
        const formData = window.formData;

        function updateStepIndicator() {
            document.querySelectorAll('.step-dot').forEach(dot => {
                const step = parseInt(dot.dataset.step);
                dot.classList.remove('active', 'completed');
                if (step === currentStep) dot.classList.add('active');
                else if (step < currentStep) dot.classList.add('completed');
            });
        }

        function captureCurrentStep() {
            const sf = document.getElementById('step-frame');
            try {
                const sd = sf.contentDocument || sf.contentWindow.document;
                if (currentStep === 1) {
                    const n = sd.getElementById('name'); if (n) formData.name = n.value;
                    const d = sd.getElementById('dob'); if (d) formData.dob = d.value;
                    const g = sd.getElementById('gender'); if (g) formData.gender = g.value;
                } else if (currentStep === 2) {
                    ['brand','model','year','plate'].forEach(k => {
                        const el = sd.getElementById(k);
                        if (el) formData[k] = el.value;
                    });
                }
            } catch (e) {}
        }

        function nextStep() {
            if (currentStep < 4) {
                captureCurrentStep();
                currentStep++;
                loadStep();
                updateStepIndicator();
            } else if (currentStep === 4) {
                submitQuote();
            }
        }

        function prevStep() {
            if (currentStep > 1) {
                currentStep--;
                loadStep();
                updateStepIndicator();
            }
        }

        function loadStep() {
            const stepFrame = document.getElementById('step-frame');
            const stepNum = currentStep;
            stepFrame.src = `step${stepNum}.html`;
        }

        function submitQuote() {
            const stepFrame = document.getElementById('step-frame');
            stepFrame.src = 'quote_result.html';
            document.querySelector('button:last-of-type').style.display = 'none';
            document.querySelector('button:first-of-type').style.display = 'none';
        }

        updateStepIndicator();
    </script>
</body>
</html>