/*
 * Native panel fitting pass.
 *
 * Evidence: ops/ia-review-20261129/audit/inventory.md and the cached
 * ScreenerWindow / OakScript Editor assets. Runtime filtering, persistence,
 * Monaco loading and cross-window symbol handoff are still pending runtime QA.
 *
 * Scope intentionally stays on existing component classes. No controls are
 * hidden and no new interaction is implied. The build owner must add this file
 * and confirm it inside the real dock, window and resized-panel variants.
 */

/* -------------------------------------------------------------------------- */
/* Native screener: ?view=screener and its docked / floating / overlay hosts. */
/* -------------------------------------------------------------------------- */

.screener-window,
.screener-window .scr-split,
.screener-window .scr-panel {
  min-width: 0;
}

.screener-window .scr-body,
.screener-window .scr-head,
.screener-window .scr-head-row,
.screener-window .scr-topbar-actions,
.screener-window .scr-topbar-controls {
  min-width: 0;
}

/* Keep the screen title before the controls in priority; only the label may
   truncate. The action cluster remains available and can use the next line. */
.screener-window .scr-topbar {
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
}

.screener-window .scr-topbar-actions {
  flex: 1 1 180px;
  overflow: hidden;
}

.screener-window .scr-screen-name {
  min-width: 0;
  max-width: 100%;
}

.screener-window .scr-screen-title {
  min-width: 0;
}

.screener-window .scr-topbar-controls {
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-inline-start: auto;
}

.screener-window .scr-panel-header {
  min-width: 0;
}

.screener-window .scr-panel-title-block {
  flex: 1 1 auto;
  overflow: hidden;
}

.screener-window .scr-panel-title {
  min-width: 0;
  max-width: 100%;
}

.screener-window .scr-panel-buttons {
  flex: 0 0 auto;
}

.screener-window .scr-pills {
  min-width: 0;
}

.screener-window .scr-pills-watchlist {
  min-width: 0;
  flex-wrap: wrap;
}

.screener-window .scr-head-row.is-row {
  align-items: flex-start;
  flex-wrap: wrap;
}

.screener-window .scr-head-row.is-row .scr-control-panel {
  flex: 1 1 240px;
  flex-wrap: wrap;
  align-items: center;
}

.screener-window .scr-head-row.is-row .scr-header-controls {
  margin-inline-start: auto;
}

.screener-window .scr-head-row.is-stacked .scr-control-panel {
  flex-wrap: wrap;
  align-items: center;
}

.screener-window .scr-head-row.is-stacked .scr-header-controls {
  margin-inline-start: auto;
}

.screener-window .scr-table-scroll {
  overscroll-behavior: contain;
}

.screener-window .scr-table-scroll,
.screener-window .scr-charts,
.screener-window .scr-heatmap {
  min-width: 0;
}

.screener-window .scr-empty {
  max-width: calc(100% - 24px);
  margin-inline: auto;
  overflow-wrap: anywhere;
}

/* Reuse the application's real narrow / tight chassis state. This tightens
   spacing before it removes any control. Existing icon-only rules stay active. */
.screener-window .scr-panel.is-narrow .scr-panel-header,
.screener-window .scr-panel.is-tight .scr-panel-header {
  padding-inline: 12px;
}

.screener-window .scr-panel.is-narrow .scr-topbar,
.screener-window .scr-panel.is-tight .scr-topbar {
  padding-inline: 12px;
}

.screener-window .scr-panel.is-narrow .scr-pills,
.screener-window .scr-panel.is-tight .scr-pills {
  padding-inline: 12px;
}

.screener-window .scr-panel.is-narrow .scr-control-panel,
.screener-window .scr-panel.is-tight .scr-control-panel {
  padding-inline: 12px;
}

.screener-window .scr-panel.is-narrow .scr-table-scroll,
.screener-window .scr-panel.is-tight .scr-table-scroll {
  margin-inline-start: 12px;
}

.screener-window .scr-panel.is-narrow .scr-charts,
.screener-window .scr-panel.is-tight .scr-charts,
.screener-window .scr-panel.is-narrow .scr-heatmap,
.screener-window .scr-panel.is-tight .scr-heatmap {
  margin-inline: 12px;
}

