<?php get_header(); ?>
<?php
    
    thebuilders_ninzio_global_variables();

    $nz_shop_layout         = (isset($GLOBALS['thebuilders_ninzio']['shop-layout']) && !empty($GLOBALS['thebuilders_ninzio']['shop-layout'])) ? $GLOBALS['thebuilders_ninzio']['shop-layout'] : 'medium';
    $nz_shop_sidebar        = ($GLOBALS['thebuilders_ninzio']['shop-sidebar']) ? $GLOBALS['thebuilders_ninzio']['shop-sidebar'] : "none";
    $nz_shop_sidebar_single = ($GLOBALS['thebuilders_ninzio']['shop-sidebar-single']) ? $GLOBALS['thebuilders_ninzio']['shop-sidebar-single'] : "none";
    $nz_shop_rp             = ($GLOBALS['thebuilders_ninzio']['shop-rp'] && $GLOBALS['thebuilders_ninzio']['shop-rp'] == 1) ? "true" : "false";
    $nz_shop_rpn            = ($GLOBALS['thebuilders_ninzio']['shop-rpn']) ? $GLOBALS['thebuilders_ninzio']['shop-rpn'] : 3;

    $nz_rh_version      = (isset($GLOBALS['thebuilders_ninzio']['rh-version']) && !empty($GLOBALS['thebuilders_ninzio']['rh-version'])) ? $GLOBALS['thebuilders_ninzio']['rh-version'] : 'version1'; 
    $nz_header_version  = (isset($GLOBALS['thebuilders_ninzio']['header-version']) && !empty($GLOBALS['thebuilders_ninzio']['header-version'])) ? $GLOBALS['thebuilders_ninzio']['header-version'] : 'version1';

    $styles             = "";
    $styles_fp          = "";

    $styles_title       = "";
    $styles_breadcrumbs = "";

    $nz_shop_title             = (isset( $GLOBALS['thebuilders_ninzio']['shop-title']) && !empty($GLOBALS['thebuilders_ninzio']['shop-title'])) ? esc_attr($GLOBALS['thebuilders_ninzio']["shop-title"]) : "";
    $nz_text_color             = (isset( $GLOBALS['thebuilders_ninzio']['shop-text-color']) && !empty($GLOBALS['thebuilders_ninzio']['shop-text-color'])) ? $GLOBALS['thebuilders_ninzio']["shop-text-color"] : "";
    $nz_back_color             = (isset( $GLOBALS['thebuilders_ninzio']['shop-back']['background-color']) && !empty($GLOBALS['thebuilders_ninzio']['shop-back']['background-color'])) ? $GLOBALS['thebuilders_ninzio']["shop-back"]['background-color'] : "#f7f7f7";
    $nz_back_img               = (isset( $GLOBALS['thebuilders_ninzio']['shop-back']['background-image']) && !empty($GLOBALS['thebuilders_ninzio']['shop-back']['background-image'])) ? $GLOBALS['thebuilders_ninzio']['shop-back']["background-image"] : "";
    $nz_back_img_repeat        = (isset( $GLOBALS['thebuilders_ninzio']['shop-back']['background-repeat']) && !empty($GLOBALS['thebuilders_ninzio']['shop-back']['background-repeat'])) ? $GLOBALS['thebuilders_ninzio']['shop-back']['background-repeat'] : "no-repeat";
    $nz_back_img_position      = (isset( $GLOBALS['thebuilders_ninzio']['shop-back']['background-position']) && !empty($GLOBALS['thebuilders_ninzio']['shop-back']['background-position'])) ? $GLOBALS['thebuilders_ninzio']['shop-back']['background-position'] : "left top";
    $nz_back_img_attachment    = (isset( $GLOBALS['thebuilders_ninzio']['shop-back']['background-attachment']) && !empty($GLOBALS['thebuilders_ninzio']['shop-back']['background-attachment'])) ? $GLOBALS['thebuilders_ninzio']['shop-back']['background-attachment'] : "scroll";
    $nz_back_img_size          = (isset( $GLOBALS['thebuilders_ninzio']['shop-back']['background-size']) && !empty($GLOBALS['thebuilders_ninzio']['shop-back']['background-size'])) ? $GLOBALS['thebuilders_ninzio']['shop-back']['background-size'] : "auto";
    $nz_breadcrumbs_text_color = (isset( $GLOBALS['thebuilders_ninzio']['shop-breadcrumbs-text-color']) && !empty($GLOBALS['thebuilders_ninzio']['shop-breadcrumbs-text-color'])) ? $GLOBALS['thebuilders_ninzio']["shop-breadcrumbs-text-color"] : "#777777";
    $nz_shop_text_border_color = (isset( $GLOBALS['thebuilders_ninzio']['shop-text-border-color']['color']) && !empty($GLOBALS['thebuilders_ninzio']['shop-text-border-color']['color'])) ? thebuilders_ninzio_hex_to_rgba($GLOBALS['thebuilders_ninzio']["shop-text-border-color"]['color'],$GLOBALS['thebuilders_ninzio']["shop-text-border-color"]['alpha']) : "";
    $nz_parallax               = (isset( $GLOBALS['thebuilders_ninzio']['shop-parallax']) && $GLOBALS['thebuilders_ninzio']['shop-parallax'] == 1) ? "true" : "false";

    if (!empty($nz_back_color)) {$styles .= 'background-color:'.$nz_back_color.';';}
    if (!empty($nz_text_color)) {$styles .= 'color:'.$nz_text_color.';';}
    if (!empty($nz_back_img)) {

        if ($nz_parallax != "true" && $nz_back_img_attachment != "fixed") {
            $styles .= 'background-image:url('.$nz_back_img.');';
            $styles .= 'background-repeat:'.$nz_back_img_repeat.';';
            $styles .= 'background-position:'.$nz_back_img_position.';';
            if ($nz_back_img_size == "cover") {$styles .= '-webkit-background-size: cover;-moz-background-size: cover;background-size: cover;';}
        }

        if ($nz_parallax == "true" || $nz_back_img_attachment == "fixed") {

            $nz_back_img_repeat     = "no-repeat";
            $nz_back_img_size       = "cover";

            $styles_fp .= 'background-image:url('.$nz_back_img.');';
            $styles_fp .= 'background-repeat:'.$nz_back_img_repeat.';';
            $styles_fp .= 'background-position:'.$nz_back_img_position.';';
        }

        if ($nz_parallax == "true") {$nz_back_img_attachment = "scroll";}

    }

    if (!empty($nz_breadcrumbs_text_color)) {
        $styles_breadcrumbs .= 'color:'.$nz_breadcrumbs_text_color.';';
    }

    if ($nz_rh_version == "version2") {

        if (!empty($nz_shop_text_border_color)) {
            $styles_title .= 'box-shadow:inset 0 0 0 3px '.$nz_shop_text_border_color.';';
        }

    }

