<?php
/*
Template Name: Login Page
*/
get_header();
?>
<aside class="sidebar-left">
    <nav class="menu table-contents__menu">
        <button class="button table-contents-menu__button">
            <?php pll_e('Navigation'); ?>
            <?php
            $sidebar = get_field('sidebar', 'option');
            $icon = $sidebar['icon'];
            ?>
            <img class="sidebar__arrow" src="<?php echo esc_url($icon['url']); ?>" alt="<?php echo esc_attr($icon['alt']); ?>" title="<?php echo esc_attr($icon['title']); ?>" />
        </button>
        <ul class="table-contents-menu__list active" id="menuContent">
            <?php $block_4 = get_field('block_4');
            $i = 0;
            foreach ($block_4 as $row) :
                $i++;
                $title = $row['title'];
            ?>
                <li>
                    <a href="#content-<?php echo $i; ?>"><?php echo esc_html($title); ?></a>
                </li>
            <?php endforeach; ?>

            <?php $faq_section = get_field('faq_section');
            $title = $faq_section['title']; ?>
            <li><a href="#10"><?php echo esc_html($title); ?></a></li>
        </ul>
    </nav>
</aside>
<?php
$block_1 = get_field('block_1');
$bg_image = $block_1['bg_image'];
$title = $block_1['title'];
$text = $block_1['text'];
?>
<section class="banner banner__bonus">
    <div class="background banner__background banner-bonus__background">
        <img
            src="<?php echo esc_url($bg_image['url']); ?>"
            alt="<?php echo esc_attr($bg_image['alt']); ?>"
            title="<?php echo esc_attr($bg_image['title']); ?>" />
    </div>
    <div class="banner__wrap banner-bonus__wrap">
        <div class="banner__content">
            <?php if (function_exists('kama_breadcrumbs')) kama_breadcrumbs(' '); ?>
            <h1 class="title general banner__title"><?php echo $title; ?></h1>
            <p class="banner__text">
                <?php echo $text; ?>
            </p>
            <a href="<?php echo esc_url($ref_link); ?>" class="button banner__button"><?php pll_e('Register now'); ?></a>
        </div>
    </div>
</section>
<main class="main">

    <?php $block_2 = get_field('block_2');
    $content = $block_2['content']; ?>
    <section class="content article">
        <?php echo $content; ?>
    </section>

    <?php
    $block_3 = get_field('block_3');
    $bg_image = $block_3['bg_image'];
    $title = $block_3['title'];
    $icon_eye = $block_3['icon_eye'];
    ?>
    <section class="login">
        <div class="login__content">
            <h2 class="title high login__title"><?php echo esc_html($title); ?></h2>
            <form class="login__form">
                <div class="login-input__group">
                    <p><?php pll_e('Email'); ?></p>
                    <input type="email" placeholder="<?php pll_e('Email'); ?>" required />
                </div>
                <div class="login-input__group">
                    <p><?php pll_e('Password'); ?></p>
                    <input
                        type="password"
                        placeholder="<?php pll_e('Password'); ?>"
                        id="passwordField"
                        required />
                    <div class="toggle-password" onclick="togglePassword()">
                        <img width="24" src="<?php echo esc_url($icon_eye['url']); ?>" alt="<?php echo esc_attr($icon_eye['alt']); ?>" title="<?php echo esc_attr($icon_eye['title']); ?>">
                    </div>
                </div>
                <div class="login-forgot__password">
                    <a href="<?php echo esc_url($ref_link); ?>"><?php pll_e('Forgot password?'); ?></a>
                </div>
                <a href="<?php echo esc_url($ref_link); ?>" class="button login__button">
                    <?php pll_e('Log in'); ?>
                </a>
            </form>
        </div>
        <div class="image login__image">
            <img src="<?php echo esc_url($bg_image['url']); ?>" alt="<?php echo esc_attr($bg_image['alt']); ?>" title="<?php echo esc_attr($bg_image['title']); ?>">
        </div>
    </section>
    
    <?php
    $block_4 = get_field('block_4');
    $total = count($block_4);
    $i = 0;
    foreach ($block_4 as $row) :
        $i++;
        $title = $row['title'];
        $content = $row['content'];
    ?>
        <article class="content article description" id=" content-<?php echo esc_attr($i); ?>">
            <h2 class="title high features__title"><?php echo esc_html($title); ?></h2>
            <?php echo $content; ?>
            <?php if ($i % 2 === 0):
            ?>
                <a href="<?php echo esc_url($ref_link); ?>" class="button article__button">
                    <?php pll_e('Get bonus'); ?>
                </a>
            <?php endif; ?>
        </article>
    <?php endforeach; ?>

    <?php
    $faq_section = get_field('faq_section');
    $title = $faq_section['title'];
    $faq = $faq_section['faq'];
    if ($faq_section) :
    ?>
        <section class="faq" id="10">
            <h2 class="title high features__title"><?php echo esc_html($title); ?></h2>
            <ul class="faq__list">

                <?php
                $i = 0;
                foreach ($faq as $row) :
                    $i++;
                    $title = $row['title'];
                    $text = $row['text'];
                ?>
                    <li class="faq__item">
                        <button data-tab="tab-<?php echo ($i); ?>" class="faq__question">
                            <?php echo ($title); ?>
                            <div class="image faq-question__image">
                                <?php $faq_icon = get_field('faq_icon', "option"); ?>
                                <img
                                    src="<?php echo esc_url($faq_icon['url']); ?>"
                                    alt="<?php echo esc_attr($faq_icon['alt']); ?>"
                                    title="<?php echo esc_attr($faq_icon['title']); ?>" />
                            </div>
                        </button>
                        <div id="tab-<?php echo ($i); ?>" class="faq__answer">
                            <p>
                                <?php echo esc_html($text); ?>
                            </p>
                        </div>
                    </li>
                <?php endforeach; ?>
            </ul>
        </section>
    <?php endif; ?>
</main>
</div>
<?php
get_footer();
