/**
 * 衍生品市场数据看板样式 - 紧凑暗色风格
 */

:root {
    --bg-primary: #0d0d16;
    --bg-secondary: #161625;
    --bg-card: #12121e;
    --bg-hover: #1a1a2e;
    --text-primary: #e2e8f0;
    --text-secondary: #8892a4;
    --text-muted: #4b5568;
    --border-color: rgba(255,255,255,0.07);
    --accent-blue: #3b82f6;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --accent-orange: #f59e0b;
    --accent-purple: #a78bfa;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    max-width: 100%;
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1.5;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 16px 20px;
}

/* 页面头部 */
.page-header {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.page-header h1 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.update-time {
    color: var(--text-muted);
    font-size: 12px;
}

/* 标签导航 */
.tab-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px 18px;
    font-size: 13px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.2s, border-color 0.2s;
    line-height: 1.35;
    white-space: normal;
}

.tab-btn:hover { color: var(--text-primary); }

.tab-btn.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
}

/* 标签面板 */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* 面板头部 */
.panel-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.panel-header h2 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.update-info {
    font-size: 11px;
    color: var(--text-muted);
}

/* 币种标签 */
.coin-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    flex-wrap: wrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.coin-tabs::-webkit-scrollbar { display: none; }

.coin-tab-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.coin-tab-btn:hover { border-color: var(--accent-blue); color: var(--text-primary); }

.coin-tab-btn.active {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: white;
}

/* 周期标签 */
.period-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.period-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 3px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.period-btn:hover { border-color: var(--accent-blue); }

.period-btn.active {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: white;
}

/* 卡片 */
.chart-card, .table-card, .summary-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 14px 16px;
    margin-bottom: 14px;
    min-width: 0;
}

.chart-card h3, .table-card h3 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* 图表高度 */
.chart-card canvas { max-height: 220px !important; height: 220px !important; width: 100% !important; }
#liq-heatmap-chart  { max-height: 220px !important; height: 220px !important; }
#fng-chart          { max-height: 200px !important; height: 200px !important; }

/* 热力图图例 */
.heatmap-legend {
    display: flex;
    gap: 16px;
    margin-bottom: 10px;
    font-size: 12px;
    color: var(--text-secondary);
}

.legend-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}

.legend-dot.long  { background: var(--accent-red); }
.legend-dot.short { background: var(--accent-green); }

/* 表格 */
.table-wrapper { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

th, td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--border-color); }

th { color: var(--text-muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }

td { color: var(--text-primary); font-size: 13px; }

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
    font-size: 13px;
}

/* 正负值颜色 */
.positive { color: var(--accent-green); }
.negative { color: var(--accent-red); }

/* 指标列表（交易所分布条形） */
.metric-list { display: flex; flex-direction: column; gap: 7px; }

.metric-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: var(--bg-secondary);
    border-radius: 4px;
    min-width: 0;
}

.metric-exchange { font-size: 12px; font-weight: 500; color: var(--text-primary); }
.metric-value    { font-size: 13px; font-weight: 600; color: var(--accent-blue); }

.exchange-bar-wrap {
    background: rgba(255,255,255,0.05);
    height: 16px;
    border-radius: 3px;
    overflow: hidden;
}

.exchange-bar {
    height: 100%;
    background: var(--accent-blue);
    opacity: 0.55;
    transition: width 0.3s;
}

.exchange-pct { font-size: 11px; color: var(--text-muted); }

.metric-row .metric-exchange,
.metric-row .metric-value,
.metric-row .exchange-pct,
.metric-row .exchange-bar-wrap {
    min-width: 0 !important;
    overflow-wrap: anywhere;
}

/* 交易所爆仓分布：强制可收缩，避免移动端被内联 min-width 撑出 */
#liq-exchange-dist .metric-list {
    width: 100%;
    min-width: 0;
}

#liq-exchange-dist .metric-row > * {
    min-width: 0 !important;
}

/* 汇总统计网格 */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
}

.summary-item {
    background: var(--bg-secondary);
    padding: 10px 12px;
    border-radius: 5px;
    border-left: 2px solid var(--accent-blue);
}

.summary-label {
    color: var(--text-muted);
    font-size: 11px;
    margin-bottom: 5px;
}

.summary-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.summary-sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* 多空比 */
.ls-list { display: flex; flex-direction: column; gap: 10px; }

.ls-row {
    background: var(--bg-secondary);
    padding: 10px 12px;
    border-radius: 5px;
}

.ls-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.ls-exchange { font-weight: 600; font-size: 13px; }
.ls-label    { color: var(--text-muted); font-size: 11px; }
.ls-ratio    { color: var(--accent-blue); font-weight: 600; font-size: 12px; }

.ls-bar {
    display: flex;
    height: 22px;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 6px;
}

