/* ============================================================================
   Strategy Correlation Heatmap
   - Correlation matrix grid layout
   - Color-coded heatmap cells
   - Legend and scale
   ============================================================================ */

.correlation-heatmap {
    display: inline-block;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow-x: auto;
    overflow-y: auto;
    background: var(--bg-card);
    margin-bottom: 24px;
    max-width: 100%;
}

.correlation-row {
    display: flex;
}

.correlation-row.header-row {
    background: var(--bg-secondary);
}

.correlation-cell {
    width: 50px;
    height: 50px;
    min-width: 50px;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    font-size: 0.85em;
    position: relative;
    transition: all 0.2s;
    flex-shrink: 0;
}

.correlation-cell.corner-cell {
    background: var(--bg-secondary);
    border: none;
    width: auto;
    min-width: 120px;
    max-width: 400px;
}

.correlation-cell.header-cell {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    font-weight: 600;
    color: var(--text-primary);
    padding: 12px 8px;
    width: 50px;
    min-width: 50px;
    height: auto;
    min-height: 150px;
    font-size: 0.75em;
    white-space: nowrap;
    overflow: visible;
}

.correlation-cell.diagonal-cell {
    background: var(--bg-secondary);
    cursor: default;
}

.correlation-cell.row-header {
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-primary);
    padding: 8px 8px 8px 4px;
    text-align: right;
    justify-content: flex-end;
    width: auto;
    min-width: 120px;
    max-width: 400px;
    font-size: 0.75em;
    white-space: nowrap;
    overflow: visible;
}

.correlation-cell.data-cell {
    cursor: pointer;
}

.correlation-cell.data-cell:hover {
    transform: scale(1.1);
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border-color: #667eea;
}

.correlation-value {
    font-weight: 600;
    font-size: 0.85em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Legend */
.correlation-legend {
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.legend-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    font-size: 0.95em;
}

.legend-scale {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-color {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.legend-item span {
    font-size: 0.85em;
    color: var(--text-secondary);
    font-weight: 500;
}

.legend-description {
    color: var(--text-secondary);
    font-size: 0.85em;
    line-height: 1.5;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .correlation-cell {
        width: 60px;
        height: 60px;
        min-width: 60px;
        min-height: 60px;
        font-size: 0.75em;
    }

    .correlation-cell.row-header {
        width: auto;
        min-width: 100px;
        max-width: 250px;
        font-size: 0.65em;
    }

    .correlation-cell.corner-cell {
        width: auto;
        min-width: 100px;
        max-width: 250px;
    }

    .correlation-cell.header-cell {
        width: 60px;
        min-width: 60px;
        min-height: 120px;
        font-size: 0.65em;
    }

    .correlation-value {
        font-size: 0.75em;
    }

    .legend-scale {
        gap: 12px;
    }

    .legend-color {
        width: 24px;
        height: 24px;
    }
}

/* Dark theme specific adjustments */
body:not(.light-theme) .correlation-cell.data-cell {
    color: #1a1a1a;
}

/* Light theme specific adjustments */
body.light-theme .correlation-cell.data-cell {
    color: #1a1a1a;
}

body.light-theme .correlation-heatmap {
    background: #ffffff;
}

body.light-theme .correlation-row.header-row {
    background: #f7fafc;
}

body.light-theme .correlation-cell.row-header,
body.light-theme .correlation-cell.corner-cell,
body.light-theme .correlation-cell.diagonal-cell {
    background: #f7fafc;
}

/* ============================================================================
   Rolling Sharpe Table
   ============================================================================ */

.rolling-sharpe-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

.rolling-sharpe-table thead th {
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-weight: 600;
    padding: 10px 14px;
    text-align: center;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.rolling-sharpe-table thead th:first-child {
    text-align: left;
}

.rolling-sharpe-table .sharpe-label-row th {
    background: transparent;
    border-bottom: none;
    padding: 0 14px 10px;
    font-weight: 500;
    font-size: 0.9em;
    color: var(--text-secondary);
}

.rolling-sharpe-table thead th:nth-child(2) {
    text-align: center;
}

.rolling-sharpe-table tbody td {
    padding: 8px 14px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.rolling-sharpe-table tbody td:first-child {
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
}

.rolling-sharpe-table tbody tr:hover {
    background: rgba(102, 126, 234, 0.05);
}

.sharpe-cell {
    font-weight: 600;
    border-radius: 4px;
    font-variant-numeric: tabular-nums;
}

.sharpe-cell.sharpe-strong-pos { background: rgba(72, 187, 120, 0.30); color: #48bb78; }
.sharpe-cell.sharpe-med-pos    { background: rgba(72, 187, 120, 0.20); color: #48bb78; }
.sharpe-cell.sharpe-light-pos  { background: rgba(72, 187, 120, 0.10); color: #48bb78; }
.sharpe-cell.sharpe-light-neg  { background: rgba(239, 68, 68, 0.10); color: #ef4444; }
.sharpe-cell.sharpe-med-neg    { background: rgba(239, 68, 68, 0.20); color: #ef4444; }
.sharpe-cell.sharpe-strong-neg { background: rgba(239, 68, 68, 0.30); color: #ef4444; }

.sharpe-cell.sharpe-na {
    color: var(--text-secondary);
    font-weight: 400;
}

.sharpe-signal {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.sharpe-signal-pause {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.sharpe-signal-ok,
.sharpe-signal-active {
    background: rgba(72, 187, 120, 0.2);
    color: #48bb78;
}

.sharpe-signal-na {
    color: var(--text-secondary);
    font-weight: 400;
}

/* Light theme overrides */
body.light-theme .sharpe-cell.sharpe-strong-pos { background: rgba(72, 187, 120, 0.25); color: #2f855a; }
body.light-theme .sharpe-cell.sharpe-med-pos    { background: rgba(72, 187, 120, 0.15); color: #2f855a; }
body.light-theme .sharpe-cell.sharpe-light-pos  { background: rgba(72, 187, 120, 0.08); color: #2f855a; }
body.light-theme .sharpe-cell.sharpe-light-neg  { background: rgba(239, 68, 68, 0.08); color: #c53030; }
body.light-theme .sharpe-cell.sharpe-med-neg    { background: rgba(239, 68, 68, 0.15); color: #c53030; }
body.light-theme .sharpe-cell.sharpe-strong-neg { background: rgba(239, 68, 68, 0.25); color: #c53030; }

body.light-theme .sharpe-signal-pause { background: rgba(239, 68, 68, 0.15); color: #c53030; }
body.light-theme .sharpe-signal-ok,
body.light-theme .sharpe-signal-active { background: rgba(72, 187, 120, 0.15); color: #2f855a; }

/* Responsive */
@media (max-width: 768px) {
    .rolling-sharpe-table {
        font-size: 0.8em;
    }

    .rolling-sharpe-table thead th,
    .rolling-sharpe-table tbody td {
        padding: 6px 8px;
    }
}

/* Matrix container scrolling */
#correlationMatrix {
    overflow-x: auto;
    overflow-y: auto;
    max-width: 100%;
}

/* Custom scrollbar for better UX */
.correlation-heatmap::-webkit-scrollbar,
#correlationMatrix::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}

.correlation-heatmap::-webkit-scrollbar-track,
#correlationMatrix::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

.correlation-heatmap::-webkit-scrollbar-thumb,
#correlationMatrix::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.correlation-heatmap::-webkit-scrollbar-thumb:hover,
#correlationMatrix::-webkit-scrollbar-thumb:hover {
    background: #667eea;
}
