<?php
$h = $homeData ?? site_home_data(itx_homepage_v7_data());
$globalFooter = itx_global_footer_data();
$theme = theme_settings();
$headerPrimary = $theme['primary'] ?? '#711F37';
$headerAccent = $theme['accent'] ?? '#9B3B58';
$headerDark = $theme['dark'] ?? '#111113';
$headerGray = $theme['gray'] ?? '#73737A';
$headerSurface = $theme['surface'] ?? '#F2F2F3';
$headerContainer = $theme['container'] ?? '1180';
$headerMenu = site_menu_items(menu_items('header'));
if (!$headerMenu) {
 $headerMenu = [
 ['label' => site_ui('nav.home'), 'url' => '/'],
 ['label' => site_ui('nav.services'), 'url' => '/services'],
 ['label' => site_ui('nav.about'), 'url' => '/about-us'],
 ['label' => site_ui('nav.blog'), 'url' => '/blog'],
 ['label' => site_ui('nav.contact'), 'url' => '/contact-us'],
 ];
}
$hasBlog = false;
foreach ($headerMenu as $menuItem) {
 if (rtrim((string)($menuItem['url'] ?? ''), '/') === '/blog') { $hasBlog = true; break; }
}
if (!$hasBlog) $headerMenu[] = ['label' => site_ui('nav.blog'), 'url' => '/blog'];
$publicHref = static function (string $href): string { return page_block_href($href); };
$headerLogo = branding_asset('site_logo_header');
$footerLogo = branding_asset('site_logo_footer');
$favicon = branding_asset('site_favicon');
$digitFa = static function(string $v): string { return site_is_en() ? $v : strtr($v, ['0'=>'۰','1'=>'۱','2'=>'۲','3'=>'۳','4'=>'۴','5'=>'۵','6'=>'۶','7'=>'۷','8'=>'۸','9'=>'۹']); };
$languageSwitch = site_language_switch_url(site_is_en() ? 'fa' : 'en');
$tel = static fn(string $v): string => preg_replace('/[^0-9+]/','',$v) ?: $v;
$iconSvg = static function(string $icon): string {
 return match($icon) {
 'chip' => '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor"><path d="M9 3v2m6-2v2M9 19v2m6-2v2M5 9H3m2 6H3m18-6h-2m2 6h-2M7 19h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2Zm2-10h6v6H9V9Z"/></svg>',
 'arrows' => '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor"><path d="M8 7h12m0 0-4-4m4 4-4 4m0 6H4m0 0 4 4m-4-4 4-4"/></svg>',
 'cart' => '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor"><path d="M3 3h2l.4 2M7 13h10l4-8H5.4M7 13 5.4 5M7 13l-2.293 2.293A1 1 0 0 0 5.414 17H17m0 0a2 2 0 1 0 0 4 2 2 0 0 0 0-4Zm-8 2a2 2 0 1 1-4 0 2 2 0 0 1 4 0Z"/></svg>',
 'server' => '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor"><path d="M5 12h14M5 12a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2M5 12a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2m-2-4h.01M17 16h.01"/></svg>',
 'code' => '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor"><path d="m10 20 4-16m4 4 4 4-4 4M6 16l-4-4 4-4"/></svg>',
 'team' => '<svg viewBox="0 0 20 20" fill="currentColor"><path d="M9 6a3 3 0 1 1-6 0 3 3 0 0 1 6 0Zm8 0a3 3 0 1 1-6 0 3 3 0 0 1 6 0Zm-4.07 11c.046-.327.07-.66.07-1a6.97 6.97 0 0 0-1.5-4.33A5 5 0 0 1 19 16v1h-6.07ZM6 11a5 5 0 0 1 5 5v1H1v-1a5 5 0 0 1 5-5Z"/></svg>',
 'bolt' => '<svg viewBox="0 0 20 20" fill="currentColor"><path d="M11.3 1.046A1 1 0 0 1 12 2v5h4a1 1 0 0 1 .82 1.573l-7 10A1 1 0 0 1 8 18v-5H4a1 1 0 0 1-.82-1.573l7-10a1 1 0 0 1 1.12-.38Z"/></svg>',
 'chart' => '<svg viewBox="0 0 20 20" fill="currentColor"><path d="M2 11a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1v-5Zm6-4a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1H9a1 1 0 0 1-1-1V7Zm6-3a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1V4Z"/></svg>',
 default => '<svg viewBox="0 0 20 20" fill="currentColor"><path d="M3.172 5.172a4 4 0 0 1 5.656 0L10 6.343l1.172-1.171a4 4 0 1 1 5.656 5.656L10 17.657l-6.828-6.829a4 4 0 0 1 0-5.656Z"/></svg>',
 };
};
?>
<!doctype html>
<html lang="<?=e(site_lang())?>" dir="<?=e(site_dir())?>">
<head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title><?=e($title ?? (site_is_en() ? 'ITX Trade | Where Technology Meets Trade' : 'دایان تجارت داده گستر | Where Technology Meets Trade'))?></title>
<link rel="alternate" hreflang="fa" href="<?=e(site_language_switch_url('fa'))?>"><link rel="alternate" hreflang="en" href="<?=e(site_language_switch_url('en'))?>">
<?php if(!empty($meta_description)):?><meta name="description" content="<?=e($meta_description)?>"><?php endif;?>
<?php if($favicon!==''):?><link rel="icon" href="<?=e($favicon)?>"><link rel="shortcut icon" href="<?=e($favicon)?>"><?php endif;?>
<link rel="preconnect" href="https://cdn.jsdelivr.net"><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/Vazirmatn-font-face.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css" referrerpolicy="no-referrer">
<link rel="stylesheet" href="<?=url('/assets/css/home-v7.css?v=8.6.0')?>">
<link rel="stylesheet" href="<?=url('/assets/css/shared-public-header.css?v=8.6.0')?>">
<link rel="stylesheet" href="<?=url('/assets/css/shared-public-footer.css?v=8.6.0')?>">
<style>
.site-header{--blue:<?=e($headerPrimary)?>;--blue-2:<?=e($headerAccent)?>;--navy-900:<?=e($headerDark)?>;--navy-800:<?=e($headerDark)?>;--silver-500:<?=e($headerGray)?>;--silver-100:<?=e($headerSurface)?>}
.site-header .container{width:min(calc(100% - 40px),<?=e($headerContainer)?>px)}
@media(max-width:820px){.site-header .container{width:min(calc(100% - 30px),<?=e($headerContainer)?>px)}}
.site-header .brand-logo-image{display:block;width:auto;max-width:190px;height:52px;object-fit:contain}.itx7-footer .brand-logo-image{display:block;width:auto;max-width:190px;height:58px;object-fit:contain}@media(max-width:520px){.site-header .brand-logo-image{max-width:145px;height:44px}}
.language-switch{display:inline-grid;place-items:center;min-width:42px;height:42px;padding:0 10px;border:1px solid rgba(255,255,255,.14);border-radius:12px;font-size:12px;font-weight:900;color:#fff;background:rgba(255,255,255,.05)}
html[dir="ltr"] .itx7-blog-heading .itx7-kicker{text-align:left} html[dir="ltr"] .nav-dropdown-menu{right:auto;left:-28px}
</style>
</head>
<body class="itx7-body">
<header class="site-header" id="top">
 <div class="container header-inner">
 <a href="<?=e(site_public_url('/'))?>" class="brand" aria-label="<?=e(setting('site_name', 'ITX Trade'))?>">
 <?php if($headerLogo!==''):?><img class="brand-logo-image" src="<?=e($headerLogo)?>" alt="<?=e(setting('site_name', 'ITX Trade'))?>"><?php else:?>
 <span class="brand-mark"><span>ITX</span></span>
 <span class="brand-copy"><strong><?=e(setting('site_name', 'ITX Trade'))?></strong><small><?=e(site_company_name())?></small></span>
 <?php endif;?>
 </a>
 <nav class="main-nav" id="mainNav" aria-label="<?=e(site_ui('nav.main_aria'))?>">
 <?php foreach ($headerMenu as $item): ?>
 <?php
 $href = (string)($item['url'] ?? '#');
 $menuPath = rtrim((string)(parse_url($href, PHP_URL_PATH) ?: $href), '/');
 $isServicesMenu = $menuPath === '/services';
 $serviceSectionActive = in_array(rtrim(site_path_without_locale(current_path()), '/'), ['/services', '/it-services', '/trade-services', '/network-infrastructure', '/data-center-cloud', '/international-trade', '/technology-consulting'], true);
 ?>
 <?php if ($isServicesMenu): ?>
 <div class="nav-dropdown <?=$serviceSectionActive ? 'active' : ''?>">
 <div class="nav-dropdown-trigger">
 <a href="<?=e($publicHref($href))?>" class="nav-parent-link <?=$serviceSectionActive ? 'active' : ''?>"><?=e($item['label'] ?? site_ui('nav.services'))?></a>
 <button class="nav-dropdown-toggle" type="button" aria-label="<?=e(site_ui('nav.services_aria'))?>" aria-expanded="false"><i class="fa-solid fa-chevron-down"></i></button>
 </div>
 <div class="nav-dropdown-menu">
 <a href="<?=e(site_public_url('/it-services'))?>" class="<?=menu_link_active('/it-services') ? 'active' : ''?>">
 <span class="nav-dropdown-icon"><i class="fa-solid fa-network-wired"></i></span>
 <span><strong><?=e(site_ui('nav.it'))?></strong><small><?=e(site_ui('nav.it_sub'))?></small></span>
 <i class="fa-solid <?=site_is_en()?'fa-arrow-right':'fa-arrow-left'?> nav-dropdown-arrow"></i>
 </a>
 <a href="<?=e(site_public_url('/trade-services'))?>" class="<?=menu_link_active('/trade-services') ? 'active' : ''?>">
 <span class="nav-dropdown-icon"><i class="fa-solid fa-briefcase"></i></span>
 <span><strong><?=e(site_ui('nav.trade'))?></strong><small><?=e(site_ui('nav.trade_sub'))?></small></span>
 <i class="fa-solid <?=site_is_en()?'fa-arrow-right':'fa-arrow-left'?> nav-dropdown-arrow"></i>
 </a>
 </div>
 </div>
 <?php else: ?>
 <a href="<?=e($publicHref($href))?>" class="<?=menu_link_active($href) ? 'active' : ''?>"><?=e($item['label'] ?? '')?></a>
 <?php endif; ?>
 <?php endforeach; ?>
 </nav>
 <div class="header-actions">
 <a class="language-switch" href="<?=e($languageSwitch)?>" hreflang="<?=site_is_en()?'fa':'en'?>" aria-label="<?=site_is_en()?'View Persian version':'مشاهده نسخه انگلیسی'?>"><?=site_is_en()?'FA':'EN'?></a><a class="header-cta" href="<?=e(site_public_url('/contact-us'))?>"><?=e(site_ui('nav.consult'))?> <i class="fa-solid <?=site_is_en()?'fa-arrow-right':'fa-arrow-left'?>"></i></a>
 <button class="menu-toggle" id="menuToggle" type="button" aria-controls="mainNav" aria-label="<?=e(site_ui('nav.menu_aria'))?>" aria-expanded="false"><i class="fa-solid fa-bars"></i></button>
 </div>
 </div>
</header>

<main>
<section id="home" class="itx7-hero">
 <div class="itx7-orb itx7-orb-a"></div><div class="itx7-orb itx7-orb-b"></div>
 <div class="itx7-container itx7-hero-inner">
 <p class="itx7-kicker"><?=e($h['hero']['company'])?></p>
 <h1><span class="itx7-gradient-text"><?=e($h['hero']['title_top'])?></span><br><span><?=e($h['hero']['title_bottom'])?></span></h1>
 <p class="itx7-hero-copy"><?=e($h['hero']['description'])?></p>
 <div class="itx7-actions"><a href="#contact" class="itx7-btn itx7-btn-maroon"><?=e($h['hero']['primary_label'])?><span><?=site_is_en()?'→':'←'?></span></a><a href="#services" class="itx7-btn itx7-btn-outline"><?=e($h['hero']['secondary_label'])?></a></div>
 <div class="itx7-stats">
 <?php foreach($h['stats'] as $stat):?><div class="itx7-stat"><strong><?=e($stat['value'])?></strong><span><?=e($stat['label'])?></span></div><?php endforeach;?>
 </div>
 </div>
</section>

<section id="services" class="itx7-section itx7-services">
 <div class="itx7-container">
 <div class="itx7-section-head"><p class="itx7-kicker"><?=e($h['services_heading']['kicker'])?></p><h2 class="itx7-gradient-text"><?=e($h['services_heading']['title'])?></h2></div>
 <div class="itx7-service-grid">
 <?php foreach($h['services'] as $service):?>
 <article class="itx7-card itx7-service-card"><div class="itx7-icon-box"><?=$iconSvg($service['icon']??'heart')?></div><h3><?=e($service['title'])?></h3><p><?=e($service['text'])?></p><?php if(!empty($service['extra_value'])):?><div class="itx7-extra"><strong><?=e($service['extra_value'])?></strong><span><?=e($service['extra_label']??'')?></span></div><?php endif;?></article>
 <?php endforeach;?>
 </div>
 </div>
</section>

<section id="vision" class="itx7-section itx7-vision">
 <div class="itx7-orb itx7-orb-c"></div>
 <div class="itx7-container"><div class="itx7-section-head"><p class="itx7-kicker"><?=e($h['vision_heading']['kicker'])?></p><h2 class="itx7-gradient-text"><?=e($h['vision_heading']['title'])?></h2></div>
 <div class="itx7-vision-grid"><?php foreach($h['vision'] as $item):?><article class="itx7-card itx7-vision-card"><div class="itx7-mini-icon"><?=$iconSvg($item['icon']??'heart')?></div><p><?=e($item['text'])?></p></article><?php endforeach;?></div>
 </div>
</section>

<section id="blog" class="itx7-section itx7-blog">
 <div class="itx7-container"><div class="itx7-blog-heading"><div><p class="itx7-kicker"><?=e($h['blog']['kicker'])?></p><h2><?=e($h['blog']['title_prefix'])?> <span class="itx7-gradient-text"><?=e($h['blog']['title_highlight'])?></span></h2></div><a class="itx7-btn itx7-btn-outline" href="<?=e(page_block_href($h['blog']['button_url']))?>"><?=e($h['blog']['button_label'])?></a></div>
 <?php if(empty($recentPosts)):?><div class="itx7-empty"><?=e(site_ui('blog.empty'))?></div><?php else:?><div class="itx7-blog-grid">
 <?php foreach($recentPosts as $post):?><article class="itx7-blog-card">
 <a class="itx7-blog-media" href="<?=e(site_public_url('/blog/'.$post['slug']))?>"><?php if(trim((string)($post['featured_image']??''))!==''):?><img src="<?=e(page_block_href($post['featured_image']))?>" alt="<?=e($post['title'])?>" loading="lazy"><?php else:?><span class="itx7-media-placeholder">ITX</span><?php endif;?></a>
 <div class="itx7-blog-body"><div class="itx7-blog-meta"><span><?=$digitFa(substr((string)$post['created_at'],0,10))?></span><span>•</span><span><?=e($post['category']??site_ui('blog.articles'))?></span></div><h3><a href="<?=e(site_public_url('/blog/'.$post['slug']))?>"><?=e($post['title'])?></a></h3><?php if(!empty($post['excerpt'])):?><p><?=e($post['excerpt'])?></p><?php endif;?><div class="itx7-tags"><span><?=e($post['category']??site_ui('blog.business'))?></span></div></div>
 </article><?php endforeach;?>
 </div><?php endif;?>
 </div>
</section>

<section id="contact" class="itx7-section itx7-contact">
 <div class="itx7-container itx7-contact-inner"><h2><?=e($h['contact']['title_prefix'])?> <span class="itx7-gradient-text"><?=e($h['contact']['title_highlight'])?></span> <?=e($h['contact']['title_suffix'])?></h2><p><?=e($h['contact']['text'])?></p>
 <div class="itx7-contact-grid"><a href="tel:<?=e($tel($h['contact']['mobile1']))?>"><span>📱</span><strong><?=$digitFa($h['contact']['mobile1'])?></strong></a><a href="tel:<?=e($tel($h['contact']['mobile2']))?>"><span>📱</span><strong><?=$digitFa($h['contact']['mobile2'])?></strong></a><a href="tel:<?=e($tel($h['contact']['phone']))?>"><span>☎️</span><strong><?=$digitFa($h['contact']['phone'])?></strong></a></div>
 <a href="mailto:<?=e($h['contact']['email'])?>" class="itx7-btn itx7-btn-maroon itx7-email-btn"><?=e($h['contact']['email'])?></a>
 </div>
</section>
</main>

<footer class="itx7-footer"><div class="itx7-container"><div class="itx7-footer-grid">
 <div><div class="itx7-brand"><?php if($footerLogo!==''):?><img class="brand-logo-image" src="<?=e($footerLogo)?>" alt="<?=e(setting('site_name', 'ITX Trade'))?>"><?php elseif($headerLogo!==''):?><img class="brand-logo-image" src="<?=e($headerLogo)?>" alt="<?=e(setting('site_name', 'ITX Trade'))?>"><?php else:?><span class="itx7-brand-mark small">ITX</span><span class="itx7-brand-name"><?=e(site_company_name())?></span><?php endif;?></div><p><?=e($globalFooter['about'])?></p></div>
 <div><h4><?=e(site_ui('footer.contact'))?></h4><ul><li><?=$digitFa($globalFooter['mobile1'])?></li><li><?=$digitFa($globalFooter['mobile2'])?></li><li><?=$digitFa($globalFooter['phone'])?></li><li><a href="mailto:<?=e($globalFooter['email'])?>"><?=e($globalFooter['email'])?></a></li></ul></div>
 <div><h4><?=e(site_ui('footer.address'))?></h4><ul><li><?=e($globalFooter['address1'])?></li><li><?=e($globalFooter['address2'])?></li></ul></div>
 <div><h4><?=e(site_ui('footer.quick'))?></h4><ul><li><a href="<?=e(site_public_url('/about-us'))?>"><?=e(site_ui('nav.about'))?></a></li><li><a href="#services"><?=e(site_ui('nav.services'))?></a></li><li><a href="#blog"><?=e(site_ui('footer.news'))?></a></li><li><a href="#contact"><?=e(site_ui('footer.consult'))?></a></li></ul></div>
 </div>
 <div class="itx7-footer-bottom"><p>itxtrade © <?=e($globalFooter['copyright_year'])?>. <?=e($globalFooter['copyright'])?></p><div class="itx7-social"><a href="<?=e($globalFooter['twitter'])?>" aria-label="X">X</a><a href="<?=e($globalFooter['linkedin'])?>" aria-label="LinkedIn">in</a><a href="<?=e($globalFooter['instagram'])?>" aria-label="Instagram">◎</a></div></div>
</div></footer>
<button id="itx7BackToTop" class="itx7-back" type="button" aria-label="<?=e(site_ui('common.back_top'))?>">↑</button>
<script src="<?=url('/assets/js/itx-trade.js?v=8.1.0')?>"></script>
<script src="<?=url('/assets/js/home-v7.js?v=7.0.0')?>"></script>
</body></html>