.ls-bar-long {
    background: var(--accent-green);
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 11px; font-weight: 600;
}

.ls-bar-short {
    background: var(--accent-red);
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 11px; font-weight: 600;
}

.ls-legend {
    display: flex;
    justify-content: space-around;
    font-size: 11px;
    color: var(--text-secondary);
}

/* 恐慌指数 */
.fng-gauge {
    text-align: center;
    padding: 24px;
    background: var(--bg-secondary);
    border-radius: 6px;
}

.fng-value  { font-size: 56px; font-weight: 700; }
.fng-label  { font-size: 15px; color: var(--text-secondary); margin-top: 6px; }
.fng-date   { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* 爆仓近期记录表格 */
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th { text-align: left; padding: 6px 10px; color: var(--text-muted); font-weight: 500; border-bottom: 1px solid var(--border-color); font-size: 11px; text-transform: uppercase; }
.data-table td { padding: 6px 10px; border-bottom: 1px solid rgba(255,255,255,0.03); color: var(--text-primary); }
.data-table tbody tr:hover { background: rgba(255,255,255,0.02); }

/* 响应式 */
@media (max-width: 768px) {
    body { font-size: 12px; }

    .container { padding: 8px; }

    .page-header {
        margin-bottom: 12px;
        padding-bottom: 10px;
    }

    .tab-nav {
        gap: 8px;
        margin-bottom: 16px;
        border-bottom: none;
    }

    .tab-btn {
        padding: 7px 12px;
        font-size: 12px;
        margin-bottom: 0;
        border: 1px solid var(--border-color);
        border-radius: 4px;
    }

    .tab-btn.active {
        background: rgba(59,130,246,0.12);
        border-bottom-color: var(--accent-blue);
    }

    .coin-tabs {
        flex-wrap: nowrap !important;
    }
    .coin-tab-btn,
    .period-btn {
        white-space: nowrap;
        flex-shrink: 0;
        line-height: 1.35;
    }

    .summary-grid { grid-template-columns: 1fr 1fr; }

    .chart-card,
    .table-card,
    .summary-card {
        padding: 10px;
    }

    .chart-card canvas {
        max-height: 200px !important;
        height: 200px !important;
    }

    #liq-heatmap-chart {
        max-height: 260px !important;
        height: 260px !important;
    }

    .heatmap-legend,
    .ls-header,
    .ls-legend {
        flex-wrap: wrap;
        gap: 6px 12px;
    }

    .metric-row {
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        gap: 6px;
        overflow: hidden;
    }

    .metric-row .metric-exchange {
        min-width: 90px !important;
        max-width: 90px;
        flex-shrink: 0;
        font-size: 11px;
    }

    .metric-row .exchange-bar-wrap {
        flex: 1;
        min-width: 0;
    }

    .metric-row .metric-value {
        min-width: 44px;
        text-align: right !important;
        font-size: 11px;
        flex-shrink: 0;
    }

    .metric-row .exchange-pct {
        min-width: 70px;
        text-align: right !important;
        font-size: 10px;
        flex-shrink: 0;
    }

    #liq-exchange-dist .metric-exchange {
        white-space: nowrap;
    }

    #liq-exchange-dist .metric-value {
        text-align: right !important;
        white-space: nowrap;
    }

    #liq-exchange-dist .exchange-bar-wrap {
        width: auto;
    }

    #liq-exchange-dist .exchange-pct {
        white-space: nowrap !important;
        text-align: right !important;
    }

    .table-wrapper { overflow-x: visible; }

    .data-table,
    .data-table tbody,
    .data-table tr,
    .data-table td {
        display: block;
        width: 100%;
    }

    .data-table thead { display: none; }

    .data-table tr {
        padding: 8px 0;
        border-bottom: 1px solid var(--border-color);
    }

    .data-table tbody tr:hover { background: transparent; }

    .data-table td {
        padding: 4px 0;
        border-bottom: none;
    }

    .data-table td::before {
        display: block;
        margin-bottom: 2px;
        color: var(--text-muted);
        font-size: 11px;
        font-weight: 500;
    }

    #liq-recent-table .data-table td:nth-child(1)::before { content: 'Time'; }
    #liq-recent-table .data-table td:nth-child(2)::before { content: 'Exchange'; }
    #liq-recent-table .data-table td:nth-child(3)::before { content: 'Side'; }
    #liq-recent-table .data-table td:nth-child(4)::before { content: 'Price'; }
    #liq-recent-table .data-table td:nth-child(5)::before { content: 'Amount (USD)'; }

    .fng-gauge { padding: 18px 14px; }
    .fng-value { font-size: 44px; }
}

@media (max-width: 480px) {
    .container { padding: 6px; }
    .summary-grid { grid-template-columns: 1fr; }

    .chart-card,
    .table-card,
    .summary-card {
        padding: 8px;
    }

    .chart-card canvas {
        max-height: 180px !important;
        height: 180px !important;
    }

    #liq-heatmap-chart {
        max-height: 240px !important;
        height: 240px !important;
    }
}

