<?php

namespace Autogedal\Extend\Cron;

use Magento\Framework\App\ResourceConnection;
use Magento\Store\Model\StoreManagerInterface;
use Magento\UrlRewrite\Model\UrlFinderInterface;
use Magento\UrlRewrite\Service\V1\Data\UrlRewrite;
use Magento\Framework\UrlInterface;
use Amasty\ShopbySeo\Helper\Url as SeoUrlHelper;
use Amasty\ShopbyPage\Model\PageFactory;
use Amasty\ShopbyPage\Model\ResourceModel\Page as PageResource;
use Psr\Log\LoggerInterface;

class RefreshGreenValleyBrandModelCaroserie
{
    const CATEGORY_ID   = 2161;
    const BRAND_ATTR_ID = 747;
    const MODEL_ATTR_ID = 748;
    const BRAND_CODE    = 'auto_brand';
    const MODEL_CODE    = 'auto_model';
    const BODY_CODE     = 'auto_body_bare';

    const SUV_MODELS = [
        ['brand' => 'Audi',       'model' => 'Q3'],
        ['brand' => 'Audi',       'model' => 'Q5'],
        ['brand' => 'Audi',       'model' => 'Q7'],
        ['brand' => 'BMW',        'model' => 'X3'],
        ['brand' => 'BMW',        'model' => 'X5'],
        ['brand' => 'BMW',        'model' => 'X6'],
        ['brand' => 'Dacia',      'model' => 'Duster'],
        ['brand' => 'Hyundai',    'model' => 'Santa Fe'],
        ['brand' => 'Hyundai',    'model' => 'Tucson'],
        ['brand' => 'Kia',        'model' => 'Sportage'],
        ['brand' => 'Land Rover', 'model' => 'Discovery'],
        ['brand' => 'Land Rover', 'model' => 'Range Rover Evoque'],
        ['brand' => 'Mitsubishi', 'model' => 'Outlander'],
        ['brand' => 'Nissan',     'model' => 'X-Trail'],
        ['brand' => 'Renault',    'model' => 'Captur'],
        ['brand' => 'Skoda',      'model' => 'Enyaq'],
        ['brand' => 'Subaru',     'model' => 'Forester'],
        ['brand' => 'Suzuki',     'model' => 'Vitara'],
        ['brand' => 'Toyota',     'model' => 'Rav4'],
        ['brand' => 'Volkswagen', 'model' => 'Tiguan'],
        ['brand' => 'Volkswagen', 'model' => 'Touareg'],
        ['brand' => 'Volvo',      'model' => 'XC90'],
    ];

    const ALL_BRANDS = [
        'Audi', 'BMW', 'Citroen', 'Dacia', 'Fiat', 'Ford', 'Honda',
        'Hyundai', 'Mercedes', 'Nissan', 'Opel', 'Peugeot', 'Renault',
        'Seat', 'Skoda', 'Toyota', 'Volkswagen', 'Volvo',
    ];

    private $resource;
    private $storeManager;
    private $urlFinder;
    private $seoUrlHelper;
    private $pageFactory;
    private $pageResource;
    private $logger;

    private $connection;
    private $baseUrl;
    private $catUrlPath;
    private $statusAttrId;
    private $bodyAttrId;
    private $bodyAttrTable;
    private $suvBodyId;

    public function __construct(
        ResourceConnection $resource,
        StoreManagerInterface $storeManager,
        UrlFinderInterface $urlFinder,
        SeoUrlHelper $seoUrlHelper,
        PageFactory $pageFactory,
        PageResource $pageResource,
        LoggerInterface $logger
    ) {
        $this->resource      = $resource;
        $this->storeManager  = $storeManager;
        $this->urlFinder     = $urlFinder;
        $this->seoUrlHelper  = $seoUrlHelper;
        $this->pageFactory   = $pageFactory;
        $this->pageResource  = $pageResource;
        $this->logger        = $logger;
    }

