/* OT Terminal — Chart Toolbar, Canvas Panes, Time Axis */

.ot-chart-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: var(--ot-bg-panel);
  border-bottom: 1px solid var(--ot-border-subtle);
  overflow-x: auto;
}

.ot-chart-toolbar__symbol {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  padding-right: 10px;
  border-right: 1px solid var(--ot-border-subtle);
}

.ot-chart-toolbar__glyph {
  width: 22px;
  height: 22px;
  border-radius: var(--ot-radius-sm);
  background: var(--ot-bg-panel-raised);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--ot-text-secondary);
}

.ot-chart-toolbar__symbol-id {
  line-height: 1.15;
}

.ot-chart-toolbar__symbol-code {
  font-size: var(--ot-fs-sm);
  font-weight: 700;
  color: var(--ot-text-primary);
}

.ot-chart-toolbar__symbol-name {
  font-size: 10px;
  color: var(--ot-text-tertiary);
}

.ot-chart-toolbar__caret {
  width: 12px;
  height: 12px;
  color: var(--ot-text-tertiary);
}

.ot-timeframes {
  display: flex;
  align-items: center;
  gap: 1px;
  flex: 0 0 auto;
  padding-right: 10px;
  border-right: 1px solid var(--ot-border-subtle);
}

.ot-timeframes button {
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--ot-radius-sm);
  color: var(--ot-text-secondary);
}

.ot-timeframes button:hover {
  color: var(--ot-text-primary);
  background: var(--ot-bg-panel-raised);
}

.ot-timeframes button.is-active {
  color: var(--ot-gold-bright);
  background: var(--ot-gold-wash);
}

/* Post-foundation: compact "More" timeframe control (3M/6M/1Y) — same
   button look as the inline row (inherits .ot-timeframes button above)
   plus a small chevron and, when its own menu is open or one of its
   timeframes is active, the same gold highlight the inline buttons use. */
.ot-timeframes__more {
  display: flex;
  align-items: center;
  gap: 3px;
}
.ot-timeframes__more svg {
  width: 10px;
  height: 10px;
}

/* The dropdown menu itself reuses .ot-indicators-menu's panel chrome
   (dark raised background, border, shadow, portal-anchored absolute
   positioning, the [hidden]-safe display rule) but is far narrower since
   it only ever holds 3 short buttons in a single column. */
.ot-timeframes-more-menu {
  width: auto;
  min-width: 96px;
  padding: 4px;
  gap: 2px;
}
.ot-timeframes-more-menu button {
  padding: 7px 10px;
  font-size: 11px;
  font-weight: 600;
  text-align: left;
  border-radius: var(--ot-radius-sm);
  color: var(--ot-text-secondary);
}
.ot-timeframes-more-menu button:hover {
  color: var(--ot-text-primary);
  background: var(--ot-bg-panel);
}
.ot-timeframes-more-menu button.is-active {
  color: var(--ot-gold-bright);
  background: var(--ot-gold-wash);
}

.ot-chart-toolbar__tools {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
}

.ot-chart-toolbar__btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ot-text-secondary);
  border-radius: var(--ot-radius-sm);
  white-space: nowrap;
}

.ot-chart-toolbar__btn:hover {
  color: var(--ot-text-primary);
  background: var(--ot-bg-panel-raised);
}

.ot-chart-toolbar__btn svg {
  width: 13px;
  height: 13px;
}

.ot-chart-toolbar__spacer {
  flex: 1 1 auto;
}

/* ===== OHLC readout above the price pane ===== */
.ot-ohlc-readout {
  position: absolute;
  top: 8px;
  left: 12px;
  z-index: 5;
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 11px;
  color: var(--ot-text-secondary);
  pointer-events: none;
}

.ot-ohlc-readout b {
  color: var(--ot-text-primary);
  font-weight: 600;
}

.ot-ohlc-readout .ot-change-pill {
  font-weight: 700;
}

/* ===== Sub-pane labels (RSI / MACD / Volume) ===== */
.ot-pane-label {
  position: absolute;
  top: 6px;
  left: 12px;
  z-index: 5;
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--ot-text-secondary);
  pointer-events: none;
}

.ot-pane-label span {
  font-weight: 500;
  color: var(--ot-text-tertiary);
}

.ot-pane-label__close {
  position: absolute;
  top: 4px;
  right: 6px;
  z-index: 6;
  pointer-events: auto;
}

/* ===== Time axis / range footer ===== */
.ot-chart-timeaxis {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 0 8px 3px;
  overflow: hidden;
  background: var(--ot-bg-panel);
}

.ot-range-select {
  display: flex;
  align-items: center;
  gap: 1px;
  min-width: 0;
  flex: 0 1 auto;
  overflow-x: auto;
  scrollbar-width: none;
}

.ot-range-select::-webkit-scrollbar {
  display: none;
}

.ot-range-select button {
  flex: 0 0 auto;
  padding: 4px 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ot-text-secondary);
  border-radius: var(--ot-radius-sm);
}

.ot-range-select button:hover {
  color: var(--ot-text-primary);
}

