/* TickerTape Component - 移动端行情轮播组件 */
/* 纯CSS实现，支持触摸滑动 - 股票行情UI风格 */

.ticker-tape-container {
    width: 100%;
    height: 60px;
    overflow: hidden;
    background: #ffffff;
    padding: 0;
    position: relative;
    display: flex;           /* 让内部内容在纵向居中 */
    align-items: center;
    user-select: none;
    -webkit-user-select: none;
    margin: 0;
}

.ticker-tape-track {
    display: flex;
    gap: 8px;
    padding: 0 8px;
    height: auto;            /* 高度由内部卡片决定，由容器居中 */
    justify-content: center; /* 初始无数据时居中显示加载状态 */
    cursor: grab;
    transition: none;            /* 使用 JS 控制动画，禁用额外过渡，提升移动端流畅度 */
    will-change: transform;      /* 提示浏览器优化 transform 变化 */
    touch-action: none;          /* 所有触摸手势交由 JS 处理，避免浏览器与惯性动画争抢 */
    /* 启用 GPU 加速，提升滚动流畅度 */
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    perspective: 1000px;
}

.ticker-tape-track.dragging {
    cursor: grabbing;
    transition: none;
    /* 拖拽时也保持 GPU 加速 */
    transform: translate3d(0, 0, 0);
}

.ticker-tape-track.has-data {
    justify-content: flex-start; /* 有数据时左对齐，支持滚动 */
}

/* ===================== TradingView 风格复刻（Tape） ===================== */
.tv-tape {
    border-top: 1px solid #eeeeee;
    border-bottom: 1px solid #eeeeee;
}

.tv-tape .ticker-tape-track {
    gap: 0;
    padding: 0;
}

.tv-tape .ticker-item {
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    background: #ffffff;
    border-radius: 0;
    width: 190px;    /* 固定宽度，不随内容变化 */
    flex-shrink: 0;  /* 防止被压缩 */
    height: 64px;    /* 固定高度 */
    margin-top: 0;
    border-right: 1px solid #eeeeee;
}

.tv-tape .ticker-item:hover {
    background: #fafafa;
}

.tv-tape-left {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    flex: 1;    /* 占据剩余空间 */
    min-width: 0;  /* 允许缩小 */
}

