/* ============================================
   Mobile Bottom Navigation - Stable Earning
   모바일 전용 하단 네비게이션 바
   ============================================ */

/* 기본적으로 숨김 (PC에서는 표시 안함) */
.mobile-bottom-nav {
    display: none;
}

/* 모바일에서만 표시 */
@media (max-width: 768px) {

    /* 메인 콘텐츠 하단 패딩 (네비게이션 바에 가려지지 않도록) */
    #main-wrap {
        padding-bottom: calc(78px + env(safe-area-inset-bottom, 0)) !important;
    }

    /* 하단 네비게이션 바 */
    .mobile-bottom-nav {
        display: flex !important;
        position: fixed;
        /* iOS Safari safe area 대응 */
        bottom: 0;
        bottom: constant(safe-area-inset-bottom);
        /* iOS 11.0-11.2 */
        bottom: env(safe-area-inset-bottom, 0);
        /* iOS 11.2+ */
        left: 0;
        right: 0;
        /* 높이는 콘텐츠 + safe area */
        min-height: 68px;
        height: calc(68px + env(safe-area-inset-bottom, 0));
        background: rgba(26, 26, 26, 0.98);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border-top: 1px solid #3d3d3d;
        /* safe area를 padding-bottom으로 처리 */
        padding-bottom: 0;
        padding-bottom: constant(safe-area-inset-bottom);
        /* iOS 11.0-11.2 */
        padding-bottom: env(safe-area-inset-bottom, 0);
        /* iOS 11.2+ */
        z-index: 99999;
        justify-content: space-around;
        align-items: flex-start;
        padding-top: 8px;
        /* 스크롤 시 안정화를 위한 하드웨어 가속 */
        -webkit-transform: translate3d(0, 0, 0);
        transform: translate3d(0, 0, 0);
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
        /* 레이아웃 안정화 */
        box-sizing: border-box;
    }

    /* 네비게이션 아이템 공통 */
    .mobile-bottom-nav .nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-decoration: none;
        color: #868e96;
        font-size: 11px;
        font-weight: 500;
        padding: 8px 16px;
        min-width: 64px;
        min-height: 48px;
        border-radius: 8px;
        transition: all 0.2s ease;
        position: relative;
        background: transparent;
        border: none;
        cursor: pointer;
    }

    .mobile-bottom-nav .nav-item:hover,
    .mobile-bottom-nav .nav-item:focus {
        color: #adb5bd;
        background: rgba(255, 255, 255, 0.05);
    }

    .mobile-bottom-nav .nav-item:active {
        transform: scale(0.95);
        background: rgba(77, 171, 247, 0.1);
    }

    /* 활성 상태 */
    .mobile-bottom-nav .nav-item.active {
        color: #4dabf7;
    }

    .mobile-bottom-nav .nav-item.active::before {
        content: '';
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 32px;
        height: 3px;
        background: #4dabf7;
        border-radius: 0 0 3px 3px;
    }

    /* 아이콘 */
    .mobile-bottom-nav .nav-icon {
        width: 24px;
        height: 24px;
        margin-bottom: 4px;
        fill: currentColor;
    }

    /* 라벨 */
    .mobile-bottom-nav .nav-label {
        font-size: 11px;
        line-height: 1;
        white-space: nowrap;
    }

    /* ===== 드롭업 메뉴 (게시판) ===== */
    .mobile-bottom-nav .nav-item-dropdown {
        position: relative;
        /* nav-item과 동일한 크기/정렬 */
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        min-width: 64px;
        min-height: 48px;
    }

    /* 드롭다운 버튼 - nav-item과 동일한 스타일 */
    .mobile-bottom-nav .nav-btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-decoration: none;
        color: #868e96;
        font-size: 11px;
        font-weight: 500;
        padding: 8px 16px;
        margin: 0;
        min-width: 64px;
        min-height: 48px;
        background: transparent;
        border: none;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .mobile-bottom-nav .nav-btn:hover,
    .mobile-bottom-nav .nav-btn:focus {
        color: #adb5bd;
    }

    .mobile-bottom-nav .nav-btn:active {
        transform: scale(0.95);
    }

    /* 활성 상태 및 드롭업 열림 상태 */
    .mobile-bottom-nav .nav-item-dropdown.active .nav-btn,
    .mobile-bottom-nav .nav-item-dropdown.open .nav-btn {
        color: #4dabf7;
    }

    /* 드롭업 열림 시 상단 인디케이터 */
    .mobile-bottom-nav .nav-item-dropdown.open::before {
        content: '';
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 32px;
        height: 3px;
        background: #4dabf7;
        border-radius: 0 0 3px 3px;
    }

    .mobile-bottom-nav .nav-dropdown-menu {
        position: absolute;
        bottom: calc(100% + 10px);
        left: 50%;
        transform: translateX(-50%) translateY(10px);
        background: rgba(30, 30, 30, 0.98);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border: 1px solid #3d3d3d;
        border-radius: 12px;
        padding: 8px 0;
        min-width: 160px;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
        opacity: 0;
        visibility: hidden;
        transition: all 0.2s ease;
        z-index: 10000;
    }

    /* 드롭업 화살표 */
    .mobile-bottom-nav .nav-dropdown-menu::after {
        content: '';
        position: absolute;
        bottom: -8px;
        left: 50%;
        transform: translateX(-50%);
        border-left: 8px solid transparent;
        border-right: 8px solid transparent;
        border-top: 8px solid rgba(30, 30, 30, 0.98);
    }

    /* 드롭업 메뉴 열림 상태 */
    .mobile-bottom-nav .nav-item-dropdown.open .nav-dropdown-menu {
        opacity: 1;
        visibility: visible;
        transform: translateX(-50%) translateY(0);
    }

    /* 드롭업 메뉴 아이템 */
    .mobile-bottom-nav .nav-dropdown-menu a {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 12px 16px;
        color: #e0e0e0;
        text-decoration: none;
        font-size: 14px;
        font-weight: 500;
        transition: background 0.15s ease;
    }

    .mobile-bottom-nav .nav-dropdown-menu a:hover {
        background: rgba(77, 171, 247, 0.15);
        color: #4dabf7;
    }

    .mobile-bottom-nav .nav-dropdown-menu a:first-child {
        border-radius: 12px 12px 0 0;
    }

    .mobile-bottom-nav .nav-dropdown-menu a:last-child {
        border-radius: 0 0 12px 12px;
    }

    /* 드롭업 오버레이 (배경 클릭 시 닫기 용) */
    .nav-dropdown-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 9998;
    }

    .nav-dropdown-overlay.active {
        display: block;
    }
}