    public function execute()
    {
        $this->logger->info('RefreshGreenValleyBrandModelCaroserie: start');

        $this->connection = $this->resource->getConnection();
        $pageTable        = $this->resource->getTableName('amasty_amshopby_page');
        $pageStoreTable   = $this->resource->getTableName('amasty_amshopby_page_store');

        $this->statusAttrId = (int)$this->connection->fetchOne(
            "SELECT attribute_id FROM " . $this->resource->getTableName('eav_attribute') .
            " WHERE attribute_code = 'status' AND entity_type_id = 4"
        );

        $bodyAttrRow = $this->connection->fetchRow(
            $this->connection->select()
                ->from($this->resource->getTableName('eav_attribute'), ['attribute_id', 'backend_type'])
                ->where('attribute_code = ?', self::BODY_CODE)
                ->where('entity_type_id = 4')
                ->limit(1)
        );
        if (!$bodyAttrRow || !$bodyAttrRow['attribute_id']) {
            $this->logger->error('RefreshGreenValleyBrandModelCaroserie: attribute ' . self::BODY_CODE . ' not found');
            return;
        }
        $this->bodyAttrId    = (int)$bodyAttrRow['attribute_id'];
        $this->bodyAttrTable = $this->resource->getTableName('catalog_product_entity_' . $bodyAttrRow['backend_type']);

        $this->suvBodyId = $this->getOptionIdByLabel($this->bodyAttrId, 'SUV');

        /** @var \Magento\Store\Model\Store $store */
        $store            = $this->storeManager->getStore(1);
        $storeId          = $store->getId();
        $this->storeManager->setCurrentStore($storeId);
        $this->baseUrl    = rtrim($store->getBaseUrl(UrlInterface::URL_TYPE_WEB), '/');

        $rewrite = $this->urlFinder->findOneByData([
            UrlRewrite::ENTITY_TYPE   => 'category',
            UrlRewrite::ENTITY_ID     => self::CATEGORY_ID,
            UrlRewrite::STORE_ID      => $storeId,
            UrlRewrite::REDIRECT_TYPE => 0,
        ]);
        $this->catUrlPath = $rewrite
            ? str_replace('.html', '', $rewrite->getRequestPath())
            : 'bare-transversale';

        $suvUrlMap   = $this->buildSuvUrlMap();
        $brandUrlMap = $this->buildBrandUrlMap();
        $css         = $this->getCss();
        $faqHtml     = $this->getFaqHtml();

        $combinations = $this->getActiveCombinations();
        $created      = 0;
        $updated      = 0;
        $skipped      = 0;

        foreach ($combinations as $combo) {
            $brandId   = $combo['brand_id'];
            $modelId   = $combo['model_id'];
            $bodyValue = $combo['body_value'];
            $brandName = $combo['brand_name'];
            $modelName = $combo['model_name'];
            $bodyLabel = $this->getOptionLabelById($bodyValue) ?: (string)$bodyValue;

            $conditions = json_encode([
                json_encode(['filter' => (string)self::BRAND_ATTR_ID, 'value' => (string)$brandId]),
                json_encode(['filter' => (string)self::MODEL_ATTR_ID, 'value' => (string)$modelId]),
                json_encode(['filter' => (string)$this->bodyAttrId,   'value' => (string)$bodyValue]),
            ]);

            $seoUrl = $this->buildUrl([
                self::BRAND_CODE => $brandId,
                self::MODEL_CODE => $modelId,
                self::BODY_CODE  => $bodyValue,
            ]);

            $pageId = $this->connection->fetchOne(
                $this->connection->select()
                    ->from($pageTable, 'page_id')
                    ->where('conditions = ?', $conditions)
                    ->where('FIND_IN_SET(?, categories)', self::CATEGORY_ID)
            );

            if (!$pageId) {
                $pageId = $this->connection->fetchOne(
                    $this->connection->select()
                        ->from($pageTable, 'page_id')
                        ->where('url = ?', $seoUrl)
                );
            }

            $description = $this->buildDescription(
                $brandId, $brandName, $modelId, $modelName,
                $bodyValue, $bodyLabel, $suvUrlMap, $brandUrlMap, $css, $faqHtml
            );

            if ($pageId) {
                $this->connection->update(
                    $pageTable,
                    ['description' => $description],
                    ['page_id = ?' => $pageId]
                );
                $updated++;
            } else {
                $page = $this->pageFactory->create();
                $page->addData([
                    'position'         => 'replace',
                    'url'              => $seoUrl,
                    'title'            => 'Bare transversale ' . $brandName . ' ' . $modelName,
                    'description'      => $description,
                    'meta_title'       => 'Bare transversale ' . $brandName . ' ' . $modelName . ' ' . $bodyLabel . ' - Green Valley',
                    'meta_description' => 'Bare transversale ' . $brandName . ' ' . $modelName . ' ' . $bodyLabel . '. Disponibile pe Autogedal. Livrare rapida in toata Romania.',
                    'conditions'       => $conditions,
                    'categories'       => (string)self::CATEGORY_ID,
                    'tag_robots'       => 'INDEX,FOLLOW',
                ]);
                $this->pageResource->save($page);
                $this->connection->insert($pageStoreTable, ['page_id' => $page->getId(), 'store_id' => 0]);
                $created++;
            }
        }

        $this->logger->info("RefreshGreenValleyBrandModelCaroserie: done. Created=$created Updated=$updated Skipped=$skipped");
    }

