/**
 * netgrid-charts 1.0 – Standard-Design, BEM-Klassen (ngc-*)
 * Individualisierbar durch Überschreiben der Klassen oder CSS-Variablen.
 */

/* -------------------------------------------------------------------------
   CSS-Variablen (Client kann überschreiben)
   ------------------------------------------------------------------------- */
.ngc-chart {
  --ngc-font-family: inherit;
  --ngc-font-size: 12px;
  --ngc-font-color: #374151;
  --ngc-title-font-size: 1rem;
  --ngc-title-font-weight: 600;
  --ngc-legend-gap: 0.5rem;
  --ngc-legend-color-size: 0.75rem;
  --ngc-border-radius: 6px;
  --ngc-plot-bg: transparent;
  --ngc-grid-color: rgba(0, 0, 0, 0.08);
}

/* Block: Chart-Container */
.ngc-chart {
  position: relative;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  font-family: var(--ngc-font-family);
  font-size: var(--ngc-font-size);
  color: var(--ngc-font-color);
  line-height: 1.4;
}

/* Element: Titel */
.ngc-chart__title {
  margin: 0 0 0.75rem;
  font-size: var(--ngc-title-font-size);
  font-weight: var(--ngc-title-font-weight);
  color: var(--ngc-font-color);
}

/* Element: Plot-Bereich (Canvas-Wrapper) */
.ngc-chart__plot {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 1;
  min-height: 200px;
  background: var(--ngc-plot-bg);
  border-radius: var(--ngc-border-radius);
}

/* Element: Canvas */
.ngc-chart__canvas {
  display: block;
  width: 100%;
  height: auto;
  vertical-align: middle;
}

/* Element: Legende */
.ngc-chart__legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ngc-legend-gap);
  justify-content: center;
  margin-top: 1rem;
  padding: 0;
  list-style: none;
}

/* Element: Legenden-Eintrag */
.ngc-chart__legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

/* Modifier: Legende klickbar (Toggle Serie) */
.ngc-chart__legend-item--toggleable {
  cursor: pointer;
  user-select: none;
}

.ngc-chart__legend-item--toggleable:hover {
  opacity: 0.85;
}

/* Modifier: Serie deaktiviert (ausgeblendet) */
.ngc-chart__legend-item--inactive {
  opacity: 0.45;
}

.ngc-chart__legend-item--inactive .ngc-chart__legend-color {
  opacity: 0.6;
}

/* Element: Legenden-Farbe (Farbpunkt) */
.ngc-chart__legend-color {
  flex-shrink: 0;
  width: var(--ngc-legend-color-size);
  height: var(--ngc-legend-color-size);
  border-radius: 2px;
}

/* Element: Legenden-Text */
.ngc-chart__legend-label {
  font-size: var(--ngc-font-size);
  color: var(--ngc-font-color);
}

/* Element: Tooltip (für spätere Erweiterung) */
.ngc-chart__tooltip {
  position: absolute;
  z-index: 999999999;
  padding: 0.35rem 0.5rem;
  font-size: var(--ngc-font-size);
  background: #1f2937;
  color: #f9fafb;
  border-radius: 4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.ngc-chart__tooltip-content {
  white-space: nowrap;
}

/* -------------------------------------------------------------------------
   Modifier: Farbschemata (Container/Umgebung)
   Client kann .ngc-chart--scheme-* am Container setzen oder eigene Klassen nutzen.
   ------------------------------------------------------------------------- */
.ngc-chart--scheme-default {
  --ngc-font-color: #374151;
  --ngc-plot-bg: transparent;
}

.ngc-chart--scheme-pastel {
  --ngc-font-color: #475569;
  --ngc-plot-bg: #f8fafc;
}

.ngc-chart--scheme-muted {
  --ngc-font-color: #64748b;
  --ngc-plot-bg: #f1f5f9;
}

.ngc-chart--scheme-dark {
  --ngc-font-color: #e2e8f0;
  --ngc-plot-bg: #1e293b;
  --ngc-grid-color: rgba(255, 255, 255, 0.1);
}

.ngc-chart--scheme-dark .ngc-chart__title,
.ngc-chart--scheme-dark .ngc-chart__legend-label {
  color: #e2e8f0;
}

/* -------------------------------------------------------------------------
   Modifier: Legende Position (optional)
   ------------------------------------------------------------------------- */
.ngc-chart--legend-top .ngc-chart__legend {
  margin-top: 0;
  margin-bottom: 1rem;
  order: -1;
}

.ngc-chart--legend-left .ngc-chart__legend {
  justify-content: flex-start;
}

.ngc-chart--legend-right .ngc-chart__legend {
  justify-content: flex-end;
}

/* -------------------------------------------------------------------------
   Fullscreen-Toolbar und Lightbox-Modal
   ------------------------------------------------------------------------- */
.ngc-chart__toolbar {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 10;
}

.ngc-chart__fullscreen-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.06);
  color: var(--ngc-font-color);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.ngc-chart__fullscreen-btn:hover {
  background: rgba(0, 0, 0, 0.12);
}

.ngc-chart__fullscreen-btn:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
}

.ngc-chart__modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: rgba(0, 0, 0, 0.6);
  animation: ngc-modal-fade 0.2s ease;
}

@keyframes ngc-modal-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.ngc-chart__modal-content {
  position: relative;
  width: 90vw;
  max-width: 1200px;
  height: 85vh;
  max-height: 900px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  overflow: auto;
  animation: ngc-modal-scale 0.2s ease;
}

@keyframes ngc-modal-scale {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.ngc-chart__modal-content .ngc-chart {
  width: 100%;
  height: 100%;
  min-height: 100%;
}

.ngc-chart--in-modal .ngc-chart__toolbar {
  display: none;
}

.ngc-chart--in-modal .ngc-chart__legend {
  flex-shrink: 0;
  min-height: 1.5rem;
  visibility: visible;
}

.ngc-chart__modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 11;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.06);
  font-size: 1.25rem;
  line-height: 1;
  color: #374151;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.ngc-chart__modal-close:hover {
  background: rgba(0, 0, 0, 0.12);
}

.ngc-chart__modal-close:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
}
