<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가

// add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨
add_stylesheet('<link rel="stylesheet" href="'.G5_SHOP_CSS_URL.'/style.css">', 0);
?>

<?php if($config['cf_kakao_js_apikey']) { ?>
<script src="https://developers.kakao.com/sdk/js/kakao.min.js"></script>
<script src="<?php echo G5_JS_URL; ?>/kakaolink.js"></script>
<script>
    // 사용할 앱의 Javascript 키를 설정해 주세요.
    Kakao.init("<?php echo $config['cf_kakao_js_apikey']; ?>");
</script>
<?php } ?>

<form name="fitem" action="<?php echo $action_url; ?>" method="post" onsubmit="return fitem_submit(this);">
<input type="hidden" name="it_id[]" value="<?php echo $it['it_id']; ?>">
<input type="hidden" name="sw_direct">
<input type="hidden" name="url">
<input type="hidden" id="mb_point_balance" value="<?php echo (int)(isset($member['mb_point']) ? $member['mb_point'] : 0); ?>">

<div id="sit_ov_wrap">
    <?php
    // 이미지(중) 썸네일
    $thumb_img = '';
    $thumb_img_w = 280; // 넓이
    $thumb_img_h = 280; // 높이
    for ($i=1; $i<=10; $i++)
    {
        if(!$it['it_img'.$i])
            continue;

        $thumb = get_it_thumbnail($it['it_img'.$i], $thumb_img_w, $thumb_img_h);

        if(!$thumb)
            continue;

        $thumb_img .= '<li>';
        $thumb_img .= '<a href="'.G5_SHOP_URL.'/largeimage.php?it_id='.$it['it_id'].'&amp;no='.$i.'" class="popup_item_image slide_img" target="_blank">'.$thumb.'</a>';
        $thumb_img .= '</li>'.PHP_EOL;
    }
    if ($thumb_img)
    {
        echo '<div id="sit_pvi">'.PHP_EOL;
        echo '<button type="button" id="sit_pvi_prev" class="sit_pvi_btn" >이전</button>'.PHP_EOL;
        echo '<button type="button" id="sit_pvi_next" class="sit_pvi_btn">다음</button>'.PHP_EOL;
        echo '<ul id="sit_pvi_slide" style="width:'.$thumb_img_w.'px;height:'.$thumb_img_h.'px">'.PHP_EOL;
        echo $thumb_img;
        echo '</ul>'.PHP_EOL;
        echo '</div>';
    }
    ?>

    <!-- 다른 상품 보기 시작 { -->
    <div id="sit_siblings">
        <?php
        if ($prev_href || $next_href) {
            $prev_title = '<i class="fa fa-caret-left" aria-hidden="true"></i> '.$prev_title;
            $next_title = $next_title.' <i class="fa fa-caret-right" aria-hidden="true"></i>';

            echo $prev_href.$prev_title.$prev_href2;
            echo $next_href.$next_title.$next_href2;
        } else {
            echo '<span class="sound_only">이 분류에 등록된 다른 상품이 없습니다.</span>';
        }
        ?>
        <a href="<?php echo G5_SHOP_URL; ?>/largeimage.php?it_id=<?php echo $it['it_id']; ?>&amp;no=1" target="_blank" class="popup_item_image "><i class="fa fa-search-plus" aria-hidden="true"></i><span class="sound_only">확대보기</span></a>
    </div>
    <!-- } 다른 상품 보기 끝 -->

    <div id="sit_star_sns">
        <?php
        $sns_title = get_text($it['it_name']).' | '.get_text($config['cf_title']);
        $sns_url  = G5_SHOP_URL.'/item.php?it_id='.$it['it_id'];

        $_is_vpn = (isset($it['it_spec_sales_type']) && $it['it_spec_sales_type'] === 'vpn-mall');
        $_vpn_grade = $_is_vpn ? strtoupper(trim((string)(isset($it['it_spec_grade']) ? $it['it_spec_grade'] : ''))) : '';
        if($_is_vpn && $_vpn_grade !== '') {
            $_grade_colors = array(
                'BASIC' => array('bg'=>'#6c757d','color'=>'#fff'),
                'PLUS'  => array('bg'=>'#0d6efd','color'=>'#fff'),
                'PRO'   => array('bg'=>'#198754','color'=>'#fff'),
                'ULTRA' => array('bg'=>'#6f42c1','color'=>'#fff'),
                'MAX'   => array('bg'=>'#dc3545','color'=>'#fff'),
            );
            $_gc = isset($_grade_colors[$_vpn_grade]) ? $_grade_colors[$_vpn_grade] : array('bg'=>'#555','color'=>'#fff');
            $_vpn_spec_os = isset($it['it_spec_os']) ? trim((string)$it['it_spec_os']) : '';
            if($_vpn_spec_os !== '') { $_os_parts=explode('-',$_vpn_spec_os); $_cat=strtoupper(trim($_os_parts[0])); if($_cat!=='') echo '<span class="vpn-category-badge" style="display:inline-block;padding:2px 10px;border-radius:0;font-size:12px;font-weight:700;letter-spacing:.5px;background:#0891b2;color:#fff;margin-right:6px;vertical-align:middle;">'.h($_cat).'</span>'; }
            echo '<span class="vpn-grade-badge" style="display:inline-block;padding:2px 10px;border-radius:0;font-size:12px;font-weight:700;letter-spacing:.5px;background:'.h($_gc['bg']).';color:'.h($_gc['color']).';margin-right:6px;vertical-align:middle;">'.h($_vpn_grade).'</span>';
            // 등급 위치 스펙트럼
            $_gspec = array('BASIC'=>'#6c757d','PLUS'=>'#0d6efd','PRO'=>'#198754','ULTRA'=>'#6f42c1','MAX'=>'#dc3545');
            echo '<span style="display:inline-flex;align-items:center;gap:2px;margin-left:4px;vertical-align:middle;">';
            echo '<span style="font-size:10px;color:#aaa;">낮음</span>';
            foreach ($_gspec as $_gn => $_gc2) {
                $_is_cur = ($_gn === $_vpn_grade);
                echo '<span style="display:inline-block;width:'.($_is_cur?'20':'12').'px;height:'.($_is_cur?'8':'5').'px;background:'.htmlspecialchars($_gc2,ENT_QUOTES).';opacity:'.($_is_cur?'1':'0.25').';vertical-align:middle;"></span>';
            }
            echo '<span style="font-size:10px;color:#dc3545;font-weight:700;">높음</span>';
            echo '</span>';
        } elseif(!$_is_vpn && ($score = get_star_image($it['it_id']))) { ?>
        <span class="sound_only">고객평점 <?php echo $score?>개</span>
        <img src="<?php echo G5_SHOP_URL; ?>/img/s_star<?php echo $score?>.png" alt="" class="sit_star" width="100"> <span class="st_bg"></span>
        <?php } ?>


         <i class="fa fa-commenting-o" aria-hidden="true"></i><span class="sound_only">리뷰</span> <?php echo $it['it_use_cnt']; ?>
        <span class="st_bg"></span> <i class="fa fa-heart-o" aria-hidden="true"></i><span class="sound_only">위시</span> <?php echo get_wishlist_count_by_item($it['it_id']); ?>
        <button type="button" class="btn_sns_share"><i class="fa fa-share-alt" aria-hidden="true"></i><span class="sound_only">sns 공유</span></button>
        <div class="sns_area">
            <?php echo get_sns_share_link('facebook', $sns_url, $sns_title, G5_MSHOP_SKIN_URL.'/img/facebook.png'); ?>
            <?php echo get_sns_share_link('twitter', $sns_url, $sns_title, G5_MSHOP_SKIN_URL.'/img/twitter.png'); ?>
            <?php echo get_sns_share_link('googleplus', $sns_url, $sns_title, G5_MSHOP_SKIN_URL.'/img/gplus.png'); ?>
            <?php echo get_sns_share_link('kakaotalk', $sns_url, $sns_title, G5_MSHOP_SKIN_URL.'/img/sns_kakao.png'); ?>
            <?php
            $href = G5_SHOP_URL.'/iteminfo.php?it_id='.$it_id;
            ?>
            <a href="javascript:popup_item_recommend('<?php echo $it['it_id']; ?>');" id="sit_btn_rec"><i class="fa fa-envelope-o" aria-hidden="true"></i><span class="sound_only">추천하기</span></a></div>
        </div>
    <script>
    $(".btn_sns_share").click(function(){
        $(".sns_area").show();
    });
    $(document).mouseup(function (e){
        var container = $(".sns_area");
        if( container.has(e.target).length === 0)
        container.hide();
    });


    </script>
    <section id="sit_ov" class="2017_renewal_itemform">
        <h2>상품간략정보 및 구매기능</h2>
        <div class="sit_ov_wr">
            <strong id="sit_title"><?php echo stripslashes($it['it_name']); ?></strong>
            <?php if($it['it_basic']) { ?><p id="sit_desc"><?php echo $it['it_basic']; ?></p><?php } ?>
            <?php if($is_orderable) { ?>
            <p id="sit_opt_info">
                상품 선택옵션 <?php echo $option_count; ?> 개, 추가옵션 <?php echo $supply_count; ?> 개
            </p>
            <?php } ?>

            <div class="sit_ov_tbl">
                <table >
                <colgroup>
                    <col class="grid_2">
                    <col>
                </colgroup>
                <tbody>
                <?php if ($it['it_maker']) { ?>
                <tr>
                    <th scope="row">제조사</th>
                    <td><?php echo $it['it_maker']; ?></td>
                </tr>
                <?php } ?>

                <?php if ($it['it_origin']) { ?>
                <tr>
                    <th scope="row">원산지</th>
                    <td><?php echo $it['it_origin']; ?></td>
                </tr>
                <?php } ?>

                <?php if ($it['it_brand']) { ?>
                <tr>
                    <th scope="row">브랜드</th>
                    <td><?php echo $it['it_brand']; ?></td>
                </tr>
                <?php } ?>
                <?php if ($it['it_model']) { ?>
                <tr>
                    <th scope="row">모델</th>
                    <td><?php echo $it['it_model']; ?></td>
                </tr>
                <?php } ?>
                <?php if (!$it['it_use']) { // 판매가능이 아닐 경우 ?>
                <tr>
                    <th scope="row">판매가격</th>
                    <td>판매중지</td>
                </tr>
                <?php } else if ($it['it_tel_inq']) { // 전화문의일 경우 ?>
                <tr>
                    <th scope="row">판매가격</th>
                    <td>전화문의</td>
                </tr>
                <?php } else { // 전화문의가 아닐 경우?>
                <?php if ($it['it_cust_price']) { // 1.00.03?>
                <tr>
                    <th scope="row">시중가격</th>
                    <td><?php echo display_price($it['it_cust_price']); ?></td>
                </tr>
                <?php } ?>

                <tr>
                    <th scope="row">판매가격</th>
                    <td>
                        <?php echo display_price(get_price($it)); ?>
                        <input type="hidden" id="it_price" value="<?php echo (int)((isset($it['pt_it']) && (string)$it['pt_it'] === '2') ? apms_item_hourly_base_price($it) : get_price($it)); ?>">
                    </td>
                </tr>
                <?php } ?>

                <?php
                /* 재고 표시하는 경우 주석 해제
                <tr>
                    <th scope="row">재고수량</th>
                    <td><?php echo number_format(get_it_stock_qty($it_id)); ?> 일</td>
                </tr>
                */
                ?>

                <?php if ($config['cf_use_point']) { // 포인트 사용한다면 ?>
                <tr>
                    <th scope="row"><label for="disp_point">포인트</label></th>
                    <td>
                        <?php
                        if($it['it_point_type'] == 2) {
                            echo '구매금액(추가옵션 제외)의 '.$it['it_point'].'%';
                        } else {
                            $it_point = get_item_point($it);
                            echo number_format($it_point).'점';
                        }
                        ?>
                    </td>
                </tr>
                <?php } ?>
                <?php
                $ct_send_cost_label = '배송비결제';

                if($it['it_sc_type'] == 1)
                    $sc_method = '무료배송';
                else {
                    if($it['it_sc_method'] == 1)
                        $sc_method = '수령후 지불';
                    else if($it['it_sc_method'] == 2) {
                        $ct_send_cost_label = '<label for="ct_send_cost">배송비결제</label>';
                        $sc_method = '<select name="ct_send_cost" id="ct_send_cost">
                                          <option value="0">주문시 결제</option>
                                          <option value="1">수령후 지불</option>
                                      </select>';
                    }
                    else
                        $sc_method = '주문시 결제';
                }
                ?>
                <tr>
                    <th><?php echo $ct_send_cost_label; ?></th>
                    <td><?php echo $sc_method; ?></td>
                </tr>
                <?php if($it['it_buy_min_qty']) { ?>
                <tr>
                    <th>최소계약일수</th>
                    <td><?php echo function_exists('apms_contract_hours_text') ? apms_contract_hours_text(apms_buy_qty_to_hours($it['it_buy_min_qty'])) : (number_format($it['it_buy_min_qty']).' 일'); ?></td>
                </tr>
                <?php } ?>
                <?php if($it['it_buy_max_qty']) { ?>
                <tr>
                    <th>최대계약일수</th>
                    <td><?php echo function_exists('apms_contract_hours_text') ? apms_contract_hours_text(apms_buy_qty_to_hours($it['it_buy_max_qty'])) : (number_format($it['it_buy_max_qty']).' 일'); ?></td>
                </tr>
                <?php } ?>
                </tbody>
                </table>
            </div>
        </div>
        <?php
        if($option_item) {
        ?>
        <section class="sit_option">
            <h3>선택옵션</h3>
            <table class="sit_op_sl">
            <colgroup>
                <col class="grid_2">
                <col>
            </colgroup>
            <tbody>
            <?php // 선택옵션
            echo $option_item;
            ?>
            </tbody>
            </table>
        </section>
        <?php
        }
        ?>

        <?php
        if($supply_item) {
        ?>
        <section class="sit_option">
            <h3>추가옵션</h3>
            <table class="sit_op_sl">
            <colgroup>
                <col class="grid_2">
                <col>
            </colgroup>
            <tbody>
            <?php // 추가옵션
            echo $supply_item;
            ?>
            </tbody>
            </table>
        </section>
        <?php
        }
        ?>

        <?php if ($it['it_use'] && !$it['it_tel_inq'] && !$is_soldout) { ?>
        <div id="sit_sel_option">
        <?php
        if(!$option_item) {
            if(!$it['it_buy_min_qty'])
                $it['it_buy_min_qty'] = 1;

            $use_contract_pricing_mobile = (isset($it['pt_it']) && (string)$it['pt_it'] === '2');

            if($use_contract_pricing_mobile) {
                $allowed_units = apms_allowed_pricing_units_from_item($it);
                $min_contract_hours = apms_buy_qty_to_hours($it['it_buy_min_qty']);
                if($min_contract_hours <= 0) {
                    $min_contract_hours = 1;
                }
                $max_contract_hours = apms_buy_qty_to_hours($it['it_buy_max_qty']);
                if($max_contract_hours <= 0) {
                    $max_contract_hours = (365 * 24);
                }
                $total_contract_hours = max(1, $min_contract_hours);
                $default_unit = apms_pricing_unit_from_day_hour((int)floor($total_contract_hours / 24), (int)($total_contract_hours % 24));
                if(empty($allowed_units[$default_unit])) {
                    $default_unit = apms_best_pricing_unit_for_hours($it, $total_contract_hours, 'hour');
                }
                $default_count = apms_pricing_count_from_day_hour((int)floor($total_contract_hours / 24), (int)($total_contract_hours % 24), $default_unit);
                $usage_deposit_price = (int)apms_usage_deposit_price_from_item($it);
                if($default_unit === 'usage') {
                    $default_count = $usage_deposit_price;
                    if($default_count < 5000) $default_count = 5000;
                    if($default_count > 1000000) $default_count = 1000000;
                }
                list($default_day_qty, $default_hour_qty) = apms_day_hour_from_pricing_unit($default_unit, $default_count);
            }
        ?>
            <ul id="sit_opt_added">
                <li class="sit_opt_list">
                    <input type="hidden" name="io_type[<?php echo $it_id; ?>][]" value="0">
                    <input type="hidden" name="io_id[<?php echo $it_id; ?>][]" value="">
                    <input type="hidden" name="io_value[<?php echo $it_id; ?>][]" value="<?php echo $it['it_name']; ?>">
                    <input type="hidden" class="io_price" value="0">
                    <input type="hidden" class="io_stock" value="<?php echo $it['it_stock_qty']; ?>">
                    <?php if(!empty($use_contract_pricing_mobile)) { ?>
                    <div class="opt_name">
                        <span class="sit_opt_subj">이용권 선택</span>
                    </div>
                    <div class="opt_count ct_pricing_form">
                        <div class="ct_pricing_inline_row">
                            <select id="ct_pricing_unit_<?php echo $i; ?>" class="ct_pricing_unit">
                                <?php if($allowed_units['usage']) { ?><option value="usage" <?php echo get_selected('usage', $default_unit); ?>>종량제 이용권</option><?php } ?>
                                <?php if($allowed_units['hour']) { ?><option value="hour" <?php echo get_selected('hour', $default_unit); ?>>1시간 이용권</option><?php } ?>
                                <?php if($allowed_units['day']) { ?><option value="day" <?php echo get_selected('day', $default_unit); ?>>1일 이용권</option><?php } ?>
                                <?php if($allowed_units['month']) { ?><option value="month" <?php echo get_selected('month', $default_unit); ?>>1개월(30일) 이용권</option><?php } ?>
                                <?php if($allowed_units['year']) { ?><option value="year" <?php echo get_selected('year', $default_unit); ?>>1년(365일) 이용권</option><?php } ?>
                            </select>

                            <div class="ct_pricing_count_wrap">
                                <input type="number" name="ct_pricing_count[<?php echo $it_id; ?>][]" min="1" step="1" value="<?php echo (int)$default_count; ?>" class="num_input ct_pricing_count">
                                <span class="ct_pricing_suffix">시간</span>
                            </div>
                        </div>

                        <input type="hidden" name="ct_pricing_unit[<?php echo $it_id; ?>][]" value="<?php echo $default_unit; ?>" class="ct_pricing_unit_hidden">
                        <input type="hidden" name="ct_qty[<?php echo $it_id; ?>][]" value="<?php echo (int)$default_day_qty; ?>" id="ct_qty_<?php echo $i; ?>" min="<?php echo (int)$min_contract_hours; ?>" max="<?php echo (int)$max_contract_hours; ?>" class="ct_qty_hidden">
                        <input type="hidden" name="ct_qty_hour[<?php echo $it_id; ?>][]" value="<?php echo (int)$default_hour_qty; ?>" id="ct_qty_hour_<?php echo $i; ?>" min="0" max="23" class="ct_qty_hour_hidden">
                        <div class="ct_human_time_hint" style="font-size:12px; color:#666;"><?php echo ($default_unit === 'usage') ? ('유효기한: 주문일로부터 365일 / 충전필요금액: '.number_format(max(0, (int)$default_count - (int)(isset($member['mb_point']) ? $member['mb_point'] : 0))).' Point') : ('선택기간: '.apms_contract_hours_text($total_contract_hours)); ?></div>
                    </div>
                    <?php } else { ?>
                    <div class="opt_name">
                        <span class="sit_opt_subj"><?php echo $it['it_name']; ?></span>
                    </div>
                    <div class="opt_count">
                        <label for="ct_qty_<?php echo $i; ?>" class="sound_only">수량</label>
                       <button type="button" class="sit_qty_minus"><i class="fa fa-minus" aria-hidden="true"></i><span class="sound_only">감소</span></button>
                        <input type="text" name="ct_qty[<?php echo $it_id; ?>][]" value="<?php echo $it['it_buy_min_qty']; ?>" id="ct_qty_<?php echo $i; ?>" class="num_input" size="5">
                        <button type="button" class="sit_qty_plus"><i class="fa fa-plus" aria-hidden="true"></i><span class="sound_only">증가</span></button>
                        <span class="sit_opt_prc">+0원</span>
                    </div>
                    <?php } ?>
                </li>
            </ul>
            <script>
            $(function() {
                function unitHours(unit) {
                    if (unit === 'day') return 24;
                    if (unit === 'month') return 24 * 30;
                    if (unit === 'year') return 24 * 365;
                    if (unit === 'usage') return 1;
                    return 1;
                }

                function unitSuffix(unit) {
                    if (unit === 'day') return '일';
                    if (unit === 'month') return '개월';
                    if (unit === 'year') return '년';
                    if (unit === 'usage') return 'Point';
                    return '시간';
                }

                function contractHoursText(hours) {
                    var totalHours = parseInt(hours, 10) || 0;
                    if (totalHours <= 0) return '0시간';
                    if (totalHours < 24) return number_format(String(totalHours)) + '시간';
                    var day = Math.floor(totalHours / 24);
                    var hour = totalHours % 24;
                    if (hour > 0) return number_format(String(day)) + '일 ' + number_format(String(hour)) + '시간';
                    return number_format(String(day)) + '일';
                }

                function syncContractPeriod($li) {
                    var $qtyHidden = $li.find('.ct_qty_hidden');
                    if (!$qtyHidden.length) {
                        return;
                    }

                    var minHoursRaw = parseFloat($qtyHidden.attr('min'));
                    var maxHoursRaw = parseFloat($qtyHidden.attr('max'));
                    if (isNaN(minHoursRaw) || minHoursRaw < 1) minHoursRaw = 1;
                    if (isNaN(maxHoursRaw) || maxHoursRaw < minHoursRaw) maxHoursRaw = (365 * 24);
                    var minHours = Math.max(1, Math.ceil(minHoursRaw));
                    var maxHours = Math.max(minHours, Math.floor(maxHoursRaw));

                    var unit = String($li.find('.ct_pricing_unit').val() || 'hour');
                    var $countInput = $li.find('.ct_pricing_count');
                    var count = parseInt($countInput.val(), 10);
                    if (isNaN(count) || count < 1) count = 1;

                    $li.find('.ct_pricing_suffix').text(unitSuffix(unit));

                    if (unit === 'usage') {
                        if (count < 5000) count = 5000;
                        if (count > 1000000) count = 1000000;
                        $countInput.attr('min', '5000').attr('max', '1000000').attr('step', '1000').val(String(count));
                        $li.find('.ct_pricing_unit_hidden').val('usage');
                        $li.find('.ct_qty_hidden').val(0);
                        $li.find('.ct_qty_hour_hidden').val(1);
                        var mbPoint = parseInt($('#mb_point_balance').val(), 10);
                        if (isNaN(mbPoint) || mbPoint < 0) mbPoint = 0;
                        var needAmount = Math.max(0, count - mbPoint);
                        $li.find('.ct_human_time_hint').text('유효기한: 주문일로부터 365일 / 충전필요금액: ' + number_format(String(needAmount)) + ' Point');
                        price_calculate();
                        return;
                    }

                    $countInput.attr('min', '1').removeAttr('max').attr('step', '1');
                    var hoursPerUnit = unitHours(unit);
                    var totalHours = count * hoursPerUnit;
                    if (totalHours < minHours) totalHours = minHours;
                    if (totalHours > maxHours) totalHours = maxHours;
                    count = Math.max(1, Math.round(totalHours / hoursPerUnit));
                    totalHours = count * hoursPerUnit;
                    if (totalHours > maxHours) totalHours = maxHours;

                    var day = Math.floor(totalHours / 24);
                    var hour = totalHours % 24;

                    $countInput.val(String(count));
                    $li.find('.ct_pricing_unit_hidden').val(unit);
                    $li.find('.ct_qty_hidden').val(day);
                    $li.find('.ct_qty_hour_hidden').val(hour);
                    $li.find('.ct_human_time_hint').text('선택기간: ' + contractHoursText(totalHours));

                    price_calculate();
                }

                $(document).on('change', '.ct_pricing_unit', function() {
                    syncContractPeriod($(this).closest('li'));
                });

                $(document).on('input change', '.ct_pricing_count', function() {
                    syncContractPeriod($(this).closest('li'));
                });

                price_calculate();
                $('#sit_sel_option li').each(function() {
                    syncContractPeriod($(this));
                });
            });
            </script>
        <?php } ?>
        </div>

        <div id="sit_tot_price"></div>
        <?php } ?>

        <?php if($is_soldout) { ?>
        <p id="sit_ov_soldout">상품의 재고가 부족하여 구매할 수 없습니다.</p>
        <?php } ?>

        <div id="sit_ov_btn">
            <?php if ($is_orderable) { ?>
            <input type="submit" onclick="document.pressed=this.value;" value="장바구니" id="sit_btn_cart">
            <input type="submit" onclick="document.pressed=this.value;" value="바로구매" id="sit_btn_buy">
            <?php } ?>
            <?php if(!$is_orderable && $it['it_soldout'] && $it['it_stock_sms']) { ?>
            <a href="javascript:popup_stocksms('<?php echo $it['it_id']; ?>');" id="sit_btn_buy">재입고알림</a>
            <?php } ?>
            <a href="javascript:item_wish(document.fitem, '<?php echo $it['it_id']; ?>');" id="sit_btn_wish"><span class="sound_only">위시리스트</span><i class="fa fa-heart-o" aria-hidden="true"></i></a>
            <?php if ($naverpay_button_js) { ?>
            <div class="naverpay-item"><?php echo $naverpay_request_js.$naverpay_button_js; ?></div>
            <?php } ?>
        </div>
    </section>