/* 라이트 모드 지원 */
@media (max-width: 768px) {
    [data-bs-theme="light"] .mobile-bottom-nav {
        background: rgba(255, 255, 255, 0.95);
        border-top-color: #dee2e6;
    }

    [data-bs-theme="light"] .mobile-bottom-nav .nav-item {
        color: #495057;
    }

    /* 게시판 버튼 라이트 모드 */
    [data-bs-theme="light"] .mobile-bottom-nav .nav-btn {
        color: #495057;
    }

    [data-bs-theme="light"] .mobile-bottom-nav .nav-item:hover,
    [data-bs-theme="light"] .mobile-bottom-nav .nav-btn:hover {
        color: #212529;
        background: rgba(0, 0, 0, 0.05);
    }

    [data-bs-theme="light"] .mobile-bottom-nav .nav-item.active {
        color: #1971c2;
    }

    /* 게시판 드롭다운 활성/열림 상태 라이트 모드 */
    [data-bs-theme="light"] .mobile-bottom-nav .nav-item-dropdown.active .nav-btn,
    [data-bs-theme="light"] .mobile-bottom-nav .nav-item-dropdown.open .nav-btn {
        color: #1971c2;
    }

    [data-bs-theme="light"] .mobile-bottom-nav .nav-item.active::before,
    [data-bs-theme="light"] .mobile-bottom-nav .nav-item-dropdown.open::before {
        background: #1971c2;
    }

    [data-bs-theme="light"] .mobile-bottom-nav .nav-dropdown-menu {
        background: rgba(255, 255, 255, 0.98);
        border-color: #dee2e6;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    }

    [data-bs-theme="light"] .mobile-bottom-nav .nav-dropdown-menu::after {
        border-top-color: rgba(255, 255, 255, 0.98);
    }

    [data-bs-theme="light"] .mobile-bottom-nav .nav-dropdown-menu a {
        color: #212529;
    }

    [data-bs-theme="light"] .mobile-bottom-nav .nav-dropdown-menu a:hover {
        background: rgba(25, 113, 194, 0.1);
        color: #1971c2;
    }
}