?>
<?php if ($nz_rh_version != "none"): ?>
    <header class="rich-header page-header <?php echo esc_attr($nz_rh_version); ?>" data-parallax="<?php echo esc_attr($nz_parallax); ?>" style="<?php echo esc_attr($styles); ?>">
        <?php if ($nz_parallax == "true"): ?>
            <div class="parallax-container" style="<?php echo esc_attr($styles_fp); ?>">&nbsp;</div>
        <?php endif ?>
        <?php if ($nz_back_img_attachment == "fixed"): ?>
            <div class="fixed-container" style="<?php echo esc_attr($styles_fp); ?>">&nbsp;</div>
        <?php endif ?>
        <div class="container nz-clearfix">

            <?php if ($nz_rh_version == "version1"): ?>
                <div class="rh-content">
                    <?php if (isset($GLOBALS['thebuilders_ninzio']['shop-title']) && !empty($GLOBALS['thebuilders_ninzio']['shop-title'])): ?>
                        <h1 style="<?php echo esc_attr($styles_title); ?>"><?php echo esc_attr($GLOBALS['thebuilders_ninzio']['shop-title']); ?></h1>
                    <?php else: ?>
                        <h1 style="<?php echo esc_attr($styles_title); ?>"><?php echo esc_html__("Archive", 'thebuilders'); ?></h1>
                    <?php endif ?>
                    <div style="<?php echo esc_attr($styles_breadcrumbs); ?>" class="nz-breadcrumbs nz-clearfix"><?php thebuilders_ninzio_breadcrumbs(); ?></div>
                </div>
            <?php elseif ($nz_rh_version == "version2"): ?>
                <div class="rh-content">
                    <?php if (isset($GLOBALS['thebuilders_ninzio']['shop-title']) && !empty($GLOBALS['thebuilders_ninzio']['shop-title'])): ?>
                        <h1 style="<?php echo esc_attr($styles_title); ?>"><?php echo esc_attr($GLOBALS['thebuilders_ninzio']['shop-title']); ?></h1>
                    <?php else: ?>
                        <h1 style="<?php echo esc_attr($styles_title); ?>"><?php echo esc_html__("Archive", 'thebuilders'); ?></h1>
                    <?php endif ?>
                </div>
            <?php endif ?>
        </div>
    </header>
