<?php

use Tech360\Utils as Utils;

$has_advanced_settings = get_field( 'enable_advanced_settings' ) && ( get_field( 'css_classes' ) || get_field( 'css_id' ) );

if( $has_advanced_settings ) {
	if( get_field( 'css_id' ) ) {
		$adv_id = Utils::sluggify( Utils::trim_all( get_field( 'css_id' ) ) );
	} else {
		$adv_id = 'service-' . get_the_ID();
	}
?>

<div id="<?php echo $adv_id ?>" class="<?php echo Utils::trim_all( get_field( 'css_classes' ) ) ?>">

<?php
}
?>
<div class="header-image position-relative" style="<?php Utils::_header_style( get_the_ID() ) ?>">
	<div class="container position-relative z-index-1">
		<div class="row">
			<div class="col-md-6">
				<h1 class="text-light"><?php the_title() ?></h1>
			</div>
		</div>
	</div>
<?php
if( get_field( 'header_overlay_opacity' ) ) {
	$overlay_style = [ 'background-color: #000' ];
	$overlay_style[] = sprintf( 'opacity: %s', ( intval( get_field( 'header_overlay_opacity' ) ) / 100 ) );
?>
	<span class="bg-overlay" style="<?php echo implode( '; ', $overlay_style ) ?>"></span>
<?php
}
?>
</div>

<div id="page-main-content" class="container py-5">
	<div class="row">
		<div class="col-md-8">
			<?php the_content() ?>
		</div>
		<div class="col-md-4 mt-4 mt-md-0">
			<?php
			if( has_post_thumbnail() ) {
			?>
			<div class="side-widget">
				<?php the_post_thumbnail( 'post-thumbnail', [ 'class' => 'img-fluid img-border' ] ) ?>
			</div>
			<?php
			}
			?>
			<div class="side-widget">
				<h4><?php esc_html_e( 'Browse services', 'tech360' ) ?></h4>
				<div class="side-menu-wrapper mt-3">
					<?php Utils::render_menu( 'service', [ 'active' => get_the_ID() ] ) ?>
				</div>
			</div>
		</div>
	</div>
</div>

<?php
if( $has_advanced_settings ) {
?>
</div>
<?php
}
?>

<div class="has-bg py-5">
	<div class="container">
		<div class="row">
			<div class="col-md-8 offset-md-2 text-center">
				<h2 class="section-title"><?php esc_html_e( 'Explore our other services', 'tech360' ) ?></h2>
			</div>
		</div>
	</div>
	<div class="container container-wide mt-4">
		<?php echo do_shortcode( sprintf( '[services-slider exclude=%s]', get_the_ID() ) ); ?>
	</div>
</div>
