/* 零壹期货图表系统专用样式 - 隔离命名空间 */
/* 修改：使用属性选择器适配所有图表容器 */
[data-default-group] {
    font-family: 'Microsoft YaHei', 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #1e2a3a 0%, #2c3e50 100%);
    border-radius: 12px;
    padding: 15px;
    margin: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    width: calc(100% - 20px);
    height: calc(100vh - 20px);
    box-sizing: border-box;
    position: relative;
}

/* 页面顶部横幅 */
.my-chart-header {
    background: linear-gradient(90deg, #2c3e50 0%, #34495e 100%);
    color: #ecf0f1;
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 3px;
    text-align: center;
    font-size: clamp(14px, 2vw, 16px);
    font-weight: bold;
    border: 1px solid #4a6572;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* 图表容器 - 完全自适应 */
.my-chart-wrapper {
    position: relative;
    width: 100%;
    height: calc(100vh - 120px);
    min-height: 300px;
    background: #1a2530;
    border-radius: 8px;
    border: 1px solid #34495e;
    overflow: hidden;
}

/* 品种选择器 - 可拖动 - 适配新的高性能拖动方案 */
.my-symbol-selector {
	opacity: 0.25;
    position: absolute;
    top: 0;
    right: 0;
    transform: translate3d(var(--selector-x, 15px), var(--selector-y, 15px), 0); /* 修复：启用GPU加速 */
    z-index: 10000;
    background: rgba(26, 37, 48, 0.95);
    border: 1px solid #4a6572;
    border-radius: 6px;
    padding: 8px 12px;
    backdrop-filter: none; /* 修复：移除模糊效果 */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    cursor: move;
    min-width: auto;
    width: auto;
    max-width: 300px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); /* 修改：添加过渡动画 */
    touch-action: none;
    user-select: none;
    
    /* 修复：添加清晰渲染优化 */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 新增：边缘自动隐藏样式 */
.my-symbol-selector.edge-hidden {
    opacity: 0.25;
    transform: translate3d(var(--selector-x, 15px), var(--selector-y, 15px), 0) scale(0.92);
}

.my-symbol-selector.edge-hidden:hover {
    opacity: 0.95;
    transform: translate3d(var(--selector-x, 15px), var(--selector-y, 15px), 0) scale(1);
}

.my-symbol-selector:hover {
	opacity: 0.95;
    border-color: #3498db;
}

.my-selector-title {
    color: #ecf0f1;
    font-size: clamp(11px, 1.5vw, 12px);
    margin-bottom: 6px;
    font-weight: bold;
    border-bottom: 1px solid #4a6572;
    padding-bottom: 4px;
    text-align: center;
    
    /* 修复：文字清晰渲染 */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 紧凑的并排布局 - 修复：默认不换行，只在必要时换行 */
.my-selector-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: nowrap; /* 默认不换行 */
    white-space: nowrap;
}

.my-category-select, .my-symbol-select {
    background: #2c3e50;
    color: #ecf0f1;
    border: 1px solid #4a6572;
    border-radius: 4px;
    padding: 5px 8px;
    font-size: clamp(10px, 1.5vw, 11px);
    outline: none;
    z-index: 10001;
    position: relative;
    min-width: 120px; /* 保持合适的最小宽度 */
    flex: 0 1 auto; /* 允许收缩但不强制拉伸 */
    max-width: 150px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    
    /* 修复：下拉框清晰渲染 */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.my-category-select {
    min-width: 140px;
}

.my-symbol-select {
    min-width: 100px;
}

.my-category-select:focus, .my-symbol-select:focus {
    border-color: #3498db;
    box-shadow: 0 0 5px rgba(52, 152, 219, 0.5);
}

/* 页面底部信息 */
.my-chart-footer {
    background: linear-gradient(90deg, #2c3e50 0%, #34495e 100%);
    color: #ecf0f1;
    padding: 10px 20px;
    border-radius: 8px;
    margin-top: 3px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: clamp(10px, 1.5vw, 12px);
    border: 1px solid #4a6572;
    flex-wrap: wrap;
}

.my-copyright {
    text-align: center;
    flex: 1;
    min-width: 200px;
}

.my-performance-info {
    text-align: right;
    color: #95a5a6;
    font-family: 'Courier New', monospace;
    font-size: clamp(9px, 1.5vw, 11px);
}

/* 图表加载遮罩 */
.my-chart-mask {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(26, 37, 48, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    color: #ecf0f1;
    font-size: clamp(14px, 2vw, 16px);
    border-radius: 8px;
    transition: opacity 0.3s ease;
}

/* === 新增：默认隐藏分类选择器 - 开始 === */
.my-symbol-selector .my-category-select {
    display: none !important;
}

.my-symbol-selector.multiple-groups .my-category-select {
    display: block !important;
}

.my-symbol-selector.multiple-groups .my-selector-row {
    gap: 8px; /* 恢复多分类时的间距 */
}
/* === 新增：默认隐藏分类选择器 - 结束 === */

/* 响应式设计 - 增强移动端适配 */
@media (max-width: 768px) {
    [data-default-group] {
        padding: 10px;
        margin: 5px;
        width: calc(100% - 10px);
        height: calc(100vh - 10px);
    }
    
    .my-chart-wrapper {
        height: calc(100vh - 150px);
        min-height: 250px;
    }
    
    .my-symbol-selector {
        position: absolute;
        transform: translate3d(var(--selector-x, 10px), var(--selector-y, 10px), 0); /* 修复：保持GPU加速 */
        margin: 0;
        width: auto;
        max-width: 280px;
        cursor: move;
    }
    
    .my-selector-row {
        flex-direction: row;
        gap: 6px;
        flex-wrap: nowrap; /* 小屏幕也不换行 */
    }
    
    .my-category-select, .my-symbol-select {
        min-width: 100px; /* 保持最小宽度 */
        font-size: 11px;
        padding: 6px 8px;
    }
    
    .my-chart-footer {
        flex-direction: column;
        gap: 8px;
        text-align: center;
        padding: 12px 15px;
    }
    
    .my-performance-info {
        text-align: center;
    }
}

/* 超小屏幕适配 - 只在非常窄的时候才换行 */
@media (max-width: 400px) {
    [data-default-group] {
        padding: 8px;
        margin: 4px;
        width: calc(100% - 8px);
        height: calc(100vh - 8px);
        border-radius: 6px;
    }
    
    .my-chart-wrapper {
        height: calc(100vh - 120px);
        min-height: 200px;
    }
    
    .my-chart-header {
        padding: 8px 12px;
        margin-bottom: 10px;
        font-size: 13px;
    }
    
    .my-symbol-selector {
        max-width: 95vw; /* 超小屏幕宽度限制 */
        padding: 6px 8px;
        transform: translate3d(var(--selector-x, 5px), var(--selector-y, 5px), 0);
    }
    
    .my-selector-title {
        font-size: 11px;
    }
    
    .my-selector-row {
        flex-direction: column; /* 超小屏幕改为垂直布局 */
        gap: 4px;
        flex-wrap: wrap;
    }
    
    .my-category-select, .my-symbol-select {
        min-width: 0;
        max-width: 100%; /* 全宽度 */
        width: 100%;
        font-size: 10px;
        padding: 5px 6px;
    }
    
    .my-chart-footer {
        padding: 8px 10px;
        gap: 6px;
    }
}

/* 小屏幕适配 - 保持单行但缩小间距 */
@media (max-width: 768px) and (min-width: 401px) {
    .my-symbol-selector {
        max-width: 280px;
    }
    
    .my-selector-row {
        gap: 6px; /* 缩小间距但不换行 */
        flex-wrap: nowrap;
    }
    
    .my-category-select, .my-symbol-select {
        min-width: 100px;
        flex: 1;
        font-size: 11px;
        padding: 5px 6px;
    }
    
    .my-category-select {
        min-width: 120px;
    }
}

/* 横屏模式适配 */
@media (max-height: 500px) and (orientation: landscape) {
    .my-chart-wrapper {
        height: calc(100vh - 100px);
        min-height: 200px;
    }
    
    .my-chart-header {
        padding: 8px 15px;
        margin-bottom: 8px;
    }
    
    .my-chart-footer {
        padding: 8px 15px;
        margin-top: 8px;
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    .my-symbol-selector {
        cursor: move;
    }
    
    .my-category-select, .my-symbol-select {
        padding: 10px 12px;
        font-size: 14px;
    }
}

/* 性能优化 */
.performance-optimized {
    transform: translateZ(0);
    will-change: transform;
}

/* 加载动画 */
.my-loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #3498db;
    animation: spin 1s ease-in-out infinite;
    margin-right: 10px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}