// Copyright (C) 2026 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

.pf-chart-svg {
  display: flex;
  min-height: 0;
  min-width: 0;
  overflow: clip; // Make sure the chart content never overflows leading to a resize oberver loop.
  contain: content; // Ensure the chart is self-contained and doesn't cause reflows outside of it.

  &.pf-chart-svg--fill-parent {
    height: 100%;
    width: 100%;
  }

  &.pf-chart-svg--legend-top {
    flex-direction: column-reverse;
  }

  &.pf-chart-svg--legend-bottom {
    flex-direction: column;
  }

  &.pf-chart-svg--legend-right {
    flex-direction: row;
  }

  .pf-chart-svg__container {
    flex: 1 1 0;
    min-height: 0;
    min-width: 0;
  }

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

  .pf-chart-svg__loading,
  .pf-chart-svg__empty {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: var(--pf-color-text-muted);
    font-size: var(--pf-font-size-s);
  }

  .pf-chart-svg__legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 12px;
    padding: 4px 8px;
    font-size: 10px;
  }

  &.pf-chart-svg--legend-top .pf-chart-svg__legend,
  &.pf-chart-svg--legend-bottom .pf-chart-svg__legend {
    justify-content: center;
  }

  &.pf-chart-svg--legend-right .pf-chart-svg__legend {
    flex-direction: column;
    align-items: flex-start;
    flex: 0 0 auto;
    width: 140px;
    overflow: hidden;
  }

  .pf-chart-svg__legend-entry {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    user-select: none;
  }

  .pf-chart-svg__legend-entry--hidden {
    opacity: 0.4;

    .pf-chart-svg__legend-name,
    .pf-chart-svg__legend-value {
      text-decoration: line-through;
    }
  }

  .pf-chart-svg__legend-swatch {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    flex: 0 0 auto;
  }

  .pf-chart-svg__legend-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .pf-chart-svg__legend-value {
    font-weight: bold;
    margin-left: 2px;
  }
}

.pf-chart-svg__tooltip-content {
  font-size: var(--pf-font-size-s);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pf-chart-svg__tooltip-header {
  font-weight: bold;
  margin-bottom: 2px;
}

.pf-chart-svg__tooltip-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pf-chart-svg__tooltip-row--hovered {
  font-weight: bold;
}

.pf-chart-svg__tooltip-row--muted {
  color: var(--pf-color-text-muted);
}

.pf-chart-svg__tooltip-swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex: 0 0 auto;
}

.pf-chart-svg__tooltip-name {
  flex: 1 1 auto;
  margin-right: 8px;
}

.pf-chart-svg__tooltip-value {
  font-weight: bold;
}

.pf-chart-svg__axis-title {
  color: var(--pf-color-text-muted);
  font-size: var(--pf-font-size-s);
}

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

.pf-chart-svg__line {
  color: var(--pf-color-border);
}

.pf-chart-svg__gridline {
  color: var(--pf-color-border);
  opacity: 0.3;
}

.pf-chart-svg__hover-guide {
  color: var(--pf-color-text-muted);
}

.pf-chart-svg__selection {
  color: var(--pf-color-accent);
  fill-opacity: 0.08;
  stroke-opacity: 0.3;
}

.pf-chart-svg__brush {
  color: var(--pf-color-accent);
  fill-opacity: 0.15;
  stroke-opacity: 0.5;
}

.pf-chart-svg__point-marker {
  fill: var(--pf-color-background);
}