</div>


<div id="sit_tab">
    <ul class="tab_tit">
        <li><button type="button" rel="#sit_inf" class="selected">상품정보</button></li>
        <li><button type="button" rel="#sit_use">사용후기</button></li>
        <li><button type="button" rel="#sit_qa">상품문의</button></li>
        <li><button type="button" rel="#sit_dvex">배송/교환</button></li>
    </ul>
    <ul class="tab_con">

        <!-- 상품 정보 시작 { -->
        <li id="sit_inf">
            <h2 class="contents_tit"><span>상품 정보</span></h2>

            <?php if ($it['it_explan'] || $it['it_mobile_explan']) { // 상품 상세설명 ?>
            <h3>상품 상세설명</h3>
            <div id="sit_inf_explan">
                <?php echo ($it['it_mobile_explan'] ? conv_content($it['it_mobile_explan'], 1) : conv_content($it['it_explan'], 1)); ?>
            </div>
            <?php } ?>


            <?php
            if ($it['it_info_value']) { // 상품 정보 고시
                $info_data = unserialize(stripslashes($it['it_info_value']));
                if(is_array($info_data)) {
                    $gubun = $it['it_info_gubun'];
                    $info_array = $item_info[$gubun]['article'];
            ?>
            <h3>상품 정보 고시</h3>
            <table id="sit_inf_open">
            <tbody>
            <?php
            foreach($info_data as $key=>$val) {
                $ii_title = $info_array[$key][0];
                $ii_value = $val;
            ?>
            <tr>
                <th scope="row"><?php echo $ii_title; ?></th>
                <td><?php echo $ii_value; ?></td>
            </tr>
            <?php } //foreach?>
            </tbody>
            </table>
            <!-- 상품정보고시 end -->
            <?php
                } else {
                    if($is_admin) {
                        echo '<p>상품 정보 고시 정보가 올바르게 저장되지 않았습니다.<br>config.php 파일의 G5_ESCAPE_FUNCTION 설정을 addslashes 로<br>변경하신 후 관리자 &gt; 상품정보 수정에서 상품 정보를 다시 저장해주세요. </p>';
                    }
                }
            } //if
            ?>

        </li>
        <!-- 사용후기 시작 { -->
        <li id="sit_use">
            <h2>사용후기</h2>

            <div id="itemuse"><?php include_once(G5_SHOP_PATH.'/itemuse.php'); ?></div>
        </li>
        <!-- } 사용후기 끝 -->

        <!-- 상품문의 시작 { -->
        <li id="sit_qa">
            <h2>상품문의</h2>

            <div id="itemqa"><?php include_once(G5_SHOP_PATH.'/itemqa.php'); ?></div>
        </li>
        <!-- } 상품문의 끝 -->

        <?php if ($default['de_baesong_content']) { // 배송정보 내용이 있다면 ?>
        <!-- 배송정보 시작 { -->
        <li id="sit_dvex">
            <h2>배송/교환정보</h2>
            <div id="sit_dvr">
                <h3>배송정보</h3>

                <?php echo conv_content($default['de_baesong_content'], 1); ?>
            </div>
            <!-- } 배송정보 끝 -->
            <?php } ?>


            <?php if ($default['de_change_content']) { // 교환/반품 내용이 있다면 ?>
            <!-- 교환/반품 시작 { -->
            <div id="sit_ex" >
                <h3>교환/반품</h3>

                <?php echo conv_content($default['de_change_content'], 1); ?>
            </div>
            <!-- } 교환/반품 끝 -->
            <?php } ?>
        </li>
    </ul>
</div>
<script>
$(function (){
    $(".tab_con>li").hide();
    $(".tab_con>li:first").show();
    $(".tab_tit li button").click(function(){
        $(".tab_tit li button").removeClass("selected");
        $(this).addClass("selected");
        $(".tab_con>li").hide();
        $($(this).attr("rel")).show();
    });
});
</script>
</form>

<?php if($default['de_mobile_rel_list_use']) { ?>
<!-- 관련상품 시작 { -->
<section id="sit_rel">
    <h2>관련상품</h2>
    <div class="sct_wrap">
        <?php
        $rel_skin_file = $skin_dir.'/'.$default['de_mobile_rel_list_skin'];
        if(!is_file($rel_skin_file))
            $rel_skin_file = G5_MSHOP_SKIN_PATH.'/'.$default['de_mobile_rel_list_skin'];

        $sql = " select b.* from {$g5['g5_shop_item_relation_table']} a left join {$g5['g5_shop_item_table']} b on (a.it_id2=b.it_id) where a.it_id = '{$it['it_id']}' and b.it_use='1' ";
        $list = new item_list($rel_skin_file, $default['de_mobile_rel_list_mod'], 0, $default['de_mobile_rel_img_width'], $default['de_mobile_rel_img_height']);
        $list->set_query($sql);
        echo $list->run();
        ?>
    </div>
</section>
<!-- } 관련상품 끝 -->
<?php } ?>


<script>
$(window).bind("pageshow", function(event) {
    if (event.originalEvent.persisted) {
        document.location.reload();
    }
});

$(function(){
    // 상품이미지 슬라이드
    var time = 500;
    var idx = idx2 = 0;
    var slide_width = $("#sit_pvi_slide").width();
    var slide_count = $("#sit_pvi_slide li").size();
    $("#sit_pvi_slide li:first").css("display", "block");
    if(slide_count > 1)
        $(".sit_pvi_btn").css("display", "inline");

    $("#sit_pvi_prev").click(function() {
        if(slide_count > 1) {
            idx2 = (idx - 1) % slide_count;
            if(idx2 < 0)
                idx2 = slide_count - 1;
            $("#sit_pvi_slide li:hidden").css("left", "-"+slide_width+"px");
            $("#sit_pvi_slide li:eq("+idx+")").filter(":not(:animated)").animate({ left: "+="+slide_width+"px" }, time, function() {
                $(this).css("display", "none").css("left", "-"+slide_width+"px");
            });
            $("#sit_pvi_slide li:eq("+idx2+")").css("display", "block").filter(":not(:animated)").animate({ left: "+="+slide_width+"px" }, time,
                function() {
                    idx = idx2;
                }
            );
        }
    });

    $("#sit_pvi_next").click(function() {
        if(slide_count > 1) {
            idx2 = (idx + 1) % slide_count;
            $("#sit_pvi_slide li:hidden").css("left", slide_width+"px");
            $("#sit_pvi_slide li:eq("+idx+")").filter(":not(:animated)").animate({ left: "-="+slide_width+"px" }, time, function() {
                $(this).css("display", "none").css("left", slide_width+"px");
            });
            $("#sit_pvi_slide li:eq("+idx2+")").css("display", "block").filter(":not(:animated)").animate({ left: "-="+slide_width+"px" }, time,
                function() {
                    idx = idx2;
                }
            );
        }
    });

    // 상품이미지 크게보기
    $(".popup_item_image").click(function() {
        var url = $(this).attr("href");
        var top = 10;
        var left = 10;
        var opt = 'scrollbars=yes,top='+top+',left='+left;
        popup_window(url, "largeimage", opt);

        return false;
    });
});

// 상품보관
function item_wish(f, it_id)
{
    f.url.value = "<?php echo G5_SHOP_URL; ?>/wishupdate.php?it_id="+it_id;
    f.action = "<?php echo G5_SHOP_URL; ?>/wishupdate.php";
    f.submit();
}

// 추천메일
function popup_item_recommend(it_id)
{
    if (!g5_is_member)
    {
        if (confirm("회원만 추천하실 수 있습니다."))
            document.location.href = "<?php echo G5_BBS_URL; ?>/login.php?url=<?php echo urlencode(G5_SHOP_URL."/item.php?it_id=$it_id"); ?>";
    }
    else
    {
        url = "<?php echo G5_SHOP_URL; ?>/itemrecommend.php?it_id=" + it_id;
        opt = "scrollbars=yes,width=616,height=420,top=10,left=10";
        popup_window(url, "itemrecommend", opt);
    }
}

// 재입고SMS 알림
function popup_stocksms(it_id)
{
    url = "<?php echo G5_SHOP_URL; ?>/itemstocksms.php?it_id=" + it_id;
    opt = "scrollbars=yes,width=616,height=420,top=10,left=10";
    popup_window(url, "itemstocksms", opt);
}

var guestLoginMaxAttemptsMobile = 5;
var guestLoginCaptchaRequiredMobile = false;
var guestLoginCaptchaSessionUrlMobile = "<?php echo G5_CAPTCHA_URL; ?>/kcaptcha_session.php";
var pendingGuestActionMobile = "";
var pendingGuestFormMobile = null;

function setGuestLoginStatusMobile(message, isError)
{
    var statusEl = document.getElementById("guest-login-required-status-mobile");
    if (!statusEl) return;

    if (!message) {
        statusEl.textContent = "";
        statusEl.style.display = "none";
        statusEl.className = "guest-login-status-mobile";
        return;
    }

    statusEl.textContent = message;
    statusEl.style.display = "block";
    statusEl.className = isError ? "guest-login-status-mobile is-error" : "guest-login-status-mobile is-info";
}

function setGuestLoginFormLockedMobile(locked)
{
    var submitBtn = document.getElementById("guest-login-submit-btn-mobile");
    var idInput = document.getElementById("guest_login_mb_id_mobile");
    var pwInput = document.getElementById("guest_login_mb_password_mobile");
    var autoInput = document.getElementById("guest_login_auto_login_mobile");

    if (submitBtn) submitBtn.disabled = !!locked;
    if (idInput) idInput.disabled = false;
    if (pwInput) pwInput.disabled = false;
    if (autoInput) autoInput.disabled = false;
}

function refreshGuestCaptchaImageMobile(url, sessionUrl)
{
    var img = document.getElementById("guest-login-captcha-image-mobile");
    if (!img) return;

    var baseUrl = url || "<?php echo G5_CAPTCHA_URL; ?>/kcaptcha_image.php";
    var sessionApi = sessionUrl || guestLoginCaptchaSessionUrlMobile;
    var applyImage = function() {
        var sep = baseUrl.indexOf("?") >= 0 ? "&" : "?";
        img.src = baseUrl + sep + "t=" + new Date().getTime();
    };

    if (typeof $ !== "undefined" && sessionApi) {
        $.ajax({
            type: "POST",
            url: sessionApi,
            cache: false
        }).always(applyImage);
    } else {
        applyImage();
    }
}

function setGuestLoginCaptchaRequiredMobile(required, imageUrl, sessionUrl)
{
    guestLoginCaptchaRequiredMobile = !!required;

    if (sessionUrl) {
        guestLoginCaptchaSessionUrlMobile = sessionUrl;
    }

    var wrap = document.getElementById("guest-login-captcha-wrap-mobile");
    var keyInput = document.getElementById("guest_login_captcha_key_mobile");

    if (wrap) {
        wrap.style.display = guestLoginCaptchaRequiredMobile ? "block" : "none";
    }

    if (keyInput) {
        keyInput.value = "";
        keyInput.required = guestLoginCaptchaRequiredMobile;
    }

    if (guestLoginCaptchaRequiredMobile) {
        refreshGuestCaptchaImageMobile(imageUrl, sessionUrl);
    }
}

function executePendingGuestActionMobile()
{
    if (!pendingGuestFormMobile || !pendingGuestActionMobile) {
        return;
    }

    if (pendingGuestActionMobile === "cart") {
        $.post("<?php echo G5_SHOP_URL; ?>/itemcart.php", $(pendingGuestFormMobile).serialize(), function(error) {
            if (error != "OK") {
                alert(error.replace(/\\n/g, "\n"));
                return;
            }

            document.location.href = "<?php echo G5_SHOP_URL; ?>/cart.php";
        });
    } else if (pendingGuestActionMobile === "buy") {
        pendingGuestFormMobile.submit();
    }
}

function submitGuestLoginLayerFormMobile(ev)
{
    if (ev) ev.preventDefault();

    var idInput = document.getElementById("guest_login_mb_id_mobile");
    var pwInput = document.getElementById("guest_login_mb_password_mobile");
    var autoInput = document.getElementById("guest_login_auto_login_mobile");
    var captchaInput = document.getElementById("guest_login_captcha_key_mobile");
    var submitBtn = document.getElementById("guest-login-submit-btn-mobile");
    if (!idInput || !pwInput) return false;

    var mbId = (idInput.value || "").trim();
    var mbPassword = (pwInput.value || "").trim();
    var captchaKey = captchaInput ? (captchaInput.value || "").trim() : "";
    var autoLogin = autoInput && autoInput.checked ? 1 : 0;

    if (!mbId || !mbPassword) {
        setGuestLoginStatusMobile("회원아이디와 비밀번호를 입력해 주세요.", true);
        return false;
    }

    if (guestLoginCaptchaRequiredMobile && !captchaKey) {
        setGuestLoginStatusMobile("자동등록방지 숫자를 입력해 주세요.", true);
        return false;
    }

    if (submitBtn) submitBtn.disabled = true;
    setGuestLoginStatusMobile("로그인 확인 중입니다...", false);

    $.ajax({
        url: "<?php echo G5_BBS_URL; ?>/ajax.layer_login.php",
        type: "POST",
        dataType: "json",
        data: {
            mb_id: mbId,
            mb_password: mbPassword,
            captcha_key: captchaKey,
            auto_login: autoLogin
        }
    }).done(function(res) {
        if (!res || !res.ok) {
            var remaining = (res && typeof res.remaining_attempts !== "undefined") ? parseInt(res.remaining_attempts, 10) : guestLoginMaxAttemptsMobile;
            if (isNaN(remaining)) remaining = guestLoginMaxAttemptsMobile;

            var msg = (res && res.message) ? res.message : "로그인에 실패했습니다. 아이디 또는 비밀번호를 확인해 주세요.";
            if (remaining > 0) {
                msg += "\n남은 시도 " + remaining + "회";
            }
            setGuestLoginStatusMobile(msg, true);
            setGuestLoginCaptchaRequiredMobile(!!(res && res.captcha_required), res && res.captcha_image_url ? res.captcha_image_url : "", res && res.captcha_session_url ? res.captcha_session_url : "");
            setGuestLoginFormLockedMobile(false);
            return;
        }

        setGuestLoginStatusMobile("로그인에 성공했습니다. 주문을 계속 진행합니다.", false);
        if (typeof g5_is_member !== "undefined") {
            g5_is_member = true;
        }
        closeGuestLoginLayerMobile();
        executePendingGuestActionMobile();
    }).fail(function() {
        setGuestLoginStatusMobile("로그인 요청 중 오류가 발생했습니다. 잠시 후 다시 시도해 주세요.", true);
    }).always(function() {
        if (submitBtn && !submitBtn.disabled) {
            submitBtn.disabled = false;
        } else if (submitBtn) {
            var idDisabled = idInput && idInput.disabled;
            if (!idDisabled) {
                submitBtn.disabled = false;
            }
        }
    });

    return false;
}

function openGuestLoginLayerMobile(message, subMessage)
{
    var modal = document.getElementById("guest-login-required-modal-mobile");
    if (!modal) return;

    var messageEl = document.getElementById("guest-login-required-message-mobile");
    var subMessageEl = document.getElementById("guest-login-required-submessage-mobile");
    if (messageEl) {
        messageEl.textContent = message || "회원이시라면 로그인하신 후에 주문하여 주십시오.";
    }
    if (subMessageEl) {
        subMessageEl.textContent = subMessage || "비회원은 상품을 구입할 수 있는 권한이 없습니다.";
    }

    setGuestLoginStatusMobile("", false);
    setGuestLoginFormLockedMobile(false);
    setGuestLoginCaptchaRequiredMobile(false, "");

    modal.classList.add("is-open");
    document.body.classList.add("lnb-modal-open");

    var idInput = document.getElementById("guest_login_mb_id_mobile");
    var pwInput = document.getElementById("guest_login_mb_password_mobile");
    if (pwInput) {
        pwInput.value = "";
    }
    if (idInput) {
        idInput.focus();
    }
}

function closeGuestLoginLayerMobile()
{
    var modal = document.getElementById("guest-login-required-modal-mobile");
    if (!modal) return;
    modal.classList.remove("is-open");
    document.body.classList.remove("lnb-modal-open");
}

function confirmGuestAutoLoginMobile(el)
{
    if (!el || !el.checked) {
        return true;
    }

    if(!confirm("자동로그인을 사용하시면 다음부터 회원아이디와 비밀번호를 입력하실 필요가 없습니다.\n\n공공장소에서는 개인정보가 유출될 수 있으니 사용을 자제하여 주십시오.\n\n자동로그인을 사용하시겠습니까?")) {
        el.checked = false;
        return false;
    }

    return true;
}

function fsubmit_check(f)
{
    // 판매가격이 0 보다 작다면
    if (document.getElementById("it_price").value < 0) {
        alert("전화로 문의해 주시면 감사하겠습니다.");
        return false;
    }

    if($(".sit_opt_list").size() < 1) {
        alert("상품의 선택옵션을 선택해 주십시오.");
        return false;
    }

    var val, io_type, result = true;
    var sum_qty = 0;
    var min_qty = parseInt(<?php echo (int)(function_exists('apms_buy_qty_to_hours') ? apms_buy_qty_to_hours($it['it_buy_min_qty']) : $it['it_buy_min_qty']); ?>, 10);
    var max_qty = parseInt(<?php echo (int)(function_exists('apms_buy_qty_to_hours') ? apms_buy_qty_to_hours($it['it_buy_max_qty']) : $it['it_buy_max_qty']); ?>, 10);
    var $el_type = $("input[name^=io_type]");
    var $el_qty_hour = $("input[name^=ct_qty_hour]");

    $("input[name^=ct_qty]").each(function(index) {
        val = $(this).val();
        var day = parseInt(val, 10);
        if (isNaN(day) || day < 0) day = 0;
        var hour = 0;
        if ($el_qty_hour.eq(index).length > 0) {
            hour = parseInt($el_qty_hour.eq(index).val(), 10);
            if (isNaN(hour) || hour < 0) hour = 0;
            if (hour > 23) hour = 23;
        }
        var totalHours = (day * 24) + hour;
        if (totalHours < 1) {
            alert("계약시간은 최소 1시간 이상이어야 합니다.");
            result = false;
            return false;
        }

        io_type = $el_type.eq(index).val();
        if(io_type == "0")
            sum_qty += totalHours;
    });

    if(!result) {
        return false;
    }

    if(min_qty > 0 && sum_qty < min_qty) {
        alert("계약시간 총합은 "+number_format(String(min_qty))+"시간 이상으로 주문해 주십시오.");
        return false;
    }

    if(max_qty > 0 && sum_qty > max_qty) {
        alert("계약시간 총합은 "+number_format(String(max_qty))+"시간 이하로 주문해 주십시오.");
        return false;
    }

    if (!g5_is_member) {
        openGuestLoginLayerMobile(
            "회원이시라면 로그인하신 후에 주문하여 주십시오.",
            "비회원은 상품을 구입할 수 있는 권한이 없습니다."
        );
        return false;
    }

    return true;
}

document.addEventListener("keydown", function(ev) {
    if (ev.key === "Escape") {
        closeGuestLoginLayerMobile();
    }
});

// 바로구매, 장바구니 폼 전송
function fitem_submit(f)
{
    f.action = "<?php echo $action_url; ?>";
    f.target = "";

    if (document.pressed == "장바구니") {
        f.sw_direct.value = 0;
    } else { // 바로구매
        f.sw_direct.value = 1;
    }

    // 판매가격이 0 보다 작다면
    if (document.getElementById("it_price").value < 0) {
        alert("전화로 문의해 주시면 감사하겠습니다.");
        return false;
    }

    if($(".sit_opt_list").size() < 1) {
        alert("상품의 선택옵션을 선택해 주십시오.");
        return false;
    }

    var val, io_type, result = true;
    var sum_qty = 0;
    var min_qty = parseInt(<?php echo (int)(function_exists('apms_buy_qty_to_hours') ? apms_buy_qty_to_hours($it['it_buy_min_qty']) : $it['it_buy_min_qty']); ?>, 10);
    var max_qty = parseInt(<?php echo (int)(function_exists('apms_buy_qty_to_hours') ? apms_buy_qty_to_hours($it['it_buy_max_qty']) : $it['it_buy_max_qty']); ?>, 10);
    var $el_type = $("input[name^=io_type]");
    var $el_qty_hour = $("input[name^=ct_qty_hour]");

    $("input[name^=ct_qty]").each(function(index) {
        val = $(this).val();
        var day = parseInt(val, 10);
        if (isNaN(day) || day < 0) day = 0;
        var hour = 0;
        if ($el_qty_hour.eq(index).length > 0) {
            hour = parseInt($el_qty_hour.eq(index).val(), 10);
            if (isNaN(hour) || hour < 0) hour = 0;
            if (hour > 23) hour = 23;
        }
        var totalHours = (day * 24) + hour;
        if (totalHours < 1) {
            alert("계약시간은 최소 1시간 이상이어야 합니다.");
            result = false;
            return false;
        }

        io_type = $el_type.eq(index).val();
        if(io_type == "0")
            sum_qty += totalHours;
    });

    if(!result) {
        return false;
    }

    if(min_qty > 0 && sum_qty < min_qty) {
        alert("계약시간 총합은 "+number_format(String(min_qty))+"시간 이상으로 주문해 주십시오.");
        return false;
    }

    if(max_qty > 0 && sum_qty > max_qty) {
        alert("계약시간 총합은 "+number_format(String(max_qty))+"시간 이하로 주문해 주십시오.");
        return false;
    }

    if (!g5_is_member) {
        pendingGuestFormMobile = f;
        pendingGuestActionMobile = (document.pressed == "장바구니") ? "cart" : "buy";
        openGuestLoginLayerMobile(
            "회원이시라면 로그인하신 후에 주문하여 주십시오.",
            "비회원은 상품을 구입할 수 있는 권한이 없습니다."
        );
        return false;
    }

    return true;
}

// 모바일용 가격계산 오버라이드 (계약시간/종량제 충전필요금액 반영)
function price_calculate()
{
    var it_price = parseFloat($("input#it_price").val());
    if(isNaN(it_price)) return;

    var remainMbPoint = parseInt($('#mb_point_balance').val(), 10);
    if (isNaN(remainMbPoint) || remainMbPoint < 0) remainMbPoint = 0;

    var total = 0;
    $("#sit_sel_option li").each(function() {
        var $li = $(this);
        var ioPrice = parseFloat($li.find('input.io_price').val());
        if (isNaN(ioPrice)) ioPrice = 0;

        var day = parseInt($li.find("input[name^=ct_qty]").val(), 10);
        if (isNaN(day) || day < 0) day = 0;
        var hour = parseInt($li.find("input[name^=ct_qty_hour]").val(), 10);
        if (isNaN(hour) || hour < 0) hour = 0;
        if (hour > 23) hour = 23;
        var totalHours = (day * 24) + hour;
        if (totalHours < 1) totalHours = 1;

        var unit = String($li.find('.ct_pricing_unit').val() || 'hour');
        if (unit === 'usage') {
            var usageAmount = parseInt($li.find('.ct_pricing_count').val(), 10);
            if (isNaN(usageAmount)) usageAmount = 5000;
            if (usageAmount < 5000) usageAmount = 5000;
            if (usageAmount > 1000000) usageAmount = 1000000;
            $li.find('.ct_pricing_count').val(String(usageAmount));

            var needAmount = usageAmount - remainMbPoint;
            if (needAmount < 0) needAmount = 0;
            remainMbPoint -= usageAmount;
            if (remainMbPoint < 0) remainMbPoint = 0;

            total += (needAmount + (ioPrice * totalHours));
        } else {
            total += ((it_price + ioPrice) * totalHours);
        }
    });

    $("#sit_tot_price").empty().html("<span>주문합계 :</span> "+number_format(String(Math.round(total)))+" Point");
}
</script>
<style>
.guest-login-layer-mobile {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: none;
}
.guest-login-layer-mobile.is-open {
    display: block;
}
.guest-login-layer-mobile .guest-login-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.52);
}
.guest-login-layer-mobile .guest-login-dialog {
    position: relative;
    max-width: 460px;
    width: calc(100% - 24px);
    margin: 8vh auto 0;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 22px 48px rgba(2, 6, 23, 0.28);
    overflow: hidden;
}
.guest-login-layer-mobile .guest-login-head {
    padding: 16px 18px;
    border-bottom: 1px solid #eef2f7;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.guest-login-layer-mobile .guest-login-head strong {
    font-size: 18px;
    font-weight: 800;
    color: #111827;
}
.guest-login-layer-mobile .guest-login-close {
    background: transparent;
    border: 0;
    font-size: 22px;
    line-height: 1;
    color: #6b7280;
}
.guest-login-layer-mobile .guest-login-body {
    padding: 16px;
}
.guest-login-layer-mobile .guest-login-message {
    font-size: 16px;
    font-weight: 700;
    color: #111827;
    line-height: 1.45;
    margin-bottom: 4px;
}
.guest-login-layer-mobile .guest-login-submessage {
    font-size: 14px;
    color: #374151;
    line-height: 1.5;
    margin-bottom: 12px;
}
.guest-login-status-mobile {
    display: none;
    margin-bottom: 10px;
    font-size: 13px;
    line-height: 1.45;
    white-space: pre-line;
    padding: 8px 10px;
    border-radius: 8px;
}
.guest-login-status-mobile.is-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}
.guest-login-status-mobile.is-info {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}
.guest-login-layer-mobile .guest-login-form .input-group {
    width: 100%;
    margin-bottom: 10px;
    display: table;
    border-collapse: separate;
}
.guest-login-layer-mobile .guest-login-form .input-group-addon {
    width: 40px;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    color: #6b7280;
    display: table-cell;
    text-align: center;
    vertical-align: middle;
}
.guest-login-layer-mobile .guest-login-form .form-control {
    display: table-cell;
    width: 100%;
    height: 42px;
    border: 1px solid #d1d5db;
    border-left: 0;
    box-shadow: none;
    padding: 6px 10px;
}
.guest-login-layer-mobile .guest-login-form .btn-login-submit {
    width: 100%;
    height: 44px;
    margin-top: 2px;
    border: 0;
    border-radius: 8px;
    background: #2f3b4a;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
}
.guest-login-layer-mobile .guest-login-form .guest-login-auto {
    margin: 10px 0 8px;
    font-size: 14px;
    color: #4b5563;
    display: flex;
    align-items: center;
    gap: 6px;
}
.guest-login-layer-mobile .guest-login-foot {
    padding: 0 16px 16px;
    display: flex;
    justify-content: flex-end;
}
.guest-login-layer-mobile .guest-login-close-btn {
    border: 1px solid #d1d5db;
    background: #fff;
    color: #374151;
    border-radius: 999px;
    padding: 8px 14px;
    font-weight: 600;
}
</style>

