<?php
require_once __DIR__ . '/includes/functions.php';
$settings = getSettings();
$sectors = getData('sectors');
$exhibitors = getData('exhibitors');
$testimonials = getData('testimonials');
$gallery = getData('gallery');

$pageTitle = $settings['seo_home_title'];
$pageDesc = $settings['seo_home_desc'];

$activities = [
    ['icon' => '💬', 'title' => 'Industry Round-table'],
    ['icon' => '🤝', 'title' => 'Hosted Buyer Programme'],
    ['icon' => '☪️', 'title' => 'Halal Forum'],
    ['icon' => '🌍', 'title' => 'Trade Delegation Visits'],
    ['icon' => '🔗', 'title' => 'Business Matching'],
];

$whyItems = [
    ['icon' => 'trending-up', 'title' => 'Growing Market', 'desc' => 'Ethiopia is one of Africa\'s fastest-growing economies with rising demand for imported food and beverage products.'],
    ['icon' => 'users', 'title' => '135M+ Consumers', 'desc' => 'Access a massive and expanding consumer base across Ethiopia and the broader East African region.'],
    ['icon' => 'globe', 'title' => 'Regional Hub', 'desc' => 'Addis Ababa is the diplomatic capital of Africa, offering connections to the entire continent.'],
    ['icon' => 'briefcase', 'title' => 'Trade-Only Event', 'desc' => 'Meet qualified buyers, distributors, and decision-makers — no general public access.'],
    ['icon' => 'award', 'title' => '16th Edition', 'desc' => 'Benefit from 15 years of established reputation and a loyal visitor base.'],
    ['icon' => 'truck', 'title' => 'Gateway to East Africa', 'desc' => 'Use Ethiopia as your launchpad into Kenya, Somalia, Djibouti, Sudan, and South Sudan.'],
];

$marketStats = [
    ['value' => '135.9M', 'label' => 'Population'],
    ['value' => '8.1%', 'label' => 'GDP Growth'],
    ['value' => '$36B', 'label' => 'Agro-Food Sector'],
    ['value' => '$3.6B', 'label' => 'Annual Food Imports'],
];

// Get all images flat for gallery preview
$allGalleryImages = [];
foreach ($gallery as $year => $imgs) {
    foreach ($imgs as $img) {
        $allGalleryImages[] = ['year' => $year, 'img' => $img];
    }
}
$galleryPreview = array_slice($allGalleryImages, 0, 6);

$allPackagesInclude = $settings['all_packages_include'] ?? [];
$packageShellFeatures = $settings['package_shell_features'] ?? [];
$packageSpaceFeatures = $settings['package_space_features'] ?? [];
$packagePavilionFeatures = $settings['package_pavilion_features'] ?? [];

$heroHeadline = !empty($settings['hero_headline']) ? $settings['hero_headline'] : "East Africa's Premier Food & Beverage Trade Exhibition";
$heroSubtext = !empty($settings['hero_subtext']) ? $settings['hero_subtext'] : "Connect with 15,000+ trade buyers, distributors, and decision-makers from across Ethiopia and East Africa.";

include __DIR__ . '/includes/header.php';
?>

