/*
 * BybitFX – 모바일 반응형 공통 스타일
 * 모든 페이지에서 header.php를 통해 자동 로드됨
 */

/* ===== PREVENT HORIZONTAL SCROLL (mobile) ===== */
@media (max-width: 1023px) {
    html, body {
        overflow-x: hidden;
        max-width: 100vw;
    }
    #div-1 {
        overflow-x: hidden !important;
    }
}

/* ===== TOUCH TARGET ===== */
@media (max-width: 1023px) {
    .btn-primary, .btn-outline {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* ===== PANEL / CARD 모바일 패딩 ===== */
@media (max-width: 767px) {
    .panel {
        border-radius: 8px;
    }
    main {
        padding-left: 12px;
        padding-right: 12px;
    }
}

/* ===== TABLE → CARD 전환 (포지션, 히스토리 등) ===== */
@media (max-width: 767px) {
    .mob-card-table thead {
        display: none;
    }
    .mob-card-table tbody tr {
        display: block;
        background: #131722;
        border: 1px solid #1e2535;
        border-radius: 8px;
        margin-bottom: 8px;
        padding: 12px;
    }
    .mob-card-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 4px 0;
        border: none;
        font-size: 12px;
    }
    .mob-card-table tbody td::before {
        content: attr(data-label);
        color: #6b7280;
        font-size: 11px;
        font-weight: 600;
        flex-shrink: 0;
        margin-right: 8px;
    }
}

/* ===== EXCHANGE PAGE 모바일 ===== */
@media (max-width: 1023px) {
    /* #div-1: top nav(56px) + bottom nav(56px) 모두 제외 */
    #div-1 {
        height: calc(100vh - 56px - 56px) !important;
    }
    #mob-tabs {
        display: flex !important;
        height: 44px;
    }
    .mob-tab {
        min-height: 44px;
        touch-action: manipulation;
    }
    /* Stats row: horizontal scroll */
    #div-8 {
        overflow-x: auto;
    }
}

/* ===== COIN SELECTOR POPUP (mobile) ===== */
@media (max-width: 767px) {
    /* Full-width popup, anchored below ticker */
    #col-coins {
        top: 100px !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 0 0 12px 12px !important;
        max-height: calc(100vh - 160px) !important;
    }
    /* Hide bulky header stats, keep coin name + price only */
    #coins-hdr-stats { display: none !important; }
    /* Compact header padding */
    #col-coins > div:first-child {
        padding: 8px 12px !important;
    }
    #market-search {
        font-size: 12px !important;
        height: 20px !important;
        line-height: 20px !important;
        padding: 0 !important;
        margin: 0 !important;
        -webkit-appearance: none;
        appearance: none;
    }
    /* Coin list max height */
    #div-18 { max-height: calc(100vh - 240px) !important; }
}

/* ===== EXCHANGE - COMPACT TICKER (mobile) ===== */
@media (max-width: 767px) {
    #div-2 {
        height: 44px !important;
        min-height: 44px !important;
        padding-left: 8px !important;
        padding-right: 8px !important;
        gap: 8px !important;
    }
    /* Hide redundant asset icon next to button */
    #div-3 { display: none !important; }
    /* Compact price */
    #main-price { font-size: 15px !important; }
    #main-change { font-size: 10px !important; }
    /* Hide vertical divider */
    #div-7 { display: none !important; }
    /* Compact stats row */
    #div-8 { gap: 10px !important; }
    #div-8 > div > p:first-child { font-size: 9px !important; }
    #div-8 > div > p:last-child  { font-size: 10px !important; }
}

/* ===== EXCHANGE - ORDER FORM COMPACT (mobile) ===== */
@media (max-width: 767px) {
    /* Remove left border on mobile (full width) */
    #col-order { border-left: none !important; }

    /* Compact inputs */
    #col-order input[type="text"],
    #col-order select {
        height: 34px !important;
        min-height: 34px !important;
        font-size: 13px !important;
    }

    /* Compact control rows */
    #col-order .gap-2\.5  { gap: 5px !important; }
    #col-order .pt-2\.5   { padding-top: 6px !important; }
    #col-order .pb-2      { padding-bottom: 5px !important; }
    #col-order .py-2\.5   { padding-top: 5px !important; padding-bottom: 5px !important; }
    #col-order .px-2\.5   { padding-left: 8px !important; padding-right: 8px !important; }

    /* Buy/Sell buttons: bigger touch target */
    #col-order button[onclick*="submitOrder"] {
        min-height: 44px !important;
        font-size: 13px !important;
    }

    /* Hide heavy balance details (saves ~120px) */
    #div-71 { display: none !important; }
    #div-80 { display: none !important; }

    /* Position panel compact tab bar */
    .pos-tab-btn {
        font-size: 10px !important;
        padding-left: 8px !important;
        padding-right: 8px !important;
        height: 36px !important;
    }

    /* Position panel body: horizontal scroll for table */
    #pos-panel-body {
        overflow-x: auto !important;
    }

    /* Orderbook full-width on Book tab */
    #col-orderbook { width: 100% !important; }

    /* Timeframe bar: compact */
    #tf-bar { height: 32px !important; }
    .tf-btn { padding: 4px 8px !important; font-size: 10px !important; }
}

/* ===== FOOTER 모바일 완전 숨김 (하단 nav가 대체) ===== */
@media (max-width: 1023px) {
    footer { display: none !important; }
}
@media (max-width: 767px) {
    .max-w-2xl, .max-w-xl, .max-w-md {
        padding-left: 16px;
        padding-right: 16px;
    }
    /* 입력 필드 충분한 높이 */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"] {
        min-height: 48px;
        padding: 12px 16px !important;
    }
    /* 제출 버튼 */
    button[type="submit"], .btn-submit {
        min-height: 52px;
        font-size: 15px;
    }
}

/* ===== MARKETS PAGE 모바일 ===== */
@media (max-width: 767px) {
    .market-row td {
        padding-top: 10px;
        padding-bottom: 10px;
    }
    /* 코인명 줄바꿈 방지 */
    .market-row .coin-name {
        font-size: 13px;
        white-space: nowrap;
    }
}

/* ===== MODAL (전역 Alert) 모바일 ===== */
@media (max-width: 480px) {
    #fx-modal-box {
        width: calc(100% - 24px) !important;
        border-radius: 16px !important;
    }
}

/* ===== FOOTER 모바일 ===== */
@media (max-width: 767px) {
    footer .flex.items-center.justify-between {
        flex-direction: column;
        gap: 6px;
        height: auto !important;
        padding: 10px 16px;
        text-align: center;
    }
}

/* ===== SCROLLBAR 모바일 숨김 ===== */
@media (max-width: 767px) {
    .custom-scroll::-webkit-scrollbar {
        display: none;
    }
    .custom-scroll {
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
}

/* ===== 숫자 (가격) tabular-nums 강제 ===== */
.tabular-nums {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

/* ===== ACTIVE STATE (터치 피드백) ===== */
@media (max-width: 1023px) {
    .mob-nav-item:active,
    button:active {
        opacity: 0.7;
        transition: opacity 0.05s;
    }
}
