/* Mobile 響應式設計專用 CSS */

/* 基本手機版樣式 */
@media (max-width: 768px) {
    /* 確保內容不會被固定頂部導航欄遮擋 */
    body {
        padding-top: 0;
    }
    
    /* 手機版頂部導航欄優化 - 動態高度 */
    #topbar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1030;
        background-color: #213743;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        padding: 5px 0;
        min-height: 120px; /* 最小高度 */
        max-height: 60vh; /* 最大高度不超過螢幕的60% */
        height: auto; /* 動態高度 */
        overflow-x: hidden;
        overflow-y: auto;
        white-space: normal;
        -webkit-overflow-scrolling: touch;
    }
    
    /* 確保所有頂部導航欄元素都可點擊 */
    #topbar * {
        pointer-events: auto;
        touch-action: manipulation;
    }
    
    #topbar .cursor-pointer,
    #topbar .btn,
    #topbar a {
        z-index: 1100;
        position: relative;
        pointer-events: auto;
        touch-action: manipulation;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* 主要內容區域調整 - 動態適應 */
    #app {
        margin-top: 0;
        padding-top: 130px; /* 為動態頂部導航欄留出基本空間 */
    }
    
    /* 搜尋和篩選控制項優化 */
    .row.mb-3 {
        margin-bottom: 1rem !important;
        margin-top: 1rem;
    }
    
    /* 頂部導航欄內容佈局優化 - 行佈局 */
    #topbar .d-md-flex {
        display: block !important;
        padding: 0 8px;
        width: 100%;
        height: auto;
        line-height: normal; /* 恢復正常行高 */
    }
    
    #topbar .d-md-flex .px-2 {
        display: inline-block !important;
        width: calc(33.333% - 8px); /* 稍微增加間距 */
        margin: 4px 4px; /* 增加上下邊距 */
        vertical-align: top;
        box-sizing: border-box;
        line-height: 1.3; /* 與上面的設定保持一致 */
    }
    
    #topbar .container-xl {
        overflow: visible !important;
        white-space: normal;
        width: 100%;
        height: auto;
        padding: 0;
        max-width: 100%;
    }
    
    /* 垂直滾動條樣式 */
    #topbar::-webkit-scrollbar {
        width: 4px;
    }
    
    #topbar::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.1);
        border-radius: 2px;
    }
    
    #topbar::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.4);
        border-radius: 2px;
    }
    
    #topbar::-webkit-scrollbar-thumb:hover {
        background: rgba(255, 255, 255, 0.6);
    }
    
    /* 數據行佈局 - 每行3個項目 */
    .topbar-data-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        margin: 2px 0;
        gap: 4px;
    }
    
    #topbar .px-2 {
        flex: 1;
        text-align: center;
        white-space: normal; /* 允許文字換行 */
        word-wrap: break-word; /* 強制長單詞換行 */
        overflow-wrap: break-word; /* 現代瀏覽器支持 */
        font-size: 0.6rem;
        padding: 6px 4px !important;
        margin: 0 !important;
        background: rgba(255,255,255,0.05);
        border-radius: 4px;
        border: 1px solid rgba(255,255,255,0.1);
        display: block;
        min-height: 32px; /* 增加最小高度以容納多行文字 */
        line-height: 1.3; /* 增加行高以改善可讀性 */
        max-height: 60px; /* 限制最大高度 */
        overflow: hidden; /* 隱藏過多的內容 */
    }
    
    /* 在手機版隱藏桌面版專用按鈕 */
    .desktop-only {
        display: none !important;
    }
    
    /* 其他導航按鈕優化 */
    #topbar .cursor-pointer {
        background-color: rgba(255, 255, 255, 0.1);
        border-radius: 4px;
        padding: 4px 8px !important;
        margin: 1px 0 !important;
        font-weight: bold;
        transition: all 0.2s ease;
        border: 1px solid rgba(255, 255, 255, 0.15);
        min-height: 30px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.6rem;
        white-space: nowrap;
        flex: 1;
        text-align: center;
    }
    
    #topbar .cursor-pointer:hover,
    #topbar .cursor-pointer:active {
        background-color: rgba(255, 255, 255, 0.2);
        border-color: rgba(255, 255, 255, 0.3);
        transform: translateY(-1px);
    }
    
    #topbar .btn {
        margin: 1px 0 !important;
        min-height: 30px;
        padding: 4px 8px !important;
        border-radius: 4px;
        font-weight: bold;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s ease;
        font-size: 0.6rem;
        white-space: nowrap;
        flex: 1;
        text-align: center;
    }
    
    #topbar .btn:hover,
    #topbar .btn:active {
        background-color: rgba(255, 255, 255, 0.1);
        transform: translateY(-1px);
    }
    
    /* 添加垂直滾動指示器 */
    #topbar::after {
        content: '↑ 滑動查看更多 ↓';
        position: absolute;
        bottom: 3px;
        right: 8px;
        font-size: 0.5rem;
        color: rgba(255, 255, 255, 0.6);
        pointer-events: none;
        z-index: 1040;
        background: linear-gradient(180deg, transparent 0%, #213743 30%, #213743 70%, transparent 100%);
        padding: 2px 4px;
        border-radius: 2px;
        opacity: 0.8;
    }
    
    /* 當滾動到右邊時隱藏指示器 */
    #topbar::-webkit-scrollbar {
        height: 2px;
    }
    
    #topbar::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.1);
    }
    
    #topbar::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.3);
        border-radius: 1px;
    }
    
    #topbar::-webkit-scrollbar-thumb:hover {
        background: rgba(255, 255, 255, 0.5);
    }
    
    /* 表單控制項在手機版的優化 */
    .form-control-sm {
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
    }
    
    /* 按鈕組在手機版的優化 */
    .btn-group-sm > .btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
    
    /* 響應式網格調整 */
    .col-md-4.col-12,
    .col-md-2.col-6,
    .col-md-3.col-6 {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    /* 頂部控制按鈕區域 - Stats 和 Presenter Mode */
    #topbar-control-section {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        padding: 6px 8px; /* 增加垂直內距 */
        background: rgba(255,255,255,0.08);
        border-bottom: 1px solid rgba(255,255,255,0.1);
        margin-bottom: 6px; /* 增加與數據區域的間距 */
        gap: 8px;
        min-height: 50px; /* 確保控制區域有足夠高度 */
    }
    
    /* 手機版數據區域文字優化 */
    #topbar .px-2 b {
        display: block; /* 讓標籤換行 */
        font-size: 0.55rem;
        margin-bottom: 2px;
        color: rgba(255,255,255,0.8);
    }
    
    /* 處理長數據字串的顯示 */
    #topbar .px-2 {
        hyphens: auto; /* 啟用自動斷字 */
        -webkit-hyphens: auto;
        -ms-hyphens: auto;
    }
    
    /* 針對特定數據類型的優化 */
    #topbar .px-2:nth-child(6) { /* Max LS */
        font-size: 0.55rem; /* 稍微縮小字體以容納更多內容 */
    }
    
    #topbar-control-section .control-btn {
        flex: 1;
        background-color: rgba(255, 255, 255, 0.2);
        border: 2px solid rgba(255, 255, 255, 0.3);
        border-radius: 8px;
        padding: 8px 12px;
        font-weight: bold;
        transition: all 0.2s ease;
        min-height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.75rem;
        color: #fff;
        text-align: center;
        cursor: pointer;
        touch-action: manipulation;
    }
    
    #topbar-control-section .control-btn:hover,
    #topbar-control-section .control-btn:active {
        background-color: rgba(255, 255, 255, 0.3);
        border-color: rgba(255, 255, 255, 0.5);
        transform: translateY(-1px);
    }
    
    /* 優化長字串顯示（如錢包地址、哈希值等） */
    #topbar .px-2 {
        text-overflow: ellipsis; /* 過長文字顯示省略號 */
    }
    
    /* 為不同類型的數據提供更好的顯示 */
    #topbar .px-2:contains("Max LS") {
        font-size: 0.5rem !important;
        line-height: 1.2;
    }
    
    /* 在極小螢幕上進一步優化 */
    @media (max-width: 360px) {
        #topbar .px-2 {
            font-size: 0.5rem;
            padding: 4px 2px !important;
            min-height: 28px;
        }
        
        #topbar .d-md-flex .px-2 {
            width: calc(50% - 6px); /* 在小螢幕上改為2欄佈局 */
        }
        
        #topbar .d-md-flex .px-2:nth-child(odd) {
            clear: left;
        }
    }
    
    /* 提供備選的簡化顯示模式 */
    #topbar .px-2.simplified {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 0.55rem;
        min-height: 24px;
    }
}