<!-- ==================== HERO ==================== -->
<section class="hero-section">
    <div class="container">
        <div class="row g-4 align-items-center">
            <!-- Left Column -->
            <div class="col-lg-7 reveal">
                <div class="date-badge">16–18 November 2026 · Addis Ababa, Ethiopia</div>
                <h1><?php echo e($heroHeadline); ?></h1>
                <p class="hero-sub"><?php echo e($heroSubtext); ?></p>

                <!-- Countdown -->
                <div class="countdown-wrap" data-countdown="2026-11-16">
                    <div class="countdown-box"><span class="countdown-number">00</span><span class="countdown-label">Days</span></div>
                    <span class="countdown-sep">:</span>
                    <div class="countdown-box"><span class="countdown-number">00</span><span class="countdown-label">Hours</span></div>
                    <span class="countdown-sep">:</span>
                    <div class="countdown-box"><span class="countdown-number">00</span><span class="countdown-label">Mins</span></div>
                    <span class="countdown-sep">:</span>
                    <div class="countdown-box"><span class="countdown-number">00</span><span class="countdown-label">Secs</span></div>
                    <div class="countdown-expired" style="display:none;">Expo Has Started!</div>
                </div>

                <!-- CTA Buttons -->
                <div class="mt-4">
                    <a href="<?php echo BASE_URL; ?>/register.php" class="btn-green me-2 mb-2">Book a Stand</a>
                    <a href="<?php echo BASE_URL; ?>/contact.php" class="btn-red mb-2">Register to Visit</a>
                </div>

                <!-- Trust Strip -->
                <div class="trust-strip">
                    <span>16th Edition</span>
                    <span>500+ Exhibitors</span>
                    <span>40+ Countries</span>
                    <span>15,000+ Visitors</span>
                    <span>135M+ Consumers</span>
                </div>
            </div>

            <!-- Right Column — Event Overview Card -->
            <div class="col-lg-5 reveal">
                <div class="section-card" style="border:none;">
                    <h3 style="font-family:var(--font-heading);font-size:1.1rem;text-transform:uppercase;color:var(--text-dark);margin-bottom:1.5rem;">Event Overview</h3>
                    <div class="row g-3 mb-3">
                        <div class="col-6">
                            <div class="stat-number" data-count-up="16">0</div>
                            <div class="stat-label">Editions</div>
                        </div>
                        <div class="col-6">
                            <div class="stat-number" data-count-up="10000" data-suffix="+">0</div>
                            <div class="stat-label">Sqm Exhibition</div>
                        </div>
                        <div class="col-6">
                            <div class="stat-number" data-count-up="40" data-suffix="+">0</div>
                            <div class="stat-label">Countries</div>
                        </div>
                        <div class="col-6">
                            <div class="stat-number" data-count-up="15000" data-suffix="+">0</div>
                            <div class="stat-label">Visitors</div>
                        </div>
                    </div>
                    <hr style="border-color:var(--border-light);margin:1rem 0;">
                    <p style="font-size:0.88rem;color:var(--text-secondary);margin:0;">
                        <strong style="color:var(--text-dark);">Date:</strong> 16–18 November 2026<br>
                        <strong style="color:var(--text-dark);">Venue:</strong> Millennium Hall, Addis Ababa<br>
                        <strong style="color:var(--text-dark);">Organiser:</strong> Prime Expo FZE / INEXPO GROUP
                    </p>
                </div>
            </div>
        </div>
    </div>
</section>

<!-- ==================== STATS STRIP ==================== -->
<section class="section-alt">
    <div class="container">
        <div class="row g-4 reveal">
            <div class="col-md-3 col-6">
                <div class="stat-card">
                    <div class="stat-number" data-count-up="500" data-suffix="+">0</div>
                    <div class="stat-label">Exhibitors</div>
                </div>
            </div>
            <div class="col-md-3 col-6">
                <div class="stat-card">
                    <div class="stat-number" data-count-up="15000" data-suffix="+">0</div>
                    <div class="stat-label">Visitors</div>
                </div>
            </div>
            <div class="col-md-3 col-6">
                <div class="stat-card">
                    <div class="stat-number" data-count-up="40" data-suffix="+">0</div>
                    <div class="stat-label">Countries</div>
                </div>
            </div>
            <div class="col-md-3 col-6">
                <div class="stat-card">
                    <div class="stat-number" data-count-up="16">0</div>
                    <div class="stat-label">Editions</div>
                </div>
            </div>
        </div>
    </div>
</section>

<!-- ==================== ABOUT THE EXPO ==================== -->
<section class="section">
    <div class="container">
        <div class="row g-4 align-items-center">
            <div class="col-lg-7 reveal">
                <span class="section-label">About The Expo</span>
                <h2 class="section-title">Ethiopia's Premier Food &amp; Beverage Trade Show</h2>
                <p class="section-subtitle mt-2"><?php echo nl2br(e(substr($settings['about_text'], 0, 300))); ?>...</p>
                <a href="<?php echo BASE_URL; ?>/about.php" class="btn-outline-green mt-3">Learn More</a>
            </div>
            <div class="col-lg-5 reveal">
                <div class="section-card">
                    <h3 style="font-family:var(--font-heading);font-size:1rem;text-transform:uppercase;color:var(--text-dark);margin-bottom:1.25rem;">Quick Facts</h3>
                    <div class="row g-3">
                        <div class="col-6">
                            <div class="stat-number" data-count-up="16">0</div>
                            <div class="stat-label">Editions Held</div>
                        </div>
                        <div class="col-6">
                            <div class="stat-number" data-count-up="500" data-suffix="+">0</div>
                            <div class="stat-label">Exhibitors</div>
                        </div>
                        <div class="col-6">
                            <div class="stat-number" data-count-up="40" data-suffix="+">0</div>
                            <div class="stat-label">Participating Countries</div>
                        </div>
                        <div class="col-6">
                            <div class="stat-number" data-count-up="15000" data-suffix="+">0</div>
                            <div class="stat-label">Trade Visitors</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>

