<?php
/**
 * Site header.
 *
 * @package Shabnam_MuchWOW
 */

defined( 'ABSPATH' ) || exit;

$shabnam_logo_url       = function_exists( 'shabnam_framework_logo_url' ) ? shabnam_framework_logo_url() : '';
$shabnam_site_icon_url  = function_exists( 'shabnam_framework_site_icon_url' ) ? shabnam_framework_site_icon_url() : get_template_directory_uri() . '/favicon.ico';
$shabnam_theme_color    = function_exists( 'shabnam_get_setting' ) ? shabnam_get_setting( 'secondary_color', '#FFD200' ) : '#FFD200';
$shabnam_sticky_header  = function_exists( 'shabnam_get_setting' ) ? (bool) shabnam_get_setting( 'sticky_header', true ) : true;
$shabnam_header_blur    = function_exists( 'shabnam_get_setting' ) ? (bool) shabnam_get_setting( 'header_blur', true ) : true;
$shabnam_cookie_notice  = function_exists( 'shabnam_get_setting' ) ? (bool) shabnam_get_setting( 'cookie_notice', true ) : true;
$shabnam_back_to_top    = function_exists( 'shabnam_get_setting' ) ? (bool) shabnam_get_setting( 'back_to_top', true ) : true;
$shabnam_back_to_top_position = function_exists( 'shabnam_get_setting' ) ? shabnam_get_setting( 'back_to_top_position', 'right' ) : 'right';
$shabnam_back_to_top_position = in_array( $shabnam_back_to_top_position, array( 'right', 'left' ), true ) ? $shabnam_back_to_top_position : 'right';
$shabnam_show_cart      = function_exists( 'shabnam_get_setting' ) ? (bool) shabnam_get_setting( 'show_cart', true ) : true;
$shabnam_show_account   = function_exists( 'shabnam_get_setting' ) ? (bool) shabnam_get_setting( 'show_account', true ) : true;
$shabnam_style_variant  = function_exists( 'shabnam_muchwow_style_variant' ) ? shabnam_muchwow_style_variant() : 'one';
$shabnam_header_variant = 'two' === $shabnam_style_variant ? 'header-two' : 'header-three';
$shabnam_header_dark    = in_array( $shabnam_style_variant, array( 'one', 'three' ), true ) ? ' uc-dark' : '';
$shabnam_account_url    = function_exists( 'shabnam_muchwow_account_url' ) ? shabnam_muchwow_account_url() : wp_login_url();
$shabnam_header_cta_url = function_exists( 'shabnam_get_setting' ) ? shabnam_get_setting( 'header_cta_url', shabnam_contact_url() ) : shabnam_contact_url();
$shabnam_header_cta_text = function_exists( 'shabnam_get_setting' ) ? shabnam_get_setting( 'header_cta_text', 'به ما بپیوندید!' ) : 'به ما بپیوندید!';
$shabnam_mobile_logo_url = $shabnam_logo_url ? $shabnam_logo_url : shabnam_asset_uri( 'images/common/logo-mark.svg' );
?>
<!doctype html>
<html <?php language_attributes(); ?> dir="rtl">
<head>
	<meta charset="<?php bloginfo( 'charset' ); ?>">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta name="theme-color" content="<?php echo esc_attr( sanitize_hex_color( $shabnam_theme_color ) ?: '#FFD200' ); ?>">
	<link rel="icon" href="<?php echo esc_url( $shabnam_site_icon_url ); ?>">
	<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<?php wp_body_open(); ?>

<?php if ( $shabnam_cookie_notice ) : ?>
<div class="uc-gdpr-notification uc-notification min-w-1/2 uc-notification-bottom-left lg:m-2" id="uc-gdpr-notification">
	<div class="uc-notification-message vstack lg:hstack items-end gap-2 lg:gap-4 lg:p-3 bg-white text-dark border rounded-1-5 min-w-1/2">
		<a class="uc-notification-close text-dark" data-uc-close="" id="uc-close-gdpr-notification"></a>
		<div class="vstack">
			<h2 class="h5 ft-primary fw-bold -ls-1 m-0 text-dark"><?php esc_html_e( 'مدیریت حریم خصوصی', 'shabnam-muchwow' ); ?></h2>
			<p class="fs-6 mt-1"><?php esc_html_e( 'برای ارائه تجربه بهتر، این وب‌سایت از کوکی‌ها استفاده می‌کند. با ادامه استفاده از سایت، با سیاست‌های سایت موافقت می‌کنید.', 'shabnam-muchwow' ); ?></p>
		</div>
		<button class="btn btn-sm btn-primary px-2" id="uc-accept-gdpr"><?php esc_html_e( 'می‌پذیرم', 'shabnam-muchwow' ); ?></button>
	</div>
