<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
include_once(THEMA_PATH.'/assets/thema.php');
?>
<script>
function redirectToPage(t) {
    if (t == 'charge') {
        // 새로운 URL로 이동 (현재 창에 로드)
        window.location.href = '<?php echo G5_URL."/shoppoint/orderform.php";?>';

        // 새 창에 로드
        //window.open('<?php echo G5_URL."/shoppoint/orderform.php";?>', '_blank');
    } else if (t == 'withdraw') {
        // 새로운 URL로 이동 (현재 창에 로드)
        window.location.href = '<?php echo G5_URL."/shoppoint/orderform4withdraw.php";?>';

        // 새 창에 로드
        //window.open('<?php echo G5_URL."/shoppoint/orderform4withdraw.php";?>', '_blank');
    }

}

var lnbLogoutTargetUrl = '';
function lnbOpenLogoutConfirm(e, logoutUrl) {
	if (e) e.preventDefault();
	lnbLogoutTargetUrl = logoutUrl || '';
	var modal = document.getElementById('lnb-logout-modal');
	if (!modal) return false;
	modal.classList.add('is-open');
	document.body.classList.add('lnb-modal-open');
	var confirmBtn = document.getElementById('lnb-logout-confirm-btn');
	if (confirmBtn) confirmBtn.focus();
	return false;
}

function lnbCloseLogoutConfirm() {
	var modal = document.getElementById('lnb-logout-modal');
	if (!modal) return;
	modal.classList.remove('is-open');
	document.body.classList.remove('lnb-modal-open');
}

function lnbDoLogout() {
	if (!lnbLogoutTargetUrl) {
		lnbCloseLogoutConfirm();
		return;
	}
	window.location.href = lnbLogoutTargetUrl;
}

document.addEventListener('keydown', function(ev) {
	if (ev.key === 'Escape') {
		lnbCloseLogoutConfirm();
	}
});
</script>