.tv-tape-top {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tv-badge {
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background: #bd9e56;
    color: #ffffff;
    font-size: 10px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.tv-symbol {
    font-weight: 700;
    font-size: 13px;
    color: #111111;
    line-height: 1.1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tv-tape-bottom {
    display: flex;
    align-items: baseline;
    gap: 6px;
    white-space: nowrap;
}

.tv-price {
    font-size: 13px;
    font-weight: 600;
    color: #111111;
    letter-spacing: -0.2px;
}

.tv-currency {
    font-size: 10px;
    color: #7a7a7a;
    font-weight: 600;
}

.tv-change {
    font-size: 11px;
    font-weight: 700;
    color: #7a7a7a;
}

.tv-change.down {
    color: #ff4757;
}

.tv-change.up {
    color: #3b82f6;
}

.tv-spark-wrap {
    width: 44px;
    height: 24px;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tv-spark {
    width: 100%;
    height: 100%;
    pointer-events: none; /* 图表区域不拦截事件，整张卡片都可拖动 */
}

.tv-spark-skeleton {
    width: 44px;   /* 固定宽度 */
    height: 24px;  /* 固定高度 */
    border-radius: 6px;
    background: linear-gradient(90deg, #f5f5f5 0%, #e0e0e0 50%, #f5f5f5 100%);
    background-size: 200% 100%;
    animation: tv-spark-loading 1.2s ease-in-out infinite;
}

.tv-spark.is-hidden,
.tv-spark-skeleton.is-hidden {
    display: none;
}

@keyframes tv-spark-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* 单个行情项 */
.ticker-item {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 4px;
    min-width: 150px;
    height: 56px;
    margin-top: 8px;
    transition: background-color 0.2s ease;
}

.ticker-item:hover {
    background: #e9ecef;
}

/* 合约图标 */
.ticker-icon {
    font-size: 14px;
    line-height: 1;
    min-width: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 合约名称 */
.ticker-symbol {
    font-weight: 600;
    font-size: 11px;
    color: #1a1a1a;
    min-width: 55px;
}

/* 价格区域 */
.ticker-price-section {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.ticker-price {
    font-family: 'SF Mono', 'Monaco', 'Consolas', 'Courier New', monospace;
    font-size: 12px;
    font-weight: 600;
    color: #1a1a1a;
    letter-spacing: -0.3px;
}

.ticker-price.up {
    color: #3b82f6;
}

.ticker-price.down {
    color: #ff4757;
}

/* 涨跌幅标签 */
.ticker-change {
    font-size: 9px;
    font-weight: 600;
    padding: 2px 4px;
    border-radius: 2px;
    min-width: 45px;
    text-align: center;
}

.ticker-change.bg-up {
    background: #3b82f6;
    color: white;
}

.ticker-change.bg-down {
    background: #ff4757;
    color: white;
}

.ticker-change.bg-flat {
    background: #e9ecef;
    color: #6c757d;
}

/* 空状态 */
.ticker-tape-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 60px;
    background: #f8f9fa;
    color: #999;
    font-size: 13px;
}

/* 加载状态 */
.ticker-tape-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 60px;
    background: #f8f9fa;
    color: #999;
    font-size: 13px;
}

.ticker-loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #e9ecef;
    border-top-color: #2196f3;
    border-radius: 50%;
    animation: ticker-spin 0.8s linear infinite;
}

@keyframes ticker-spin {
    to {
        transform: rotate(360deg);
    }
}

/* 响应式设计 - 小屏手机 */
@media (max-width: 380px) {
    .ticker-tape-track {
        gap: 6px;
        padding: 0 6px;
    }

    .ticker-item {
        min-width: 140px;
        padding: 6px 10px;
        gap: 4px;
        height: 56px;
        margin-top: 8px;
    }

    .ticker-icon {
        font-size: 12px;
        min-width: 14px;
    }

    .ticker-symbol {
        font-size: 10px;
        min-width: 50px;
    }

    .ticker-price {
        font-size: 11px;
    }

    .ticker-change {
        font-size: 8px;
        padding: 1px 3px;
        min-width: 40px;
    }

    /* TV tape 紧凑布局 */
    .tv-tape .ticker-item {
        width: 200px;  /* 小屏幕固定宽度 */
        padding: 8px 8px;
        gap: 6px;
    }

    .tv-symbol { font-size: 14px; }
    .tv-price { font-size: 13px; }
    .tv-change { font-size: 11px; }
}

/* 超小屏幕优化 */
@media (max-width: 340px) {
    .ticker-tape-track {
        gap: 5px;
        padding: 0 5px;
    }

    .ticker-item {
        min-width: 120px;
        padding: 5px 8px;
        gap: 3px;
        height: 56px;
        margin-top: 8px;
    }

    .ticker-icon {
        font-size: 11px;
        min-width: 12px;
    }

    .ticker-symbol {
        font-size: 9px;
        min-width: 45px;
    }

    .ticker-price {
        font-size: 10px;
    }

    .ticker-change {
        font-size: 7px;
        padding: 1px 2px;
        min-width: 35px;
    }

    /* TV tape 超小屏优化 */
    .tv-tape .ticker-item {
        width: 180px;  /* 超小屏幕固定宽度 */
    }

    .tv-badge {
        width: 20px;
        height: 20px;
        font-size: 10px;
    }

    .tv-spark {
        width: 50px;
        height: 26px;
    }
}

/* 预热进度样式 */
.warmup-progress {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 60px;
    padding: 0 20px;
    text-align: center;
}

.warmup-status {
    margin-top: 12px;
    font-size: 13px;
    color: #4b5563;
    font-weight: 500;
}

.warmup-progress-bar {
    width: 100%;
    max-width: 300px;
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
    margin-top: 12px;
}

.warmup-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6 0%, #2563eb 100%);
    transition: width 0.3s ease;
    border-radius: 3px;
}

.warmup-progress-text {
    margin-top: 6px;
    font-size: 11px;
    color: #6b7280;
}