<!-- ==================== ASSOCIATED ACTIVITIES ==================== -->
<section class="section-alt">
    <div class="container">
        <div class="text-center mb-4 reveal">
            <span class="section-label">Programme</span>
            <h2 class="section-title">Associated Activities</h2>
        </div>
        <div class="row g-3 reveal">
            <?php foreach ($activities as $act): ?>
            <div class="col-lg-2 col-md-4 col-6">
                <div class="activity-card">
                    <span class="icon"><?php echo $act['icon']; ?></span>
                    <span class="title"><?php echo e($act['title']); ?></span>
                </div>
            </div>
            <?php endforeach; ?>
        </div>
    </div>
</section>

<!-- ==================== WHY EXHIBIT ==================== -->
<section class="section">
    <div class="container">
        <div class="text-center mb-4 reveal">
            <span class="section-label">For Exhibitors</span>
            <h2 class="section-title">Why Exhibit?</h2>
        </div>
        <div class="row g-4">
            <div class="col-lg-7 reveal">
                <?php foreach ($whyItems as $item): ?>
                <div class="why-item">
                    <div class="why-icon">
                        <svg viewBox="0 0 24 24"><use href="#icon-<?php echo $item['icon']; ?>"/></svg>
                        <svg width="0" height="0" style="position:absolute;">
                            <?php
                            $iconPaths = [
                                'trending-up' => '<polyline points="23 6 13.5 15.5 8.5 10.5 1 18"/><polyline points="17 6 23 6 23 12"/>',
                                'users' => '<path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M23 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/>',
                                'globe' => '<circle cx="12" cy="12" r="10"/><line x1="2" y1="12" x2="22" y2="12"/><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"/>',
                                'briefcase' => '<rect x="2" y="7" width="20" height="14" rx="2" ry="2"/><path d="M16 21V5a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16"/>',
                                'award' => '<circle cx="12" cy="8" r="7"/><polyline points="8.21 13.89 7 23 12 20 17 23 15.79 13.88"/>',
                                'truck' => '<rect x="1" y="3" width="15" height="13"/><polygon points="16 8 20 8 23 11 23 16 16 16 16 8"/><circle cx="5.5" cy="18.5" r="2.5"/><circle cx="18.5" cy="18.5" r="2.5"/>',
                            ];
                            ?>
                        </svg>
                        <svg viewBox="0 0 24 24"><?php echo $iconPaths[$item['icon']] ?? ''; ?></svg>
                    </div>
                    <div>
                        <div class="why-title"><?php echo e($item['title']); ?></div>
                        <div class="why-desc"><?php echo e($item['desc']); ?></div>
                    </div>
                </div>
                <?php endforeach; ?>
            </div>
            <div class="col-lg-5 reveal">
                <div class="market-card">
                    <h3 style="font-family:var(--font-heading);font-size:1.1rem;text-transform:uppercase;margin-bottom:1.5rem;">Ethiopia Market Highlights</h3>
                    <div class="row g-3">
                        <?php foreach ($marketStats as $ms): ?>
                        <div class="col-6">
                            <div class="venue-stat" style="padding:1rem;">
                                <div class="stat-number"><?php echo e($ms['value']); ?></div>
                                <div class="stat-label"><?php echo e($ms['label']); ?></div>
                            </div>
                        </div>
                        <?php endforeach; ?>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>

