/**
 * Chart styles
 * @countermeasure/web-components/charts
 */

/* ============================================================================
   Container
   ============================================================================ */
.cmm-chart-container {
  position: relative;
  display: inline-block;
}

.cmm-chart-container canvas {
  display: block;
}

/* ============================================================================
   Legend
   ============================================================================ */
.cmm-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  padding: 0.5rem 0;
  font-size: 0.75rem;
  font-family: system-ui, -apple-system, sans-serif;
  color: hsl(var(--muted-foreground));
}

/* Horizontal layout: top and bottom */
.cmm-chart-legend--top {
  flex-direction: row;
  justify-content: center;
}

.cmm-chart-legend--bottom {
  flex-direction: row;
  justify-content: center;
}

/* Vertical layout: left and right */
.cmm-chart-legend--left {
  flex-direction: column;
  align-items: flex-start;
}

.cmm-chart-legend--right {
  flex-direction: column;
  align-items: flex-end;
}

.cmm-chart-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  cursor: pointer;
  user-select: none;
  transition: opacity var(--transition-fast);
}

.cmm-chart-legend__item:hover {
  opacity: 0.75;
}

.cmm-chart-legend__item--inactive {
  opacity: 0.4;
}

.cmm-chart-legend__item--inactive:hover {
  opacity: 0.55;
}

.cmm-chart-legend__dot {
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 50%;
  flex-shrink: 0;
}

.cmm-chart-legend__label {
  line-height: 1;
  white-space: nowrap;
}

/* ============================================================================
   Tooltip
   ============================================================================ */
.cmm-chart-tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 50;
  padding: 0.5rem 0.75rem;
  background: hsl(var(--popover));
  color: hsl(var(--popover-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  font-family: system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  box-shadow: 0 4px 12px hsl(0 0% 0% / 0.1);
  white-space: nowrap;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

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

.cmm-chart-tooltip strong {
  font-weight: 600;
  color: hsl(var(--foreground));
}

/* ============================================================================
   Crosshair overlay (used by candlestick / interactive charts)
   ============================================================================ */
.cmm-chart-crosshair {
  position: absolute;
  pointer-events: none;
  z-index: 10;
}

.cmm-chart-crosshair__line {
  position: absolute;
  background: hsl(var(--muted-foreground) / 0.3);
}

.cmm-chart-crosshair__line--x {
  width: 1px;
  top: 0;
  bottom: 0;
}

.cmm-chart-crosshair__line--y {
  height: 1px;
  left: 0;
  right: 0;
}