/* 直向模式手機版 */
@media (max-width: 768px) and (orientation: portrait) {
    /* 直向模式使用動態頂部間距 */
    #app {
        padding-top: 130px; /* 保持與主樣式一致 */
    }
    
    #topbar {
        min-height: 120px;
        max-height: 60vh;
        height: auto;
        padding: 5px 0;
        overflow-x: hidden;
        overflow-y: auto;
    }
    
    /* 容器調整 */
    .container-xl {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    /* 統計頁面直向模式優化 */
    .stats-card {
        margin-bottom: 1.5rem;
    }
    
    .stats-card .card-body {
        padding: 1.25rem 1rem;
    }
}

/* 橫向模式手機版 */
@media (max-width: 768px) and (orientation: landscape) {
    /* 橫向模式使用動態頂部間距 */
    #app {
        padding-top: 130px; /* 保持與主樣式一致 */
    }
    
    #topbar {
        min-height: 100px; /* 橫向模式稍小的最小高度 */
        max-height: 50vh; /* 橫向模式最大高度較小 */
        height: auto;
        padding: 5px 0;
        overflow-x: hidden;
        overflow-y: auto;
    }
    
    /* 容器調整 */
    .container-xl {
        padding-left: 10px;
        padding-right: 10px;
    }
    
    /* 統計頁面橫向模式優化 */
    .stats-card .card-body {
        padding: 0.75rem 0.5rem;
    }
    
    .stats-card .h5 {
        font-size: 1rem;
    }
    
    #topbar .px-2 {
        font-size: 0.5rem;
        padding: 3px 2px !important;
        min-height: 24px;
        line-height: 1.2;
    }
    
    #topbar-control-section {
        padding: 4px 8px;
        min-height: 40px;
    }
}