    private function getActiveCombinations()
    {
        return $this->connection->fetchAll(
            $this->connection->select()
                ->from(['pei_b' => $this->resource->getTableName('catalog_product_entity_varchar')], [])
                ->joinInner(
                    ['eaov_b' => $this->resource->getTableName('eav_attribute_option_value')],
                    'eaov_b.option_id = pei_b.value AND eaov_b.store_id = 0',
                    ['brand_id' => 'pei_b.value', 'brand_name' => 'eaov_b.value']
                )
                ->joinInner(
                    ['pei_m' => $this->resource->getTableName('catalog_product_entity_varchar')],
                    'pei_m.entity_id = pei_b.entity_id AND pei_m.attribute_id = ' . self::MODEL_ATTR_ID,
                    []
                )
                ->joinInner(
                    ['eaov_m' => $this->resource->getTableName('eav_attribute_option_value')],
                    'eaov_m.option_id = pei_m.value AND eaov_m.store_id = 0',
                    ['model_id' => 'pei_m.value', 'model_name' => 'eaov_m.value']
                )
                ->joinInner(
                    ['pei_body' => $this->bodyAttrTable],
                    'pei_body.entity_id = pei_b.entity_id AND pei_body.attribute_id = ' . $this->bodyAttrId,
                    ['body_value' => 'pei_body.value']
                )
                ->joinInner(
                    ['ccp' => $this->resource->getTableName('catalog_category_product')],
                    'ccp.product_id = pei_b.entity_id',
                    []
                )
                ->joinInner(
                    ['cpe_status' => $this->resource->getTableName('catalog_product_entity_int')],
                    'cpe_status.entity_id = pei_b.entity_id'
                    . ' AND cpe_status.attribute_id = ' . $this->statusAttrId
                    . ' AND cpe_status.store_id = 0 AND cpe_status.value = 1',
                    []
                )
                ->where('pei_b.attribute_id = ?', self::BRAND_ATTR_ID)
                ->where('ccp.category_id = ?', self::CATEGORY_ID)
                ->where('pei_body.value IS NOT NULL')
                ->where("pei_body.value != ''")
                ->group(['pei_b.value', 'pei_m.value', 'pei_body.value'])
                ->order(['eaov_b.value ASC', 'eaov_m.value ASC', 'pei_body.value ASC'])
        );
    }

    private function getSiblings($brandId, $modelId)
    {
        return $this->connection->fetchAll(
            $this->connection->select()
                ->from(['pei_m' => $this->resource->getTableName('catalog_product_entity_varchar')], [])
                ->joinInner(
                    ['eaov_m' => $this->resource->getTableName('eav_attribute_option_value')],
                    'eaov_m.option_id = pei_m.value AND eaov_m.store_id = 0',
                    ['option_id' => 'pei_m.value', 'model_name' => 'eaov_m.value']
                )
                ->joinInner(
                    ['pei_b' => $this->resource->getTableName('catalog_product_entity_varchar')],
                    'pei_b.entity_id = pei_m.entity_id AND pei_b.attribute_id = ' . self::BRAND_ATTR_ID
                    . ' AND pei_b.value = ' . (int)$brandId,
                    []
                )
                ->joinInner(
                    ['ccp' => $this->resource->getTableName('catalog_category_product')],
                    'ccp.product_id = pei_m.entity_id',
                    []
                )
                ->joinInner(
                    ['cpe_status' => $this->resource->getTableName('catalog_product_entity_int')],
                    'cpe_status.entity_id = pei_m.entity_id'
                    . ' AND cpe_status.attribute_id = ' . $this->statusAttrId
                    . ' AND cpe_status.store_id = 0 AND cpe_status.value = 1',
                    []
                )
                ->where('pei_m.attribute_id = ?', self::MODEL_ATTR_ID)
                ->where('pei_m.value != ?', $modelId)
                ->where('ccp.category_id = ?', self::CATEGORY_ID)
                ->group('pei_m.value')
                ->order('eaov_m.value ASC')
        );
    }