<style>
.btn-g12 {
  background-color: #fff;
  color: #28a745 !important;
  border: 1px solid #28a745;
  cursor: pointer;
  font-size: 0.9em;
  padding: 5px 10px;
  border-radius: 0px;
  height: 40px;
  line-height: 40px;
  transition: background-color 0.3s, box-shadow 0.3s;
}
.btn-g12:hover {
  background-color: #218838;
  color: #fff !important;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.btn-g12a {
  background-color: #28a745;
  color: #fff !important;
  border: none;
  padding: 1px 5px;
  border-radius: 0px;
  cursor: pointer;
  font-size: 0.9em;
  transition: background-color 0.3s, box-shadow 0.3s;
  margin-left: 5px;
}
.btn-g12a:hover {
  background-color: #218838;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.btn-g12i {
  background-color: #28a745;
  color: #fff !important;
  border: none;
  padding: 10px 10px;
  border-radius: 0px;
  cursor: pointer;
  font-size: 1.2em;
  font-weight: bold;
  transition: background-color 0.3s, box-shadow 0.3s;
  margin-left: 0px;
  width: 100%;
}
.btn-g12i:hover {
  background-color: #218838;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.btn-b12 {
  background-color: #fff;
  color: #0063ff !important;
  border: 1px solid #0063ff;
  cursor: pointer;
  font-size: 0.9em;
  padding: 5px 10px;
  border-radius: 0px;
  height: 40px;
  line-height: 40px;
  transition: background-color 0.3s, box-shadow 0.3s;
}
.btn-b12:hover {
  background-color: #3468ba;
  color: #fff !important;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.btn-b12a {
  background-color: #0063ff;
  color: #fff !important;
  border: none;
  padding: 1px 5px;
  border-radius: 0px;
  cursor: pointer;
  font-size: 0.9em;
  transition: background-color 0.3s, box-shadow 0.3s;
  margin-left: 5px;
}
.btn-b12a:hover {
  background-color: #3468ba;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.btn-b12i {
  background-color: #0063ff;
  color: #fff !important;
  border: none;
  padding: 10px 10px;
  border-radius: 0px;
  cursor: pointer;
  font-size: 1.2em;
  font-weight: bold;
  transition: background-color 0.3s, box-shadow 0.3s;
  margin-left: 0px;
  width: 100%;
}
.btn-b12i:hover {
  background-color: #3468ba;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
</style>

<div id="thema_wrapper" class="wrapper <?php echo $is_thema_layout;?> <?php echo $is_thema_font;?>">

	<!-- LNB -->
	<aside class="at-lnb">
		<div class="at-container">
			<!-- LNB Left -->
			<div class="pull-left lnb-left-logo">
				<a class="lnb-logo" href="<?php echo $at_href['home'];?>">
					<img id="lnb-main-logo"
						src="<?php echo G5_DATA_URL; ?>/common/logo_img"
						data-src-light="<?php echo G5_DATA_URL; ?>/common/logo_img"
						data-src-dark="<?php echo G5_DATA_URL; ?>/common/mobile_logo_img"
						alt="<?php echo $config['cf_title']; ?> 메인"
						style="height:46px; width:auto; max-width:none; display:block;">
				</a>
				<script>
				(function(){
					var img = document.getElementById('lnb-main-logo');
					if(!img) return;
					function applyLogo(){
						var theme = document.documentElement.getAttribute('data-site-theme');
						if(theme === 'dark'){
							img.src = img.getAttribute('data-src-dark');
							img.style.height = '36px';
						} else {
							img.src = img.getAttribute('data-src-light');
							img.style.height = '46px';
						}
					}
					applyLogo();
					var obs = new MutationObserver(applyLogo);
					obs.observe(document.documentElement, {attributes:true, attributeFilter:['data-site-theme']});
				})();
				</script>
			</div>
			<!-- LNB Right -->
			<?php $is_lnb_shop_mode = false; include(THEMA_PATH.'/_lnb_right.php'); ?>
			<div class="clearfix"></div>
		</div>
	</aside>

	<div id="lnb-logout-modal" class="lnb-logout-modal" aria-hidden="true">
		<div class="lnb-logout-backdrop" onclick="lnbCloseLogoutConfirm()"></div>
		<div class="lnb-logout-dialog" role="dialog" aria-modal="true" aria-labelledby="lnb-logout-title">
			<div class="lnb-logout-head">
				<strong id="lnb-logout-title">로그아웃</strong>
			</div>
			<div class="lnb-logout-body">
				지금 로그아웃 하시겠어요?<br>
				<span>현재 작업 중인 내용이 있다면 먼저 저장해 주세요.</span>
			</div>
			<div class="lnb-logout-foot">
				<button type="button" class="lnb-btn-cancel" onclick="lnbCloseLogoutConfirm()">취소</button>
				<button type="button" class="lnb-btn-confirm" id="lnb-logout-confirm-btn" onclick="lnbDoLogout()">로그아웃</button>
			</div>
		</div>
	</div>

	<!-- PC Header (LNB 1줄 통합으로 미사용) -->
	<header class="pc-header" style="display:none;"></header>

	<!-- Mobile Header -->
	<header class="m-header">
		<div class="at-container">
			<div class="header-wrap">
				<div class="header-icon">
					<a href="javascript:;" onclick="sidebar_open('sidebar-user');">
						<i class="fa fa-user"></i>
					</a>
				</div>
				<div class="header-logo en">
					<style>
						.circle-m {
							background-color: gold;
							color: black;
							border-radius: 50%;
							padding: 5px 10px;
							display: inline-block;
						}
						.rounded-box-m {
							background: linear-gradient(145deg, #0063ff, #6699ff);
							color: #fff;
							padding: 4px 4px 3px 4px; /* 패딩 조정 */
							margin-right: 2px;
							display: inline-block;
							font-weight: bold;
							font-family: Arial, sans-serif;
							line-height: 1; /* 라인 높이 조정 */
						}
						.blue-text-m {
							color: #0063ff;
							margin-right: 3px;
						}
					</style>
					<!-- Mobile Logo -->
					<a href="<?php echo $at_href['home'];?>">
						<?php /* <span class="rounded-box-m">R</span><span class="blue-text-m">PC</span>World.com */ ?>
						<div id="logo"><a href="<?php echo G5_SHOP_URL; ?>/"><img src="<?php echo G5_DATA_URL; ?>/common/mobile_logo_img" style="height:30px;" alt="<?php echo $config['cf_title']; ?> 메인"></a></div>
					</a>
				</div>
				<div class="header-icon" style="display:flex;align-items:center;justify-content:center;gap:6px;width:auto;padding:0 8px;">
					<button class="site-darkmode-btn" id="m-darkmode-btn" aria-label="다크/라이트 모드 전환" title="다크/라이트 모드 전환" style="margin:0;">
						<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" width="16" height="16"><path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9z"/></svg>
					</button>
					<a href="javascript:;" onclick="sidebar_open('sidebar-search');">
						<i class="fa fa-search"></i>
					</a>
				</div>
			</div>
			<div class="clearfix"></div>
		</div>
	</header>

	<!-- Menu -->
	<nav class="at-menu">
		<!-- PC Menu -->
		<div class="pc-menu">
			<!-- Menu Button & Right Icon Menu -->
			<div class="at-container">
				<div class="nav-right nav-rw nav-height">
					<ul>
						<?php if(IS_YC) { //영카트 ?>
							<li class="nav-show">
								<a href="<?php echo $at_href['cart'];?>" onclick="sidebar_open('sidebar-cart'); return false;"<?php echo tooltip('쇼핑');?>>
									<i class="fa fa-shopping-bag"></i>
									<?php if($member['cart'] || $member['today']) { ?>
										<span class="label bg-green en">
											<?php echo number_format($member['cart'] + $member['today']);?>
										</span>
									<?php } ?>
								</a>
							</li>
						<?php } ?>
						<li>
							<a href="javascript:;" onclick="sidebar_open('sidebar-response');"<?php echo tooltip('알림');?>>
								<i class="fa fa-bell"></i>
								<span class="label bg-orangered en"<?php echo ($member['response'] || $member['memo']) ? '' : ' style="display:none;"';?>>
									<span class="msgCount"><?php echo number_format($member['response'] + $member['memo']);?></span>
								</span>
							</a>
						</li>
						<li>
							<a href="javascript:;" onclick="sidebar_open('sidebar-search');"<?php echo tooltip('검색');?>>
								<i class="fa fa-search"></i>
							</a>
						</li>
						<li class="menu-all-icon"<?php echo tooltip('전체메뉴');?>>
							<a href="javascript:;" data-toggle="collapse" data-target="#menu-all">
								<i class="fa fa-th"></i>
							</a>
						</li>
					</ul>
					<div class="clearfix"></div>
				</div>
			</div>
			<?php include_once(THEMA_PATH.'/menu.php');	// 메뉴 불러오기 ?>
			<div class="clearfix"></div>
			<div class="nav-back"></div>
		</div><!-- .pc-menu -->

		<!-- PC All Menu -->
		<div class="pc-menu-all">
			<div id="menu-all" class="collapse">
				<div class="at-container table-responsive">
					<?php $oi_menu_section_count_map_all = function_exists('oi_menu_section_count_map') ? oi_menu_section_count_map($menu) : array(); ?>
					<table class="table">
					<tr>
					<?php
						$az = 0;
						for ($i=1; $i < $menu_cnt; $i++) {

							if(!$menu[$i]['gr_id']) continue;

							// 줄나눔
							if($az && $az%$is_allm == 0) {
								echo '</tr><tr>'.PHP_EOL;
							}
					?>
						<td class="<?php echo $menu[$i]['on'];?>">
							<a class="menu-a" href="<?php echo $menu[$i]['href'];?>"<?php echo $menu[$i]['target'];?>>
								<?php echo $menu[$i]['name'];?>
								<?php if($menu[$i]['new'] == "new") { ?>
									<i class="fa fa-bolt new"></i>
								<?php } ?>
							</a>
							<?php if($menu[$i]['is_sub']) { //Is Sub Menu ?>
								<div class="sub-1div">
									<ul class="sub-1dul">
									<?php for($j=0; $j < count($menu[$i]['sub']); $j++) { ?>

										<?php if($menu[$i]['sub'][$j]['line']) { //구분라인 ?>
											<li class="sub-1line"><a><?php echo $menu[$i]['sub'][$j]['line'];?></a></li>
										<?php } ?>

										<li class="sub-1dli <?php echo $menu[$i]['sub'][$j]['on'];?>">
											<?php
												$oi_menu_prefix = isset($menu[$i]['sub'][$j]['hid']) ? trim((string)$menu[$i]['sub'][$j]['hid']) : '';
												$oi_menu_cnt = ($oi_menu_prefix !== '' && isset($oi_menu_section_count_map_all[$oi_menu_prefix])) ? (int)$oi_menu_section_count_map_all[$oi_menu_prefix] : -1;
											?>
											<a href="<?php echo $menu[$i]['sub'][$j]['href'];?>" class="sub-1da<?php echo ($menu[$i]['sub'][$j]['is_sub']) ? ' sub-icon' : '';?><?php echo ($oi_menu_cnt === 0) ? ' oi-menu-empty-link' : ''; ?>"<?php echo ($oi_menu_cnt >= 0) ? ' data-menu-item-count="'.$oi_menu_cnt.'"' : ''; ?><?php echo $menu[$i]['sub'][$j]['target'];?>>
												<?php
													if (function_exists('oi_menu_link_label_html')) {
														echo oi_menu_link_label_html($menu[$i]['sub'][$j]['name'], $oi_menu_cnt);
													} else {
														echo $menu[$i]['sub'][$j]['name'];
														if ($oi_menu_cnt >= 0) echo ' ('.number_format($oi_menu_cnt).')';
													}
												?>
												<?php if($menu[$i]['sub'][$j]['new'] == "new") { ?>
													<i class="fa fa-bolt sub-1new"></i>
												<?php } ?>
											</a>
										</li>
									<?php } //for ?>
									</ul>
								</div>
							<?php } ?>
						</td>
					<?php $az++; } //for ?>
					</tr>
					</table>
					<div class="menu-all-btn">
						<div class="btn-group">
							<a class="btn btn-lightgray" href="<?php echo $at_href['main'];?>"><i class="fa fa-home"></i></a>
							<a href="javascript:;" class="btn btn-lightgray" data-toggle="collapse" data-target="#menu-all"><i class="fa fa-times"></i></a>
						</div>
					</div>
				</div>
			</div>
		</div><!-- .pc-menu-all -->

		<!-- Mobile Menu -->
		<div class="m-menu">
			<?php include_once(THEMA_PATH.'/menu-m.php');	// 메뉴 불러오기 ?>
		</div><!-- .m-menu -->
	</nav><!-- .at-menu -->

	<div class="clearfix"></div>

	<?php if($page_title) { // 페이지 타이틀 ?>
		<div class="at-title">
			<div class="at-container">
				<div class="page-title en">
					<strong<?php echo ($bo_table) ? " class=\"cursor\" onclick=\"go_page('".G5_BBS_URL."/board.php?bo_table=".$bo_table."');\"" : "";?>>
						<?php echo $page_title;?>
					</strong>
				</div>
				<?php if($page_desc) { // 페이지 설명글 ?>
					<div class="page-desc hidden-xs">
						<?php echo $page_desc;?>
					</div>
				<?php } ?>
				<div class="clearfix"></div>
			</div>
		</div>
	<?php } ?>

	<div class="at-body">
		<?php if($col_name) { ?>
			<div class="at-container">
			<?php if($col_name == "two") { ?>
				<div class="row at-row">
					<div class="col-md-<?php echo $col_content;?><?php echo ($at_set['side']) ? ' pull-right' : '';?> at-col at-main">
			<?php } else { ?>
				<div class="at-content">
			<?php } ?>
		<?php } ?>