/* 觸摸優化 */
@media (max-width: 768px) {
    /* 增加觸摸目標的大小 */
    .btn {
        min-height: 44px; /* iOS HIG建議的最小觸摸目標 */
        padding: 0.5rem 1rem;
    }
    
    .btn-sm {
        min-height: 36px;
        padding: 0.375rem 0.75rem;
    }
    
    /* 確保連結和按鈕有足夠的觸摸區域 */
    a, button {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* 表單輸入元素優化 */
    input, select, textarea {
        min-height: 44px;
        font-size: 16px; /* 防止iOS自動縮放 */
    }
    
    /* 避免橫向滾動 */
    .container-xl,
    .row {
        overflow-x: hidden;
    }
}

/* 高度較小的裝置優化 */
@media (max-height: 600px) and (max-width: 768px) {
    #topbar {
        min-height: 80px; /* 較小但仍保持動態 */
        max-height: 40vh; /* 限制最大高度 */
        padding: 3px 0;
    }
    
    #topbar .px-2 {
        font-size: 0.6rem;
        padding: 1px 5px !important;
    }
    
    #app {
        padding-top: 90px; /* 調整內容區域 */
    }
}

/* 極小高度裝置優化 */
@media (max-height: 500px) and (max-width: 768px) {
    #topbar {
        min-height: 60px; /* 最小可用高度 */
        max-height: 35vh; /* 嚴格限制最大高度 */
        padding: 2px 0;
    }
    
    #topbar .px-2 {
        font-size: 0.55rem;
        padding: 1px 4px !important;
    }
    
    #app {
        padding-top: 70px; /* 調整內容區域 */
    }
}