    private function getDynamicBodyModels($brandId, $modelId, $bodyValue)
    {
        return $this->connection->fetchAll(
            $this->connection->select()
                ->from(['pei_body' => $this->bodyAttrTable], [])
                ->joinInner(
                    ['pei_b' => $this->resource->getTableName('catalog_product_entity_varchar')],
                    'pei_b.entity_id = pei_body.entity_id AND pei_b.attribute_id = ' . self::BRAND_ATTR_ID,
                    []
                )
                ->joinInner(
                    ['eaov_b' => $this->resource->getTableName('eav_attribute_option_value')],
                    'eaov_b.option_id = pei_b.value AND eaov_b.store_id = 0',
                    ['brand_option_id' => 'pei_b.value', 'brand_name' => 'eaov_b.value']
                )
                ->joinInner(
                    ['pei_m' => $this->resource->getTableName('catalog_product_entity_varchar')],
                    'pei_m.entity_id = pei_body.entity_id AND pei_m.attribute_id = ' . self::MODEL_ATTR_ID,
                    []
                )
                ->joinInner(
                    ['eaov_m' => $this->resource->getTableName('eav_attribute_option_value')],
                    'eaov_m.option_id = pei_m.value AND eaov_m.store_id = 0',
                    ['model_option_id' => 'pei_m.value', 'model_name' => 'eaov_m.value']
                )
                ->joinInner(
                    ['ccp' => $this->resource->getTableName('catalog_category_product')],
                    'ccp.product_id = pei_body.entity_id',
                    []
                )
                ->joinInner(
                    ['cpe_status' => $this->resource->getTableName('catalog_product_entity_int')],
                    'cpe_status.entity_id = pei_body.entity_id'
                    . ' AND cpe_status.attribute_id = ' . $this->statusAttrId
                    . ' AND cpe_status.store_id = 0 AND cpe_status.value = 1',
                    []
                )
                ->where('pei_body.attribute_id = ?', $this->bodyAttrId)
                ->where('pei_body.value = ?', $bodyValue)
                ->where('ccp.category_id = ?', self::CATEGORY_ID)
                ->where(
                    'NOT (pei_b.value = ' . $this->connection->quote($brandId)
                    . ' AND pei_m.value = ' . $this->connection->quote($modelId) . ')'
                )
                ->group(['pei_b.value', 'pei_m.value'])
                ->order(['eaov_b.value ASC', 'eaov_m.value ASC'])
                ->limit(12)
        );
    }

    private function hasActiveProducts($brandId, $modelId = null, $bodyId = null)
    {
        $select = $this->connection->select()
            ->from(
                ['pei_b' => $this->resource->getTableName('catalog_product_entity_varchar')],
                ['COUNT(DISTINCT pei_b.entity_id)']
            )
            ->joinInner(
                ['ccp' => $this->resource->getTableName('catalog_category_product')],
                'ccp.product_id = pei_b.entity_id',
                []
            )
            ->joinInner(
                ['cpe_status' => $this->resource->getTableName('catalog_product_entity_int')],
                'cpe_status.entity_id = pei_b.entity_id'
                . ' AND cpe_status.attribute_id = ' . $this->statusAttrId
                . ' AND cpe_status.store_id = 0 AND cpe_status.value = 1',
                []
            )
            ->where('pei_b.attribute_id = ?', self::BRAND_ATTR_ID)
            ->where('pei_b.value = ?', $brandId)
            ->where('ccp.category_id = ?', self::CATEGORY_ID);

        if ($modelId !== null) {
            $select->joinInner(
                ['pei_m' => $this->resource->getTableName('catalog_product_entity_varchar')],
                'pei_m.entity_id = pei_b.entity_id AND pei_m.attribute_id = ' . self::MODEL_ATTR_ID
                . ' AND pei_m.value = ' . (int)$modelId,
                []
            );
        }

        if ($bodyId !== null) {
            $select->joinInner(
                ['pei_body_check' => $this->bodyAttrTable],
                'pei_body_check.entity_id = pei_b.entity_id'
                . ' AND pei_body_check.attribute_id = ' . $this->bodyAttrId
                . ' AND pei_body_check.value = ' . (int)$bodyId,
                []
            );
        }

        return (int)$this->connection->fetchOne($select) > 0;
    }