</div>
<?php endif; ?>

<div data-uc-offcanvas="overlay: true;" id="uc-menu-panel">
	<div class="uc-offcanvas-bar m-1 rounded-2 border border-2 border-black contrast-shadow-md bg-secondary-200 text-dark dark:bg-gray-900 dark:text-white">
		<header class="uc-offcanvas-header hstack justify-between items-center pb-2">
			<div class="uc-logo">
				<a class="h5 text-none text-gray-900 dark:text-white" href="<?php echo esc_url( home_url( '/' ) ); ?>">
					<img alt="<?php echo esc_attr( get_bloginfo( 'name' ) ); ?>" class="w-40px" src="<?php echo esc_url( $shabnam_mobile_logo_url ); ?>">
				</a>
			</div>
			<button class="uc-offcanvas-close rtl:end-auto rtl:start-0 m-1 mt-2 p-0 btn border-0 dark:text-white dark:text-opacity-50 hover:text-primary hover:rotate-90 duration-150 transition-all" type="button">
				<img alt="<?php esc_attr_e( 'بستن', 'shabnam-muchwow' ); ?>" class="icon icon-3" data-uc-svg="" src="<?php echo esc_url( shabnam_asset_uri( 'images/icons/close.svg' ) ); ?>">
			</button>
		</header>
		<div class="panel">
			<?php
			wp_nav_menu(
				array(
					'theme_location' => 'primary',
					'container'      => false,
					'menu_class'     => 'nav-y gap-narrow fw-medium fs-6',
					'fallback_cb'    => 'shabnam_mobile_menu_fallback',
					'depth'          => 2,
				)
			);
			?>
		</div>
	</div>
</div>

<?php if ( $shabnam_back_to_top ) : ?>
<div class="backtotop-wrap shabnam-backtotop shabnam-backtotop--<?php echo esc_attr( $shabnam_back_to_top_position ); ?> position-fixed bottom-0 z-99 m-2 vstack">
	<a class="btn btn-sm p-0 bg-yellow text-black border border-2 border-black contrast-shadow-sm w-48px h-48px rounded-circle" data-uc-backtotop="" href="#top">
		<img alt="<?php esc_attr_e( 'بازگشت به بالا', 'shabnam-muchwow' ); ?>" class="icon icon-3" data-uc-svg="" src="<?php echo esc_url( shabnam_asset_uri( 'images/icons/chevron-up.svg' ) ); ?>">
	</a>
</div>
<?php endif; ?>