.ot-range-select button.is-active {
  color: var(--ot-gold-bright);
  background: var(--ot-gold-wash);
}

.ot-chart-timeaxis__spacer {
  flex: 1 1 auto;
}

.ot-chart-timeaxis__meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 10px;
  color: var(--ot-text-tertiary);
}

.ot-chart-timeaxis__meta button {
  padding: 2px 6px;
  border-radius: var(--ot-radius-sm);
  color: var(--ot-text-tertiary);
  font-weight: 600;
}

.ot-chart-timeaxis__meta button.is-active {
  color: var(--ot-gold-bright);
}

.ot-pane-canvas-stack canvas[data-role="overlay"] {
  cursor: crosshair;
}

/* ===== Crosshair price/time tags (Phase 2) ===== */
.ot-crosshair-price-tag {
  position: absolute;
  right: 2px;
  z-index: 6;
  width: 60px;
  padding: 4px 0;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--ot-font-mono);
  color: #0a0a0d;
  background: var(--ot-text-primary);
  border-radius: var(--ot-radius-sm);
  pointer-events: none;
}

.ot-crosshair-time-tag {
  position: absolute;
  top: 1px;
  z-index: 6;
  width: 68px;
  padding: 3px 0;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--ot-font-mono);
  color: #0a0a0d;
  background: var(--ot-text-primary);
  border-radius: var(--ot-radius-sm);
  pointer-events: none;
}

/* ===== Selected-drawing style popover (Phase 2) ===== */
.ot-drawing-style-popover {
  position: absolute;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  width: 180px;
  background: var(--ot-bg-panel-raised);
  border: 1px solid var(--ot-border);
  border-radius: var(--ot-radius-md);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

/* The [hidden] attribute selector needs to win over the `display: flex`
   above — same specificity, but this rule must come after it in source
   order, which is fragile to rely on alone, so make the intent explicit. */
.ot-drawing-style-popover[hidden] {
  display: none;
}

.ot-style-popover__row {
  display: flex;
  align-items: center;
  gap: 6px;
}
/* Same `[hidden]`-vs-class specificity gotcha as `.ot-drawing-style-popover`
   above (both (0,1,0), author rule wins on cascade order regardless of the
   `hidden` attribute) — now hit by the Phase 3A per-row toggling
   (`_setPopoverRowsForType` in ChartWorkspace.js hides/shows the text/
   thickness/linestyle/fill rows per selected tool). Make it explicit here
   too rather than relying on rule order. */
.ot-style-popover__row[hidden] {
  display: none;
}

.ot-style-swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  flex: 0 0 auto;
}
/* `.ot-terminal button { background: none }` in base.css is (0,1,1) —
   one class + one element — which beats a single-class rule like
   `.ot-style-swatch` (0,1,0) regardless of source order. Scope this
   rule through the popover so it wins on specificity, not order. */
.ot-drawing-style-popover .ot-style-swatch {
  background: var(--swatch);
}
.ot-style-swatch:hover {
  border-color: var(--ot-text-primary);
}

.ot-style-thickness,
.ot-style-linestyle,
.ot-style-fill {
  flex: 1 1 0;
  padding: 4px 0;
  font-size: 10px;
  color: var(--ot-text-secondary);
  border: 1px solid var(--ot-border-subtle);
  border-radius: var(--ot-radius-sm);
  text-transform: capitalize;
}
.ot-style-thickness:hover,
.ot-style-linestyle:hover,
.ot-style-fill:hover {
  color: var(--ot-text-primary);
  border-color: var(--ot-border-strong);
}

/* ===== Text-drawing inline editor row (Phase 3A) ===== */
.ot-style-popover__text-input {
  width: 100%;
  padding: 6px 8px;
  font-size: 12px;
  font-family: inherit;
  color: var(--ot-text-primary);
  background: var(--ot-bg-app);
  border: 1px solid var(--ot-border-subtle);
  border-radius: var(--ot-radius-sm);
}
.ot-style-popover__text-input:focus {
  outline: none;
  border-color: var(--ot-gold);
}

.ot-style-popover__delete {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--ot-down);
  border-top: 1px solid var(--ot-border-subtle);
  margin-top: 2px;
  padding-top: 8px;
}
.ot-style-popover__delete:hover {
  background: var(--ot-down-dim);
  border-radius: var(--ot-radius-sm);
}
.ot-style-popover__delete svg {
  width: 13px;
  height: 13px;
}

/* ===== Overlay-indicator legend, price pane (Phase 3B) ===== */
.ot-indicator-legend {
  position: absolute;
  top: 26px;
  left: 12px;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 10px;
  font-weight: 600;
  font-family: var(--ot-font-mono);
  pointer-events: none;
}
.ot-indicator-legend__chip b {
  font-weight: 700;
  color: var(--ot-text-primary);
}

/* ===== Sub-pane current-value readout (Phase 3B) ===== */
.ot-pane-label__value {
  font-family: var(--ot-font-mono);
  font-weight: 700;
  color: var(--ot-text-primary);
}