    private function buildSuvUrlMap()
    {
        if (!$this->suvBodyId) {
            return [];
        }
        $map = [];
        foreach (self::SUV_MODELS as $item) {
            $brandId = $this->getOptionIdByLabel(self::BRAND_ATTR_ID, $item['brand']);
            $modelId = $this->getOptionIdByLabel(self::MODEL_ATTR_ID, $item['model']);
            if (!$brandId || !$modelId || !$this->hasActiveProducts($brandId, $modelId, $this->suvBodyId)) {
                continue;
            }
            $key       = $item['brand'] . '|' . $item['model'];
            $map[$key] = $this->buildUrl([
                self::BRAND_CODE => $brandId,
                self::MODEL_CODE => $modelId,
                self::BODY_CODE  => $this->suvBodyId,
            ]);
        }
        return $map;
    }

    private function buildBrandUrlMap()
    {
        $map = [];
        foreach (self::ALL_BRANDS as $brandName) {
            $brandId = $this->getOptionIdByLabel(self::BRAND_ATTR_ID, $brandName);
            if (!$brandId || !$this->hasActiveProducts($brandId)) {
                continue;
            }
            $map[$brandName] = $this->buildUrl([self::BRAND_CODE => $brandId]);
        }
        return $map;
    }

    private function buildDescription(
        $brandId, $brandName, $modelId, $modelName,
        $bodyValue, $bodyLabel, array $suvUrlMap, array $brandUrlMap, $css, $faqHtml
    ) {
        $isSuv = ($this->suvBodyId && $bodyValue == $this->suvBodyId);

        // Bloc 1: alte modele din acelasi brand
        $siblings     = $this->getSiblings($brandId, $modelId);
        $siblingsHtml = '';
        foreach ($siblings as $sib) {
            $url           = $this->buildUrl([self::BRAND_CODE => $brandId, self::MODEL_CODE => $sib['option_id']]);
            $siblingsHtml .= '<a class="il-sibling-card" href="' . htmlspecialchars($url) . '">'
                . htmlspecialchars($sib['model_name']) . '</a> ';
        }

        // Bloc 2: alte brand+model cu aceeasi caroserie
        $bloc2Html = '';
        if ($isSuv) {
            foreach (self::SUV_MODELS as $item) {
                $key = $item['brand'] . '|' . $item['model'];
                if (strtolower($item['brand']) === strtolower($brandName)
                    && strtolower($item['model']) === strtolower($modelName)) {
                    continue;
                }
                if (!isset($suvUrlMap[$key])) {
                    continue;
                }
                $bloc2Html .= '<a class="il-model-card" href="' . htmlspecialchars($suvUrlMap[$key]) . '">'
                    . '<div class="il-model-brand">' . htmlspecialchars($item['brand']) . '</div>'
                    . '<div class="il-model-name">' . htmlspecialchars($item['model']) . '</div>'
                    . '<div class="il-model-body">SUV</div>'
                    . '</a>';
            }
        } else {
            foreach ($this->getDynamicBodyModels($brandId, $modelId, $bodyValue) as $dm) {
                $url = $this->buildUrl([
                    self::BRAND_CODE => $dm['brand_option_id'],
                    self::MODEL_CODE => $dm['model_option_id'],
                    self::BODY_CODE  => $bodyValue,
                ]);
                $bloc2Html .= '<a class="il-model-card" href="' . htmlspecialchars($url) . '">'
                    . '<div class="il-model-brand">' . htmlspecialchars($dm['brand_name']) . '</div>'
                    . '<div class="il-model-name">' . htmlspecialchars($dm['model_name']) . '</div>'
                    . '<div class="il-model-body">' . htmlspecialchars($bodyLabel) . '</div>'
                    . '</a>';
            }
        }

        // Bloc 3: toate brandurile (filtrate dupa produse active)
        $bloc3Html = '';
        foreach (self::ALL_BRANDS as $b) {
            if (!isset($brandUrlMap[$b])) {
                continue;
            }
            $bloc3Html .= '<a class="il-brand-card" href="' . htmlspecialchars($brandUrlMap[$b]) . '">'
                . htmlspecialchars($b) . '</a> ';
        }

        $bloc1 = $siblingsHtml ? '
<div class="il-block">
<div class="il-header"><div class="il-header-left"><h3 class="il-title">Alte modele ' . htmlspecialchars($brandName) . '</h3></div></div>
<div class="il-siblings-grid">' . $siblingsHtml . '</div>
</div>' : '';

        $bloc2 = $bloc2Html ? '
<div class="il-block">
<div class="il-header"><div class="il-header-left"><h3 class="il-title">Alte ' . htmlspecialchars(ucfirst(strtolower($bodyLabel))) . '-uri cu bare transversale</h3></div></div>
<div class="il-models-grid">' . $bloc2Html . '</div>
</div>' : '';

        $bloc3 = $bloc3Html ? '
<div class="il-block">
<div class="il-header"><div class="il-header-left"><h3 class="il-title">Bare transversale pentru orice marcă</h3></div></div>
<div class="il-brands-grid">' . $bloc3Html . '</div>
</div>' : '';

        return $css . '
<div class="il-section">' . $bloc1 . $bloc2 . $bloc3 . '
</div>
' . $faqHtml;
    }

