/* ========================================
   모바일 하단 메뉴 리뉴얼
   adminmode=1 전용, 기존 gnb-tab 대체
   ======================================== */

/* 기존 gnb-tab 제거됨 (백업: v3/inc_gnb_tab_backup.php) */
.gnb-tab-wrap {
    display: none !important;
}

#wrap {
    padding-bottom: 60px !important;
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
    #wrap {
        padding-bottom: calc(60px + env(safe-area-inset-bottom)) !important;
    }
}

/* 데스크탑에서 새 메뉴 숨김 */
@media (min-width: 769px) {
    .btm-nav,
    .btm-panel,
    .btm-overlay {
        display: none !important;
    }
    #wrap {
        padding-bottom: 0 !important;
    }
}

/* --- Overlay --- */
.btm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 10002;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

.btm-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* --- Bottom Navigation Bar --- */
.btm-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10002;
    height: 60px;
    background: #ffffff;
    border-top: 1px solid #f0f0f0;
    box-shadow: 0 -1px 12px rgba(0, 0, 0, 0.06);
    padding-bottom: env(safe-area-inset-bottom, 0);
}

@supports (height: env(safe-area-inset-bottom)) {
    .btm-nav {
        height: calc(60px + env(safe-area-inset-bottom));
    }
}

.btm-nav-inner {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 60px;
    max-width: 480px;
    margin: 0 auto;
}

.btm-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 0;
    min-width: 56px;
    color: #4b5563;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: -0.01em;
    background: none;
    border: none;
    cursor: pointer;
    transition: color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    text-decoration: none;
    outline: none;
}

.btm-tab.active {
    color: #2563eb;
    font-weight: 700;
}

.btm-tab:active {
    transform: scale(0.92);
    transition: transform 0.1s;
}

/* --- Slide-up Panel --- */
.btm-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 60px;
    z-index: 10002;
    background: #ffffff;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.12);
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    will-change: transform;
}

@supports (bottom: env(safe-area-inset-bottom)) {
    .btm-panel {
        bottom: calc(60px + env(safe-area-inset-bottom));
    }
}

.btm-panel.active {
    transform: translateY(0);
}

/* --- Submenu Grid Items --- */
.btm-submenu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 14px 4px 10px;
    border-radius: 14px;
    color: #374151;
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    transition: background-color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.btm-submenu-item:active {
    background-color: #f5f5f5;
}

.btm-icon-wrap {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease;
}

.btm-submenu-item:active .btm-icon-wrap {
    transform: scale(0.93);
}

/* --- Accordion (더보기 패널) --- */
.btm-accordion {
    border-bottom: 1px solid #f3f4f6;
}

.btm-accordion:last-child {
    border-bottom: none;
}

.btm-accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 14px 4px;
    background: none;
    border: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

.btm-accordion-header:active {
    opacity: 0.7;
}

.btm-chevron {
    transition: transform 0.25s ease;
}

.btm-accordion.open .btm-chevron {
    transform: rotate(180deg);
}

.btm-accordion-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.btm-accordion.open .btm-accordion-body {
    max-height: 400px;
}

.btm-accordion-link {
    display: block;
    padding: 11px 16px 11px 48px;
    color: #6b7280;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    border-radius: 8px;
    transition: background-color 0.15s ease, color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.btm-accordion-link:active {
    background-color: #f3f4f6;
    color: #374151;
}

/* --- 플로팅 버튼 위치: 새 하단메뉴(60px) 바로 위로 조정 --- */
/* 모바일: 애피상담소 버튼만 하단 메뉴 패널/오버레이 뒤로, 팝업 열리면 메뉴 위로 */
@media (max-width: 768px) {
    #chatbot {
        position: relative;
        z-index: 10000;
    }
    /* 팝업(상담소/챗봇) 열린 상태에서는 메뉴 위에 표시 */
    #chatbot:has(.chatbot-faq.active) {
        z-index: 10003 !important;
    }
    /* AI상담 팝업(#aichatbox)이 보일 때도 #chatbot을 메뉴 위로 */
    #chatbot:has(#aichatbox[style*="display: block"]),
    #chatbot:has(#aichatbox[style*="display:block"]) {
        z-index: 10003 !important;
    }
    /* 모바일: 애드픽 AI상담 팝업은 하단 메뉴 위 레이어로 표시 */
    #aichatbox.aichatbox,
    .faq-search .aichatbox {
        z-index: 10003 !important;
    }
    /* FAQ 검색 페이지에서 AI상담 팝업 열렸을 때 상위도 메뉴 위로 */
    .faq-search:has(#aichatbox[style*="display: block"]),
    .faq-search:has(#aichatbox[style*="display:block"]) {
        position: relative;
        z-index: 10003 !important;
    }
    /* 모바일: 롤렛 당첨 팝업을 하단 메뉴 위 레이어로 표시 */
    .page-roulette .modal-popup,
    #modalRoulette {
        z-index: 10003 !important;
    }
    /* 푸시 알림 설정 유도 팝업을 하단 메뉴 위에 표시 */
    .modal-popup.modal-notification-setting,
    #pushRemindPopup .modal-popup {
        z-index: 10003 !important;
    }
    /* 쇼핑몰 상세: 쇼핑하기/공유하기 팝업을 하단 메뉴 위에 표시 */
    .shopping-main-content .modal-popup,
    #modalVisitShop.modal-popup,
    #modalPopupSnsShare.modal-popup {
        z-index: 10003 !important;
    }
}
.chatbot-faq .chatbot {
    bottom: 72px !important;
}
.chatbot-faq .chatbot::before {
    bottom: 137px !important;
}
.chatbot-faq .chatbot::after {
    bottom: 115px !important;
}
.chatbot-faq .chatbot.bottom {
    bottom: 72px !important;
}
.chatbot-faq .chatbot.bottom::before {
    bottom: 137px !important;
}
.chatbot-faq .chatbot.bottom::after {
    bottom: 115px !important;
}

.body-page-bbs .btn-write {
    bottom: 72px !important;
}
.icon-link {
    bottom: 72px !important;
}
.body-page-bbs .chatbot-faq.withwrite .chatbot {
    bottom: 132px !important;
}
.body-page-bbs .chatbot-faq.withwrite .chatbot::before {
    bottom: 197px !important;
}
.body-page-bbs .chatbot-faq.withwrite .chatbot::after {
    bottom: 175px !important;
}

@supports (bottom: env(safe-area-inset-bottom)) {
    .chatbot-faq .chatbot,
    .chatbot-faq .chatbot.bottom {
        bottom: calc(72px + env(safe-area-inset-bottom)) !important;
    }
    .body-page-bbs .btn-write,
    .icon-link {
        bottom: calc(72px + env(safe-area-inset-bottom)) !important;
    }
    .body-page-bbs .chatbot-faq.withwrite .chatbot {
        bottom: calc(132px + env(safe-area-inset-bottom)) !important;
    }
}
