/* ===================================================================
   HBC Mobile CSS — 앱 수준 모바일 최적화
   적용: src/main/resources/static/css/hbc-mobile.css
   =================================================================== */

/* ── CSS 변수 ── */
:root {
    --mobile-bottom-nav-height: 64px;
    --mobile-topbar-height: 56px;
    --mobile-safe-bottom: env(safe-area-inset-bottom, 0px);
    --touch-target: 48px;
}

/* ============================================================
   1. 전역 모바일 기초
   ============================================================ */
@media (max-width: 767.98px) {

    /* 바디 여백 — 하단 탭바 공간 확보 */
    body {
        padding-bottom: calc(var(--mobile-bottom-nav-height) + var(--mobile-safe-bottom));
        -webkit-tap-highlight-color: transparent;
        -webkit-text-size-adjust: 100%;
    }

    /* pt-6 override */
    .pt-6 {
        padding-top: calc(var(--mobile-topbar-height) + 12px) !important;
    }

    /* 전체 컨테이너 패딩 */
    .container-xl,
    .container {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    /* py-5 override */
    .py-5 { padding-top: 1.5rem !important; padding-bottom: 1.5rem !important; }
    .pb-5 { padding-bottom: 1.5rem !important; }
    .mb-5 { margin-bottom: 1.5rem !important; }
    .mb-4 { margin-bottom: 1rem !important; }
    .mt-5 { margin-top: 1.5rem !important; }

    /* 터치 타겟 */
    a, button, .btn { min-height: var(--touch-target); }
    .btn { display: inline-flex; align-items: center; justify-content: center; }
    .btn-sm { min-height: 40px; }

    /* 텍스트 크기 */
    h1, .hbc-hero-title { font-size: 1.6rem !important; line-height: 1.25 !important; }
    h2 { font-size: 1.35rem !important; }
    h3 { font-size: 1.2rem !important; }
    h4 { font-size: 1.1rem !important; }
    h5 { font-size: 1rem !important; }
    h6 { font-size: 0.9rem !important; }

    /* 카드 패딩 */
    .hbc-card-body { padding: 1rem !important; }
    .hbc-card-header { padding: 0.75rem 1rem !important; }
}

/* ============================================================
   2. 모바일 상단 네비게이션
   ============================================================ */
@media (max-width: 767.98px) {

    .hbc-navbar {
        height: var(--mobile-topbar-height) !important;
        padding: 0 12px !important;
    }

    /* 브랜드 */
    .hbc-logo-text .logo-sub { display: none !important; }
    .hbc-logo-text .logo-main { font-size: 1.1rem !important; }
    .hbc-logo-icon { width: 32px !important; height: 32px !important; }

    /* 포인트 배지 — 상단 노출 */
    .hbc-balance-badge {
        font-size: 0.78rem !important;
        padding: 4px 8px !important;
        border-radius: 20px;
        background: rgba(245,158,11,0.12);
        border: 1px solid rgba(245,158,11,0.3);
    }

    /* 데스크톱 메뉴 완전 숨김 */
    .navbar-collapse { display: none !important; }

    /* 토글 버튼 크기 */
    .navbar-toggler { 
        padding: 8px !important; 
        min-height: auto !important;
        min-width: 40px;
    }

    /* 네비게이션 우측 영역 */
    .navbar .d-flex.align-items-center.gap-3 {
        gap: 8px !important;
    }
}

/* ============================================================
   3. 하단 탭 네비게이션 (모바일 전용)
   ============================================================ */
.mobile-bottom-nav {
    display: none;
}

@media (max-width: 767.98px) {
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: var(--mobile-bottom-nav-height);
        padding-bottom: var(--mobile-safe-bottom);
        background: rgba(15, 18, 30, 0.97);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid rgba(255,255,255,0.08);
        z-index: 1050;
        justify-content: space-around;
        align-items: center;
    }

    .mobile-tab-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        flex: 1;
        height: 100%;
        text-decoration: none;
        color: rgba(255,255,255,0.45);
        font-size: 0.6rem;
        font-weight: 600;
        letter-spacing: 0.02em;
        transition: color 0.15s;
        position: relative;
        padding: 4px 0;
        min-height: auto; /* 탭 아이템은 예외 */
    }

    .mobile-tab-item i {
        font-size: 1.4rem;
        line-height: 1;
    }

    .mobile-tab-item.active {
        color: #f59e0b;
    }

    .mobile-tab-item.active i {
        filter: drop-shadow(0 0 8px rgba(245,158,11,0.5));
    }

    /* 중앙 드랍 버튼 강조 */
    .mobile-tab-item.tab-bookclub {
        background: linear-gradient(135deg, #f59e0b, #d97706);
        width: 52px;
        height: 52px;
        border-radius: 16px;
        margin-top: -10px;
        color: #000 !important;
        flex: none;
        box-shadow: 0 4px 16px rgba(245,158,11,0.4);
        font-size: 0.58rem;
        font-weight: 700;
        min-height: auto;
    }

    .mobile-tab-item.tab-bookclub i {
        font-size: 1.3rem;
    }

    /* 배지 */
    .mobile-tab-badge {
        position: absolute;
        top: 6px;
        right: calc(50% - 18px);
        background: #ef4444;
        color: #fff;
        font-size: 0.55rem;
        font-weight: 700;
        min-width: 14px;
        height: 14px;
        border-radius: 7px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 3px;
        line-height: 1;
    }
}