<!-- ==================== PRODUCT SECTORS ==================== -->
<section class="section-alt">
    <div class="container">
        <div class="text-center mb-4 reveal">
            <span class="section-label">Exhibit Profile</span>
            <h2 class="section-title">Product Sectors</h2>
            <p class="section-subtitle mx-auto">12 sectors covering the entire food &amp; beverage value chain</p>
        </div>
        <?php if (!empty($sectors)): ?>
        <div class="row g-4 reveal">
            <?php foreach (array_slice($sectors, 0, 8) as $sector): ?>
            <div class="col-lg-3 col-md-4 col-sm-6">
                <div class="sector-card">
                    <div class="sector-icon"><?php echo $sector['icon']; ?></div>
                    <div class="sector-name"><?php echo e($sector['name']); ?></div>
                    <div class="sector-desc"><?php echo e(truncateText($sector['description'], 90)); ?></div>
                </div>
            </div>
            <?php endforeach; ?>
        </div>
        <div class="text-center mt-4 reveal">
            <a href="<?php echo BASE_URL; ?>/sectors.php" class="btn-outline-green">View All Sectors</a>
        </div>
        <?php else: ?>
        <div class="empty-state">
            <span class="empty-state-icon">🏭</span>
            <p>Sector information will be updated soon.</p>
        </div>
        <?php endif; ?>
    </div>
</section>

<!-- ==================== STAND PACKAGES ==================== -->
<section class="section">
    <div class="container">
        <div class="text-center mb-4 reveal">
            <span class="section-label">Packages</span>
            <h2 class="section-title">Stand Options</h2>
            <p class="section-subtitle mx-auto">Choose the package that fits your exhibition needs</p>
        </div>
        <div class="row g-4 reveal">
            <!-- Shell Scheme -->
            <div class="col-lg-4">
                <div class="package-card">
                    <div class="pkg-title"><?php echo e($settings['package_shell_title']); ?></div>
                    <ul class="pkg-features">
                        <?php foreach ($packageShellFeatures as $f): ?><li><?php echo e($f); ?></li><?php endforeach; ?>
                    </ul>
                    <a href="<?php echo BASE_URL; ?>/register.php" class="btn-green w-100 text-center">Enquire Now</a>
                </div>
            </div>
            <!-- Space Only -->
            <div class="col-lg-4">
                <div class="package-card featured">
                    <div class="pkg-title"><?php echo e($settings['package_space_title']); ?></div>
                    <ul class="pkg-features">
                        <?php foreach ($packageSpaceFeatures as $f): ?><li><?php echo e($f); ?></li><?php endforeach; ?>
                    </ul>
                    <a href="<?php echo BASE_URL; ?>/register.php" class="btn-white w-100 text-center">Enquire Now</a>
                </div>
            </div>
            <!-- Country Pavilion -->
            <div class="col-lg-4">
                <div class="package-card">
                    <div class="pkg-title"><?php echo e($settings['package_pavilion_title']); ?></div>
                    <ul class="pkg-features">
                        <?php foreach ($packagePavilionFeatures as $f): ?><li><?php echo e($f); ?></li><?php endforeach; ?>
                    </ul>
                    <a href="<?php echo BASE_URL; ?>/register.php" class="btn-green w-100 text-center">Enquire Now</a>
                </div>
            </div>
        </div>

        <!-- All Packages Include -->
        <?php if (!empty($allPackagesInclude)): ?>
        <div class="mt-5 reveal">
            <h4 style="font-family:var(--font-heading);font-size:0.9rem;text-transform:uppercase;text-align:center;margin-bottom:1.5rem;color:var(--text-secondary);">All Packages Include</h4>
            <div class="row g-2 justify-content-center">
                <?php foreach ($allPackagesInclude as $inc): ?>
                <div class="col-md-4 col-sm-6">
                    <div style="display:flex;align-items:center;gap:0.5rem;font-size:0.85rem;color:var(--text-body);">
                        <span style="color:var(--green);font-weight:700;">✓</span> <?php echo e($inc); ?>
                    </div>
                </div>
                <?php endforeach; ?>
            </div>
        </div>
        <?php endif; ?>
    </div>
</section>