/* ===== Indicators menu (Phase 3B) =====
   Anchored the same way the old checkbox menu was (`.ot-search-results`
   pattern from SymbolSearch) but with its own class — this menu is
   materially larger (active list + settings + add-categories) and needs
   its own width/scroll/section rules. */
.ot-indicators-menu {
  position: absolute;
  /* top/left are set from JS (IndicatorPanel._positionMenu) against the
     portal root's own bounding box, not against the toolbar button's
     offsetParent — see the portal-root comment in IndicatorPanel.js. */
  z-index: 60;
  width: 280px;
  max-height: min(70vh, 520px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: var(--ot-bg-panel-raised);
  border: 1px solid var(--ot-border);
  border-radius: var(--ot-radius-md);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  padding: 8px;
  gap: 8px;
}
.ot-indicators-menu[hidden] {
  display: none;
}

.ot-indicators-menu__volume {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 8px;
  border-bottom: 1px solid var(--ot-border-subtle);
  font-size: var(--ot-fs-sm);
  font-weight: 600;
  color: var(--ot-text-secondary);
}
.ot-indicators-menu__volume .ot-icon-btn.is-off {
  color: var(--ot-text-disabled);
}

.ot-indicators-menu__empty {
  padding: 10px 6px;
  font-size: var(--ot-fs-xs);
  color: var(--ot-text-tertiary);
}

.ot-indicator-row {
  border-radius: var(--ot-radius-sm);
  background: var(--ot-bg-panel);
  margin-bottom: 4px;
}
.ot-indicator-row__main {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
}
.ot-indicator-row__swatch {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--swatch);
  flex: 0 0 auto;
}
.ot-indicator-row__name {
  font-size: var(--ot-fs-sm);
  font-weight: 600;
  color: var(--ot-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ot-indicator-row__pane {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--ot-text-tertiary);
  letter-spacing: 0.3px;
}
.ot-indicator-row__actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
  flex: 0 0 auto;
}
.ot-indicator-row__actions .ot-icon-btn {
  width: 24px;
  height: 24px;
}
.ot-indicator-row__remove:hover {
  color: var(--ot-down);
  background: var(--ot-down-dim);
}

.ot-indicator-row__settings {
  padding: 2px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ot-indicator-row__settings[hidden] {
  display: none;
}
.ot-ind-settings__params,
.ot-ind-settings__style {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ot-ind-settings__row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ot-ind-settings__row > label {
  flex: 0 0 78px;
  font-size: 10px;
  color: var(--ot-text-tertiary);
}
.ot-ind-settings__row select,
.ot-ind-settings__row input[type="number"] {
  flex: 1 1 auto;
  min-width: 0;
  background: var(--ot-bg-input);
  border: 1px solid var(--ot-border-subtle);
  border-radius: var(--ot-radius-sm);
  color: var(--ot-text-primary);
  font-size: 11px;
  padding: 3px 6px;
  font-family: var(--ot-font-mono);
}
.ot-ind-settings__checkbox {
  flex: 1 1 auto !important;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ot-text-secondary) !important;
  font-size: 11px !important;
  cursor: pointer;
}
.ot-ind-settings__checkbox input {
  accent-color: var(--ot-gold);
}
.ot-ind-settings__swatches {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}
/* Same `.ot-terminal button { background: none }` specificity gotcha the
   drawing style popover already works around (see .ot-style-swatch
   above) — this menu is a different subtree, so it needs its own
   equal-or-higher-specificity override. */
.ot-indicators-menu .ot-style-swatch {
  background: var(--swatch);
  width: 16px;
  height: 16px;
}
.ot-indicators-menu .ot-style-swatch.is-selected,
.ot-indicators-menu .ot-style-thickness.is-selected,
.ot-indicators-menu .ot-style-linestyle.is-selected,
.ot-indicators-menu .ot-style-fill.is-selected {
  box-shadow: 0 0 0 2px var(--ot-gold-bright);
}
.ot-indicators-menu .ot-style-thickness,
.ot-indicators-menu .ot-style-linestyle,
.ot-indicators-menu .ot-style-fill {
  padding: 3px 6px;
  font-size: 9px;
}

.ot-indicators-menu__add {
  border-top: 1px solid var(--ot-border-subtle);
  padding-top: 8px;
}
.ot-indicators-menu__add-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--ot-text-tertiary);
  margin-bottom: 6px;
}
.ot-indicators-menu__category {
  margin-bottom: 8px;
}
.ot-indicators-menu__category-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--ot-gold-dim);
  margin-bottom: 4px;
}
.ot-indicators-menu__type-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.ot-indicators-menu__add-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ot-text-secondary);
  background: var(--ot-bg-panel);
  border: 1px solid var(--ot-border-subtle);
  border-radius: var(--ot-radius-sm);
}
.ot-indicators-menu__add-btn:hover {
  color: var(--ot-gold-bright);
  border-color: var(--ot-gold-dim);
  background: var(--ot-gold-wash);
}
.ot-indicators-menu__add-btn svg {
  width: 11px;
  height: 11px;
}

/* ===== Empty-state affordance for future chart engine ===== */
.ot-chart-workspace[data-ot-loading="true"] .ot-chart-panes::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.02), transparent);
  pointer-events: none;
}