/* ============================================================
   4. 모바일 오프캔버스 메뉴 개선
   ============================================================ */
@media (max-width: 767.98px) {
    .hbc-offcanvas {
        width: 85vw !important;
        max-width: 320px !important;
        background: #0f1320 !important;
    }

    .hbc-mobile-link {
        display: flex;
        align-items: center;
        padding: 14px 16px !important;
        min-height: var(--touch-target);
        border-radius: 12px;
        font-size: 0.92rem !important;
        font-weight: 500;
        color: rgba(255,255,255,0.8) !important;
        text-decoration: none;
        transition: background 0.15s;
        border: none;
        background: none;
        width: 100%;
    }

    .hbc-mobile-link:hover,
    .hbc-mobile-link:active {
        background: rgba(255,255,255,0.06) !important;
        color: white !important;
    }

    .hbc-mobile-link i {
        font-size: 1.15rem;
        width: 28px;
        flex-shrink: 0;
    }

    /* 섹션 구분선 */
    .offcanvas-body hr {
        border-color: rgba(255,255,255,0.07) !important;
        margin: 8px 0 !important;
    }
}

/* ============================================================
   5. 히어로 섹션
   ============================================================ */
@media (max-width: 767.98px) {
    .hbc-hero {
        min-height: auto !important;
        padding: 0 !important;
    }

    .hbc-hero .row { min-height: auto !important; }
    .hbc-hero .col-lg-6:first-child { padding-top: 2rem; }

    .hbc-coin-container {
        display: none !important; /* 히어로 코인 숨김 — 공간 절약 */
    }

    .hbc-hero-badge {
        font-size: 0.72rem !important;
        padding: 5px 12px !important;
    }

    .hbc-hero-desc {
        font-size: 0.88rem !important;
        line-height: 1.65 !important;
    }

    /* CTA 버튼 풀 너비 */
    .hbc-hero .d-flex.flex-wrap.gap-3 {
        flex-direction: column !important;
    }
    .hbc-hero .d-flex.flex-wrap.gap-3 > a,
    .hbc-hero .d-flex.flex-wrap.gap-3 > button {
        width: 100% !important;
    }

    /* 통계 3열 */
    .hbc-stat-card .hbc-stat-num { font-size: 1.1rem !important; }
    .hbc-stat-card .hbc-stat-label { font-size: 0.65rem !important; }
}

/* ============================================================
   6. 페이지 헤더
   ============================================================ */
