<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
/**
 * Template Name: Avision Landing Page
 * Description: Custom landing page template with user's exact HTML design
 *
 * WordPress: Assign this template to a page via Page Attributes > Template
 * Replit: This template is loaded directly by the router for /home and / routes
 */
$plugin_url = defined( 'AVISION_PLUGIN_URL' ) ? AVISION_PLUGIN_URL : '/wordpress/wp-content/plugins/avision-dashboard/';
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Avision - Local SEO Audit Tool</title>
    <link rel="stylesheet" href="<?php echo $plugin_url; ?>assets/css/home-landing.css">
    <style>
        .av-header { background: white; padding: 0 24px; position: fixed; top: 0; left: 0; right: 0; z-index: 1000; border-bottom: 1px solid #E2E8F0; }
        .av-header-inner { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; height: 70px; }
        .av-logo { font-size: 1.8rem; font-weight: 800; color: var(--accent); text-decoration: none; }
        .av-logo span { color: var(--primary); }
        .av-nav { display: flex; gap: 30px; list-style: none; margin: 0; padding: 0; }
        .av-nav a { color: var(--text-light); text-decoration: none; font-weight: 500; font-size: 1rem; transition: color 0.2s; }
        .av-nav a:hover { color: var(--primary); }
        .av-header-flags { display: flex; gap: 10px; align-items: center; }
        .av-header-flag { width: 28px; height: 20px; border-radius: 4px; cursor: pointer; border: 2px solid transparent; transition: all 0.2s; opacity: 0.6; }
        .av-header-flag:hover, .av-header-flag.active { opacity: 1; border-color: var(--primary); }
        .av-hero { padding-top: 160px; }
        .flag-img { display: block; width: 32px; height: 24px; object-fit: cover; border-radius: 4px; }
    </style>
</head>
<body>

<div class="av-wrapper">

    <!-- NAVIGATION HEADER -->
    <header class="av-header">
        <div class="av-header-inner">
            <a href="/" class="av-logo">Avi<span>sion</span></a>
            <nav>
                <ul class="av-nav">
                    <li><a href="/" data-i18n="nav_home">Home</a></li>
                    <li><a href="/local-seo" data-i18n="nav_local_seo">Local SEO</a></li>
                    <li><a href="/demo-dashboard" data-i18n="nav_dashboard">Dashboard</a></li>
                    <li><a href="/payment" data-i18n="nav_pricing">Pricing</a></li>
                </ul>
            </nav>
            <div class="av-header-flags">
                <img src="https://flagcdn.com/w40/us.png" alt="English" class="av-header-flag active" onclick="setLanguage('en')" id="header-btn-en">
                <img src="https://flagcdn.com/w40/fr.png" alt="French" class="av-header-flag" onclick="setLanguage('fr')" id="header-btn-fr">
                <img src="https://flagcdn.com/w40/es.png" alt="Spanish" class="av-header-flag" onclick="setLanguage('es')" id="header-btn-es">
            </div>
        </div>
    </header>

    <!-- 1. HERO SECTION -->
    <section class="av-hero" id="top">
        <div class="av-container">
            <div class="av-hero-content">
                <h1 data-i18n="hero_title">Your customers are looking for a pro like you. <br><span class="text-highlight">But do they find you first?</span></h1>
                <p data-i18n="hero_sub">Phone not ringing enough? It's probably Google's Fault. Discover what is blocking your local growth. Get your free diagnosis in less than a minute.</p>
                
                <div class="av-form-placeholder">
                    <form onsubmit="handleAudit(event)">
                        <div class="av-input-group">
                            <input type="text" id="businessInput" class="av-input" placeholder="Enter your business name..." required>
                            <button type="submit" class="av-btn" id="auditBtn">
                                <span id="btnText" data-i18n="btn_audit">Get Free Audit</span>
                                <div class="spinner" id="btnSpinner"></div>
                            </button>
                        </div>
                    </form>
                </div>

                <div class="av-social-proof" data-i18n="social_proof">
                    ✅ Already 1,200+ businesses analyzed this week.
                </div>
            </div>
        </div>
    </section>

    <!-- 2. THE SECRET (MAP VISUAL) -->
    <section class="section-spacer bg-soft">
        <div class="av-container">
            <div class="av-grid-2">
                <div>
                    <h2 data-i18n="secret_title">📍 The "Secret" of the Top 3 Results</h2>
                    <p data-i18n="secret_text_1">Did you know that <strong>46% of all Google searches are local?</strong><br>(e.g., "Plumber near me", "Best Italian restaurant").</p>
                    <p data-i18n="secret_text_2">Google only displays <strong>3 businesses</strong> at the top of the map.</p>
                    
                    <ul style="list-style:none; padding:0; margin-bottom:30px;">
                        <li data-i18n="secret_list_1">🟢 If you are in: <strong>Your phone rings.</strong></li>
                        <li data-i18n="secret_list_2">🔴 If you are out: <strong>You are invisible.</strong></li>
                    </ul>

                    <div class="av-punchline-container">
                        <div class="av-punchline-bar"></div>
                        <p class="av-punchline-text" data-i18n="punchline">
                            Don't let luck <br>
                            decide your revenue.
                        </p>
                    </div>
                </div>
                
                <div class="av-map-container">
                    <div class="av-css-map">
                        <div class="av-map-pin pin-1"></div>
                        <div class="av-map-pin pin-2"></div>
                        <div class="av-map-pin pin-gray pin-3"></div>
                    </div>
                    <div class="av-map-list-item">
                        <div class="av-rank-circle bg-green">A</div>
                        <div><strong data-i18n="map_comp_1">Competitor #1</strong> <br> <span style="font-size:1.10rem; color:#F59E0B;">★★★★★ (142)</span></div>
                    </div>
                    <div class="av-map-list-item">
                        <div class="av-rank-circle bg-green">B</div>
                        <div><strong data-i18n="map_comp_2">Competitor #2</strong> <br> <span style="font-size:1.10rem; color:#F59E0B;">★★★★☆ (89)</span></div>
                    </div>
                    <div class="av-map-list-item" style="opacity:0.5;">
                        <div class="av-rank-circle bg-gray">?</div>
                        <div><strong data-i18n="map_you">You? (Invisible)</strong> <br> <span style="font-size:1.10rem;" data-i18n="map_no_rank">No ranking found</span></div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- 3. AGITATION (INVERSION) -->
    <section class="section-spacer">
        <div class="av-container">
            <div class="av-grid-2">
                <!-- Visuel Gauche -->
                <div class="av-ghost-visual">
                    <div class="av-result-row">
                        <div class="av-skeleton-img"></div>
                        <div class="av-skeleton-text">
                            <div class="av-line" style="width: 80%;"></div>
                            <div class="av-line short"></div>
                        </div>
                    </div>
                    <div class="av-result-row">
                        <div class="av-skeleton-img"></div>
                        <div class="av-skeleton-text">
                            <div class="av-line" style="width: 70%;"></div>
                            <div class="av-line short"></div>
                        </div>
                    </div>
                    <div class="av-result-row av-ghost-row">
                        <div class="av-ghost-badge" data-i18n="ghost_badge">INVISIBLE</div>
                        <div class="av-skeleton-img"></div>
                        <div class="av-skeleton-text">
                            <div class="av-line" style="width: 60%;"></div>
                            <div class="av-line short"></div>
                        </div>
                    </div>
                </div>

                <!-- Texte Droite -->
                <div>
                    <h2 data-i18n="invisible_title">Are You Invisible to Your Neighbors?</h2>
                    <p data-i18n="invisible_text_1">You are an excellent professional, but that is no longer enough. If you don't appear in the "Local Pack," your competitors are stealing your clients effortlessly.</p>
                    <p data-i18n="invisible_text_2">The problem? <strong>Google changes its rules all the time.</strong> What worked for you last year might be penalizing you today.</p>
                </div>
            </div>
        </div>
    </section>

    <!-- 4. SOLUTION (AVI) -->
    <section class="section-spacer bg-soft">
        <div class="av-container">
            <div class="text-center">
                <h2 data-i18n="avi_title">Meet Avi, Your AI Consultant.</h2>
                <p style="max-width:800px; margin:0 auto;" data-i18n="avi_sub">Forget expensive agencies and confusing technical reports. Avi is an artificial intelligence trained to analyze your local presence like a human expert, but instantly.</p>
            </div>

            <div class="av-cards-grid">
                <div class="av-feature-card">
                    <span class="av-icon">🧠</span>
                    <h3 data-i18n="card_1_title">Action-Oriented</h3>
                    <p data-i18n="card_1_text">He tells you exactly <em>what to do</em>, not just what is wrong.</p>
                </div>
                <div class="av-feature-card">
                    <span class="av-icon">⚡</span>
                    <h3 data-i18n="card_2_title">Instant</h3>
                    <p data-i18n="card_2_text">A complete diagnosis while you grab a coffee.</p>
                </div>
                <div class="av-feature-card">
                    <span class="av-icon">⚖️</span>
                    <h3 data-i18n="card_3_title">Impartial</h3>
                    <p data-i18n="card_3_text">No sales talk, no bias. Just raw data.</p>
                </div>
            </div>
        </div>
    </section>

    <!-- 5. COMPARISON TABLE (RESPONSIVE) -->
    <section class="section-spacer">
        <div class="av-container">
            <h2 class="text-center" data-i18n="table_title">🤖 Why choose Avi over a Traditional Agency?</h2>
            <div class="av-table-wrapper">
                <table class="av-table">
                    <thead>
                        <tr>
                            <th data-i18n="th_feature">Feature</th>
                            <th data-i18n="th_agency">Traditional Agency</th>
                            <th data-i18n="th_avi">Avi (Your Local AI)</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td data-i18n="td_speed">Speed</td>
                            <td data-i18n="td_agency_1">📞 Endless phone meetings</td>
                            <td data-i18n="td_avi_1">⚡ Instant Result (60s)</td>
                        </tr>
                        <tr>
                            <td data-i18n="td_clarity">Clarity</td>
                            <td data-i18n="td_agency_2">📄 Confusing 50-page reports</td>
                            <td data-i18n="td_avi_2">🎯 Clear & Prioritized Plan</td>
                        </tr>
                        <tr>
                            <td data-i18n="td_cost">Cost</td>
                            <td data-i18n="td_agency_3">💰 $500 quote just for an audit</td>
                            <td data-i18n="td_avi_3">🎁 Initial Audit 100% Free</td>
                        </tr>
                        <tr>
                            <td data-i18n="td_obj">Objectivity</td>
                            <td data-i18n="td_agency_4">🤷‍♂️ "It depends..."</td>
                            <td data-i18n="td_avi_4">🔍 Data-Driven Analysis</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </section>

    <!-- 6. HOW IT WORKS -->
    <section class="section-spacer bg-soft">
        <div class="av-container">
            <h2 class="text-center" data-i18n="steps_title">3 Steps to Clarity</h2>
            <div class="av-steps-grid">
                <div>
                    <div class="av-step-num">1</div>
                    <h3 data-i18n="step_1_title">Enter Name</h3>
                    <p data-i18n="step_1_text">Enter your business name in the search bar.</p>
                </div>
                <div>
                    <div class="av-step-num">2</div>
                    <h3 data-i18n="step_2_title">AI Scan</h3>
                    <p data-i18n="step_2_text">Avi scans your profile, reviews, and competitors in real-time.</p>
                </div>
                <div>
                    <div class="av-step-num">3</div>
                    <h3 data-i18n="step_3_title">Action Plan</h3>
                    <p data-i18n="step_3_text">Receive your Trust Score and an immediate action plan.</p>
                </div>
            </div>
        </div>
    </section>

    <!-- 7. REVIEWS (SLIDER) -->
    <section class="section-spacer">
        <div class="av-container">
            <h2 class="text-center" data-i18n="reviews_title">They Unlocked Their Growth with Avi</h2>
            
            <div class="av-slider-wrapper">
                <button class="av-slider-btn av-prev" onclick="scrollSlider(-1)">&#8249;</button>
                
                <div class="av-slider-container" id="reviewSlider">
                    <div class="av-review-slide">
                        <div>
                            <div class="av-stars">⭐⭐⭐⭐⭐</div>
                            <p class="av-review-text" data-i18n="review_1_text">"I finally understood why I wasn't ranking. The 'Missing Keywords' section was a shock. I applied the changes and saw results in 3 weeks."</p>
                        </div>
                        <div class="av-review-author" data-i18n="review_1_author">— Mark D., Osteopath</div>
                    </div>
                    <div class="av-review-slide">
                        <div>
                            <div class="av-stars">⭐⭐⭐⭐⭐</div>
                            <p class="av-review-text" data-i18n="review_2_text">"My agency charged me $500/month for reports I didn't understand. Avi gave me a clear roadmap in 1 minute."</p>
                        </div>
                        <div class="av-review-author" data-i18n="review_2_author">— Sarah L., Restaurant Owner</div>
                    </div>
                    <div class="av-review-slide">
                        <div>
                            <div class="av-stars">⭐⭐⭐⭐⭐</div>
                            <p class="av-review-text" data-i18n="review_3_text">"I'm not technical at all. The step-by-step guide for the first 30 days is exactly what I needed."</p>
                        </div>
                        <div class="av-review-author" data-i18n="review_3_author">— James P., Plumber</div>
                    </div>
                </div>

                <button class="av-slider-btn av-next" onclick="scrollSlider(1)">&#8250;</button>
            </div>
        </div>
    </section>

    <!-- 8. FAQ -->
    <section class="section-spacer bg-soft">
        <div class="av-container" style="max-width: 900px;">
            <h2 class="text-center" style="margin-bottom: 50px;" data-i18n="faq_title">Frequently Asked Questions</h2>
            
            <details class="av-faq-item">
                <summary data-i18n="faq_1_q">Is it really free?</summary>
                <div class="av-faq-content" data-i18n="faq_1_a">
                    Yes, the initial audit, the Trust Score, and the "Quick Win" advice are 100% free. You can choose to unlock the detailed 90-day roadmap if you want to go further, but there is no obligation.
                </div>
            </details>

            <details class="av-faq-item">
                <summary data-i18n="faq_2_q">Do you need my passwords?</summary>
                <div class="av-faq-content" data-i18n="faq_2_a">
                    No, never. Avi only analyzes public data—exactly what your potential customers see when they search for you.
                </div>
            </details>

            <details class="av-faq-item">
                <summary data-i18n="faq_3_q">Does it work for my profession?</summary>
                <div class="av-faq-content" data-i18n="faq_3_a">
                    Avi is optimized for all local businesses and service professionals (Dentists, Lawyers, Plumbers, Restaurants, Real Estate Agents, etc.).
                </div>
            </details>
        </div>
    </section>

    <!-- 9. FINAL CTA -->
    <section class="section-spacer text-center">
        <div class="av-container">
            <h2 data-i18n="cta_title">Ready to dominate your local area?</h2>
            <p data-i18n="cta_sub">Don't let another customer go to your competitor.</p>
            <a href="#top" class="av-btn av-btn-large" data-i18n="cta_btn">⬆️ Start My Free Analysis</a>
        </div>
    </section>

</div>

<script>
    let currentLanguage = 'en';
    const auditPageUrl = "/local-seo"; 

    const translations = {
        en: {
            nav_home: 'Home',
            nav_local_seo: 'Local SEO',
            nav_dashboard: 'Dashboard',
            nav_pricing: 'Pricing',
            hero_title: 'Your customers are looking for a pro like you. <br><span class="text-highlight">But do they find you first?</span>',
            hero_sub: "Phone not ringing enough? It's probably Google's Fault. Discover what is blocking your local growth. Get your free diagnosis in less than a minute.",
            placeholder: 'Enter your business name...',
            btn_audit: 'Get Free Audit',
            social_proof: '✅ Already 1,200+ businesses analyzed this week.',
            
            secret_title: '📍 The "Secret" of the Top 3 Results',
            secret_text_1: 'Did you know that <strong>46% of all Google searches are local?</strong><br>(e.g., "Plumber near me", "Best Italian restaurant").',
            secret_text_2: 'Google only displays <strong>3 businesses</strong> at the top of the map.',
            secret_list_1: '🟢 If you are in: <strong>Your phone rings.</strong>',
            secret_list_2: '🔴 If you are out: <strong>You are invisible.</strong>',
            punchline: "Don't let luck <br>decide your revenue.",
            map_comp_1: 'Competitor #1',
            map_comp_2: 'Competitor #2',
            map_you: 'You? (Invisible)',
            map_no_rank: 'No ranking found',

            ghost_badge: 'INVISIBLE',
            invisible_title: 'Are You Invisible to Your Neighbors?',
            invisible_text_1: 'You are an excellent professional, but that is no longer enough. If you don\'t appear in the "Local Pack," your competitors are stealing your clients effortlessly.',
            invisible_text_2: 'The problem? <strong>Google changes its rules all the time.</strong> What worked for you last year might be penalizing you today.',

            avi_title: 'Meet Avi, Your AI Consultant.',
            avi_sub: 'Forget expensive agencies and confusing technical reports. Avi is an artificial intelligence trained to analyze your local presence like a human expert, but instantly.',
            
            card_1_title: 'Action-Oriented',
            card_1_text: 'He tells you exactly <em>what to do</em>, not just what is wrong.',
            card_2_title: 'Instant',
            card_2_text: 'A complete diagnosis while you grab a coffee.',
            card_3_title: 'Impartial',
            card_3_text: 'No sales talk, no bias. Just raw data.',

            table_title: '🤖 Why choose Avi over a Traditional Agency?',
            th_feature: 'Feature', th_agency: 'Traditional Agency', th_avi: 'Avi (Your Local AI)',
            td_speed: 'Speed', td_agency_1: '📞 Endless phone meetings', td_avi_1: '⚡ Instant Result (60s)',
            td_clarity: 'Clarity', td_agency_2: '📄 Confusing 50-page reports', td_avi_2: '🎯 Clear & Prioritized Plan',
            td_cost: 'Cost', td_agency_3: '💰 $500 quote just for an audit', td_avi_3: '🎁 Initial Audit 100% Free',
            td_obj: 'Objectivity', td_agency_4: '🤷‍♂️ "It depends..."', td_avi_4: '🔍 Data-Driven Analysis',

            steps_title: '3 Steps to Clarity',
            step_1_title: 'Enter Name', step_1_text: 'Enter your business name in the search bar.',
            step_2_title: 'AI Scan', step_2_text: 'Avi scans your profile, reviews, and competitors in real-time.',
            step_3_title: 'Action Plan', step_3_text: 'Receive your Trust Score and an immediate action plan.',

            reviews_title: 'They Unlocked Their Growth with Avi',
            review_1_text: '"I finally understood why I wasn\'t ranking. The \'Missing Keywords\' section was a shock. I applied the changes and saw results in 3 weeks."',
            review_1_author: '— Mark D., Osteopath',
            review_2_text: '"My agency charged me $500/month for reports I didn\'t understand. Avi gave me a clear roadmap in 1 minute."',
            review_2_author: '— Sarah L., Restaurant Owner',
            review_3_text: '"I\'m not technical at all. The step-by-step guide for the first 30 days is exactly what I needed."',
            review_3_author: '— James P., Plumber',

            faq_title: 'Frequently Asked Questions',
            faq_1_q: 'Is it really free?', faq_1_a: 'Yes, the initial audit, the Trust Score, and the "Quick Win" advice are 100% free. You can choose to unlock the detailed 90-day roadmap if you want to go further, but there is no obligation.',
            faq_2_q: 'Do you need my passwords?', faq_2_a: 'No, never. Avi only analyzes public data—exactly what your potential customers see when they search for you.',
            faq_3_q: 'Does it work for my profession?', faq_3_a: 'Avi is optimized for all local businesses and service professionals (Dentists, Lawyers, Plumbers, Restaurants, Real Estate Agents, etc.).',

            cta_title: 'Ready to dominate your local area?',
            cta_sub: 'Don\'t let another customer go to your competitor.',
            cta_btn: '⬆️ Start My Free Analysis',
            loading: 'Analyzing...'
        },
        fr: {
            nav_home: 'Accueil',
            nav_local_seo: 'SEO Local',
            nav_dashboard: 'Tableau de bord',
            nav_pricing: 'Tarifs',
            hero_title: 'Vos clients cherchent un pro comme vous. <br><span class="text-highlight">Mais vous trouvent-ils en premier ?</span>',
            hero_sub: "Le téléphone ne sonne pas assez ? C'est probablement la faute de Google. Découvrez ce qui bloque votre croissance locale. Obtenez votre diagnostic gratuit en moins d'une minute.",
            placeholder: 'Entrez le nom de votre entreprise...',
            btn_audit: 'Audit Gratuit',
            social_proof: '✅ Déjà 1 200+ entreprises analysées cette semaine.',
            
            secret_title: '📍 Le "Secret" du Top 3 Google',
            secret_text_1: 'Saviez-vous que <strong>46% des recherches Google sont locales ?</strong><br>(ex: "Plombier près de chez moi", "Meilleur restaurant italien").',
            secret_text_2: 'Google n\'affiche que <strong>3 entreprises</strong> en haut de la carte.',
            secret_list_1: '🟢 Si vous y êtes : <strong>Votre téléphone sonne.</strong>',
            secret_list_2: '🔴 Si vous n\'y êtes pas : <strong>Vous êtes invisible.</strong>',
            punchline: 'Ne laissez pas la chance <br>décider de votre CA.',
            map_comp_1: 'Concurrent #1',
            map_comp_2: 'Concurrent #2',
            map_you: 'Vous ? (Invisible)',
            map_no_rank: 'Aucun classement',

            ghost_badge: 'INVISIBLE',
            invisible_title: 'Êtes-vous invisible pour vos voisins ?',
            invisible_text_1: 'Vous êtes un excellent professionnel, mais cela ne suffit plus. Si vous n\'apparaissez pas dans le "Pack Local", vos concurrents volent vos clients sans effort.',
            invisible_text_2: 'Le problème ? <strong>Google change ses règles tout le temps.</strong> Ce qui marchait l\'année dernière vous pénalise peut-être aujourd\'hui.',

            avi_title: 'Rencontrez Avi, votre Consultant IA.',
            avi_sub: 'Oubliez les agences coûteuses et les rapports techniques incompréhensibles. Avi est une intelligence artificielle entraînée pour analyser votre présence locale comme un expert humain, mais instantanément.',
            
            card_1_title: 'Orienté Action',
            card_1_text: 'Il vous dit exactement <em>quoi faire</em>, pas juste ce qui ne va pas.',
            card_2_title: 'Instantané',
            card_2_text: 'Un diagnostic complet le temps de prendre un café.',
            card_3_title: 'Impartial',
            card_3_text: 'Pas de discours commercial, pas de biais. Juste des données brutes.',

            table_title: '🤖 Pourquoi choisir Avi plutôt qu\'une Agence ?',
            th_feature: 'Fonctionnalité', th_agency: 'Agence Traditionnelle', th_avi: 'Avi (Votre IA Local)',
            td_speed: 'Vitesse', td_agency_1: '📞 Réunions interminables', td_avi_1: '⚡ Résultat Instantané (60s)',
            td_clarity: 'Clarté', td_agency_2: '📄 Rapports flous de 50 pages', td_avi_2: '🎯 Plan Clair & Priorisé',
            td_cost: 'Coût', td_agency_3: '💰 Devis à 500€ juste pour l\'audit', td_avi_3: '🎁 Audit Initial 100% Gratuit',
            td_obj: 'Objectivité', td_agency_4: '🤷‍♂️ "Ça dépend..."', td_avi_4: '🔍 Analyse basée sur la Data',

            steps_title: '3 Étapes vers la Clarté',
            step_1_title: 'Entrez votre Nom', step_1_text: 'Tapez le nom de votre entreprise dans la barre de recherche.',
            step_2_title: 'Scan IA', step_2_text: 'Avi scanne votre profil, vos avis et vos concurrents en temps réel.',
            step_3_title: 'Plan d\'Action', step_3_text: 'Recevez votre Score de Confiance et un plan d\'action immédiat.',

            reviews_title: 'Ils ont débloqué leur croissance avec Avi',
            review_1_text: '"J\'ai enfin compris pourquoi je n\'étais pas classé. La section \'Mots-clés manquants\' a été un choc. J\'ai appliqué les changements et vu des résultats en 3 semaines."',
            review_1_author: '— Marc D., Ostéopathe',
            review_2_text: '"Mon agence me facturait 500€/mois pour des rapports que je ne comprenais pas. Avi m\'a donné une feuille de route claire en 1 minute."',
            review_2_author: '— Sarah L., Restauratrice',
            review_3_text: '"Je ne suis pas technique du tout. Le guide étape par étape pour les 30 premiers jours est exactement ce qu\'il me fallait."',
            review_3_author: '— James P., Plombier',

            faq_title: 'Questions Fréquentes',
            faq_1_q: 'Est-ce vraiment gratuit ?', faq_1_a: 'Oui, l\'audit initial, le Score de Confiance et les conseils "Quick Win" sont 100% gratuits. Vous pouvez choisir de débloquer la feuille de route détaillée de 90 jours si vous voulez aller plus loin, mais sans obligation.',
            faq_2_q: 'Avez-vous besoin de mes mots de passe ?', faq_2_a: 'No, jamais. Avi analyse uniquement les données publiques—exactement ce que vos clients potentiels voient quand ils vous cherchent.',
            faq_3_q: 'Est-ce que ça marche pour mon métier ?', faq_3_a: 'Avi est optimisé pour tous les commerces locaux et professionnels de service (Dentistes, Avocats, Plombiers, Restaurants, Agents Immobiliers, etc.).',

            cta_title: 'Prêt à dominer votre secteur ?',
            cta_sub: 'Ne laissez pas un autre client aller chez votre concurrent.',
            cta_btn: '⬆️ Lancer mon Analyse Gratuite',
            loading: 'Analyse en cours...'
        },
        es: {
            nav_home: 'Inicio',
            nav_local_seo: 'SEO Local',
            nav_dashboard: 'Panel',
            nav_pricing: 'Precios',
            hero_title: 'Tus clientes buscan un profesional como tú. <br><span class="text-highlight">¿Pero te encuentran primero?</span>',
            hero_sub: '¿El teléfono no suena lo suficiente? Probablemente sea culpa de Google. Descubre qué bloquea tu crecimiento local. Obtén tu diagnóstico gratuito en menos de un minuto.',
            placeholder: 'Ingresa el nombre de tu negocio...',
            btn_audit: 'Auditoría Gratis',
            social_proof: '✅ Ya 1.200+ empresas analizadas esta semana.',
            
            secret_title: '📍 El "Secreto" del Top 3 de Google',
            secret_text_1: '¿Sabías que <strong>el 46% de las búsquedas en Google son locales?</strong><br>(ej: "Fontanero cerca de mí", "Mejor restaurante italiano").',
            secret_text_2: 'Google solo muestra <strong>3 empresas</strong> en la parte superior del mapa.',
            secret_list_1: '🟢 Si estás ahí: <strong>Tu teléfono suena.</strong>',
            secret_list_2: '🔴 Si no estás: <strong>Eres invisible.</strong>',
            punchline: 'No dejes que la suerte <br>decida tus ingresos.',
            map_comp_1: 'Competidor #1',
            map_comp_2: 'Competidor #2',
            map_you: '¿Tú? (Invisible)',
            map_no_rank: 'Sin clasificación',

            ghost_badge: 'INVISIBLE',
            invisible_title: '¿Eres invisible para tus vecinos?',
            invisible_text_1: 'Eres un excelente profesional, pero eso ya no es suficiente. Si no apareces en el "Pack Local", tus competidores te roban clientes sin esfuerzo.',
            invisible_text_2: '¿El problema? <strong>Google cambia sus reglas todo el tiempo.</strong> Lo que funcionaba el año pasado podría estar penalizándote hoy.',

            avi_title: 'Conoce a Avi, tu Consultor IA.',
            avi_sub: 'Olvídate de agencias costosas e informes técnicos confusos. Avi es una inteligencia artificial entrenada para analizar tu presencia local como un experto humano, pero al instante.',
            
            card_1_title: 'Orientado a la Acción',
            card_1_text: 'Te dice exactamente <em>qué hacer</em>, no solo qué está mal.',
            card_2_title: 'Instantáneo',
            card_2_text: 'Un diagnóstico completo mientras tomas un café.',
            card_3_title: 'Imparcial',
            card_3_text: 'Sin discurso de ventas, sin sesgos. Solo datos puros.',

            table_title: '🤖 ¿Por qué elegir a Avi sobre una Agencia?',
            th_feature: 'Característica', th_agency: 'Agencia Tradicional', th_avi: 'Avi (Tu IA Local)',
            td_speed: 'Velocidad', td_agency_1: '📞 Reuniones interminables', td_avi_1: '⚡ Resultado Instantáneo (60s)',
            td_clarity: 'Claridad', td_agency_2: '📄 Informes confusos de 50 págs', td_avi_2: '🎯 Plan Claro y Priorizado',
            td_cost: 'Costo', td_agency_3: '💰 $500 solo por una auditoría', td_avi_3: '🎁 Auditoría Inicial 100% Gratis',
            td_obj: 'Objetividad', td_agency_4: '🤷‍♂️ "Depende..."', td_avi_4: '🔍 Análisis basado en Datos',

            steps_title: '3 Pasos hacia la Claridad',
            step_1_title: 'Ingresa Nombre', step_1_text: 'Escribe el nombre de tu negocio en la barra de búsqueda.',
            step_2_title: 'Escaneo IA', step_2_text: 'Avi escanea tu perfil, reseñas y competidores en tiempo real.',
            step_3_title: 'Plan de Acción', step_3_text: 'Recibe tu Puntuación de Confianza y un plan de acción inmediato.',

            reviews_title: 'Desbloquearon su crecimiento con Avi',
            review_1_text: '"Finalmente entendí por qué no aparecía. La sección \'Palabras clave faltantes\' fue un shock. Apliqué los cambios y vi resultados en 3 semanas."',
            review_1_author: '— Mark D., Osteópata',
            review_2_text: '"Mi agencia me cobraba $500/mes por informes que no entendía. Avi me dio una hoja de ruta clara en 1 minuto."',
            review_2_author: '— Sarah L., Dueña de Restaurante',
            review_3_text: '"No soy nada técnico. La guía paso a paso para los primeros 30 días es exactamente lo que necesitaba."',
            review_3_author: '— James P., Fontanero',

            faq_title: 'Preguntas Frecuentes',
            faq_1_q: '¿Es realmente gratis?', faq_1_a: 'Sí, la auditoría inicial, la Puntuación de Confianza y los consejos "Quick Win" son 100% gratuitos. Puedes optar por desbloquear la hoja de ruta detallada de 90 días si quieres ir más allá, pero sin obligación.',
            faq_2_q: '¿Necesitan mis contraseñas?', faq_2_a: 'No, nunca. Avi solo analiza datos públicos, exactamente lo que ven tus clientes potenciales cuando te buscan.',
            faq_3_q: '¿Funciona para mi profesión?', faq_3_a: 'Avi está optimizado para todos los negocios locales y profesionales de servicios (Dentistas, Abogados, Fontaneros, Restaurantes, Agentes Inmobiliarios, etc.).',

            cta_title: '¿Listo para dominar tu área?',
            cta_sub: 'No dejes que otro cliente se vaya con tu competidor.',
            cta_btn: '⬆️ Iniciar Mi Análisis Gratuito',
            loading: 'Analizando...'
        }
    };

    function setLanguage(lang) {
        currentLanguage = lang;
        const t = translations[lang];

        // Update header flags
        document.querySelectorAll('.av-header-flag').forEach(btn => btn.classList.remove('active'));
        const headerFlag = document.getElementById('header-btn-' + lang);
        if (headerFlag) headerFlag.classList.add('active');

        // Update placeholder
        document.getElementById('businessInput').placeholder = t.placeholder;

        // Update all i18n text
        document.querySelectorAll('[data-i18n]').forEach(el => {
            const key = el.getAttribute('data-i18n');
            if (t[key]) {
                el.innerHTML = t[key];
            }
        });
    }

    function handleAudit(e) {
        e.preventDefault();
        
        const btn = document.getElementById('auditBtn');
        const spinner = document.getElementById('btnSpinner');
        const btnText = document.getElementById('btnText');
        const inputField = document.getElementById('businessInput');
        const inputVal = inputField.value;

        if (!inputVal) {
            inputField.style.border = "2px solid #EF4444";
            inputField.focus();
            setTimeout(() => {
                inputField.style.border = "1px solid #ccc";
            }, 2000);
            return;
        }
        
        btn.disabled = true;
        btn.style.opacity = "0.8";
        btnText.innerText = translations[currentLanguage].loading;
        spinner.style.display = "block";

        setTimeout(() => {
            const safeName = encodeURIComponent(inputVal);
            const finalUrl = `${auditPageUrl}?business_name=${safeName}&lang=${currentLanguage}`;
            window.location.href = finalUrl;
        }, 2000);
    }

    function scrollSlider(direction) {
        const slider = document.getElementById('reviewSlider');
        slider.scrollBy({ left: direction * 400, behavior: 'smooth' });
    }

    // Check URL for language param
    const urlParams = new URLSearchParams(window.location.search);
    const langParam = urlParams.get('lang');
    if (langParam && translations[langParam]) {
        setLanguage(langParam);
    }
</script>
</body>
</html>