<header class="uc-header <?php echo esc_attr( $shabnam_header_variant ); ?> uc-navbar-sticky-wrap z-999<?php echo esc_attr( $shabnam_header_dark ); ?><?php echo $shabnam_header_blur ? ' shabnam-header-blur' : ' shabnam-header-flat'; ?>"<?php if ( $shabnam_sticky_header ) : ?> data-uc-sticky="start: 100vh; animation: uc-animation-slide-top; sel-target: .uc-navbar-container; cls-active: uc-navbar-sticky; cls-inactive: uc-navbar-transparent; end: !*;"<?php endif; ?>>
	<nav class="uc-navbar-container bg-transparent mt-3 xl:mt-4 uc-navbar-float ft-tertiary z-1" data-anime="translateY: [-40, 0]; opacity: [0, 1]; duration: 750; delay: 0;">
		<div class="uc-navbar-main" style="--uc-nav-height: 100px">
			<div class="container">
				<div class="uc-navbar min-h-64px lg:min-h-80px xl:min-h-100px ps-2 pe-1 lg:px-4 bg-white bg-opacity-10 rounded-2 lg:rounded-3 border border-1 border-black backdrop-2" data-uc-navbar="animation: uc-animation-slide-top-small; duration: 150;">
					<div class="uc-navbar-left">
						<div class="uc-logo">
							<a class="panel text-none shabnam-site-logo" href="<?php echo esc_url( home_url( '/' ) ); ?>">
								<?php if ( $shabnam_logo_url ) : ?>
									<img alt="<?php echo esc_attr( get_bloginfo( 'name' ) ); ?>" src="<?php echo esc_url( $shabnam_logo_url ); ?>">
								<?php else : ?>
									<span class="h5 xl:h4 m-0 text-white text-uppercase"><?php bloginfo( 'name' ); ?></span>
								<?php endif; ?>
							</a>
						</div>
					</div>
					<div class="uc-navbar-center">
						<?php
						wp_nav_menu(
							array(
								'theme_location' => 'primary',
								'container'      => false,
								'menu_class'     => 'uc-navbar-nav fs-4 gap-3 lg:gap-4 d-none lg:d-flex fw-semibold text-white',
								'fallback_cb'    => 'shabnam_primary_menu_fallback',
								'depth'          => 2,
							)
						);
						?>
					</div>
					<div class="uc-navbar-right">
						<?php if ( $shabnam_show_account ) : ?>
							<a class="shabnam-account-link d-inline-flex items-center justify-center me-1 lg:me-2" href="<?php echo esc_url( $shabnam_account_url ); ?>" aria-label="<?php echo esc_attr( is_user_logged_in() ? __( 'حساب کاربری', 'shabnam-muchwow' ) : __( 'ورود به حساب', 'shabnam-muchwow' ) ); ?>">
								<svg viewBox="0 0 24 24" width="22" height="22" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><circle cx="12" cy="8" r="3.4" stroke="currentColor" stroke-width="1.8"/><path d="M5.5 19c.55-3.55 2.7-5.35 6.5-5.35S17.95 15.45 18.5 19" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/></svg>
								<span class="shabnam-account-dot" aria-hidden="true"></span>
							</a>
						<?php endif; ?>
						<?php if ( class_exists( 'WooCommerce' ) && $shabnam_show_cart ) : ?>
							<div class="shabnam-cart-shell me-1 lg:me-2" data-shabnam-cart-shell>
								<button class="shabnam-cart-link d-inline-flex items-center justify-center text-white" data-shabnam-cart type="button" aria-expanded="false" aria-controls="shabnam-header-mini-cart" aria-label="<?php esc_attr_e( 'نمایش سبد خرید', 'shabnam-muchwow' ); ?>">
									<span class="shabnam-cart-icon" aria-hidden="true"><svg viewBox="0 0 24 24" width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M3.5 4.5h2l1.45 9.12a2 2 0 0 0 1.98 1.68h7.94a2 2 0 0 0 1.96-1.62L20 7.5H6.05" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/><circle cx="9.2" cy="19" r="1.25" fill="currentColor"/><circle cx="17.2" cy="19" r="1.25" fill="currentColor"/></svg></span>
									<span class="shabnam-cart-count"><?php echo esc_html( WC()->cart ? WC()->cart->get_cart_contents_count() : 0 ); ?></span>
								</button>
								<div class="shabnam-cart-dropdown" id="shabnam-header-mini-cart" data-shabnam-cart-dropdown aria-hidden="true">
									<div class="shabnam-cart-dropdown-head"><strong><?php esc_html_e( 'سبد خرید شما', 'shabnam-muchwow' ); ?></strong><a href="<?php echo esc_url( wc_get_cart_url() ); ?>"><?php esc_html_e( 'مشاهده سبد', 'shabnam-muchwow' ); ?></a></div>
									<div class="shabnam-cart-dropdown-inner"><?php woocommerce_mini_cart(); ?></div>
								</div>
							</div>
						<?php endif; ?>
						<a class="shabnam-header-cta btn btn-sm xl:btn-md border border-2 border-black bg-gradient-45n from-secondary to-tertiary contrast-shadow -rotate-2 hover:rotate-0 d-none lg:d-inline-flex" href="<?php echo esc_url( $shabnam_header_cta_url ); ?>" style="--shadowColor: var(--color-secondary)">
							<span class="text-black"><?php echo esc_html( $shabnam_header_cta_text ); ?></span>
							<span class="fs-5 mb-narrow">💪</span>
						</a>
						<a class="btn btn-md btn-secondary w-48px h-48px p-0 border border-2 border-black contrast-shadow-sm d-inline-flex lg:d-none" data-uc-toggle="" href="#uc-menu-panel">
							<img alt="<?php esc_attr_e( 'منو', 'shabnam-muchwow' ); ?>" class="icon icon-3" data-uc-svg="" src="<?php echo esc_url( shabnam_asset_uri( 'images/icons/menu.svg' ) ); ?>">
						</a>
					</div>
				</div>
			</div>
		</div>
	</nav>
</header>

<div id="shabnam-spa-content" class="shabnam-spa-content" data-shabnam-spa-content>
