/* OT Terminal — Shell Layout */

.ot-terminal .ot-shell {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  width: 100%;
}

.ot-terminal .ot-shell-header {
  flex: 0 0 var(--ot-header-h);
  height: var(--ot-header-h);
}

.ot-terminal .ot-shell-body {
  flex: 1 1 auto;
  display: grid;
  /* --ot-wl-track is the watchlist column: its width when expanded, 0 when
     collapsed (.ot-watchlist-collapsed) — so it combines cleanly with the
     drawing-rail collapse and the tablet/mobile rules. */
  --ot-wl-track: var(--ot-watchlist-w);
  grid-template-columns: var(--ot-wl-track) minmax(0, 1fr) var(--ot-drawing-w);
  /* Without an explicit row track, CSS Grid sizes the (implicit) row
     to its content's min-content height. Because the chart workspace
     nests flex-in-flex panes, that min-content can end up taller than
     the viewport, which silently pushes the footer to overlap the
     chart instead of shrinking the panes. Pinning the row to exactly
     the container's height — and allowing it to go below content size
     with the `0` in minmax — is what makes the grid item (and every
     flex child inside it) actually respect the available height. */
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
  transition: grid-template-columns var(--ot-transition-base);
}

.ot-terminal .ot-shell-body.ot-drawing-collapsed {
  grid-template-columns: var(--ot-wl-track) minmax(0, 1fr) 0px;
}

.ot-terminal .ot-shell-body.ot-watchlist-collapsed {
  --ot-wl-track: 0px;
}

.ot-terminal .ot-shell-footer {
  flex: 0 0 var(--ot-strip-h);
  height: var(--ot-strip-h);
}

/* ===== Chart workspace internal layout ===== */
.ot-chart-workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--ot-bg-inset);
  border-left: 1px solid var(--ot-border-subtle);
  border-right: 1px solid var(--ot-border-subtle);
}

.ot-chart-toolbar {
  flex: 0 0 var(--ot-toolbar-h);
  height: var(--ot-toolbar-h);
}

.ot-chart-panes {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  /* Advanced Indicators phase — up to 9 "separate" category indicators
     (RSI/MACD/ATR + the 6 new pane types) can now coexist on one panel,
     each a fixed 80px sub-pane (see .ot-chart-pane-sub below). Price pane
     bottoms out at its own 160px min-height, so past a handful of active
     panes the column's total height can exceed the container — scroll
     rather than silently clip/overlap panes. No effect at typical counts
     (≤4 panes): nothing to scroll, no visible change. */
  overflow-y: auto;
}

/* Chart-visibility pass: the price pane always keeps at least half of
   the panel's pane area (60%); sub-panes (volume/RSI/MACD/...) are 80px
   when there is room and shrink (down to 36px) in short panels such as 2x2
   layouts instead of crushing the price pane. */
.ot-chart-pane-price {
  flex: 1 1 65%;
  min-height: max(120px, 60%);
  position: relative;
}

.ot-chart-pane-sub {
  flex: 0 1 80px;
  height: auto;
  min-height: 36px;
  position: relative;
  border-top: 1px solid var(--ot-border-subtle);
}

.ot-chart-pane-sub[hidden] {
  display: none;
}

.ot-chart-timeaxis {
  flex: 0 0 var(--ot-timeaxis-h);
  height: var(--ot-timeaxis-h);
  border-top: 1px solid var(--ot-border-subtle);
  position: relative;
}

/* Time labels get their own row above the range buttons (they used to
   be painted underneath the buttons and collided with them). */
.ot-chart-timeaxis > canvas {
  bottom: auto !important;
  height: var(--ot-timeaxis-label-h) !important;
}

.ot-pane-canvas-stack {
  position: absolute;
  inset: 0;
}

.ot-pane-canvas-stack canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
