/* ============== Schwartz Value Colors ============== */
.value-self-direction,
.value-self_direction { --value-color: #8B4513; }
.value-stimulation { --value-color: #FF8C00; }
.value-hedonism { --value-color: #FFD700; }
.value-achievement { --value-color: #9ACD32; }
.value-power { --value-color: #2E8B57; }
.value-security { --value-color: #4682B4; }
.value-conformity { --value-color: #6A5ACD; }
.value-tradition { --value-color: #9370DB; }
.value-benevolence { --value-color: #DB7093; }
.value-universalism { --value-color: #CD5C5C; }

/* Extended 19 values */
.value-self_directed_thoughts { --value-color: #8B4513; }
.value-self_directed_actions { --value-color: #A0522D; }
.value-dominance { --value-color: #228B22; }
.value-resources { --value-color: #2E8B57; }
.value-face { --value-color: #3CB371; }
.value-personal_security { --value-color: #4682B4; }
.value-societal_security { --value-color: #5F9EA0; }
.value-rule_conformity { --value-color: #6A5ACD; }
.value-interpersonal_conformity { --value-color: #7B68EE; }
.value-humility { --value-color: #8A2BE2; }
.value-dependability { --value-color: #9370DB; }
.value-caring { --value-color: #DB7093; }
.value-universal_concern { --value-color: #CD5C5C; }
.value-preservation_of_nature { --value-color: #BC8F8F; }
.value-tolerance { --value-color: #B22222; }

/* ============== Radar Chart ============== */
.radar-chart-container {
    position: relative;
    height: 100%;
    min-height: 450px;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.radar-legend {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(255, 255, 255, 0.9);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: calc(12px * var(--text-scale, 1));
}

/* ============== Violin Plots ============== */
.violin-plot-container {
    margin-bottom: 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    width: 100%;
    max-width: 100%;
}

.violin-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.violin-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid var(--text-primary);
}

.violin-label {
    /* flex: 1; Removed to prevent line stretching */
    font-weight: 600;
    font-size: calc(13px * var(--text-scale, 1));
    color: var(--text-primary);
}

.violin-mean {
    margin-left: auto; /* Pushes mean and moe to the right */
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--text-primary);
}

.violin-moe {
    font-family: var(--font-mono);
    font-size: calc(11px * var(--text-scale, 1));
    color: var(--text-secondary);
}

.violin-chart-wrapper {
    height: 100px; /* Default; overridden by JS for multi-group comparison */
    padding: 10px;
    position: relative;
    background: var(--bg-primary);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.violin-chart-wrapper svg {
    display: block;
    width: 100%;
    height: 100%;
}

/* Pin button */
.violin-pin-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    padding: 3px 5px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s, color 0.15s;
    flex-shrink: 0;
    margin-left: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.violin-pin-btn svg {
    transition: transform 0.2s;
}

.violin-plot-container.pinned .violin-pin-btn svg {
    transform: rotate(45deg);
}

.violin-plot-container:hover .violin-pin-btn,
.violin-plot-container.pinned .violin-pin-btn {
    opacity: 1;
}

.violin-pin-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.violin-plot-container.pinned {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.violin-plot-container.pinned .violin-pin-btn {
    color: var(--primary);
    border-color: var(--primary);
}

/* No data state for violin plots */
.violin-plot-container.no-data {
    opacity: 0.6;
}

.violin-chart-wrapper.violin-no-data {
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
}

.no-data-placeholder {
    color: var(--text-muted);
    font-size: calc(12px * var(--text-scale, 1));
    font-style: italic;
}

/* ============== Time Series Chart ============== */
.time-series-container {
    position: relative;
    height: 100%;
}

.time-series-legend {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.95);
    padding: 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    font-size: calc(12px * var(--text-scale, 1));
}

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

.legend-item:last-child {
    margin-bottom: 0;
}

.legend-color {
    width: 16px;
    height: 3px;
    border-radius: 2px;
}

.legend-color.dashed {
    background: repeating-linear-gradient(
        90deg,
        var(--color) 0px,
        var(--color) 4px,
        transparent 4px,
        transparent 8px
    );
}

/* ============== Value Cards Grid ============== */
.value-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.value-card {
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    transition: all 0.2s;
    cursor: pointer;
}

.value-card:hover {
    border-color: var(--value-color, var(--primary));
    box-shadow: var(--shadow-sm);
}

.value-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.value-card-color {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--value-color, var(--primary));
}

.value-card-name {
    flex: 1;
    font-weight: 600;
}

.value-card-score {
    font-size: calc(24px * var(--text-scale, 1));
    font-weight: 700;
    color: var(--value-color, var(--primary));
    margin-bottom: 4px;
}

.value-card-bar {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

.value-card-fill {
    height: 100%;
    background: var(--value-color, var(--primary));
    border-radius: 3px;
    transition: width 0.5s ease-out;
}

.value-card-moe {
    font-size: calc(12px * var(--text-scale, 1));
    color: var(--text-secondary);
    margin-top: 8px;
}

/* ============== Tooltips & Value Names ============== */
.value-name, .metric-label {
    cursor: help;
    border-bottom: 1px dotted var(--text-secondary);
    position: relative;
    display: inline-block;
}

.value-name:hover, .metric-label:hover {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Custom Tooltip Element (created by JS) */
.custom-tooltip {
    position: fixed;
    background: rgba(33, 37, 41, 0.98);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: calc(12px * var(--text-scale, 1));
    line-height: 1.4;
    white-space: pre-wrap;
    max-width: 300px;
    z-index: 9999;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.1);
}

/* Rich Value Chart Tooltip (Plotly hover - matches tutorial style) */
.value-chart-tooltip {
    position: fixed;
    max-width: 320px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.value-chart-tooltip.visible {
    opacity: 1;
}

.value-chart-tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.value-chart-tooltip-name {
    font-weight: 700;
    font-size: calc(15px * var(--text-scale, 1));
}

.value-chart-tooltip-rating {
    font-weight: 600;
    font-size: calc(14px * var(--text-scale, 1));
    color: var(--primary);
}

.value-chart-tooltip-desc {
    font-size: calc(13px * var(--text-scale, 1));
    line-height: 1.5;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.value-chart-tooltip-scale {
    font-size: calc(12px * var(--text-scale, 1));
    padding: 10px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

.value-chart-tooltip-scale-title {
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.value-chart-tooltip-scale-row {
    display: flex;
    gap: 8px;
    margin-bottom: 4px;
}

.value-chart-tooltip-scale-row:last-child {
    margin-bottom: 0;
}

.value-chart-tooltip-scale-label {
    font-weight: 600;
    min-width: 35px;
}

.value-chart-tooltip-scale-text {
    color: var(--text-secondary);
}

.value-chart-tooltip.compare-mode {
    max-width: 380px;
}

/* ============== Compare Tooltip ============== */
.compare-tooltip-groups {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}

.compare-tooltip-group {
    padding: 8px 10px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

.compare-tooltip-group-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    font-size: calc(13px * var(--text-scale, 1));
}

.compare-tooltip-group-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.compare-tooltip-group-name {
    flex: 1;
}

.compare-tooltip-group-mean {
    color: var(--primary);
    font-variant-numeric: tabular-nums;
}

.compare-tooltip-logs {
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid var(--border-color);
}

.compare-tooltip-log {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: calc(12px * var(--text-scale, 1));
    padding: 2px 0 2px 14px;
    color: var(--text-secondary);
}

.compare-tooltip-log-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
}

.compare-tooltip-log-value {
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
    margin-left: 8px;
}

/* ============== Comparison Charts ============== */
.comparison-chart-wrapper {
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
}

.comparison-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
}

.comparison-top-row {
    margin-top: 0;
}

.comparison-timeseries {
    margin-top: 20px;
}

.chart-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    overflow: hidden;
    min-width: 0;
}

.chart-section h3 {
    margin: 0 0 16px 0;
    font-size: calc(16px * var(--text-scale, 1));
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.chart-section .section-header h3 {
    margin: 0;
    padding: 0;
    border-bottom: none;
    line-height: 1;
}

.comparison-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.comparison-legend {
    display: flex;
    gap: 16px;
}

.comparison-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: calc(13px * var(--text-scale, 1));
}

.comparison-legend-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
}

/* ============== Circular Bar Chart (Radar Alternative) ============== */
.circular-chart {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    max-width: 400px;
    margin: 0 auto;
}

.circular-chart svg {
    width: 100%;
    height: 100%;
}

.circular-bar {
    transition: all 0.5s ease-out;
}

.circular-bar:hover {
    filter: brightness(1.1);
}

.circular-label {
    font-size: calc(10px * var(--text-scale, 1));
    font-weight: 600;
    fill: var(--text-primary);
}

/* ============== Sparklines ============== */
.sparkline-container {
    display: inline-block;
    vertical-align: middle;
    margin-left: 8px;
}

.sparkline {
    height: 24px;
    width: 80px;
}

.sparkline-line {
    fill: none;
    stroke: var(--primary);
    stroke-width: 1.5;
}

.sparkline-area {
    fill: rgba(74, 144, 226, 0.1);
}

/* ============== Heatmap ============== */
.heatmap-container {
    overflow-x: auto;
}

.heatmap-table {
    border-collapse: collapse;
    width: 100%;
}

.heatmap-table th,
.heatmap-table td {
    padding: 8px 12px;
    text-align: center;
    border: 1px solid var(--border-color);
    font-size: calc(13px * var(--text-scale, 1));
}

.heatmap-table th {
    background: var(--bg-secondary);
    font-weight: 600;
}

.heatmap-cell {
    min-width: 60px;
    transition: all 0.2s;
}

.heatmap-cell.highlight {
    box-shadow: inset 0 0 0 2px var(--primary);
}

/* ============== Tooltips ============== */
.chart-tooltip {
    position: absolute;
    background: rgba(33, 37, 41, 0.95);
    color: white;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: calc(13px * var(--text-scale, 1));
    pointer-events: none;
    z-index: 1000;
    max-width: 300px;
    box-shadow: var(--shadow-lg);
}

.chart-tooltip-title {
    font-weight: 600;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.chart-tooltip-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 4px;
}

.chart-tooltip-label {
    color: rgba(255, 255, 255, 0.7);
}

.chart-tooltip-value {
    font-weight: 600;
    font-family: var(--font-mono);
}

/* ============== Loading States ============== */
.chart-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 200px;
}

.chart-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--bg-tertiary);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ============== No Data States ============== */
.chart-no-data {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 200px;
    color: var(--text-secondary);
}

.chart-no-data-icon {
    font-size: calc(48px * var(--text-scale, 1));
    margin-bottom: 12px;
    opacity: 0.5;
}

/* ============== Annotations ============== */
.annotation-marker {
    cursor: pointer;
}

.annotation-marker circle {
    transition: all 0.2s;
}

.annotation-marker:hover circle {
    r: 8;
    filter: brightness(1.2);
}

.annotation-line {
    stroke-dasharray: 4 2;
    opacity: 0.6;
}

/* ============== Dark Mode Overrides ============== */
[data-theme="dark"] .radar-legend {
    background: rgba(26, 26, 46, 0.95);
    color: var(--text-primary);
}

[data-theme="dark"] .time-series-legend {
    background: rgba(26, 26, 46, 0.95);
    border-color: var(--border-dark);
    color: var(--text-primary);
}

[data-theme="dark"] .chart-tooltip {
    background: rgba(15, 52, 96, 0.95);
}

[data-theme="dark"] .violin-header {
    background: var(--bg-tertiary);
}

[data-theme="dark"] .violin-label {
    color: var(--text-primary);
}

/* ============== Print Styles ============== */
@media print {
    .chart-container {
        break-inside: avoid;
        border: 1px solid #ddd;
    }

    .viz-actions,
    .sidebar,
    .header-right {
        display: none !important;
    }
}