    private function buildUrl(array $params)
    {
        $raw = $this->baseUrl . '/' . $this->catUrlPath . '/?' . http_build_query($params);
        return $this->seoUrlHelper->seofyUrl($raw, self::CATEGORY_ID, true) . '.html';
    }

    private function getOptionIdByLabel($attrId, $label)
    {
        return $this->connection->fetchOne(
            $this->connection->select()
                ->from(['eaov' => $this->resource->getTableName('eav_attribute_option_value')], ['eaov.option_id'])
                ->joinInner(
                    ['eao' => $this->resource->getTableName('eav_attribute_option')],
                    'eao.option_id = eaov.option_id AND eao.attribute_id = ' . (int)$attrId,
                    []
                )
                ->where('eaov.store_id = 0')
                ->where('eaov.value = ?', $label)
                ->limit(1)
        ) ?: null;
    }

    private function getOptionLabelById($optionId)
    {
        return $this->connection->fetchOne(
            $this->connection->select()
                ->from($this->resource->getTableName('eav_attribute_option_value'), ['value'])
                ->where('option_id = ?', $optionId)
                ->order('store_id ASC')
                ->limit(1)
        ) ?: null;
    }

    private function getCss()
    {
        return '<style>
.il-section{margin:40px 0}.il-block{margin-bottom:40px}.il-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:16px}.il-header-left{display:flex;align-items:center;gap:12px}.il-title{font-size:22px;font-weight:700;color:#1a1a1a;margin:0}.il-brands-grid{display:grid;grid-template-columns:repeat(6,1fr);gap:8px}.il-brand-card{background:#f3f4f6;border-radius:8px;padding:14px 16px;text-decoration:none;display:block;border:2px solid transparent;transition:border-color .2s,background .2s;font-size:15px;font-weight:500;color:#1a1a1a}.il-brand-card:hover{border-color:#e53e3e;background:#fff;text-decoration:none;color:#1a1a1a}.il-models-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:10px}.il-model-card{background:#f3f4f6;border-radius:10px;padding:14px 18px;text-decoration:none;display:block;border:2px solid transparent;transition:border-color .2s,background .2s}.il-model-card:hover{border-color:#e53e3e;background:#fff;text-decoration:none}.il-model-brand{font-size:11px;font-weight:600;letter-spacing:.8px;text-transform:uppercase;color:#6b7280;margin-bottom:4px}.il-model-name{font-size:18px;font-weight:700;color:#111827}.il-model-body{font-size:11px;color:#9ca3af;margin-top:3px}.il-siblings-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}.il-sibling-card{background:#f3f4f6;border-radius:8px;padding:14px 16px;text-decoration:none;display:block;border:2px solid transparent;transition:border-color .2s,background .2s;font-size:16px;font-weight:600;color:#1a1a1a}.il-sibling-card:hover{border-color:#e53e3e;background:#fff;text-decoration:none;color:#1a1a1a}@media(max-width:767px){.il-siblings-grid{grid-template-columns:repeat(2,1fr)}.il-models-grid{grid-template-columns:repeat(2,1fr)}.il-brands-grid{grid-template-columns:repeat(3,1fr)}}
</style>';
    }

