/* Chart-Werkzeuge (chart-tools.js): Werkzeugleiste, OHLC-Legende, Replay-Leiste,
   Alarmliste, Toasts und Rueckfrage - alles als absolute Kinder von
   .gt-chart-frame. Nur Praefix .gt-ct- / #gt-ct-, nur innerhalb des Frames.
   Sprache: Deck (Glas rgba(17,24,39,.72), Lavendel-Haarlinien, Mono-Zahlen,
   Radius 10px). Im Server-Modus (html.lwr-lite) nimmt lite.css Blur, Schatten
   und Uebergaenge ohnehin weg; die Regeln hier sind darauf vorbereitet. */

.gt-chart-frame .gt-ct-ui {
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  font-size: 11.5px;
  color: #9a94b8;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}
.gt-chart-frame .gt-ct-ui *,
.gt-chart-frame .gt-ct-ui *::before,
.gt-chart-frame .gt-ct-ui *::after { box-sizing: border-box; }
.gt-chart-frame .gt-ct-mono { font-family: "JetBrains Mono", monospace; }

/* ---- Werkzeugleiste (links, rechts neben der Preisachse) ---- */
.gt-chart-frame #gt-ct-toolbar {
  position: absolute;
  top: 44px;
  left: 70px; /* wird per JS auf Achsenbreite + 8px gesetzt */
  z-index: 7;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 4px;
  border: 1px solid rgba(196, 181, 253, 0.18);
  border-radius: 10px;
  background: rgba(17, 24, 39, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.gt-chart-frame .gt-ct-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  margin: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: rgba(196, 181, 253, 0.78);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.gt-chart-frame .gt-ct-btn svg {
  width: 16px;
  height: 16px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.gt-chart-frame .gt-ct-btn:hover { background: rgba(196, 181, 253, 0.1); color: #e9d5ff; }
.gt-chart-frame .gt-ct-btn.active {
  background: rgba(168, 85, 247, 0.28);
  border-color: rgba(168, 85, 247, 0.55);
  color: #f3e8ff;
}
.gt-chart-frame .gt-ct-btn.danger:hover { background: rgba(240, 68, 100, 0.16); color: #ff8fa6; }
.gt-chart-frame .gt-ct-btn.replay-on {
  background: rgba(250, 204, 21, 0.16);
  border-color: rgba(250, 204, 21, 0.5);
  color: #fde68a;
}
.gt-chart-frame .gt-ct-btn:disabled { opacity: 0.35; cursor: default; }
.gt-chart-frame .gt-ct-sep { height: 1px; margin: 2px 4px; background: rgba(196, 181, 253, 0.16); }

/* Tooltip rechts vom Knopf: Name + Kuerzel. */
.gt-chart-frame .gt-ct-btn[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  padding: 4px 9px;
  border: 1px solid rgba(196, 181, 253, 0.2);
  border-radius: 7px;
  background: rgba(10, 8, 20, 0.94);
  color: #e9d5ff;
  font-family: "Space Grotesk", sans-serif;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
  z-index: 3;
}
.gt-chart-frame .gt-ct-btn[data-tip]:hover::after { opacity: 1; }
.gt-chart-frame .gt-ct-btn[data-tip] kbd { font-family: "JetBrains Mono", monospace; }

/* Zusammengeklappt (Handy): ein Knopf, Menue klappt nach unten auf. */
.gt-chart-frame #gt-ct-toolbar .gt-ct-menu { display: none; }
@media (max-width: 700px) {
  .gt-chart-frame #gt-ct-toolbar { top: 36px; padding: 3px; }
  .gt-chart-frame #gt-ct-toolbar .gt-ct-menu { display: flex; }
  .gt-chart-frame #gt-ct-toolbar:not(.open) > .gt-ct-btn:not(.gt-ct-menu),
  .gt-chart-frame #gt-ct-toolbar:not(.open) > .gt-ct-sep { display: none; }
  .gt-chart-frame #gt-ct-toolbar.open { max-height: calc(100% - 80px); overflow-y: auto; scrollbar-width: none; }
  .gt-chart-frame .gt-ct-btn[data-tip]::after { display: none; }
}

/* Hinweis zum aktiven Werkzeug (unter der Legende). */
.gt-chart-frame #gt-ct-hint {
  position: absolute;
  top: 44px;
  left: 112px; /* JS: Achse + Leiste */
  z-index: 7;
  max-width: 60%;
  padding: 3px 9px;
  border: 1px solid rgba(168, 85, 247, 0.35);
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.72);
  color: #e9d5ff;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}
.gt-chart-frame #gt-ct-hint:empty { display: none; }

/* ---- OHLC-Legende oben links ---- */
.gt-chart-frame #gt-ct-legend {
  position: absolute;
  top: 8px;
  left: 70px; /* JS */
  /* Rechts bleibt Platz fuer die Indikator-Chips (chart-panes.css, oben rechts):
     mit 64px lief das Datum der Legende in den SMA50-Chip (Sichtpruefung 16.10.). */
  right: 350px;
  z-index: 7;
  display: flex;
  flex-direction: column;
  gap: 3px;
  pointer-events: none;
}
.gt-chart-frame .gt-ct-lg-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 10px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  line-height: 1.5;
  color: #9a94b8;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.85);
}
.gt-chart-frame .gt-ct-lg-row.ind { font-size: 10.5px; opacity: 0.9; }
.gt-chart-frame .gt-ct-lg-sym {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #e9d5ff;
}
.gt-chart-frame .gt-ct-lg-k { color: rgba(196, 181, 253, 0.55); margin-right: 3px; font-size: 9.5px; letter-spacing: 0.08em; }
.gt-chart-frame .gt-ct-lg-v { color: #f5f7fb; font-weight: 700; }
.gt-chart-frame .gt-ct-lg-v.up { color: #22c55e; }
.gt-chart-frame .gt-ct-lg-v.down { color: #f04464; }
.gt-chart-frame .gt-ct-lg-v.dim { color: #c4b5fd; font-weight: 500; }

/* ---- Replay-Leiste unten mittig ---- */
.gt-chart-frame #gt-ct-replay {
  position: absolute;
  left: 50%;
  bottom: 38px;
  z-index: 8;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid rgba(250, 204, 21, 0.4);
  border-radius: 10px;
  background: rgba(17, 24, 39, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
}
.gt-chart-frame #gt-ct-replay .gt-ct-btn { width: 26px; height: 26px; }
.gt-chart-frame .gt-ct-rp-tag {
  font-family: "JetBrains Mono", monospace;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #fde68a;
}
.gt-chart-frame .gt-ct-rp-range {
  width: 180px;
  height: 14px;
  margin: 0;
  accent-color: #a855f7;
  cursor: pointer;
}
.gt-chart-frame .gt-ct-rp-pos {
  min-width: 72px;
  font-family: "JetBrains Mono", monospace;
  font-size: 10.5px;
  color: #e9d5ff;
  text-align: center;
}
.gt-chart-frame .gt-ct-rp-speeds { display: flex; gap: 2px; }
.gt-chart-frame .gt-ct-rp-speed {
  min-width: 28px;
  height: 22px;
  padding: 0 5px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: rgba(196, 181, 253, 0.7);
  font-family: "JetBrains Mono", monospace;
  font-size: 10.5px;
  font-weight: 700;
  cursor: pointer;
}
.gt-chart-frame .gt-ct-rp-speed.active { background: rgba(168, 85, 247, 0.28); border-color: rgba(168, 85, 247, 0.55); color: #f3e8ff; }
.gt-chart-frame .gt-ct-rp-end {
  height: 24px;
  padding: 0 10px;
  border: 1px solid rgba(240, 68, 100, 0.45);
  border-radius: 7px;
  background: rgba(240, 68, 100, 0.1);
  color: #ffb3c1;
  font-family: "Space Grotesk", sans-serif;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.gt-chart-frame .gt-ct-rp-end:hover { background: rgba(240, 68, 100, 0.22); color: #fff; }
@media (max-width: 700px) {
  .gt-chart-frame #gt-ct-replay { gap: 5px; padding: 5px 7px; bottom: 34px; max-width: calc(100% - 16px); }
  .gt-chart-frame .gt-ct-rp-range { width: 80px; }
  .gt-chart-frame .gt-ct-rp-tag, .gt-chart-frame .gt-ct-rp-pos { display: none; }
}

/* ---- Alarmliste unten rechts (ueber den Pills, nur Knoepfe klickbar) ---- */
.gt-chart-frame #gt-ct-alarms {
  position: absolute;
  right: 10px;
  bottom: 38px;
  z-index: 7;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  pointer-events: none;
}
.gt-chart-frame #gt-ct-alarms:empty { display: none; }
.gt-chart-frame .gt-ct-al-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border: 1px solid rgba(250, 204, 21, 0.4);
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.82);
  color: #fde68a;
  font-family: "JetBrains Mono", monospace;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  pointer-events: auto;
}
.gt-chart-frame .gt-ct-al-toggle.hit { border-color: rgba(34, 197, 94, 0.6); }
.gt-chart-frame .gt-ct-al-toggle svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.gt-chart-frame .gt-ct-al-panel {
  display: none;
  flex-direction: column;
  gap: 2px;
  min-width: 220px;
  max-height: 180px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid rgba(196, 181, 253, 0.18);
  border-radius: 10px;
  background: rgba(17, 24, 39, 0.86);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  scrollbar-width: thin;
  pointer-events: auto;
}
.gt-chart-frame #gt-ct-alarms.open .gt-ct-al-panel { display: flex; }
.gt-chart-frame .gt-ct-al-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 7px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: #e9d5ff;
}
.gt-chart-frame .gt-ct-al-row:hover { background: rgba(196, 181, 253, 0.07); }
.gt-chart-frame .gt-ct-al-row .st { width: 14px; text-align: center; color: #facc15; font-weight: 800; }
.gt-chart-frame .gt-ct-al-row.up .st { color: #22c55e; }
.gt-chart-frame .gt-ct-al-row.down .st { color: #f04464; }
.gt-chart-frame .gt-ct-al-row .pr { flex: 1 1 auto; font-weight: 700; color: #f5f7fb; }
.gt-chart-frame .gt-ct-al-row .wh { font-size: 9.5px; color: rgba(196, 181, 253, 0.55); letter-spacing: 0.04em; }
.gt-chart-frame .gt-ct-al-del {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: rgba(196, 181, 253, 0.6);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
}
.gt-chart-frame .gt-ct-al-del:hover { background: rgba(240, 68, 100, 0.18); color: #ff8fa6; }
.gt-chart-frame .gt-ct-al-empty { padding: 6px 8px; font-size: 11px; color: rgba(196, 181, 253, 0.55); }

/* ---- Toasts oben mittig (unter der Legende; JS setzt top nach) ---- */
.gt-chart-frame #gt-ct-toasts {
  position: absolute;
  top: 46px;
  left: 50%;
  z-index: 9;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.gt-chart-frame .gt-ct-toast {
  padding: 7px 14px;
  border: 1px solid rgba(250, 204, 21, 0.6);
  border-radius: 10px;
  background: rgba(17, 24, 39, 0.9);
  color: #fde68a;
  font-family: "JetBrains Mono", monospace;
  font-size: 11.5px;
  white-space: nowrap;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  animation: gtCtToastIn 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.1) both;
}
.gt-chart-frame .gt-ct-toast.up { border-color: rgba(34, 197, 94, 0.65); color: #bbf7d0; }
.gt-chart-frame .gt-ct-toast.down { border-color: rgba(240, 68, 100, 0.65); color: #fecdd3; }
.gt-chart-frame .gt-ct-toast.info { border-color: rgba(196, 181, 253, 0.35); color: #e9d5ff; }
.gt-chart-frame .gt-ct-toast b { color: #fff; }
.gt-chart-frame .gt-ct-toast.out { animation: gtCtToastOut 0.5s ease-in both; }
@keyframes gtCtToastIn { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes gtCtToastOut { to { opacity: 0; transform: translateY(-10px); } }

/* ---- Rueckfrage (Alles loeschen) im Frame ---- */
.gt-chart-frame #gt-ct-confirm {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
  background: rgba(4, 2, 12, 0.66);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.gt-chart-frame .gt-ct-cf-box {
  width: min(360px, calc(100% - 32px));
  padding: 18px 20px 16px;
  border: 1px solid rgba(240, 68, 100, 0.5);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(24, 16, 44, 0.98), rgba(12, 8, 24, 0.98));
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.gt-chart-frame .gt-ct-cf-eyebrow {
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(196, 181, 253, 0.6);
}
.gt-chart-frame .gt-ct-cf-title { margin: 6px 0 8px; font-size: 17px; font-weight: 700; color: #fff; }
.gt-chart-frame .gt-ct-cf-text { margin: 0; font-size: 12px; line-height: 1.5; color: rgba(196, 181, 253, 0.75); }
.gt-chart-frame .gt-ct-cf-acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.gt-chart-frame .gt-ct-cf-acts button {
  height: 32px;
  padding: 0 14px;
  border-radius: 9px;
  border: 1px solid rgba(196, 181, 253, 0.25);
  background: rgba(196, 181, 253, 0.08);
  color: #e9d5ff;
  font-family: "Space Grotesk", sans-serif;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.gt-chart-frame .gt-ct-cf-acts button.ok {
  border-color: rgba(240, 68, 100, 0.6);
  background: rgba(240, 68, 100, 0.18);
  color: #ffb3c1;
}
.gt-chart-frame .gt-ct-cf-acts button:hover { filter: brightness(1.2); color: #fff; }

/* ---- Vollbild: der Frame selbst ist das Vollbild-Element ---- */
.gt-chart-frame.gt-ct-fs { border-radius: 0; }
.gt-chart-frame.gt-ct-fs #gt-ct-legend { top: 12px; }
/* Schmal (Handy): die Chips wandern unter die Legende (chart-panes.css), die Legende darf die Breite nutzen. */
@media (max-width: 700px) {
  .gt-chart-frame #gt-ct-legend { right: 64px; }
}

/* ---- Server-Modus: keine Animationen, Uebergaenge, Unschaerfe, Schatten
   (lite.css erledigt das im Dashboard global; hier fuer den Fall, dass das
   Modul ohne lite.css laeuft). ---- */
html.lwr-lite .gt-chart-frame .gt-ct-ui,
html.lwr-lite .gt-chart-frame .gt-ct-ui *,
html.lwr-lite .gt-chart-frame .gt-ct-ui *::before,
html.lwr-lite .gt-chart-frame .gt-ct-ui *::after {
  animation: none !important;
  transition: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  box-shadow: none !important;
  text-shadow: none !important;
}