@media (max-width: 767.98px) {
    .hbc-page-header {
        padding: 12px 0 12px !important;
    }

    .hbc-page-icon {
        width: 40px !important;
        height: 40px !important;
        font-size: 1.1rem !important;
    }

    /* 카테고리 탭 가로 스크롤 */
    .hbc-category-tabs {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
        flex-wrap: nowrap !important;
        padding-bottom: 4px;
        gap: 6px !important;
    }

    .hbc-category-tabs::-webkit-scrollbar { display: none; }

    .hbc-cat-tab {
        white-space: nowrap !important;
        font-size: 0.78rem !important;
        padding: 7px 14px !important;
        border-radius: 20px !important;
        flex-shrink: 0;
        min-height: 36px !important;
    }
}

/* ============================================================
   7. 서점 (Shop)
   ============================================================ */
@media (max-width: 767.98px) {

    /* 검색창 */
    .hbc-search-wrapper {
        gap: 8px !important;
    }

    .hbc-search-input {
        font-size: 0.9rem !important;
        padding: 12px 14px !important;
    }

    /* 책 그리드 — 2열 유지하되 카드 개선 */
    .col-lg-2.col-md-3.col-sm-4.col-6 {
        padding: 0 4px !important;
    }

    .hbc-book-grid-card {
        border-radius: 12px !important;
    }

    .hbc-book-grid-title {
        font-size: 0.75rem !important;
        -webkit-line-clamp: 2 !important;
    }

    .hbc-book-grid-author {
        font-size: 0.68rem !important;
    }

    .hbc-book-grid-price {
        font-size: 0.78rem !important;
    }

    .hbc-book-grid-info {
        padding: 8px !important;
    }
}

/* ============================================================
   8. 대시보드
   ============================================================ */
@media (max-width: 767.98px) {
    /* 프로필 헤더 — 세로 정렬 */
    .hbc-dashboard-header .row {
        flex-direction: column !important;
    }

    .hbc-dashboard-header .col-auto:last-child {
        width: 100%;
    }

    .hbc-balance-display {
        text-align: center;
        padding: 12px !important;
        background: rgba(245,158,11,0.06);
        border-radius: 12px;
        border: 1px solid rgba(245,158,11,0.2);
    }

    .hbc-balance-amount { 
        justify-content: center;
        font-size: 1.6rem !important;
    }

    /* 통계 4열 → 2열 */
    .hbc-stat-box {
        padding: 12px !important;
    }

    .hbc-stat-box-num { font-size: 1.3rem !important; }
    .hbc-stat-box-label { font-size: 0.7rem !important; }

    /* 빠른 메뉴 버튼 그리드 */
    .hbc-quick-btn {
        font-size: 0.85rem !important;
        padding: 12px 14px !important;
        border-radius: 10px !important;
    }

    /* 카드들 순서 재배치 — 모바일엔 빠른메뉴 마지막 */
    .hbc-mini-book-list {
        max-height: none !important;
    }
}

/* ============================================================
   9. 배지 / NFT 마켓
   ============================================================ */
@media (max-width: 767.98px) {
    /* 배지 카드 2열 */
    .badge-card {
        border-radius: 12px !important;
    }

    .badge-img-wrap {
        padding: 16px !important;
        min-height: 130px !important;
    }

    .badge-img-wrap img {
        width: 88px !important;
        height: 88px !important;
    }

    .badge-info {
        padding: 12px !important;
    }

    .badge-price { font-size: 0.95rem !important; }

    /* 구매 버튼 */
    .badge-info .d-flex.justify-content-between {
        flex-direction: column !important;
        gap: 8px !important;
    }

    .badge-info .d-flex.gap-2 {
        width: 100% !important;
    }

    .badge-info form,
    .badge-info a.btn {
        flex: 1 !important;
    }

    .badge-info .btn {
        width: 100% !important;
        padding: 10px !important;
        font-size: 0.82rem !important;
    }
}

/* ============================================================
   10. 헬리드랍
   ============================================================ */