    private function getFaqHtml()
    {
        return '
<h2 style="font-size: 2.2rem;">Intrebari frecvente</h2>
<div class="faq-container">
    <div class="faq-item"><div class="faq-question"><h3>Aveti transport gratuit?</h3></div><div class="faq-answer"><p>Nu. Taxele de transport variaza in functie de categoria produselor si sunt cuprinse intre 20 si 49 lei.</p></div></div>
    <div class="faq-item"><div class="faq-question"><h3>Exista campanii de reduceri?</h3></div><div class="faq-answer"><p>Da, derulam frecvent campanii de reduceri pentru diverse categorii de produse. Reducerile aplicate variaza, acestea putand ajunge pana la 40-50%. Urmareste site-ul nostru pentru a fi la curent cu ofertele.</p></div></div>
    <div class="faq-item"><div class="faq-question"><h3>Care este politica de retur si cat dureaza rambursarea banilor?</h3></div><div class="faq-answer"><p>Returul produselor se poate efectua in termen de 14 zile de la primirea acestora, indiferent de motivul returnarii. Viramentul bancar pentru contravaloarea produselor trimise si acceptate la retur se efectueaza in termen de maximum 14 zile de la momentul notificarii cu privire la decizia returnarii produselor, daca produsele sunt trimise inapoi inainte de expirarea perioadei de 14 zile. Mai multe detalii: <a href="https://www.autogedal.ro/retur/">Retur</a></p></div></div>
    <div class="faq-item"><div class="faq-question"><h3>Cum pot solicita un retur?</h3></div><div class="faq-answer"><p>Pentru a solicita un retur, completeaza formularul disponibil pe site: <a href="https://www.autogedal.ro/retur/">Retur</a></p></div></div>
    <div class="faq-item"><div class="faq-question"><h3>Ce metode de plata sunt disponibile?</h3></div><div class="faq-answer"><p>Poti plati ramburs la curier, online cu cardul, in 3 rate fara dobanda (cu card de cumparaturi eligibil) sau prin ordin de plata pe baza unei facturi proforme. La selectarea platii online cu cardul, procesatorul de plati va permite inclusiv plata prin Apple Pay sau Google Pay.</p></div></div>
    <div class="faq-item"><div class="faq-question"><h3>Pot plati in rate?</h3></div><div class="faq-answer"><p>Da, poti plati in 3 rate fara dobanda, daca folosesti un <a href="https://www.autogedal.ro/cms/cum-platesc">card de cumparaturi eligibil</a> (Card Avantaj - Credit Europe Bank; Card StarBT - Banca Transilvania; Bonus Card - Garanti Bank; Card Cumparaturi - Alpha Bank; Card BRD Finance).</p></div></div>
    <div class="faq-item"><div class="faq-question"><h3>Cum imi pot urmari coletul?</h3></div><div class="faq-answer"><p>Dupa finalizarea comenzii vei primi un email cu nr de AWB al coletului si firma de curierat prin care a fost expediat coletul.</p></div></div>
    <div class="faq-item"><div class="faq-question"><h3>Cat dureaza livrarea?</h3></div><div class="faq-answer"><p>De regula, livrarea se face in 1-3 zile lucratoare, in functie de adresa de destinatie. Pentru anumite categorii de produse (precum carligele de remorcare marca Aragon), livrarea se poate prelungi pana la 7-9 zile lucratoare.</p></div></div>
    <div class="faq-item"><div class="faq-question"><h3>Cum sunt protejate datele mele personale?</h3></div><div class="faq-answer"><p>Protejam datele tale personale conform Regulamentului (UE) 2016/679 (GDPR). Nu transmitem (prin vanzare sau inchiriere) catre terte parti informatiile cu caracter personal. Ai dreptul de a solicita oricand stergerea informatiilor cu caracter personal existente in baza noastra de date. Poti consulta politica noastra completa de confidentialitate aici: <a href="https://www.autogedal.ro/politica-de-confidentialitate/">Politica de confidentialitate</a></p></div></div>
</div>';
    }
}
