/**
 * Visualizations CSS - Styles für erweiterte Visualisierungen
 *
 * Komponenten:
 * - VizSelector (Sub-Navigation)
 * - Small Multiples Grid
 * - Heatmap
 * - Ranking Chart
 * - Sparklines
 */

/* ========================================
   VIZ SELECTOR (Sub-Navigation)
   Prominente Platzierung oberhalb des Charts
   ======================================== */
.viz-selector {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: var(--space-4);
    margin: 0;
    background: var(--color-bg-secondary);
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    border-bottom: 1px solid var(--color-border-light);
}

.viz-selector__label {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-muted);
    margin-right: var(--space-4);
    white-space: nowrap;
}

.viz-selector__group {
    display: flex;
    gap: var(--space-1);
    flex-wrap: wrap;
    background: var(--color-bg);
    padding: var(--space-1);
    border-radius: var(--border-radius);
    border: 1px solid var(--color-border-light);
}

.viz-selector__btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-muted);
    background: transparent;
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all var(--transition-base);
}

.viz-selector__btn:hover {
    background: var(--color-bg-secondary);
    color: var(--color-text);
}

.viz-selector__btn--active {
    background: var(--color-primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

.viz-selector__btn--active:hover {
    background: var(--color-primary-hover);
    color: white;
}

.viz-selector__icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.viz-selector__text {
    white-space: nowrap;
}

/* Responsive: Labels ausblenden auf kleinen Screens */
@media (max-width: 640px) {
    .viz-selector__text {
        display: none;
    }

    .viz-selector__btn {
        padding: var(--space-2);
    }

    .viz-selector__label {
        display: none;
    }
}

/* ========================================
   SMALL MULTIPLES GRID
   ======================================== */
.small-multiples-container {
    padding: var(--space-4);
}

.small-multiples-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-4);
}

.small-multiples-header__text {
    text-align: center;
    flex: 1;
}

.small-multiples-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    margin: 0 0 var(--space-1) 0;
}

.small-multiples-subtitle {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin: 0;
}

.small-multiples-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-4);
}

.small-multiples-grid__count {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    font-weight: var(--font-weight-normal);
}

@media (max-width: 992px) {
    .small-multiples-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .small-multiples-grid {
        grid-template-columns: 1fr;
    }
}

.small-multiples-grid__panel {
    background: var(--color-bg);
    border: 1px solid var(--color-border-light);
    border-radius: var(--border-radius);
    padding: var(--space-3);
    height: 220px;
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    flex-direction: column;
}

.small-multiples-grid__panel:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--color-border);
}

.small-multiples-grid__panel--active {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-primary-light);
}

.small-multiples-grid__title {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    margin-bottom: var(--space-2);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.small-multiples-grid__type-badge {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.small-multiples-grid__canvas {
    width: 100%;
    flex: 1;
    min-height: 0; /* Wichtig für Flexbox */
}

/* ========================================
   HEATMAP
   ======================================== */
.heatmap-container {
    position: relative;
    overflow-x: auto;
    padding: var(--space-4);
}

.heatmap-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-4);
}

.heatmap-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    margin: 0;
}

.heatmap-wrapper {
    display: flex;
    min-width: fit-content;
}

.heatmap-labels {
    display: flex;
    flex-direction: column;
    padding-top: 30px; /* Platz für Jahres-Header */
}

.heatmap-label {
    height: 28px;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding-right: var(--space-3);
    font-size: var(--font-size-xs);
    white-space: nowrap;
}

.heatmap-label__badge {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    flex-shrink: 0;
}

.heatmap-grid {
    flex: 1;
}

.heatmap-header {
    display: flex;
    height: 30px;
}

.heatmap-header__cell {
    width: 60px;
    text-align: center;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-muted);
}

.heatmap-row {
    display: flex;
}

.heatmap-cell {
    width: 60px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xs);
    border: 1px solid var(--color-bg);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.heatmap-cell:hover {
    outline: 2px solid var(--color-primary);
    outline-offset: -2px;
    z-index: 1;
}

.heatmap-cell--null {
    background: var(--color-bg-secondary);
    color: var(--color-text-muted);
}

/* Heatmap Tooltip */
.heatmap-tooltip {
    position: absolute;
    padding: var(--space-2) var(--space-3);
    background: var(--color-text);
    color: white;
    font-size: var(--font-size-xs);
    border-radius: var(--border-radius-sm);
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition-fast);
    z-index: var(--z-tooltip);
    white-space: nowrap;
}

.heatmap-tooltip.is-visible {
    opacity: 1;
}

/* Heatmap Legend */
.heatmap-legend {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-top: var(--space-4);
    justify-content: center;
}

.heatmap-legend__gradient {
    width: 150px;
    height: 12px;
    border-radius: var(--border-radius-sm);
    background: linear-gradient(to right, #f8f9fa, var(--color-primary));
}

.heatmap-legend__label {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

/* ========================================
   RANKING CHART
   ======================================== */
.ranking-container {
    position: relative;
    padding: var(--space-4);
}

.ranking-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-4);
}

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

.ranking-title {
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
}

.ranking-year-select {
    width: auto;
    min-width: 100px;
}

.ranking-chart {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.ranking-bar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.ranking-bar__rank {
    width: 24px;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-muted);
    text-align: right;
}

.ranking-bar__label {
    width: 100px;
    font-size: var(--font-size-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ranking-bar__track {
    flex: 1;
    height: 24px;
    background: var(--color-bg-secondary);
    border-radius: var(--border-radius-sm);
    overflow: hidden;
}

.ranking-bar__fill {
    height: 100%;
    border-radius: var(--border-radius-sm);
    transition: width 0.5s ease-out;
    display: flex;
    align-items: center;
    padding-left: var(--space-2);
}

.ranking-bar__value {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    color: white;
    white-space: nowrap;
}

/* ========================================
   SPARKLINES
   ======================================== */
.sparkline-cell {
    width: 100px;
    padding: var(--space-1) !important;
    vertical-align: middle;
}

.sparkline {
    display: block;
    width: 100%;
    height: 30px;
}

.sparkline-wrapper {
    position: relative;
}

.sparkline-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-text);
    color: white;
    font-size: var(--font-size-xs);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--border-radius-sm);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.sparkline-wrapper:hover .sparkline-tooltip {
    opacity: 1;
}

/* ========================================
   VIZ LOADING / ERROR STATES
   ======================================== */
.viz-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    gap: var(--space-3);
    color: var(--color-text-muted);
}

.viz-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    gap: var(--space-3);
    color: var(--color-danger);
    text-align: center;
}

.viz-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    gap: var(--space-3);
    color: var(--color-text-muted);
    text-align: center;
}
