<?php
/*
Template Name: Inner Page
*/
get_header();

// Map post slugs (with hyphens converted from WP) to template files
$post_slug = get_post_field('post_name', get_the_ID());

// Handle sub-slugs like 'pamm-investors' → template 'pamm/investors'
$slug_map = [
    'trading-accounts' => 'trading-accounts',
    'platforms'        => 'platforms',
    'markets'          => 'markets',
    'pamm'             => 'pamm',
    'pamm-investors'   => 'pamm-investors',
    'pamm-managers'    => 'pamm-managers',
    'venture'          => 'venture',
    'venture-2-step'   => 'venture-2-step',
    'venture-1-step'   => 'venture-1-step',
    'venture-instant'  => 'venture-instant',
    'venture-rules'    => 'venture-rules',
    'deposit'          => 'deposit',
    'how-to-deposit'   => 'how-to-deposit',
    'execution'        => 'execution',
    'company'          => 'company',
    'legal'            => 'legal',
    'contact'          => 'contact',
    'ib'               => 'ib',
    'affiliate'        => 'affiliate',
    'ambassador'       => 'ambassador',
    'academy'          => 'academy',
    'webinar'          => 'webinar',
    'encyclopedia'     => 'encyclopedia',
    'blog'             => 'blog',
    'faq'              => 'faq',
    'tools'            => 'tools',
    'copy-trading'     => 'copy-trading',
];

$template_slug = $slug_map[$post_slug] ?? $post_slug;
$template_file = get_template_directory() . '/template-parts/pages/' . $template_slug . '.php';

if (file_exists($template_file)) {
    include $template_file;
} else {
    echo '<section style="padding:160px 40px;text-align:center;background:#04060a">';
    echo '<div style="font-size:11px;font-weight:700;letter-spacing:.18em;text-transform:uppercase;color:rgba(200,16,46,.8);margin-bottom:16px">COMING SOON</div>';
    echo '<h1 style="font-size:48px;font-weight:700;color:#fff;margin-bottom:16px">' . get_the_title() . '</h1>';
    echo '<p style="font-size:16px;color:rgba(255,255,255,.4);">This page is under construction. Check back soon.</p>';
    echo '<a href="' . home_url('/') . '" style="display:inline-flex;align-items:center;gap:8px;margin-top:32px;padding:12px 28px;background:#C8102E;color:#fff;border-radius:10px;text-decoration:none;font-weight:600">← Back to Home</a>';
    echo '</section>';
}

get_footer();
?>