/* Multi-chart layout, in place on the chart page (see layout.js). */

/* With a layout on, the page's own chart and its overlays give way to the grid; the side panels (Indicator, Candles, Alerts) still float above it. */
#chartArea.multi > #chartContainer, #chartArea.multi > #overlayCanvas, #chartArea.multi > #scriptTables, #chartArea.multi > #indicatorLegend,
#chartArea.multi > #scrollLatestBtn, #chartArea.multi > #statusBar, #chartArea.multi > #replayBar { display: none !important; }

.lh { position: absolute; inset: 0; z-index: 4; display: grid; gap: 5px; background: var(--border-strong); }
.lh.hidden { display: none; }
/* The page's own chart is hidden behind the grid, but its overlays sit above it (z-index 5-6): hide them while a layout is on, so each cell's legend and OHLC show once. */
#layoutHost:not(.hidden) ~ :is(#overlayCanvas, #scriptTables, .chart-tl, #statusBar, #scrollLatestBtn) { display: none; }
.lh-cell { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: var(--surface-0); }
.lh-frame { display: block; width: 100%; height: 100%; border: 0; }
/* the active chart (the one the toolbar drives): an outline drawn over its edge */
.lh-cell::after { content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none; border: 2px solid transparent; transition: border-color .12s; }
.lh-cell.active::after { border-color: var(--accent); }
.lh.has-max { grid-template-areas: "x" !important; grid-template-columns: minmax(0, 1fr) !important; grid-template-rows: minmax(0, 1fr) !important; }
.lh.has-max .lh-cell { display: none; }
.lh.has-max .lh-cell.max { display: block; grid-area: x !important; }
.lh.dragging .lh-frame { pointer-events: none; } /* a frame under the pointer would swallow the drag */
.lh.dragging { cursor: grabbing; user-select: none; }

.lh-max {
  position: absolute; top: 6px; right: 62px; z-index: 3; width: 24px; height: 24px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-2); cursor: pointer; color: var(--text-2); background: var(--surface-1); border: 1px solid var(--border-strong);
  opacity: 0; transition: opacity .12s, color .12s;
}
.lh-cell:hover .lh-max { opacity: 1; }
.lh-max:hover { color: var(--text); }

/* draggable splitters, laid over the gaps between charts */
.lh-gutter { position: absolute; z-index: 5; background: transparent; touch-action: none; }
.lh-gutter.v { cursor: col-resize; }
.lh-gutter.h { cursor: row-resize; }
.lh-gutter::after { content: ""; position: absolute; border-radius: 2px; background: var(--accent); opacity: 0; transition: opacity .12s; }
.lh-gutter.v::after { left: 3px; right: 3px; top: 0; bottom: 0; }
.lh-gutter.h::after { top: 3px; bottom: 3px; left: 0; right: 0; }
.lh-gutter:hover::after, .lh-gutter.on::after { opacity: .85; }

/* toolbar button + dropdown */
.lm-wrap { position: relative; display: inline-flex; }
#layoutBtn.active { color: var(--text); background: var(--surface-3); border-color: var(--border-strong); }
.lm {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; width: 262px; padding: 12px; border-radius: var(--r-3);
  background: var(--surface-1); border: 1px solid var(--border-strong); box-shadow: var(--shadow-float);
}
.lm.hidden { display: none; }
.lm-title { font-size: var(--fs-1); font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--text-2); margin: 2px 2px 8px; }
.lm-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-bottom: 14px; }
.lm-layout {
  height: 38px; padding: 6px; border-radius: var(--r-2); cursor: pointer; background: var(--surface-0); border: 1px solid var(--border-strong);
  transition: border-color .12s, background .12s;
}
.lm-layout:hover { border-color: var(--border-strong); background: var(--surface-2); }
.lm-layout.active { background: var(--surface-0); border-color: var(--accent); box-shadow: var(--focus-ring); } /* background: the generic button.active fill (style.css) would paint the whole tile purple */
.lm-thumb { display: grid; gap: 3px; width: 100%; height: 100%; }
.lm-thumb i { display: block; border-radius: 2px; background: var(--text-2); opacity: .55; }
.lm-layout.active .lm-thumb i { background: var(--accent); opacity: .95; }
.lm-sync { display: flex; flex-direction: column; margin-bottom: 12px; }
.lm-row { display: flex; align-items: center; justify-content: space-between; padding: 7px 6px; border-radius: var(--r-2); font-size: var(--fs-2); color: var(--text); cursor: pointer; }
.lm-row:hover { background: var(--surface-3); }
.lm-row input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
.lm-reset {
  width: 100%; padding: 7px 10px; border-radius: var(--r-2); font-size: var(--fs-2); font-weight: 600; cursor: pointer; color: var(--text-2);
  background: transparent; border: 1px solid var(--border-strong);
}
.lm-reset:hover { color: var(--text); border-color: var(--border-strong); }
/* narrow: the toolbar scrolls sideways, which would clip this dropdown, so it is fixed under the header (full width on a phone) */
@media (max-width: 1260px) { .lm { position: fixed; top: var(--topbar-bottom, 52px); } } /* under the header, however many rows it has */
@media (max-width: 760px) { .lm { left: 8px; right: 8px; width: auto; } }