<!-- ==================== PAST EXHIBITORS MARQUEE ==================== -->
<section class="section-alt">
    <div class="container">
        <div class="text-center mb-4 reveal">
            <span class="section-label">Our Exhibitors</span>
            <h2 class="section-title">Past Exhibitors</h2>
        </div>
        <?php if (!empty($exhibitors)): ?>
        <div class="marquee-wrap reveal">
            <div class="marquee-track">
                <?php
                $marqueeItems = array_merge($exhibitors, $exhibitors);
                foreach ($marqueeItems as $ex):
                ?>
                <div class="exhibitor-chip"><?php echo e($ex['company_name'] ?? $ex['name'] ?? 'Exhibitor'); ?></div>
                <?php endforeach; ?>
            </div>
        </div>
        <?php else: ?>
        <div class="empty-state reveal">
            <span class="empty-state-icon">🏢</span>
            <p>Exhibitor list coming soon. <a href="<?php echo BASE_URL; ?>/register.php" style="color:var(--green);font-weight:600;">Be the first to register →</a></p>
        </div>
        <?php endif; ?>
    </div>
</section>

<!-- ==================== GALLERY PREVIEW ==================== -->
<section class="section">
    <div class="container">
        <div class="text-center mb-4 reveal">
            <span class="section-label">Memories</span>
            <h2 class="section-title">Photo Gallery</h2>
        </div>
        <?php if (!empty($galleryPreview)): ?>
        <div class="row g-3 reveal">
            <?php foreach ($galleryPreview as $gi): ?>
            <div class="col-lg-4 col-md-6">
                <div class="gallery-item" data-lightbox>
                    <img src="<?php echo UPLOADS_URL; ?>/gallery/<?php echo e($gi['year']); ?>/<?php echo e($gi['img']); ?>" alt="Ethiopia Food Expo <?php echo e($gi['year']); ?>">
                    <div class="overlay">🔍</div>
                    <div class="year-label"><?php echo e($gi['year']); ?></div>
                </div>
            </div>
            <?php endforeach; ?>
        </div>
        <div class="text-center mt-4 reveal">
            <a href="<?php echo BASE_URL; ?>/gallery.php" class="btn-outline-green">View Full Gallery</a>
        </div>
        <?php else: ?>
        <div class="empty-state reveal">
            <span class="empty-state-icon">📸</span>
            <p>Gallery photos will be added soon. Check back after the event!</p>
        </div>
        <?php endif; ?>
    </div>
</section>

<!-- ==================== TESTIMONIALS ==================== -->
<?php if (!empty($testimonials)): ?>
<section class="section-alt">
    <div class="container">
        <div class="text-center mb-4 reveal">
            <span class="section-label">Testimonials</span>
            <h2 class="section-title">What Exhibitors Say</h2>
        </div>
        <div class="row g-4 reveal">
            <?php foreach (array_slice($testimonials, 0, 3) as $t): ?>
            <div class="col-lg-4 col-md-6">
                <div class="testimonial-card">
                    <div class="star-rating"><?php echo str_repeat('★', (int)($t['rating'] ?? 5)); ?></div>
                    <div class="quote-mark">"</div>
                    <p class="quote-text"><?php echo e($t['quote']); ?></p>
                    <div class="quote-source"><?php echo e($t['company']); ?></div>
                    <div class="quote-country"><?php echo e($t['country']); ?></div>
                </div>
            </div>
            <?php endforeach; ?>
        </div>
    </div>
</section>
<?php endif; ?>

<!-- ==================== CTA BANNER ==================== -->
<section class="cta-banner">
    <div class="container reveal">
        <span class="section-label" style="color:rgba(255,255,255,0.7);border-left-color:rgba(255,255,255,0.4);">Don't Miss Out</span>
        <h2 class="cta-title">Be Part of Ethiopia Food Expo 2026</h2>
        <p class="cta-sub">Secure your stand today and connect with thousands of trade buyers from across East Africa. Limited spaces available.</p>
        <div>
            <a href="<?php echo BASE_URL; ?>/register.php" class="btn-white me-2 mb-2">Book a Stand Now</a>
            <a href="<?php echo BASE_URL; ?>/contact.php" class="btn-red-outline mb-2">Contact Us</a>
        </div>
        <div class="trust-strip justify-content-center">
            <span>16th Edition</span>
            <span>500+ Exhibitors</span>
            <span>40+ Countries</span>
            <span>15,000+ Visitors</span>
        </div>
    </div>
</section>

<?php include __DIR__ . '/includes/footer.php'; ?>