.screener-window .scr-panel.is-narrow .scr-header-controls,
.screener-window .scr-panel.is-tight .scr-header-controls {
  gap: 4px;
}

/* Keep existing disclosure and action controls together while the component
   owns the row/stacked decision. */
.screener-window .scr-panel.is-narrow .scr-head-row.is-row .scr-control-panel,
.screener-window .scr-panel.is-tight .scr-head-row.is-row .scr-control-panel {
  gap: 2px;
}

.screener-window .scr-panel.is-narrow .scr-head-row.is-row .scr-control-divider,
.screener-window .scr-panel.is-tight .scr-head-row.is-row .scr-control-divider {
  margin-inline: 4px;
}

.screener-window .scr-panel.is-narrow .scr-head-row.is-stacked .scr-filters-btn-wrap,
.screener-window .scr-panel.is-tight .scr-head-row.is-stacked .scr-filters-btn-wrap {
  margin-inline-start: 12px;
  margin-inline-end: 12px;
}

/* -------------------------------------------------------------------------- */
/* OakScript Editor: docked, resized and maximized instances.                  */
/* -------------------------------------------------------------------------- */

.oak-panel__header-left {
  flex: 1 1 auto;
  overflow: hidden;
}

.oak-panel__header-right {
  flex: 0 0 auto;
  margin-inline-start: 8px;
}

.oak-panel__name-btn {
  flex: 1 1 auto;
  overflow: hidden;
}

.oak-panel__name-btn > :first-child,
.oak-panel__logo {
  flex: 0 0 auto;
}

.oak-panel__title {
  flex: 1 1 auto;
  min-width: 0;
}

.oak-panel__action-btn,
.oak-panel__chrome-btn {
  flex: 0 0 auto;
}

.oak-panel__readonly {
  align-items: flex-start;
  gap: 0;
}

.oak-panel__readonly > :last-child {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

.oak-panel__readonly-icon {
  margin-block-start: 1px;
}

.oak-panel__readonly-header,
.oak-panel__readonly-link {
  white-space: nowrap;
}

.oak-panel__body {
  min-width: 0;
}

.oak-editor-host {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 80px;
  overflow: hidden;
}

/* The host uses an inline pixel height, so the only safe way to protect the
   editor in a short panel is to let the console shrink while keeping it
   present and scrollable. */
.oak-console {
  flex: 0 1 160px;
  min-height: 64px;
}

.oak-panel__status {
  min-width: 0;
  gap: 12px;
}

.oak-panel__status-left {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.oak-panel__status-right {
  flex: 0 0 auto;
  min-width: max-content;
}

.oak-panel__status-left .oak-panel__status-item {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.oak-panel__status-right .oak-panel__status-item {
  flex: 0 0 auto;
}

.oak-panel__status :where(.oak-panel__status-left, .oak-panel__status-right) {
  gap: 12px;
}

/* Narrow inline sizes come from the actual panel container, not the page.
   Keep this CSS feature query so the fallback above remains usable in older
   WebViews and in a host that cannot establish a named query container. */
@supports (container-type: inline-size) {
  .oak-panel {
    container-name: oak-editor;
    container-type: inline-size;
  }

  @container oak-editor (max-width: 520px) {
    .oak-panel__header {
      padding-inline: 8px 4px;
    }

    .oak-panel__header-right {
      gap: 0;
      margin-inline-start: 4px;
    }

    .oak-panel__action-btn {
      margin-inline-end: 2px;
      padding-inline: 7px;
    }

    .oak-panel__readonly {
      padding: 8px 10px;
      font-size: 13px;
      line-height: 18px;
    }

    .oak-panel__readonly-icon {
      margin-inline-end: 6px;
    }

    .oak-panel__status {
      gap: 6px;
      padding-inline: 6px;
    }

    .oak-panel__status :where(.oak-panel__status-left, .oak-panel__status-right) {
      gap: 6px;
    }
  }

  @container oak-editor (max-width: 360px) {
    .oak-panel__chrome-btn {
      width: 22px;
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .oak-panel *,
  .screener-window * {
    scroll-behavior: auto;
  }
}