<?php endif ?>
<div class="shop-layout-wrap lazy <?php echo esc_attr($nz_shop_layout); ?>" id="nz-target">
	<?php if(is_shop() || is_product_category() || is_product_tag()): ?>
		<div class="loop">
			<div class="container">
				<section class="content lazy shop-layout nz-clearfix">
					<?php if($nz_shop_sidebar == "left"): ?>

						<aside class="sidebar">
							<?php get_sidebar('shop'); ?>
						</aside>

						<section class="main-content right">
							<?php woocommerce_content(); ?>
						</section>

					<?php elseif ($nz_shop_sidebar == "right"): ?>

						<section class="main-content left">
							<?php woocommerce_content(); ?>
						</section>

						<aside class="sidebar">
							<?php get_sidebar('shop'); ?>
						</aside>

					<?php else: ?>
						<?php woocommerce_content(); ?>
					<?php endif; ?>
				</section>
				
			</div>
		</div>
	<?php endif; ?>
	<?php if (is_product()): ?>
        <?php
            $prev_post = get_adjacent_post(false, '', true);
            $next_post = get_adjacent_post(false, '', false);   
        ?>
        <div class="post-single-navigation nz-clearfix">
            <?php if(!empty($prev_post)) {echo '<a rel="prev" href="' . get_permalink($prev_post->ID) . '" title="' . $prev_post->post_title . '"></a>'; } ?>
            <?php if(!empty($next_post)) {echo '<a rel="next" href="' . get_permalink($next_post->ID) . '" title="' . $next_post->post_title . '"></a>'; } ?>
        </div>
		<section class='content nz-clearfix' data-rp="<?php echo esc_attr($nz_shop_rp); ?>" data-rpn="<?php echo esc_attr($nz_shop_rpn); ?>">
			<div class="container">

				<?php if($nz_shop_sidebar_single == "left"): ?>
					<aside class="sidebar">
						<?php get_sidebar('shop-single'); ?>
					</aside>
					<section class="main-content right">
						<?php woocommerce_content(); ?>
						<?php get_template_part( '/includes/woocommerce/woocommerce_content_related_products' ); ?>
						<div class="nz-clearfix">&nbsp;</div>
						<?php get_template_part( '/includes/woocommerce-related-products' ); ?>
					</section>
				<?php elseif ($nz_shop_sidebar_single == "right"): ?>
					<section class="main-content left">
						<?php woocommerce_content(); ?>
						<?php get_template_part( '/includes/woocommerce/woocommerce_content_related_products' ); ?>
						<div class="nz-clearfix">&nbsp;</div>
						<?php get_template_part( '/includes/woocommerce-related-products' ); ?>
					</section>
					<aside class="sidebar">
						<?php get_sidebar('shop-single'); ?>
					</aside>
				<?php else: ?>
					<?php woocommerce_content(); ?>
					<div class="nz-clearfix">&nbsp;</div>
					<?php get_template_part( '/includes/woocommerce-related-products' ); ?>
				<?php endif; ?>

			</div>
		</section>
	<?php endif ?>
</div>
<?php get_footer(); ?>