<?php
declare(strict_types=1);
require __DIR__.'/../app/bootstrap.php';
if (in_array(parse_url($_SERVER['REQUEST_URI']??'/',PHP_URL_PATH),['/','/index.php'],true) && !isset($_GET['page'])) { header('Location: /en/',true,301);exit; }
$page=(string)($_GET['page']??'home');
$allowed=['home','products','product','about','gallery','news','article','contact','privacy','page'];
if (!in_array($page,$allowed,true)) { $page='404';http_response_code(404); }
$categories=rows("SELECT * FROM categories WHERE status='published' ORDER BY sort_order,id");
$brand=setting('brand','EYY');
$record=null;$content=null;$cat=null;$filter=[];$pageNumber=max(1,(int)($_GET['p']??1));
if ($page==='product') {
    $record=one("SELECT p.*,c.name_en AS category_en,c.name_ru AS category_ru,c.name_zh AS category_zh,c.slug AS category_slug FROM products p LEFT JOIN categories c ON c.id=p.category_id WHERE p.slug=? AND p.status='published' AND p.deleted_at IS NULL AND (c.status='published' OR c.id IS NULL)",[(string)($_GET['slug']??'')]);
    if (!$record) { $page='404';http_response_code(404); }
}
if ($page==='article') {
    $record=one("SELECT * FROM articles WHERE slug=? AND status='published' AND deleted_at IS NULL",[(string)($_GET['slug']??'')]);
    if (!$record) { $page='404';http_response_code(404); }
}
if (in_array($page,['about','gallery','privacy','page'],true)) {
    $content=one("SELECT * FROM pages WHERE slug=? AND status='published'",[$page==='page'?(string)($_GET['slug']??''):$page]);
    if (!$content) { $page='404';http_response_code(404); }
}
if ($page==='products') {
    $where="p.status='published' AND p.deleted_at IS NULL AND c.status='published'";$args=[];
    if (!empty($_GET['category'])) {
        $filter['category']=(string)$_GET['category'];
        $cat=one("SELECT * FROM categories WHERE slug=? AND status='published'",[$filter['category']]);
        if (!$cat) { $page='404';http_response_code(404); }
        else { $where.=' AND p.category_id=?';$args[]=$cat['id']; }
    }
    if (!empty($_GET['q'])) {
        $filter['q']=substr((string)$_GET['q'],0,160);
        $where.=" AND (p.name_en LIKE ? ESCAPE '!' OR p.name_ru LIKE ? ESCAPE '!' OR p.name_zh LIKE ? ESCAPE '!')";
        $term='%'.str_replace(['!','%','_'],['!!','!%','!_'],$filter['q']).'%';array_push($args,$term,$term,$term);
    }
    $total=(int)(one('SELECT COUNT(*) AS n FROM products p JOIN categories c ON c.id=p.category_id WHERE '.$where,$args)['n']??0);
    $perPage=16;$pages=max(1,(int)ceil($total/$perPage));
    if ($pageNumber>$pages) { $page='404';http_response_code(404); }
    $items=$page==='products'?rows('SELECT p.*,c.name_en AS category_en,c.name_ru AS category_ru FROM products p JOIN categories c ON c.id=p.category_id WHERE '.$where.' ORDER BY p.featured DESC,p.sort_order,p.id LIMIT ? OFFSET ?',[...$args,$perPage,($pageNumber-1)*$perPage]):[];
}
$success='';$formError='';
if ($_SERVER['REQUEST_METHOD']==='POST' && ($_POST['action']??'')==='inquiry') {
    require_csrf();
    try {
        $name=post('name',200);$email=post('email',300);$phone=post('phone',100);$message=post('message',12000);$country=post('country',150);$product=post('product',500);
        if (post('website')!=='') throw new RuntimeException(l('Please try again.','Повторите попытку.'));
        if ($name==='' || $message==='' || ($email===''&&$phone==='')) throw new RuntimeException(l('Please enter your name, message and an email or phone number.','Укажите имя, сообщение, электронную почту или телефон.'));
        if ($email!=='' && !filter_var($email,FILTER_VALIDATE_EMAIL)) throw new RuntimeException(l('Please enter a valid email address.','Укажите корректный адрес электронной почты.'));
        if (rate_count(rate_key('inquiry'),900)>=5) throw new RuntimeException(l('Please contact us on WhatsApp or try again later.','Свяжитесь с нами через WhatsApp или повторите попытку позже.'));
        run('INSERT INTO inquiries(name,email,phone,country,product,message,created_at) VALUES(?,?,?,?,?,?,?)',[$name,$email,$phone,$country,$product,$message,now()]);
        rate_hit(rate_key('inquiry'),900);$success=l('Your inquiry has been received. You can also contact us on WhatsApp.','Ваш запрос получен. Вы также можете связаться с нами через WhatsApp.');
    } catch (Throwable $e) { $formError=($e instanceof RuntimeException && !($e instanceof PDOException))?$e->getMessage():l('Please use WhatsApp or email to contact us.','Свяжитесь с нами через WhatsApp или электронную почту.'); }
}
$pageNames=['home'=>l('Cable ties & injection molded products','Кабельные стяжки и пластиковые изделия'),'products'=>l('Products','Продукция'),'about'=>l('About EYY','О компании EYY'),'gallery'=>l('Applications & product details','Применение и детали продукции'),'news'=>l('Resources & insights','Полезная информация'),'contact'=>l('Contact us','Контакты'),'privacy'=>l('Privacy policy','Конфиденциальность'),'404'=>l('Page not found','Страница не найдена')];
$title=($record?field($record,$page==='product'?'name':'title'):($pageNames[$page]??'EYY')).' | EYY';
if ($cat && $page==='products') $title=field($cat,'name').' | EYY';
if ($page==='products' && $pageNumber>1) $title=l('Page ','Страница ').$pageNumber.' — '.$title;
if ($content && $page!=='404') $title=field($content,'title').' | EYY';
if ($page==='product') $title=field($record,'name').' — '.strtoupper(substr(hash('sha256',$record['source_id']?:$record['slug']),0,6)).' | EYY';
$description=$page==='product'?field($record,'summary'):l('Explore EYY nylon cable ties, automotive fasteners, stainless steel cable ties and cable management accessories. Product information and direct quotations.','Нейлоновые и нержавеющие кабельные стяжки EYY, автомобильный крепёж и аксессуары. Каталог продукции и запрос коммерческого предложения.');
if ($page==='article') $description=preg_replace('/\s+/u',' ',mb_substr_safe(field($record,'body'),0,170));
if ($cat && $page==='products') $description=field($cat,'description');
if ($content && $page!=='404') $description=preg_replace('/\s+/u',' ',mb_substr_safe(field($content,'body'),0,170));
if ($page==='contact') $description=l('Contact EYY for product enquiries. WhatsApp: ','Свяжитесь с EYY по вопросам продукции. WhatsApp: ').setting('phone').'. '.setting('email');
$canonicalArgs=[];
if ($record) $canonicalArgs['slug']=$record['slug'];
if ($page==='page') $canonicalArgs['slug']=$content['slug'];
if ($page==='products') {
    if (!empty($_GET['category'])) { $canonicalArgs['category']=(string)$_GET['category']; $filter['category']=(string)$_GET['category']; }
    if (!empty($_GET['q'])) $filter['q']=substr((string)$_GET['q'],0,160);
    if ($pageNumber>1) $canonicalArgs['p']=$pageNumber;
}
$canonical=rtrim(setting('site_url'),'/').url($page,$canonicalArgs);
$altEn=rtrim(setting('site_url'),'/').preg_replace('~^/(en|ru)/~','/en/',url($page,$canonicalArgs));
$altRu=rtrim(setting('site_url'),'/').preg_replace('~^/(en|ru)/~','/ru/',url($page,$canonicalArgs));
$isNoindex=$page==='404'||!empty($filter['q']);
$organization=['@type'=>'Organization','@id'=>rtrim(setting('site_url'),'/').'/#organization','name'=>'EYY Plastics','legalName'=>setting('company_name'),'url'=>setting('site_url'),'logo'=>rtrim(setting('site_url'),'/').'/assets/brand/EYY_Pure_Logo.svg','email'=>setting('email'),'telephone'=>setting('phone'),'contactPoint'=>['@type'=>'ContactPoint','contactType'=>'sales','telephone'=>setting('phone'),'email'=>setting('email'),'availableLanguage'=>['English','Russian']]];
$graph=[$organization,['@type'=>'WebSite','@id'=>rtrim(setting('site_url'),'/').'/#website','name'=>'EYY Plastics','url'=>setting('site_url'),'inLanguage'=>['en','ru'],'publisher'=>['@id'=>$organization['@id']]]];
if ($page==='product') {
    $graph[]=['@type'=>'Product','name'=>field($record,'name'),'description'=>field($record,'summary'),'brand'=>['@type'=>'Brand','name'=>'EYY'],'image'=>array_map(fn($x)=>rtrim(setting('site_url'),'/').'/'.$x,jdecode($record['images'])),'url'=>$canonical,'category'=>$record['category_'.lang()]??'','additionalProperty'=>array_map(fn($s)=>['@type'=>'PropertyValue','name'=>$s[lang()]??$s['en'],'value'=>$s['value']],jdecode($record['specs']))];
    $graph[]=['@type'=>'BreadcrumbList','itemListElement'=>[['@type'=>'ListItem','position'=>1,'name'=>l('Home','Главная'),'item'=>rtrim(setting('site_url'),'/').url()],['@type'=>'ListItem','position'=>2,'name'=>l('Products','Продукция'),'item'=>rtrim(setting('site_url'),'/').url('products')],['@type'=>'ListItem','position'=>3,'name'=>field($record,'name'),'item'=>$canonical]]];
}
if ($page==='article') $graph[]=['@type'=>'Article','headline'=>field($record,'title'),'inLanguage'=>lang(),'datePublished'=>date(DATE_ATOM,strtotime($record['created_at'])),'dateModified'=>date(DATE_ATOM,strtotime($record['updated_at'])),'author'=>$organization,'publisher'=>['@id'=>$organization['@id']],'mainEntityOfPage'=>$canonical];
function mb_substr_safe(string $s,int $start,int $length): string { return function_exists('mb_substr')?mb_substr($s,$start,$length):implode('',array_slice(preg_split('//u',$s,-1,PREG_SPLIT_NO_EMPTY),$start,$length)); }
function product_card(array $p): void {
    $im=jdecode($p['images'])[0]??'';
    ?><article class="product-card"><a href="<?=h(url('product',['slug'=>$p['slug']]))?>"><div class="product-photo"><?php if ($im): ?><img src="/<?=h($im)?>" alt="<?=h(field($p,'name'))?>" width="600" height="600" loading="lazy"><?php endif ?><span class="card-arrow"><?=icon('arrow')?></span></div><p class="eyebrow"><?=h($p['category_'.lang()]??'EYY')?></p><h3><?=h(field($p,'name'))?></h3><span class="product-ref">EYY · <?=h(strtoupper(substr(hash('sha256',$p['source_id']?:$p['slug']),0,6)))?></span></a></article><?php
}
function inquiry_form(string $product=''): void {
    ?><form class="inquiry-form" method="post" action="<?=h($_SERVER['REQUEST_URI'])?>#inquiry"><?=csrf_field()?><input type="hidden" name="action" value="inquiry"><input type="hidden" name="product" value="<?=h($product)?>"><div class="form-pair"><label><?=l('Name *','Имя *')?><input name="name" maxlength="100" required autocomplete="name"></label><label><?=l('Email','Электронная почта')?><input name="email" type="email" maxlength="200" autocomplete="email"></label></div><div class="form-pair"><label><?=l('Phone / WhatsApp','Телефон / WhatsApp')?><input name="phone" maxlength="80" autocomplete="tel"></label><label><?=l('Country / region','Страна / регион')?><input name="country" maxlength="100" autocomplete="country-name"></label></div><label><?=l('Your requirements *','Ваш запрос *')?><textarea name="message" rows="5" required maxlength="6000" placeholder="<?=h(l('Product, size, material, color and quantity','Товар, размер, материал, цвет и количество'))?>"></textarea></label><div class="honey" aria-hidden="true"><label>Website<input name="website" tabindex="-1" autocomplete="off"></label></div><p class="form-note"><?=l('Please include an email or phone number so we can reply.','Укажите электронную почту или телефон для ответа.')?> <a href="<?=h(url('privacy'))?>"><?=l('Privacy policy','Конфиденциальность')?></a></p><button class="button" type="submit"><?=l('Send inquiry','Отправить запрос')?> <?=icon('arrow')?></button><p class="form-note"><?=l('This form records your inquiry. For a direct conversation, use WhatsApp.','Форма сохраняет ваш запрос. Для прямого общения используйте WhatsApp.')?></p></form><?php
}
?><!doctype html><html lang="<?=lang()?>"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title><?=h($title)?></title><meta name="description" content="<?=h($description)?>"><meta name="robots" content="<?=$isNoindex?'noindex,follow':'index,follow,max-image-preview:large'?>"><link rel="canonical" href="<?=h($canonical)?>"><link rel="alternate" hreflang="en" href="<?=h($altEn)?>"><link rel="alternate" hreflang="ru" href="<?=h($altRu)?>"><link rel="alternate" hreflang="x-default" href="<?=h($altEn)?>"><meta property="og:type" content="<?=$page==='article'?'article':'website'?>"><meta property="og:title" content="<?=h($title)?>"><meta property="og:description" content="<?=h($description)?>"><meta property="og:url" content="<?=h($canonical)?>"><meta property="og:locale" content="<?=lang()==='ru'?'ru_RU':'en_US'?>"><meta property="og:site_name" content="EYY Plastics"><link rel="icon" href="/assets/brand/EYY_Pure_Logo.svg" type="image/svg+xml"><link rel="stylesheet" href="/assets/site.css"><script type="application/ld+json"><?=json_encode(['@context'=>'https://schema.org','@graph'=>$graph],JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES|JSON_HEX_TAG|JSON_HEX_AMP|JSON_HEX_APOS|JSON_HEX_QUOT)?></script><script src="/assets/site.js" defer></script></head><body>
<a class="skip" href="#main"><?=l('Skip to content','Перейти к содержимому')?></a>
<div class="topbar"><div class="wrap topbar-inner"><span><?=l('Cable ties & injection molded products','Кабельные стяжки и пластиковые изделия')?></span><a href="mailto:<?=h(setting('email'))?>"><?=h(setting('email'))?></a></div></div>
<header class="site-header"><div class="wrap header-inner"><a class="brand" href="<?=h(url())?>" aria-label="EYY"><img class="logo-wide" src="/assets/brand/<?=lang()==='ru'?'EYY_Russian_Tagline.svg':'EYY_English_Tagline.svg'?>" alt="EYY" width="320" height="134"><img class="logo-small" src="/assets/brand/EYY_Pure_Logo.svg" alt="EYY" width="150" height="56"></a><button class="menu-toggle" aria-label="<?=h(l('Open menu','Открыть меню'))?>" aria-expanded="false" aria-controls="navigation"><?=icon('menu')?></button><nav id="navigation" aria-label="<?=h(l('Main navigation','Основная навигация'))?>"><?php foreach (['home'=>l('Home','Главная'),'about'=>l('About us','О нас'),'products'=>l('Products','Продукция'),'gallery'=>l('Applications','Применение'),'news'=>l('Resources','Информация'),'contact'=>l('Contact','Контакты')] as $key=>$label): ?><a <?=$page===$key?'aria-current="page"':''?> href="<?=h(url($key))?>"><?=h($label)?></a><?php endforeach ?><div class="languages"><a href="<?=h(preg_replace('~^/(en|ru)/~','/en/',url($page,$canonicalArgs)))?>" lang="en" <?=lang()==='en'?'aria-current="true"':''?>>EN</a><span>/</span><a href="<?=h(preg_replace('~^/(en|ru)/~','/ru/',url($page,$canonicalArgs)))?>" lang="ru" <?=lang()==='ru'?'aria-current="true"':''?>>RU</a></div></nav></div></header>
<main id="main">
<?php if ($page==='home'): $banner=one("SELECT * FROM banners WHERE status='published' ORDER BY sort_order,id LIMIT 1"); ?>
<section class="hero"><div class="hero-photo"><?php if ($banner): ?><img src="/<?=h($banner['image'])?>" alt="<?=h(field($banner,'title'))?>" width="1920" height="950" fetchpriority="high"><?php endif ?></div><div class="hero-shade"></div><div class="wrap hero-content"><p class="eyebrow light">EYY · <?=l('CABLE MANAGEMENT','КАБЕЛЬНЫЙ КРЕПЁЖ')?></p><h1><?=nl2br(h($banner?field($banner,'title'):l('Cable ties & fasteners','Кабельные стяжки и крепёж')))?></h1><p><?=h($banner?field($banner,'subtitle'):l('Find the right fastening with EYY.','Подберите нужный крепёж с EYY.'))?></p><a class="button orange" href="<?=h(url('products'))?>"><?=l('Explore our products','Смотреть продукцию')?> <?=icon('arrow')?></a><span class="hero-caption"><?=l('NYLON · STAINLESS STEEL · CABLE ACCESSORIES','НЕЙЛОН · НЕРЖАВЕЮЩАЯ СТАЛЬ · АКСЕССУАРЫ')?></span></div><div class="hero-bottom"><span>01 / EYY</span><span><?=l('Discover the range','Знакомство с ассортиментом')?> ↓</span></div></section>
<section class="section wrap"><div class="section-heading"><div><p class="eyebrow"><?=l('PRODUCT SERIES','КАТЕГОРИИ ПРОДУКЦИИ')?></p><h2><?=l('Find the right fastening.','Найдите нужный крепёж.')?></h2></div><a class="text-link" href="<?=h(url('products'))?>"><?=l('View all products','Вся продукция')?> <?=icon('arrow')?></a></div><div class="category-grid"><?php foreach ($categories as $i=>$c): ?><a class="category-card" href="<?=h(url('products',['category'=>$c['slug']]))?>"><div class="category-image"><img src="/<?=h($c['image'])?>" alt="<?=h(field($c,'name'))?>" width="600" height="500" loading="lazy"></div><div class="category-caption"><span class="category-number">0<?=$i+1?></span><h3><?=h(field($c,'name'))?></h3><?=icon('arrow')?></div></a><?php endforeach ?></div></section>
<section class="section product-section"><div class="wrap"><div class="section-heading"><div><p class="eyebrow"><?=l('PRODUCT SELECTION','ВЫБОР ПРОДУКЦИИ')?></p><h2><?=l('Made for the task at hand.','Для вашей задачи.')?></h2></div><p class="heading-note"><?=l('Explore product details and tell us the specification you need.','Изучите продукцию и сообщите нам нужные характеристики.')?></p></div><div class="products-grid"><?php $featured=rows("SELECT p.*,c.name_en AS category_en,c.name_ru AS category_ru FROM products p LEFT JOIN categories c ON p.category_id=c.id WHERE p.status='published' AND p.deleted_at IS NULL AND c.status='published' ORDER BY p.featured DESC,p.sort_order,p.id LIMIT 8");foreach ($featured as $p)product_card($p); ?></div><div class="center section-end"><a class="button outline" href="<?=h(url('products'))?>"><?=l('Browse the complete catalog','Перейти в каталог')?> <?=icon('arrow')?></a></div></div></section>
<section class="section wrap about-split"><div class="about-visual"><img src="/<?=h(setting('about_image'))?>" alt="<?=h(l('Cable tie product selection','Ассортимент кабельных стяжек'))?>" width="1000" height="900" loading="lazy"><span class="image-label">EYY / <?=l('PRODUCT FOCUS','ПРОДУКЦИЯ')?></span></div><div class="about-copy"><p class="eyebrow"><?=l('ABOUT EYY','О КОМПАНИИ EYY')?></p><h2><?=l('Practical products.<br>A direct conversation.','Практичная продукция.<br>Прямой контакт.')?></h2><p><?=l('EYY brings together cable ties, automotive fasteners and cable management accessories. We help you compare product types and confirm the details that matter to your order.','EYY предлагает кабельные стяжки, автомобильный крепёж и аксессуары для организации кабелей. Мы поможем подобрать тип изделия и согласовать важные параметры заказа.')?></p><ul class="check-list"><li><?=icon('check')?><?=l('Clear product categories and images','Понятные категории и фотографии')?></li><li><?=icon('check')?><?=l('Specification-based product inquiries','Запросы по конкретным характеристикам')?></li><li><?=icon('check')?><?=l('Direct contact by WhatsApp and email','Прямой контакт через WhatsApp и почту')?></li></ul><a class="text-link" href="<?=h(url('about'))?>"><?=l('Get to know EYY','Подробнее об EYY')?> <?=icon('arrow')?></a></div></section>
<section class="application-strip"><div class="wrap"><p class="eyebrow light"><?=l('APPLICATIONS','ПРИМЕНЕНИЕ')?></p><h2><?=l('Bring order to every connection.','Порядок в каждом соединении.')?></h2><div class="application-grid"><?php foreach ([[l('Electrical & cable routing','Электрика и прокладка кабелей'),'01'],[l('Automotive wiring','Автомобильная проводка'),'02'],[l('Industrial fastening','Промышленный крепёж'),'03'],[l('Everyday organization','Повседневная организация'),'04']] as [$label,$n]): ?><div><span><?=$n?></span><h3><?=h($label)?></h3></div><?php endforeach ?></div><a class="button white" href="<?=h(url('gallery'))?>"><?=l('Explore applications','Сферы применения')?> <?=icon('arrow')?></a></div></section>
<section class="section wrap"><div class="section-heading"><div><p class="eyebrow"><?=l('RESOURCES & INSIGHTS','ПОЛЕЗНАЯ ИНФОРМАЦИЯ')?></p><h2><?=l('Know what you are choosing.','Осознанный выбор продукции.')?></h2></div><a class="text-link" href="<?=h(url('news'))?>"><?=l('All resources','Все материалы')?> <?=icon('arrow')?></a></div><div class="articles-grid"><?php foreach (rows("SELECT * FROM articles WHERE status='published' AND deleted_at IS NULL ORDER BY id LIMIT 3") as $a): ?><article class="article-card"><a href="<?=h(url('article',['slug'=>$a['slug']]))?>"><?php if ($a['image']): ?><img src="/<?=h($a['image'])?>" alt="<?=h(field($a,'title'))?>" width="700" height="430" loading="lazy"><?php endif ?><p class="eyebrow"><?=l('PRODUCT KNOWLEDGE','О ПРОДУКЦИИ')?></p><h3><?=h(field($a,'title'))?></h3><span class="text-link"><?=l('Read more','Читать далее')?> <?=icon('arrow')?></span></a></article><?php endforeach ?></div></section>
<?php elseif ($page==='products'): ?>
<section class="page-hero"><div class="wrap"><p class="eyebrow"><?=l('EYY PRODUCT CATALOG','КАТАЛОГ ПРОДУКЦИИ EYY')?></p><h1><?=h($cat?field($cat,'name'):l('Find your next solution.','Найдите нужное решение.'))?></h1><p><?=h($cat?field($cat,'description'):l('Explore cable ties, fasteners and accessories by product family.','Выбирайте стяжки, крепёж и аксессуары по категориям.'))?></p></div></section><section class="section wrap catalog-layout"><aside class="catalog-sidebar"><h2><?=l('Product categories','Категории')?></h2><a class="<?=$cat?'':'active'?>" href="<?=h(url('products'))?>"><?=l('All products','Вся продукция')?></a><?php foreach($categories as $c): ?><a class="<?=$cat&&$cat['id']==$c['id']?'active':''?>" href="<?=h(url('products',['category'=>$c['slug']]))?>"><?=h(field($c,'name'))?></a><?php endforeach ?><div class="sidebar-contact"><h3><?=l('Need help choosing?','Нужна помощь?')?></h3><p><?=l('Send us your size, material, color and quantity.','Сообщите размер, материал, цвет и количество.')?></p><a href="<?=h(wa())?>" target="_blank" rel="noopener"><?=l('Chat on WhatsApp','Написать в WhatsApp')?> ↗</a></div></aside><div><div class="catalog-toolbar"><span><?=$total?> <?=l('products','товаров')?></span><form method="get" class="search-form"><input type="hidden" name="page" value="products"><?php if ($cat): ?><input type="hidden" name="category" value="<?=h($cat['slug'])?>"><?php endif ?><label class="sr-only" for="search"><?=l('Search products','Поиск продукции')?></label><input id="search" name="q" value="<?=h($filter['q']??'')?>" placeholder="<?=h(l('Search products…','Поиск продукции…'))?>"><button aria-label="<?=h(l('Search','Поиск'))?>"><?=icon('search')?></button></form></div><div class="products-grid catalog-products"><?php foreach ($items as $p)product_card($p); ?></div><?php if (!$items): ?><p class="empty-state"><?=l('No matching products. Try another keyword or contact us.','Товары не найдены. Попробуйте другой запрос или свяжитесь с нами.')?></p><?php endif ?><?php if($pages>1):?><nav class="pagination" aria-label="<?=h(l('Pagination','Страницы'))?>"><?php for($i=1;$i<=$pages;$i++):?><a <?=$i===$pageNumber?'aria-current="page"':''?> href="<?=h(url('products',[...$filter,'p'=>$i]))?>"><?=$i?></a><?php endfor ?></nav><?php endif ?></div></section>
<?php elseif ($page==='product'): $images=jdecode($record['images']);$specs=jdecode($record['specs']); ?>
<div class="wrap breadcrumb"><a href="<?=h(url())?>"><?=l('Home','Главная')?></a><span>/</span><a href="<?=h(url('products',['category'=>$record['category_slug']]))?>"><?=h($record['category_'.lang()]??'')?></a><span>/</span><span><?=h(field($record,'name'))?></span></div><section class="wrap product-detail"><div class="gallery"><div class="gallery-main"><?php if($images):?><img id="main-product-image" src="/<?=h($images[0])?>" alt="<?=h(field($record,'name'))?>" width="1000" height="1000"><?php endif ?></div><?php if(count($images)>1):?><div class="gallery-thumbs"><?php foreach($images as $i=>$im):?><button class="thumb <?=$i===0?'selected':''?>" data-gallery="/<?=h($im)?>" aria-label="<?=h(l('Product image','Фото товара').' '.($i+1))?>"><img src="/<?=h($im)?>" alt="<?=h(field($record,'name').' '.($i+1))?>" width="160" height="160" loading="lazy"></button><?php endforeach ?></div><?php endif ?></div><div class="detail-copy"><p class="eyebrow"><?=h($record['category_'.lang()]??'EYY')?></p><h1><?=h(field($record,'name'))?></h1><p class="ref-label"><?=l('Catalog reference','Код каталога')?> / EYY-<?=h(strtoupper(substr(hash('sha256',$record['source_id']?:$record['slug']),0,6)))?></p><p class="lead"><?=h(field($record,'summary'))?></p><?php if($specs):?><dl class="spec-list"><?php foreach($specs as $s):?><div><dt><?=h($s[lang()]??$s['en'])?></dt><dd><?=h($s['value'])?></dd></div><?php endforeach ?></dl><?php endif ?><div class="button-row"><a class="button" href="<?=h(wa(field($record,'name'),rtrim(setting('site_url'),'/').url('product',['slug'=>$record['slug']])))?>" target="_blank" rel="noopener"><?=icon('whatsapp')?> <?=l('Ask on WhatsApp','Запросить в WhatsApp')?></a><a class="button outline" href="#inquiry"><?=l('Request a quote','Запросить цену')?></a></div><p class="detail-note"><?=l('Please confirm the required dimensions, material, color and order quantity when requesting a quotation.','При запросе цены укажите размеры, материал, цвет и количество.')?></p></div></section><section class="section wrap detail-lower"><div class="detail-description"><p class="eyebrow"><?=l('PRODUCT INFORMATION','ИНФОРМАЦИЯ О ТОВАРЕ')?></p><h2><?=l('A closer look.','Подробнее о продукции.')?></h2><div class="prose"><?=nl2br(h(field($record,'body')))?></div><?php foreach(jdecode($record['tables_json']) as $table):?><div class="table-scroll"><table class="spec-table"><?php foreach($table as $ri=>$row):?><tr><?php foreach($row as $cell):?><<?=$ri===0?'th':'td'?>><?=h($cell)?></<?=$ri===0?'th':'td'?>><?php endforeach ?></tr><?php endforeach ?></table></div><?php endforeach ?><?php foreach(jdecode($record['detail_images']) as $im):?><img class="detail-document" src="/<?=h($im)?>" alt="<?=h(field($record,'name').' — '.l('specification image','изображение характеристик'))?>" loading="lazy"><?php endforeach ?><div class="faq"><h3><?=l('What should I include in an inquiry?','Что указать в запросе?')?></h3><p><?=l('Share this product reference together with the dimensions, material, color, quantity and delivery destination. If you have a drawing or sample, mention it in your message.','Укажите код товара, размеры, материал, цвет, количество и место доставки. Если у вас есть чертёж или образец, сообщите об этом.')?></p><h3><?=l('How can I confirm a specification?','Как согласовать характеристики?')?></h3><p><?=l('Contact EYY with your application and requirements. Confirm the final specification and commercial terms before placing an order.','Свяжитесь с EYY и опишите применение и требования. Перед заказом согласуйте окончательные характеристики и коммерческие условия.')?></p></div></div><div class="inquiry-panel" id="inquiry"><h2><?=l('Let us know what you need.','Расскажите, что вам нужно.')?></h2><?php if($success):?><div class="notice success"><?=h($success)?></div><?php endif ?><?php if($formError):?><div class="notice error"><?=h($formError)?></div><?php endif ?><?php inquiry_form(field($record,'name'));?></div></section><section class="section product-section"><div class="wrap"><div class="section-heading"><h2><?=l('Related products','Другие товары')?></h2></div><div class="products-grid"><?php foreach(rows("SELECT p.*,c.name_en AS category_en,c.name_ru AS category_ru FROM products p JOIN categories c ON c.id=p.category_id WHERE p.category_id=? AND p.id<>? AND p.status='published' AND p.deleted_at IS NULL ORDER BY p.id LIMIT 4",[$record['category_id'],$record['id']]) as $p)product_card($p);?></div></div></section>
<?php elseif(in_array($page,['about','gallery','privacy','page'],true)): ?>
<section class="page-hero"><div class="wrap"><p class="eyebrow">EYY PLASTICS</p><h1><?=h($content?field($content,'title'):($pageNames[$page]??''))?></h1></div></section><section class="section wrap content-page"><div class="prose"><?=nl2br(h($content?field($content,'body'):''))?></div><?php if($content&&jdecode($content['images'])):?><div class="showcase-grid"><?php foreach(jdecode($content['images']) as $i=>$im):?><figure><img src="/<?=h($im)?>" alt="<?=h(field($content,'title').' '.($i+1))?>" loading="lazy"><figcaption><?=h(l('Product and application detail','Детали продукции и применения').' '.($i+1))?></figcaption></figure><?php endforeach ?></div><?php endif ?><?php if($page==='about'):?><div class="contact-summary"><h2><?=l('Talk to EYY','Свяжитесь с EYY')?></h2><p><?=h(setting('company_name'))?></p><a href="mailto:<?=h(setting('email'))?>"><?=h(setting('email'))?></a><a href="tel:<?=h(preg_replace('/[^+0-9]/','',setting('phone')))?>"><?=h(setting('phone'))?></a><a class="button" target="_blank" rel="noopener" href="<?=h(wa())?>">WhatsApp <?=icon('arrow')?></a></div><?php endif ?></section>
<?php elseif($page==='news'):?>
<section class="page-hero"><div class="wrap"><p class="eyebrow"><?=l('RESOURCES & INSIGHTS','ПОЛЕЗНЫЕ МАТЕРИАЛЫ')?></p><h1><?=l('Practical knowledge, clearly explained.','Полезная информация о продукции.')?></h1></div></section><section class="section wrap articles-grid"><?php foreach(rows("SELECT * FROM articles WHERE status='published' AND deleted_at IS NULL ORDER BY id") as $a):?><article class="article-card"><a href="<?=h(url('article',['slug'=>$a['slug']]))?>"><?php if($a['image']):?><img src="/<?=h($a['image'])?>" alt="<?=h(field($a,'title'))?>" width="700" height="430" loading="lazy"><?php endif ?><p class="eyebrow"><?=l('PRODUCT KNOWLEDGE','О ПРОДУКЦИИ')?></p><h2><?=h(field($a,'title'))?></h2><span class="text-link"><?=l('Read article','Читать статью')?> <?=icon('arrow')?></span></a></article><?php endforeach ?></section>
<?php elseif($page==='article'):?>
<section class="page-hero"><div class="wrap narrow"><p class="eyebrow"><?=l('EYY RESOURCES','МАТЕРИАЛЫ EYY')?></p><h1><?=h(field($record,'title'))?></h1><p><?=h(date('Y-m-d',strtotime($record['updated_at'])))?></p></div></section><article class="section wrap narrow article-body"><?php if($record['image']):?><img src="/<?=h($record['image'])?>" alt="<?=h(field($record,'title'))?>" loading="lazy"><?php endif ?><div class="prose"><?=nl2br(h(field($record,'body')))?></div><a class="button" href="<?=h(url('contact'))?>"><?=l('Discuss your requirements','Обсудить ваш запрос')?> <?=icon('arrow')?></a></article>
<?php elseif($page==='contact'):?>
<section class="page-hero"><div class="wrap"><p class="eyebrow"><?=l('CONTACT EYY','КОНТАКТЫ EYY')?></p><h1><?=l('A good connection<br>starts with a conversation.','Хорошее сотрудничество<br>начинается с общения.')?></h1></div></section><section class="section wrap contact-layout"><div><h2><?=l('How can we help?','Чем мы можем помочь?')?></h2><p class="lead"><?=l('Tell us about your product requirements and we will help you confirm the next step.','Расскажите о нужной продукции, и мы поможем согласовать дальнейшие действия.')?></p><div class="contact-item"><?=icon('mail')?><div><span><?=l('Email','Электронная почта')?></span><a href="mailto:<?=h(setting('email'))?>"><?=h(setting('email'))?></a></div></div><div class="contact-item"><?=icon('phone')?><div><span><?=l('Phone / WhatsApp','Телефон / WhatsApp')?></span><a href="tel:<?=h(preg_replace('/[^+0-9]/','',setting('phone')))?>"><?=h(setting('phone'))?></a></div></div><?php if(setting('address_'.lang())):?><div class="contact-item"><div><span><?=l('Address','Адрес')?></span><p><?=h(setting('address_'.lang()))?></p></div></div><?php endif ?><p class="legal-name"><?=h(setting('company_name'))?></p><a class="button whatsapp-solid" target="_blank" rel="noopener" href="<?=h(wa())?>"><?=icon('whatsapp')?> <?=l('Start a WhatsApp conversation','Написать в WhatsApp')?></a></div><div class="inquiry-panel" id="inquiry"><h2><?=l('Send an inquiry','Отправить запрос')?></h2><?php if($success):?><div class="notice success"><?=h($success)?></div><?php endif ?><?php if($formError):?><div class="notice error"><?=h($formError)?></div><?php endif ?><?php inquiry_form();?></div></section>
<?php else:?>
<section class="section wrap center"><p class="eyebrow">404</p><h1><?=l('We could not find this page.','Страница не найдена.')?></h1><a class="button" href="<?=h(url('products'))?>"><?=l('Explore products','Перейти в каталог')?></a></section>
<?php endif ?>
<?php if(!in_array($page,['contact','privacy','404'],true)):?><section class="cta-section"><div class="wrap cta-inner"><div><p class="eyebrow light"><?=l('LET’S TALK','ОБСУДИМ ВАШ ЗАПРОС')?></p><h2><?=l('The right detail makes a difference.','Подходящая деталь имеет значение.')?></h2></div><a class="button white" href="<?=h(url('contact'))?>"><?=l('Contact EYY','Связаться с EYY')?> <?=icon('arrow')?></a></div></section><?php endif ?></main>
<footer class="site-footer"><div class="wrap footer-grid"><div class="footer-brand"><img src="/assets/brand/<?=lang()==='ru'?'EYY_Russian_Tagline.svg':'EYY_English_Tagline.svg'?>" alt="EYY" width="380" height="160" loading="lazy"><p><?=l('Cable ties, fasteners and practical cable management solutions.','Кабельные стяжки, крепёж и решения для организации кабелей.')?></p></div><div><h3><?=l('Products','Продукция')?></h3><?php foreach($categories as $c):?><a href="<?=h(url('products',['category'=>$c['slug']]))?>"><?=h(field($c,'name'))?></a><?php endforeach ?></div><div><h3><?=l('Explore','Информация')?></h3><a href="<?=h(url('about'))?>"><?=l('About EYY','О компании EYY')?></a><a href="<?=h(url('gallery'))?>"><?=l('Applications','Применение')?></a><a href="<?=h(url('news'))?>"><?=l('Resources','Полезные материалы')?></a><a href="<?=h(url('privacy'))?>"><?=l('Privacy policy','Конфиденциальность')?></a><?php foreach(rows("SELECT * FROM pages WHERE status='published' AND slug NOT IN ('about','gallery','privacy')") as $extraPage):?><a href="<?=h(url('page',['slug'=>$extraPage['slug']]))?>"><?=h(field($extraPage,'title'))?></a><?php endforeach ?></div><div><h3><?=l('Get in touch','Связаться с нами')?></h3><a href="mailto:<?=h(setting('email'))?>"><?=h(setting('email'))?></a><a href="tel:<?=h(preg_replace('/[^+0-9]/','',setting('phone')))?>"><?=h(setting('phone'))?></a><a href="<?=h(wa())?>" target="_blank" rel="noopener">WhatsApp ↗</a><?php if(setting('address_'.lang())):?><p><?=h(setting('address_'.lang()))?></p><?php endif ?></div></div><div class="wrap footer-bottom"><span>© <?=date('Y')?> EYY · <?=h(setting('company_name'))?></span><span><?=l('All rights reserved.','Все права защищены.')?></span></div></footer>
<a class="whatsapp-float" target="_blank" rel="noopener" href="<?=h(wa($page==='product'?field($record,'name'):''))?>" aria-label="<?=h(l('Chat with EYY on WhatsApp','Написать EYY в WhatsApp'))?>"><?=icon('whatsapp')?><span><?=l('Chat with us','Напишите нам')?></span></a></body></html>