@media (max-width: 767.98px) {
    .hbc-drop-hero {
        padding: 0 0 1rem !important;
    }

    .hbc-drop-card-big {
        border-radius: 16px !important;
    }

    .hbc-drop-card-body { padding: 16px !important; }
    .hbc-drop-card-footer { padding: 12px 16px !important; }

    .hbc-drop-card-body h4 { font-size: 1.05rem !important; }
}

/* ============================================================
   11. 독서토론 (Bookclub)
   ============================================================ */
@media (max-width: 767.98px) {
    .club-cover { aspect-ratio: 4/3 !important; }
    .club-info { padding: 12px !important; }

    /* 상세 페이지 — 2열 → 1열 */
    .bookclub-detail .col-lg-4 { margin-bottom: 1rem; }
}

/* ============================================================
   12. 교육 강의
   ============================================================ */
@media (max-width: 767.98px) {
    .course-thumb { aspect-ratio: 16/9 !important; }
    .course-info { padding: 12px !important; }
    .course-info h6 { font-size: 0.88rem !important; }

    /* 학습 페이지 — 사이드바 */
    .learn-sidebar { 
        display: none !important;
    }

    .learn-main {
        height: auto !important;
        padding-bottom: 80px;
    }

    .learn-content {
        padding: 16px 12px 40px !important;
    }

    .video-wrap {
        border-radius: 8px !important;
    }
}

/* ============================================================
   13. 모바일 전용 UI 컴포넌트
   ============================================================ */
@media (max-width: 767.98px) {

    /* 풀 너비 버튼 컨테이너 */
    .mobile-full-btn-group {
        display: flex;
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }

    .mobile-full-btn-group .btn {
        width: 100% !important;
    }

    /* 상단 알림 배너 */
    .alert {
        border-radius: 10px !important;
        font-size: 0.84rem !important;
        padding: 12px 14px !important;
    }

    /* 모달 — 하단 슬라이드 */
    .modal-dialog {
        margin: 0 !important;
        max-width: 100% !important;
        align-items: flex-end !important;
        min-height: 100% !important;
        display: flex !important;
    }

    .modal-content {
        border-radius: 20px 20px 0 0 !important;
        border-bottom: none !important;
        width: 100% !important;
    }

    .modal-dialog-centered {
        align-items: center !important;
        margin: 12px !important;
        max-width: calc(100% - 24px) !important;
        min-height: auto !important;
    }

    .modal-dialog-centered .modal-content {
        border-radius: 20px !important;
        border: 1px solid rgba(255,255,255,0.1) !important;
    }

    /* 폼 입력 — 더 크게 */
    .hbc-form-input,
    input.hbc-form-input,
    .hbc-form-control,
    .form-control,
    .form-select,
    select {
        font-size: 16px !important; /* iOS 줌 방지 */
        min-height: 48px !important;
        border-radius: 10px !important;
    }

    textarea.hbc-form-input,
    textarea.form-control {
        min-height: auto !important;
    }

    /* 드롭다운 */
    .hbc-dropdown {
        max-width: 260px !important;
    }

    /* 페이지네이션 */
    .pagination .page-link {
        width: 36px;
        height: 36px;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 0.8rem !important;
    }
}

/* ============================================================
   14. 어드민 — 모바일 접근
   ============================================================ */
@media (max-width: 767.98px) {
    .admin-main { margin-left: 0 !important; }
    .admin-topbar { padding: 0 12px !important; height: 52px !important; }
    .admin-content { padding: 12px !important; }
    .admin-card { border-radius: 10px !important; }

    .admin-table thead th { font-size: 0.72rem !important; padding: 8px !important; }
    .admin-table tbody td { font-size: 0.78rem !important; padding: 8px !important; }

    /* 어드민 테이블 가로 스크롤 */
    .table-responsive { 
        -webkit-overflow-scrolling: touch !important;
    }
}

/* ============================================================
   15. 마이페이지 / 프로필
   ============================================================ */
@media (max-width: 767.98px) {
    /* 사이드바 → 상단 카드 */
    .mypage-sidebar .hbc-card {
        border-radius: 16px;
        margin-bottom: 12px;
    }

    /* 포인트 내역 테이블 */
    .hbc-table thead th {
        font-size: 0.72rem !important;
        padding: 8px !important;
    }
    .hbc-table tbody td {
        font-size: 0.78rem !important;
        padding: 8px !important;
    }
}

