/* ==========================================================================
   Chart Panel — Scatter + Depth Wall
   ========================================================================== */

.chart-panel {
    display: flex;            /* always flex, never none */
    flex-direction: column;
    flex-shrink: 0;
    height: 0;               /* closed = 0 */
    min-height: 0;
    overflow: hidden;
    border-top: none;
    background: var(--bg-surface);
    position: relative;
    transition: height 0.3s ease;
}

.chart-panel.is-open {
    height: 280px;            /* default; JS overrides inline */
    border-top: 1px solid var(--border-default);
}

/* Toggle arrow — full-width strip between activity and chart */
.chart-toggle-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 24px;
    flex-shrink: 0;
    cursor: pointer;
    background: var(--bg-surface);
    border: none;
    border-top: 1px solid var(--border-muted);
    color: var(--text-muted);
    transition: color 0.2s, background 0.2s;
}

.chart-toggle-arrow:hover {
    color: var(--accent);
    background: var(--accent-subtle);
}

.chart-toggle-arrow svg {
    transition: transform 0.3s ease;
}

.chart-toggle-arrow.is-open svg {
    transform: rotate(180deg);
}

/* Resize handle */
.chart-panel__resize-handle {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    cursor: ns-resize;
    z-index: 2;
    background: transparent;
    transition: background 0.15s;
}

.chart-panel__resize-handle:hover,
.chart-panel__resize-handle:active {
    background: var(--accent-muted);
}

/* Header */
.chart-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-1) var(--space-3);
    border-bottom: 1px solid var(--border-muted);
    flex-shrink: 0;
}

.chart-panel__title {
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.chart-panel__controls {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.chart-panel__bucket-label {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

/* Bucket dropdown */
.chart-panel__bucket-dropdown {
    position: relative;
}

.chart-panel__bucket-trigger {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-muted);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    padding: 2px 6px;
    cursor: pointer;
    min-width: 52px;
    transition: border-color 0.15s;
}

.chart-panel__bucket-trigger:hover {
    border-color: var(--border-default);
}

.chart-panel__bucket-trigger:focus-visible {
    outline: none;
    border-color: var(--accent);
}

.chart-panel__bucket-trigger svg {
    flex-shrink: 0;
    opacity: 0.5;
}

.chart-panel__bucket-menu {
    position: absolute;
    top: calc(100% + 2px);
    right: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    z-index: 50;
    min-width: 80px;
    overflow: hidden;
}

.chart-panel__bucket-option {
    display: block;
    width: 100%;
    padding: 4px 8px;
    text-align: left;
    background: none;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    cursor: pointer;
    border-left: 2px solid transparent;
    transition: background 0.1s, color 0.1s;
}

.chart-panel__bucket-option:hover {
    background: rgba(255, 255, 255, 0.05);
}

.chart-panel__bucket-option.is-active {
    border-left-color: var(--accent);
    color: var(--accent);
}

.chart-panel__bucket-custom {
    border-top: 1px solid var(--border-muted);
    padding: 4px;
}

.chart-panel__bucket-custom-input {
    width: 100%;
    background: var(--bg-base);
    border: 1px solid var(--border-muted);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    padding: 2px 4px;
    text-align: right;
}

.chart-panel__bucket-custom-input:focus {
    outline: none;
    border-color: var(--accent);
}

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

.chart-panel__bucket-custom-input[type="number"] {
    -moz-appearance: textfield;
}

/* Body */
.chart-panel__body {
    flex: 1;
    display: flex;
    min-height: 0;
}

.chart-panel__scatter-wrap {
    flex: 3;
    position: relative;
    min-width: 0;
}

.chart-panel__depth-wrap {
    flex: 1;
    border-left: 1px solid var(--border-muted);
    position: relative;
    min-width: 0;
}

.chart-panel__canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Tooltip */
.chart-panel__tooltip {
    display: none;
    position: absolute;
    z-index: 10;
    padding: 4px 8px;
    background: var(--bg-overlay);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-family: var(--font-mono);
    color: var(--text-primary);
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* Desktop only — hide on small screens */
@media (max-width: 1199px) {
    .chart-panel {
        display: none !important;
    }
    .chart-toggle-arrow {
        display: none !important;
    }
}
