<?php get_header();
if (!function_exists('elementor_theme_do_location') || !elementor_theme_do_location('single')):?>
    <main>
        <?php if (have_posts()): ?><?php while (have_posts()): the_post(); ?>

            <div class="mt-4 mb-5">
                <div class="custom-container">

                    <!-- breadcrumb -->
                    <?php banta_breadcrumb(); ?>


                    <!-- page head -->
                    <?php $thumbnailUrl = get_the_post_thumbnail_url(); ?>
                    <div class="single-page-head" style="background-image: url(<?php echo $thumbnailUrl; ?>)">
                        <div class="single-page-head-content">
                            <h1 class="single-title"><?php the_title(); ?></h1>

                            <!-- details -->
                            <div class="single-page-meta-box">

                                <?php $showPostAuthor = get_option(TEXT_DOMAIN . '_show_post_author'); ?>

                                <?php if ($showPostAuthor != 'false'): ?>
                                    <div class="single-post-meta-item">
                                        <i class="iconly-Profile icbr me-1"></i>
                                        <span><?php echo get_the_author(); ?></span>
                                    </div>
                                <?php endif; ?>

                                <div class="single-post-meta-item">
                                    <i class="iconly-Category icbr me-1"></i>
                                    <?php
                                    $category = get_the_category();
                                    $firstCategory = $category[0];
                                    ?>
                                    <a href="<?php echo get_term_link($firstCategory->term_id, 'category'); ?>"><?php echo $firstCategory->cat_name; ?></a>
                                </div>

                            </div>
                        </div>
                    </div>


                    <div class="row">

                        <?php $showPostSidebar = get_option(TEXT_DOMAIN . '_show_post_sidebar'); ?>

                        <!-- content -->
                        <div class="<?php echo ($showPostSidebar != 'false') ? 'col-lg-9' : 'col-12'; ?> mb-4">
                            <div class="single-box single-page-content-box">

                                <div class="single-page-content-right">
                                    <!-- share -->
                                    <?php $shareUrl = get_the_permalink();
                                    $shareTitle = get_the_title(); ?>
                                    <div class="post-share-box-icons">
                                        <a href="https://api.whatsapp.com/send?text=<?php echo $shareUrl ?>"
                                           class="social-icon-link" rel="nofollow" target="_blank"
                                           data-bs-toggle="tooltip" data-bs-placement="left"
                                           title="<?php _e('Share in Whatsapp', TEXT_DOMAIN); ?>"><i
                                                    class="icon-whatsapp"></i></a>
                                        <a href="https://t.me/share/url?url=<?php echo $shareUrl ?>"
                                           class="social-icon-link" rel="nofollow" target="_blank"
                                           data-bs-toggle="tooltip" data-bs-placement="left"
                                           title="<?php _e('Share in Telegram', TEXT_DOMAIN); ?>"><i
                                                    class="icon-telegram"></i></a>
                                        <a href="https://twitter.com/intent/tweet?url=<?php echo $shareUrl ?>&text=<?php echo $shareTitle ?>"
                                           class="social-icon-link" rel="nofollow" target="_blank"
                                           data-bs-toggle="tooltip" data-bs-placement="left"
                                           title="<?php _e('Share in X', TEXT_DOMAIN); ?>"><i class="icon-x"></i></a>
                                        <a href="https://pinterest.com/pin/create/button/?url=<?php echo $shareUrl ?>&media=<?php echo $thumbnailUrl; ?>&description=<?php echo $shareTitle ?>"
                                           class="social-icon-link" rel="nofollow" target="_blank"
                                           data-bs-toggle="tooltip" data-bs-placement="left"
                                           title="<?php _e('Share in Pinterest', TEXT_DOMAIN); ?>"><i
                                                    class="icon-pinterest"></i></a>
                                        <a href="https://www.linkedin.com/shareArticle?mini=true&url=<?php echo $shareUrl ?>&title=<?php echo $shareTitle ?>"
                                           class="social-icon-link" rel="nofollow" target="_blank"
                                           data-bs-toggle="tooltip" data-bs-placement="left"
                                           title="<?php _e('Share in Linkedin', TEXT_DOMAIN); ?>"><i
                                                    class="icon-linkedin"></i></a>
                                        <a href="https://www.facebook.com/sharer/sharer.php?u=<?php echo $shareUrl ?>"
                                           class="social-icon-link" rel="nofollow" target="_blank"
                                           data-bs-toggle="tooltip" data-bs-placement="left"
                                           title="<?php _e('Share in Facebook', TEXT_DOMAIN); ?>"><i
                                                    class="icon-facebook"></i></a>
                                    </div>

                                    <div class="horizontal-line mx-auto my-4 d-none d-lg-block"></div>

                                    <div class="flex-row flex-lg-column d-flex mb-lg-4 mt-4 mt-lg-0 w-100 justify-content-center align-items-center">
                                        <div class="post-date">
                                            <span class="day"><?php banta_date('j', get_the_date('y-m-d')); ?></span>
                                            <span class="month"><?php banta_date('F', get_the_date('y-m-d')); ?></span>
                                            <span class="year"><?php banta_date('Y', get_the_date('y-m-d')); ?></span>
                                        </div>

                                        <?php $shopPostReadingTime = get_option(TEXT_DOMAIN . '_show_post_reading_time');
                                        $readingTime = get_post_meta(get_the_ID(), TEXT_DOMAIN . '_reading-time', true);
                                        ?>
                                        <?php if ($shopPostReadingTime != 'false' && !empty($readingTime)): ?>
                                            <div class="post-date post-reading-time">
                                                <span class="day"><?php echo $readingTime ?></span>
                                                <span class="month"><?php _e('Minutes', TEXT_DOMAIN); ?></span>
                                                <span class="year"><?php _e('Reading', TEXT_DOMAIN); ?></span>
                                            </div>
                                        <?php endif; ?>

                                    </div>
                                </div>


                                <div class="single-page-content-left <?php echo has_post_thumbnail() ? '' : 'single-page-content-no-thumb'; ?>">
                                    <!-- thumbnail -->
                                    <?php if (has_post_thumbnail()): ?>
                                        <div class="single-image">
                                            <?php the_post_thumbnail(); ?>
                                        </div>
                                    <?php endif; ?>

                                    <!-- excerpt -->
                                    <?php if (has_excerpt()): ?>
                                        <div class="single-excerpt">
                                            <svg width="800px" height="800px" viewBox="0 0 24 24" fill="none"
                                                 xmlns="http://www.w3.org/2000/svg">
                                                <path d="M2 12.3501H7.79999C9.32999 12.3501 10.38 13.5101 10.38 14.9301V18.1501C10.38 19.5701 9.32999 20.7301 7.79999 20.7301H4.58002C3.16002 20.7301 2 19.5701 2 18.1501V12.3501"
                                                      stroke="#E8A20D" stroke-width="1.5" stroke-linecap="round"
                                                      stroke-linejoin="round"/>
                                                <path d="M2 12.35C2 6.29998 3.13003 5.30003 6.53003 3.28003"
                                                      stroke="#E8A20D" stroke-width="1.5" stroke-linecap="round"
                                                      stroke-linejoin="round"/>
                                                <path d="M13.6299 12.3501H19.4299C20.9599 12.3501 22.0099 13.5101 22.0099 14.9301V18.1501C22.0099 19.5701 20.9599 20.7301 19.4299 20.7301H16.2099C14.7899 20.7301 13.6299 19.5701 13.6299 18.1501V12.3501"
                                                      stroke="#E8A20D" stroke-width="1.5" stroke-linecap="round"
                                                      stroke-linejoin="round"/>
                                                <path d="M13.6299 12.35C13.6299 6.29998 14.7599 5.30003 18.1599 3.28003"
                                                      stroke="#E8A20D" stroke-width="1.5" stroke-linecap="round"
                                                      stroke-linejoin="round"/>
                                            </svg>
                                            <?php echo get_the_excerpt(); ?>
                                        </div>
                                    <?php endif; ?>

                                    <!-- content -->
                                    <div class="html-content">
                                        <?php the_content(); ?>
                                    </div>

                                    <?php if (comments_open()) comments_template(); ?>
                                </div>


                            </div>
                        </div>


                        <!-- sidebar -->
                        <?php if ($showPostSidebar != 'false'): ?>
                            <div class="col-lg-3">
                                <div class="single-sidebar">

                                    <!-- widgets -->
                                    <?php if (is_rtl()): ?>
                                        <?php if (is_active_sidebar('post_sidebar_widget_location')): ?>
                                            <div class="single-box p-4 footer-widget-container">
                                                <?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('post_sidebar_widget_location')) : ?>
                                                <?php endif; ?>
                                            </div>
                                        <?php else: ?>
                                            <div class="single-box p-4"><?php _e('No widgets have been selected for this area. ', TEXT_DOMAIN); ?></div>
                                        <?php endif; ?>
                                    <?php else: ?>
                                        <?php if (is_active_sidebar('post_sidebar_widget_location_2')): ?>
                                            <div class="single-box p-4 footer-widget-container">
                                                <?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('post_sidebar_widget_location_2')) : ?>
                                                <?php endif; ?>
                                            </div>
                                        <?php else: ?>
                                            <div class="single-box p-4"><?php _e('No widgets have been selected for this area. ', TEXT_DOMAIN); ?></div>
                                        <?php endif; ?>
                                    <?php endif; ?>


                                    <!-- related posts -->
                                    <?php
                                    global $post;
                                    $current_post_type = get_post_type($post);
                                    $args = array(
                                        'posts_per_page' => 6,
                                        'order' => 'DESC',
                                        'orderby' => 'ID',
                                        'post_type' => $current_post_type,
                                        'post__not_in' => array($post->ID)
                                    );
                                    $rel_query = new WP_Query($args); ?>
                                    <?php if ($rel_query->have_posts()) : ?>
                                        <div class="single-box p-4 mt-4 footer-widget-container">
                                            <div class="section-head-simple mb-4">
                                                <?php _e("<div class='title font-20'>Related <span class='text-primary ms-1'>Articles</span></div>", TEXT_DOMAIN); ?>
                                            </div>
                                            <?php while ($rel_query->have_posts()) :$rel_query->the_post(); ?>
                                                <?php include(TEMPLATEPATH . "/inc/loop/post-item-sm.php"); ?>
                                            <?php endwhile; ?>
                                            <?php wp_reset_query(); ?>
                                        </div>
                                    <?php endif; ?>


                                </div>
                            </div>
                        <?php endif; ?>

                    </div>


                </div>
            </div>

        <?php endwhile; ?>
        <?php endif; ?>
    </main>
<?php endif;
get_footer(); ?>