/* 確保在所有手機版情況下都有適當的間距 */
@media (max-width: 768px) {
    /* 防止內容被遮擋 */
    .row:first-child,
    .container-xl > .row:first-child {
        margin-top: 2rem;
    }
    
    /* 確保搜尋和篩選控制項有足夠的間距 */
    .row.mb-3:first-of-type {
        margin-top: 2rem !important;
        padding-top: 1rem;
    }
    
    /* 確保頁面底部有足夠的間距 */
    .container-xl {
        padding-bottom: 2rem;
    }
    
    /* 優化滾動體驗 */
    body {
        -webkit-overflow-scrolling: touch;
    }
}

/* 桌面版重寫 - 確保桌面版不受手機版CSS影響 */
@media (min-width: 769px) {
    /* 恢復桌面版頂部導航欄 */
    #topbar {
        position: relative !important;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        padding: 10px 0 !important;
        background-color: #213743;
    }
    
    #app {
        padding-top: 0 !important;
        margin-top: 0 !important;
    }
    
    /* 恢復桌面版導航欄佈局 */
    #topbar .d-md-flex {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 0 !important;
        line-height: normal !important;
    }
    
    #topbar .container-xl {
        padding: 0 15px !important;
        max-width: 1140px !important;
        overflow: visible !important;
    }
    
    #topbar .px-2 {
        display: inline-block !important;
        width: auto !important;
        margin: 0 !important;
        padding: 4px 8px !important;
        font-size: 0.8rem !important;
        min-height: auto !important;
        line-height: 1.4 !important;
        flex: none !important;
        background: rgba(255,255,255,0.05);
        border-radius: 4px;
        border: 1px solid rgba(255,255,255,0.1);
        white-space: nowrap;
    }
    
    /* 隱藏手機版控制區域，顯示桌面版專用按鈕 */
    #topbar-control-section {
        display: none !important;
    }
    
    .desktop-only {
        display: block !important;
    }
    
    /* 恢復桌面版按鈕樣式 */
    #topbar .cursor-pointer,
    #topbar .btn {
        background-color: rgba(255, 255, 255, 0.1) !important;
        border: 1px solid rgba(255, 255, 255, 0.2) !important;
        border-radius: 4px !important;
        padding: 6px 12px !important;
        margin: 0 4px !important;
        font-weight: bold !important;
        transition: all 0.2s ease !important;
        min-height: auto !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 0.8rem !important;
        white-space: nowrap !important;
        flex: none !important;
        text-align: center !important;
        color: #fff !important;
        text-decoration: none !important;
    }
    
    #topbar .cursor-pointer:hover,
    #topbar .cursor-pointer:active,
    #topbar .btn:hover,
    #topbar .btn:active {
        background-color: rgba(255, 255, 255, 0.2) !important;
        border-color: rgba(255, 255, 255, 0.4) !important;
        transform: translateY(-1px) !important;
        box-shadow: 0 2px 4px rgba(0,0,0,0.2) !important;
    }
    
    /* 確保桌面版滾動正常 */
    #topbar::after {
        display: none !important;
    }
    
    /* 恢復搜索和篩選功能顯示 */
    .search-box,
    .form-control,
    select.form-control {
        display: block !important;
        width: 100% !important;
    }
    
    /* 確保表格正常顯示 */
    .table-responsive {
        display: block !important;
        overflow-x: auto !important;
    }
} 