/* ============================================================
   16. 스크롤 / 당기기 힌트
   ============================================================ */
@media (max-width: 767.98px) {
    .hbc-scroll-hint { display: none !important; }

    /* 가로 스크롤 컨테이너 */
    .mobile-hscroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        margin: 0 -16px;
        padding: 0 16px;
    }

    .mobile-hscroll::-webkit-scrollbar { display: none; }
    .mobile-hscroll > * { flex-shrink: 0; }

    /* 섹션 패딩 축소 */
    .py-6 { padding-top: 2.5rem !important; padding-bottom: 2.5rem !important; }
    section.py-6 { padding-top: 2rem !important; padding-bottom: 2rem !important; }
}

/* ============================================================
   17. 인덱스 홈페이지 섹션들
   ============================================================ */
@media (max-width: 767.98px) {

    /* 배지 등급 — 2열 */
    .grade-card img { width: 56px !important; height: 44px !important; }
    .grade-tag { font-size: 0.62rem !important; }

    /* HBC 활용 섹션 */
    .hbc-use-card { padding: 16px !important; border-radius: 12px !important; }
    .hbc-use-num { font-size: 1.8rem !important; }
    .hbc-use-icon { width: 44px !important; height: 44px !important; font-size: 1.1rem !important; }

    /* 혜택 카드 */
    .hbc-benefit-card { padding: 16px !important; }
    .hbc-benefit-icon { width: 40px !important; height: 40px !important; font-size: 1.1rem !important; }

    /* Step 섹션 */
    .hbc-step-num {
        width: 32px !important; height: 32px !important; font-size: 0.9rem !important;
    }
    .hbc-step-icon { width: 44px !important; height: 44px !important; font-size: 1.1rem !important; }

    /* 하단 CTA */
    .hbc-section-dark .text-center > .d-flex {
        flex-direction: column !important;
        padding: 0 8px;
    }
    .hbc-section-dark .text-center > .d-flex > * {
        width: 100% !important;
    }

    /* 토큰 인포 섹션 */
    .hbc-distribution-card { padding: 16px !important; }
    .hbc-donut-container { max-width: 180px; }
}

/* ============================================================
   18. 프리뷰 카드 / 마켓 배지 그리드
   ============================================================ */
@media (max-width: 767.98px) {
    /* 3열 → 2열 강제 */
    .market-preview-card { border-radius: 10px !important; }
    .market-preview-card .p-2 { padding: 8px !important; }
    .market-preview-card .text-white.small { font-size: 0.72rem !important; }
    .market-preview-card .text-warning.small { font-size: 0.7rem !important; }
}

/* ============================================================
   19. 플로팅 액션 버튼 (모바일 전용)
   ============================================================ */
@media (max-width: 767.98px) {
    .mobile-fab {
        position: fixed;
        right: 16px;
        bottom: calc(var(--mobile-bottom-nav-height) + var(--mobile-safe-bottom) + 12px);
        width: 52px;
        height: 52px;
        border-radius: 16px;
        background: linear-gradient(135deg, #f59e0b, #d97706);
        color: #000;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.3rem;
        box-shadow: 0 4px 20px rgba(245,158,11,0.4);
        z-index: 1040;
        text-decoration: none;
        border: none;
        cursor: pointer;
        transition: transform 0.15s;
    }

    .mobile-fab:hover,
    .mobile-fab:active {
        transform: scale(0.96);
        color: #000;
    }
}

/* ============================================================
   20. 스와이프 가능 섹션 표시기
   ============================================================ */
@media (max-width: 767.98px) {
    .swipe-hint {
        display: flex;
        align-items: center;
        gap: 4px;
        color: rgba(255,255,255,0.3);
        font-size: 0.68rem;
        margin-top: 6px;
    }

    .swipe-hint i { font-size: 0.75rem; animation: swipeAnim 1.5s ease-in-out infinite; }

    @keyframes swipeAnim {
        0%, 100% { transform: translateX(0); opacity: 0.4; }
        50% { transform: translateX(4px); opacity: 0.8; }
    }
}

/* ============================================================
   21. 빠른 접근 그리드 (홈화면 스타일)
   ============================================================ */
@media (max-width: 767.98px) {
    .mobile-quick-grid {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 12px;
        padding: 8px 0;
    }

    .mobile-quick-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 5px;
        text-decoration: none;
    }

    .mobile-quick-icon {
        width: 52px;
        height: 52px;
        border-radius: 14px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.3rem;
        background: rgba(255,255,255,0.06);
        border: 1px solid rgba(255,255,255,0.08);
    }

    .mobile-quick-label {
        font-size: 0.62rem;
        color: rgba(255,255,255,0.65);
        text-align: center;
        line-height: 1.2;
    }
}