/* 兜底：所有屏幕宽度下爆仓分布保持单行 flex */
@media (max-width: 1024px) {
    #liq-exchange-dist .metric-row {
        display: flex !important;
        flex-wrap: nowrap !important;
    }
    #liq-exchange-dist .exchange-bar-wrap {
        flex: 1;
        min-width: 0;
        width: auto !important;
        grid-column: unset !important;
    }
    #liq-exchange-dist .exchange-pct {
        white-space: nowrap !important;
        text-align: right !important;
        grid-column: unset !important;
    }
}

/* ── 4时段爆仓卡片 ── */
.period-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    padding: 8px 16px 16px;
}
.period-summary-card {
    background: transparent;
    border: none;
    border-left: 1px solid #1e2230;
    border-radius: 0;
    padding: 12px 20px;
}
.period-summary-card:first-child {
    border-left: none;
}
.period-summary-card.active {
    background: transparent;
}
.period-summary-title {
    font-size: 12px;
    color: #8a9bb5;
    margin-bottom: 8px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.period-summary-total {
    font-size: 22px;
    font-weight: 700;
    color: #e2e8f0;
    margin-bottom: 10px;
}
.period-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    font-size: 13px;
}
.period-liq-long  { color: #ef4444; }
.period-liq-short { color: #10b981; }
.period-liq-pct   { font-size: 12px; color: #8a9bb5; }

@media (max-width: 480px) {
    .period-summary-grid {
        grid-template-columns: repeat(3, 1fr);
        padding: 8px;
    }
    .period-summary-card { padding: 10px 12px; }
    .period-summary-total { font-size: 16px; }
}

/* ── 移动端专项修复 ── */
@media (max-width: 768px) {
    /* 1. 持仓量：隐藏参考价格和交易所数量 */
    .oi-ref-price,
    .oi-ex-count { display: none !important; }

    /* 2. 交易量：隐藏交易所数量 */
    .vol-ex-count { display: none !important; }

    /* 3. 爆仓分布：强制单行 flex（和电脑端一样） */
    #liq-exchange-dist .metric-row {
        display: flex !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        gap: 6px !important;
    }
    #liq-exchange-dist .metric-exchange {
        min-width: 80px !important;
        max-width: 80px !important;
        flex-shrink: 0 !important;
        font-size: 11px !important;
        white-space: nowrap !important;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    #liq-exchange-dist .exchange-bar-wrap {
        flex: 1 !important;
        min-width: 0 !important;
        width: auto !important;
        grid-column: unset !important;
    }
    #liq-exchange-dist .metric-value {
        min-width: 36px !important;
        font-size: 11px !important;
        text-align: right !important;
        flex-shrink: 0 !important;
        white-space: nowrap !important;
        grid-column: unset !important;
    }
    #liq-exchange-dist .exchange-pct {
        min-width: 64px !important;
        font-size: 10px !important;
        text-align: right !important;
        flex-shrink: 0 !important;
        white-space: nowrap !important;
        grid-column: unset !important;
    }

    /* 4. 通用 metric-row 其他区域也保持单行 */
    .metric-row {
        flex-wrap: nowrap !important;
        overflow: hidden;
    }
    .metric-row .metric-exchange {
        min-width: 80px;
        max-width: 80px;
        flex-shrink: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        grid-column: unset !important;
    }
    .metric-row .exchange-bar-wrap {
        flex: 1 !important;
        grid-column: unset !important;
        width: auto !important;
    }
    .metric-row .metric-value {
        flex-shrink: 0 !important;
        grid-column: unset !important;
        white-space: nowrap !important;
    }
    .metric-row .exchange-pct {
        flex-shrink: 0 !important;
        grid-column: unset !important;
        white-space: nowrap !important;
    }
}

/* ── 近期大额爆仓：移动端保持表格行样式 ── */
@media (max-width: 768px) {
    #liq-recent-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    #liq-recent-table .data-table,
    #liq-recent-table .data-table tbody,
    #liq-recent-table .data-table tr,
    #liq-recent-table .data-table td,
    #liq-recent-table .data-table th {
        display: revert !important;
        width: auto !important;
    }
    #liq-recent-table .data-table { width: 100%; min-width: 380px; }
    #liq-recent-table .data-table thead { display: table-header-group !important; }
    #liq-recent-table .data-table tr { padding: 0; border-bottom: none; }
    #liq-recent-table .data-table td { padding: 6px 8px; border-bottom: 1px solid rgba(255,255,255,0.03); }
    #liq-recent-table .data-table td::before { display: none !important; }
    #liq-recent-table .data-table tbody tr:hover { background: rgba(255,255,255,0.02); }
}
