<?php
/** @var \Dotdigitalgroup\Email\Block\Review $block */
// @codingStandardsIgnoreFile
?>
<?php
$i = 0;
$helper = $block->helper;
$order = $block->getOrder();
$mode = $block->getMode();
$website = $block->getWebsite();
?>
<?php if ($order) : ?>
    <?php $dynamicStyle = $helper->getDynamicStyles(); ?>
    <style>
        .product-name{
            color: <?= $block->escapeHtml($dynamicStyle['nameColor']);?>;
            font-size: <?= $block->escapeHtml($dynamicStyle['fontSize']);?>;
        <?php if (in_array('bold', $dynamicStyle['nameStyle'])) : ?>
            font-weight: bold;
        <?php endif; ?><?php if (in_array('italic', $dynamicStyle['nameStyle'])) : ?>
            font-style: italic;
        <?php endif; ?><?php if (in_array('underline', $dynamicStyle['nameStyle'])) : ?>
            text-decoration: underline;
        <?php endif; ?>
        }
        .product-price{
            color: <?= $block->escapeHtml($dynamicStyle['priceColor']);?>;
            font-size: <?= $block->escapeHtml($dynamicStyle['priceFontSize']);?>;
        <?php if (in_array('bold', $dynamicStyle['priceStyle'])) : ?>
            font-weight: bold;
        <?php endif; ?><?php if (in_array('italic', $dynamicStyle['priceStyle'])) : ?>
            font-style: italic;
        <?php endif; ?><?php if (in_array('underline', $dynamicStyle['priceStyle'])) : ?>
            text-decoration: underline;
        <?php endif; ?>
        }
        .proudct-url{
            color: <?= $block->escapeHtml($dynamicStyle['urlColor']);?>;
            font-size: <?= $block->escapeHtml($dynamicStyle['urlFontSize']);?>;
        <?php if (in_array('bold', $dynamicStyle['linkStyle'])) : ?>
            font-weight: bold;
        <?php endif; ?><?php if (in_array('italic', $dynamicStyle['linkStyle'])) : ?>
            font-style: italic;
        <?php endif; ?><?php if (in_array('underline', $dynamicStyle['linkStyle'])) : ?>
            text-decoration: underline;
        <?php endif; ?>
        }
        .product-table{
            font-family: <?= $block->escapeHtml($dynamicStyle['docFont']);?>;
            background-color: <?= $block->escapeHtml($dynamicStyle['docBackgroundColor']);?>;
            width: 100% !important;
        }
        .product-table img{
            display: block;
            margin-left: auto;
            margin-right: auto
        }
        .product-table td{
            width: 25%;
            padding-bottom: 10px;
        }

        /** Styling from config field **/
        <?= $block->escapeHtml($dynamicStyle['dynamicStyling']);?>
        /** Responsive  **/
        @media (max-width: 760px) {
            /* Force table to not be like tables anymore */
            table, thead, tbody, th, td, tr {
                display: block;
            }
            .product-table td{
                width: 172px !important;
            }

            .product-table {
                width: auto !important;
            }
        }
    </style>

    <?php $items = $block->getItems(); ?>

    <?php foreach ($items as $item) : ?>
        <?php if ($i == 0) : ?>
            <table class="product-table" border="0" width="147" cellpadding="0" cellspacing="0"
            style='border-collapse: collapse;'><tr>
        <?php endif;?>
        <?php if ($mode == 'list') : ?>
            </tr><tr>
        <?php endif;?>

        <td style="vertical-align: text-top; padding-right: 2px;">
            <?= $block->getImage($item, 'category_page_grid')->toHtml(); ?>
            <div class="product-name" align="center"><b>
                    <?= mb_substr($block->escapeHtml($item->getName()), 0, 40); ?></b></div>
            <div align="center">
                <?php $url = $block->getReviewItemUrl($item->getId()) . $helper->getReviewReminderAnchor($website); ?>
                <a class="proudct-url" href="<?= $block->escapeUrl($url); ?>">
                    <?= $block->escapeHtml(__('Leave a review')); ?>
                </a>
            </div>
        </td>

        <?php if ($i++ % 4 == 3 && $mode == 'grid') : ?>
            </tr><tr>
        <?php endif; ?>
    <?php endforeach;?>
    <?php if ($i > 0) : ?>
        </table>
    <?php endif;?>
<?php endif;

