<?php
$content_file = __DIR__ . '/content.json';
$c = file_exists($content_file) ? json_decode(file_get_contents($content_file), true) : [];

function t($key, $default = '') {
    global $c;
    return !empty($c[$key]) ? htmlspecialchars($c[$key]) : htmlspecialchars($default);
}

// Gestion des chemins d'images (Soit l'image choisie dans /uploads/, soit une image par défaut)
$hero_bg = !empty($c['img_hero']) ? 'uploads/' . htmlspecialchars($c['img_hero']) : 'https://images.unsplash.com/photo-1598902108854-10e335adac99?auto=format&fit=crop&w=2000&q=80';
$temoin_bg = !empty($c['img_temoin']) ? 'uploads/' . htmlspecialchars($c['img_temoin']) : 'https://images.unsplash.com/photo-1558904541-efa843a96f01?auto=format&fit=crop&w=1000&q=80';
?>
<!DOCTYPE html>
<html lang="fr" class="scroll-smooth">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Tétrasol / Kalozia Gardens — Paysagiste Rueil-Malmaison</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@400;600;700&family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap" rel="stylesheet">
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: { primary: '#1E3626', bgBase: '#F7F5F0', textDark: '#25282A', accent: '#B88E4C', accentHover: '#9A7337' },
                    fontFamily: { serif: ['"Cormorant Garamond"', 'serif'], sans: ['"Plus Jakarta Sans"', 'sans-serif'] }
                }
            }
        }
    </script>
</head>
<body class="bg-bgBase text-textDark font-sans antialiased">

    <!-- HEADER -->
    <header class="fixed top-0 left-0 right-0 z-50 bg-bgBase/95 backdrop-blur-md border-b border-primary/10">
        <div class="max-w-7xl mx-auto px-6 py-4 flex items-center justify-between">
            <a href="#" class="flex flex-col">
                <span class="font-serif text-2xl font-bold tracking-tight text-primary leading-none">TÉTRASOL <span class="italic font-normal text-accent">PAYSAGE</span></span>
                <span class="text-[10px] uppercase tracking-widest text-gray-500 font-semibold mt-1">Kalozia Gardens • Rueil-Malmaison</span>
            </a>
            <div class="hidden md:flex items-center space-x-6 text-sm">
                <!-- BADGE REASSURANCE GOOGLE HEADER -->
                <div class="flex items-center space-x-2 bg-white px-3 py-1.5 rounded-full border border-gray-200 shadow-sm text-xs">
                    <svg class="w-4 h-4 text-yellow-500 fill-current" viewBox="0 0 24 24"><path d="M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z"/></svg>
                    <span class="font-bold text-gray-800"><?= t('google_rating', '4.9') ?>/5</span>
                    <span class="text-gray-400">|</span>
                    <span class="text-gray-600 font-medium"><?= t('google_review_count', '48') ?> avis Google</span>
                </div>
                <a href="#contact" class="px-5 py-2.5 text-xs font-semibold uppercase bg-accent text-white rounded hover:bg-accentHover transition-all"><?= t('telephone', '01 47 51 00 00') ?></a>
            </div>
        </div>
    </header>

    <!-- HERO SECTION AVEC IMAGE SELECTIONNEE PAR ADMIN -->
    <section class="relative min-h-screen flex items-center pt-28 pb-16 overflow-hidden">
        <div class="absolute inset-0 z-0">
            <img src="<?= $hero_bg ?>" alt="Terrasse bois Rueil-Malmaison" class="w-full h-full object-cover filter brightness-[0.40]">
        </div>
        <div class="relative z-10 max-w-7xl mx-auto px-6 text-white pt-12">
            <span class="inline-block text-accent uppercase tracking-widest text-xs font-semibold mb-4 bg-primary/60 backdrop-blur-md px-4 py-1.5 rounded-full border border-accent/30">
                Paysagiste Concepteur • Rueil-Malmaison & Ouest Parisien
            </span>
            <h1 class="font-serif text-4xl md:text-6xl font-normal leading-tight max-w-4xl mb-6"><?= t('hero_titre') ?></h1>
            <p class="text-lg text-gray-200 font-light max-w-2xl mb-10 leading-relaxed"><?= t('hero_sous_titre') ?></p>
            <div class="flex flex-col sm:flex-row gap-4">
                <a href="#temoin" class="px-8 py-4 text-xs font-semibold uppercase bg-accent text-white rounded shadow-lg text-center">Découvrir le Jardin Témoin</a>
                <a href="#contact" class="px-8 py-4 text-xs font-semibold uppercase bg-white/10 backdrop-blur-md text-white border border-white/30 rounded text-center">Demander une étude</a>
            </div>
        </div>
    </section>

    <!-- SECTION MODULE AVIS GOOGLE CLENTS -->
    <section class="py-24 max-w-7xl mx-auto px-6">
        <div class="text-center max-w-3xl mx-auto mb-16">
            <div class="inline-flex items-center space-x-2 bg-white px-4 py-2 rounded-full border border-gray-200 shadow-sm mb-4">
                <!-- SVG GOOGLE -->
                <svg class="w-5 h-5" viewBox="0 0 24 24"><path fill="#4285F4" d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"/><path fill="#34A853" d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"/><path fill="#FBBC05" d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.06H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.94l2.85-2.22.81-.63z"/><path fill="#EA4335" d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.06l3.66 2.84c.87-2.6 3.3-4.52 6.16-4.52z"/></svg>
                <span class="font-bold text-sm text-gray-800">Évalué <?= t('google_rating') ?>/5 par nos clients sur Google</span>
            </div>
            <h2 class="font-serif text-3xl md:text-5xl font-normal text-primary">Ce que nos clients disent de nous</h2>
        </div>

        <div class="grid grid-cols-1 md:grid-cols-3 gap-8">
            <?php 
            $reviews = $c['reviews'] ?? [];
            foreach ($reviews as $rev): 
            ?>
                <div class="bg-white p-8 rounded-xl shadow-sm border border-primary/10 flex flex-col justify-between">
                    <div>
                        <!-- ETOILES -->
                        <div class="flex text-yellow-500 mb-4">
                            <?php for($i=0; $i<$rev['note']; $i++): ?>
                                <svg class="w-5 h-5 fill-current" viewBox="0 0 24 24"><path d="M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z"/></svg>
                            <?php endfor; ?>
                        </div>
                        <p class="text-gray-700 text-sm leading-relaxed italic mb-6">« <?= htmlspecialchars($rev['texte']) ?> »</p>
                    </div>
                    <div class="border-t border-gray-100 pt-4 flex justify-between items-center">
                        <div>
                            <p class="font-bold text-sm text-primary"><?= htmlspecialchars($rev['nom']) ?></p>
                            <p class="text-xs text-gray-500"><?= htmlspecialchars($rev['ville']) ?></p>
                        </div>
                        <span class="text-[10px] uppercase font-semibold text-emerald-800 bg-emerald-50 px-2 py-1 rounded">Avis Google Vérifié</span>
                    </div>
                </div>
            <?php endforeach; ?>
        </div>
    </section>

    <!-- FOOTER -->
    <footer class="bg-primary text-gray-400 py-12 text-center text-xs">
        <p class="text-white font-serif text-xl mb-2">TÉTRASOL PAYSAGE</p>
        <p><?= t('adresse') ?> — Tél : <?= t('telephone') ?></p>
        <p class="mt-4 text-gray-500">&copy; 2026 Tétrasol / Kalozia. Tous droits réservés.</p>
    </footer>

</body>
</html>