/* ============================================
   Strategy Lab Page Styles
   策略实验室页面特定样式 - 重构版
   ============================================ */

/* ============ 布局 ============ */
.main-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

/* ============ 配置区块 ============ */
.config-section {
    margin-bottom: 28px;
}

.config-section:last-child {
    margin-bottom: 0;
}

/* ============ 指数网格 ============ */
.index-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

/* ============ 资产卡片 - 简洁设计 ============ */
.strategy-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
}

.strategy-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.12);
}

.strategy-card.selected-for-viz {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.03) 0%, rgba(118, 75, 162, 0.03) 100%);
}

/* 卡片顶部行 */
.card-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.asset-info-compact {
    flex: 1;
    min-width: 0;
}

.asset-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-dark);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.asset-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* 权重输入 */
.weight-control-compact {
    flex-shrink: 0;
}

.weight-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 4px 8px 4px 0;
    transition: border-color 0.2s;
}

.weight-input-wrapper:focus-within {
    border-color: var(--primary-color);
}

.compact-input {
    width: 50px;
    border: none;
    background: transparent;
    text-align: right;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-dark);
    padding: 4px 4px 4px 8px;
}

.compact-input:focus {
    outline: none;
}

.compact-input::-webkit-outer-spin-button,
.compact-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.weight-input-wrapper .unit {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* 移除按钮 */
.remove-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.remove-btn:hover {
    background: #fee2e2;
    color: var(--danger-color);
}

/* 算法选择控件 */
.control-row {
    margin-bottom: 12px;
}

.segmented-control {
    display: inline-flex;
    background: var(--panel-bg);
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
    width: 100%;
}

.segment-btn {
    flex: 1;
    padding: 7px 4px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.segment-btn:hover {
    color: var(--text-medium);
    background: rgba(255, 255, 255, 0.5);
}

.segment-btn.active {
    background: #fff;
    color: var(--primary-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    font-weight: 600;
}

/* 滑块区域 */
.slider-section-compact {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
}

.slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.slider-label-compact {
    font-size: 0.8rem;
    color: var(--text-light);
}

.slider-value-compact {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary-color);
    background: rgba(102, 126, 234, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
}

.compact-slider {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border-color);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.compact-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
    transition: transform 0.15s;
}

.compact-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.compact-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

/* ============ 添加指数按钮 ============ */
.add-index-btn {
    width: 100%;
    padding: 14px;
    border: 2px dashed var(--border-medium);
    background: transparent;
    color: var(--text-light);
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.25s;
    margin-top: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.add-index-btn span {
    font-size: 1.2rem;
    font-weight: 400;
}

.add-index-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(102, 126, 234, 0.04);
}

/* ============ 参数配置区 ============ */
.params-grid {
    display: grid;
    gap: 16px;
}

.param-row {
    display: grid;
    gap: 16px;
}

/* ============ 运行按钮 ============ */
.btn-run {
    width: 100%;
    padding: 16px 24px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s;
    margin-top: 24px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.25);
}

.btn-run:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.35);
}

.btn-run:active {
    transform: translateY(0);
}

.btn-run:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* ============ 可视化面板 ============ */
.viz-panel {
    min-height: 600px;
    display: flex;
    flex-direction: column;
}

.viz-placeholder {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-light);
    background: linear-gradient(180deg, var(--panel-bg) 0%, rgba(248, 250, 252, 0.5) 100%);
    border-radius: 12px;
    margin-top: 12px;
}

.placeholder-content {
    padding: 40px;
}

.placeholder-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    display: block;
    opacity: 0.4;
}

.placeholder-content p {
    margin: 0;
    color: var(--text-muted);
}

.placeholder-content strong {
    color: var(--text-medium);
}

.viz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
}

.algo-badge {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.viz-description {
    background: linear-gradient(90deg, #f0f9ff 0%, rgba(240, 249, 255, 0.5) 100%);
    border-left: 3px solid var(--info-color);
    padding: 12px 16px;
    margin-bottom: 20px;
    border-radius: 0 8px 8px 0;
    font-size: 0.9rem;
    color: var(--text-medium);
    line-height: 1.5;
}

.viz-chart-container {
    flex: 1;
    position: relative;
    min-height: 300px;
}

/* ============ 结果区域 ============ */
.results-section {
    margin-top: 24px;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.metric-card {
    background: linear-gradient(135deg, #fff 0%, var(--panel-bg) 100%);
    padding: 18px 16px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid var(--border-light);
    transition: all 0.2s;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.metric-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-dark);
}

.metric-value.positive {
    color: var(--success-color);
}

.metric-value.negative {
    color: var(--danger-color);
}

.chart-container {
    position: relative;
    height: 400px;
    width: 100%;
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    border: 1px solid var(--border-light);
}

/* ============ Modal 样式补充 ============ */
.selection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.category-header {
    grid-column: 1 / -1;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 16px;
    margin-bottom: 4px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.category-header:first-child {
    margin-top: 0;
}

.selection-item {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 14px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.selection-item:hover {
    border-color: var(--primary-color);
    background: rgba(102, 126, 234, 0.04);
}

.selection-item.selected {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border-color: transparent;
}

.check-icon {
    display: none;
    font-weight: 600;
}

.selection-item.selected .check-icon {
    display: block;
}

/* ============ 响应式设计 ============ */
@media (max-width: 1200px) {
    .main-grid {
        grid-template-columns: 1fr;
    }

    .viz-panel {
        min-height: 500px;
    }
}

@media (max-width: 768px) {
    .param-row {
        grid-template-columns: 1fr !important;
    }

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

    .segmented-control {
        flex-wrap: wrap;
    }

    .segment-btn {
        flex: 0 0 calc(33.33% - 2px);
    }
}

@media (max-width: 480px) {
    .card-top-row {
        flex-wrap: wrap;
    }

    .asset-info-compact {
        flex: 1 1 100%;
        margin-bottom: 8px;
    }

    .segment-btn {
        flex: 0 0 calc(50% - 2px);
        padding: 8px 6px;
    }

    .viz-panel {
        min-height: 400px;
    }

    .viz-placeholder .placeholder-icon {
        font-size: 3rem;
    }

    .viz-placeholder .placeholder-content {
        padding: 20px;
    }

    .results-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .metric-card {
        padding: 12px;
    }

    .metric-value {
        font-size: 1.2rem;
    }

    .param-row {
        gap: 12px;
    }

    .add-index-btn {
        padding: 12px;
    }
}

/* Additional Mobile Refinements */
@media (max-width: 768px) {
    .viz-panel {
        min-height: 450px;
    }

    .chart-container {
        height: 300px;
        padding: 10px;
    }

    .results-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .input-group label {
        font-size: 0.8em;
    }
}

/* ============ New Layout (Strategy Layout) ============ */
.strategy-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
        "assets viz"
        "params viz";
    gap: 24px;
    align-items: start;
}

.section-assets {
    grid-area: assets;
}

.section-viz {
    grid-area: viz;
}

.section-params {
    grid-area: params;
}

@media (max-width: 1200px) {
    .strategy-layout {
        grid-template-columns: 1fr;
        grid-template-areas:
            "assets"
            "params";
    }

    .section-viz {
        display: none !important;
    }
}

/* Embedded Visualization Styles */
.embedded-viz-panel {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px dashed var(--border-medium);
    animation: fadeIn 0.3s ease;
}

.embedded-viz-panel .viz-chart-container {
    height: 250px;
}

.embedded-viz-panel .viz-description {
    font-size: 0.85rem;
    padding: 8px 12px;
    margin-bottom: 12px;
}