<div id="guest-login-required-modal-mobile" class="guest-login-layer-mobile" aria-hidden="true">
    <div class="guest-login-backdrop" onclick="closeGuestLoginLayerMobile()"></div>
    <div class="guest-login-dialog" role="dialog" aria-modal="true" aria-labelledby="guest-login-required-message-mobile">
        <div class="guest-login-head">
            <strong>로그인 안내</strong>
            <button type="button" class="guest-login-close" onclick="closeGuestLoginLayerMobile()" aria-label="닫기">&times;</button>
        </div>
        <div class="guest-login-body">
            <div id="guest-login-required-message-mobile" class="guest-login-message">회원이시라면 로그인하신 후에 주문하여 주십시오.</div>
            <div id="guest-login-required-submessage-mobile" class="guest-login-submessage">비회원은 상품을 구입할 수 있는 권한이 없습니다.</div>
            <div id="guest-login-required-status-mobile" class="guest-login-status-mobile"></div>

            <form action="#" method="post" class="guest-login-form" autocomplete="off" onsubmit="return submitGuestLoginLayerFormMobile(event);">
                <input type="hidden" name="url" value="<?php echo htmlspecialchars(G5_SHOP_URL.'/item.php?it_id='.$it['it_id'].'&device=mobile', ENT_QUOTES); ?>">
                <div class="input-group">
                    <span class="input-group-addon"><i class="fa fa-user"></i></span>
                    <input type="text" name="mb_id" id="guest_login_mb_id_mobile" class="form-control" maxlength="32" placeholder="아이디 또는 이메일" required>
                </div>
                <div class="input-group">
                    <span class="input-group-addon"><i class="fa fa-lock"></i></span>
                    <input type="password" name="mb_password" id="guest_login_mb_password_mobile" class="form-control" maxlength="32" placeholder="비밀번호" required>
                </div>
                <div id="guest-login-captcha-wrap-mobile" style="display:none; margin-bottom:10px;">
                    <div style="display:flex; align-items:center; gap:8px; margin-bottom:8px;">
                        <img id="guest-login-captcha-image-mobile" src="<?php echo G5_CAPTCHA_URL; ?>/kcaptcha_image.php" alt="자동등록방지" style="height:40px; border:1px solid #d1d5db; border-radius:6px;">
                        <button type="button" class="btn_login" style="width:auto; padding:0 10px;" onclick="refreshGuestCaptchaImageMobile()">새로고침</button>
                    </div>
                    <input type="text" name="captcha_key" id="guest_login_captcha_key_mobile" class="form-control" maxlength="6" placeholder="자동등록방지 숫자 입력" inputmode="numeric" pattern="[0-9]*">
                </div>
                <label class="guest-login-auto" for="guest_login_auto_login_mobile">
                    <input type="checkbox" name="auto_login" value="1" id="guest_login_auto_login_mobile" onchange="confirmGuestAutoLoginMobile(this)">
                    자동로그인 및 로그인 상태 유지
                </label>
                <input type="submit" class="btn-login-submit" id="guest-login-submit-btn-mobile" value="Login">
            </form>
        </div>
        <div class="guest-login-foot">
            <button type="button" class="guest-login-close-btn" onclick="closeGuestLoginLayerMobile()">로그인 없이 닫기</button>
        </div>
    </div>
</div>
<?php /* 2017 리뉴얼한 테마 적용 스크립트입니다. 기존 스크립트를 오버라이드 합니다. */ ?>
<script src="<?php echo G5_JS_URL; ?>/shop.override.js"></script>