/* ============================================================
   22. 배지 민트 페이지 모바일
   ============================================================ */
@media (max-width: 767.98px) {
    .badge-selectable {
        width: 68px !important;
        padding: 6px 4px !important;
    }

    .badge-selectable img { width: 48px !important; height: 48px !important; }
    .badge-selectable .badge-name { font-size: 0.58rem !important; }

    .mint-slot {
        width: 76px !important;
        height: 84px !important;
    }

    .mint-slot img { width: 44px !important; height: 44px !important; }
}

/* ============================================================
   23. 프로그램 / 오프라인 페이지
   ============================================================ */
@media (max-width: 767.98px) {
    .program-thumb-placeholder { aspect-ratio: 16/9 !important; }
    .schedule-card { padding: 12px !important; }
}

/* ============================================================
   24. 인증 페이지 (로그인/회원가입)
   ============================================================ */
@media (max-width: 767.98px) {
    .hbc-auth-card {
        padding: 24px 20px !important;
        border-radius: 0 !important;
        min-height: 100vh !important;
        border: none !important;
    }

    .hbc-auth-bg { display: none !important; }

    /* 로그인 배경 전체 처리 */
    .container.d-flex.justify-content-center.align-items-center.min-vh-100 {
        padding: 0 !important;
        align-items: flex-start !important;
    }
}

/* ============================================================
   25. 섹션 배너 / 로드맵
   ============================================================ */
@media (max-width: 767.98px) {
    .hbc-roadmap { padding-left: 20px !important; }
    .hbc-roadmap-content { padding: 14px !important; }
    .hbc-roadmap-phase { font-size: 0.68rem !important; }
}

/* ============================================================
   26. 포인트 선물 / 내역
   ============================================================ */
@media (max-width: 767.98px) {
    .hbc-earn-item {
        padding: 10px 0 !important;
    }

    .hbc-earn-icon {
        width: 36px !important;
        height: 36px !important;
        font-size: 0.95rem !important;
    }
}

/* ============================================================
   27. 접근성 & 기타
   ============================================================ */
@media (max-width: 767.98px) {
    /* 이미지 — 깨짐 방지 */
    img { max-width: 100%; height: auto; }

    /* 긴 텍스트 줄바꿈 */
    .text-break-mobile { word-break: break-word; }

    /* 숨김 유틸 */
    .d-mobile-none { display: none !important; }
    .d-mobile-block { display: block !important; }
    .d-mobile-flex { display: flex !important; }

    /* 전체 너비 */
    .w-mobile-100 { width: 100% !important; }

    /* 텍스트 중앙 */
    .text-mobile-center { text-align: center !important; }

    /* 갭 축소 */
    .gap-mobile-2 { gap: 0.5rem !important; }
    .gap-mobile-3 { gap: 0.75rem !important; }
}

/* ============================================================
   28. 태블릿 (768px ~ 991px)
   ============================================================ */
@media (min-width: 768px) and (max-width: 991.98px) {
    .mobile-bottom-nav { display: none !important; }

    body { padding-bottom: 0 !important; }

    .pt-6 { padding-top: 80px !important; }
}