/* The Terminal's header as a slim bar on the LEFT -- 2026-09-30.
 *
 * Asked for: the header's contents (Fund Intelligence, the apps button, READY,
 * BACKEND UP, language, Logout) in one vertical place on the left, Logout at
 * the bottom, next to the Assistant's own controls rail. The Terminal's source
 * is not in this repository (only its built bundle), so this RESTYLES the same
 * header element -- nothing is moved or re-created, every control keeps its
 * own behaviour, and deleting this file's <link> restores the top bar.
 *
 * Phones keep the top bar: a vertical bar would take too much of a small screen.
 */
@media (min-width: 761px) {
  :root { --purifi-left-rail: 78px; }

  .terminalRoot { padding-left: var(--purifi-left-rail); box-sizing: border-box; }

  .terminalRoot > header.topBar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: var(--purifi-left-rail);
    box-sizing: border-box;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    gap: 10px;
    padding: 12px 6px;
    border-bottom: none;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    overflow-x: visible;
    scrollbar-width: none;
  }
  .terminalRoot > header.topBar::-webkit-scrollbar { display: none; }

  /* The build line was already hidden in practice; keep the bar quiet. */
  .terminalRoot > header.topBar > .brand { display: none; }

  /* "Fund Intelligence" / "Portfolio Intelligence" label: hidden in the bar
     (2026-09-30, asked for). Still shown in the phone top bar. */
  /* !important: the element carries an inline display:flex, which beats a normal rule. */
  .terminalRoot > header.topBar > div:not(.status) { display: none !important; }

  /* Everything else stacks; Logout (the last control) sits at the bottom. */
  .terminalRoot > header.topBar > .status {
    flex: 1 1 auto;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    min-height: 0;
  }
  .terminalRoot > header.topBar > .status > * {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin-right: 0 !important;
    text-align: center;
    justify-content: center;
  }
  .terminalRoot > header.topBar > .status .pill {
    font-size: 10px;
    padding: 4px 2px;
    white-space: normal;
    line-height: 1.2;
  }
  .terminalRoot > header.topBar > .status button,
  .terminalRoot > header.topBar > .status select {
    font-size: 11px;
    padding: 5px 2px;
    white-space: normal;
    line-height: 1.2;
  }
  .terminalRoot > header.topBar > .status > :last-child { margin-top: auto; }

  /* Language: globe on top, the language's name underneath, readable at the
     bar's width. Its inline min-width of 100px is what pushed it off the edge
     ("🌐 Englis…"); the ▼ is dropped -- the whole button opens the menu. */
  .terminalRoot > header.topBar .langSelector { display: block !important; width: 100%; }
  .terminalRoot > header.topBar .langToggle {
    width: 100% !important;
    min-width: 0 !important;
    flex-direction: column !important;
    justify-content: center !important;
    gap: 2px !important;
    padding: 6px 2px !important;
    font-size: 12px !important;
    font-weight: 600;
    line-height: 1.15;
  }
  .terminalRoot > header.topBar .langToggle > span:first-child { font-size: 18px !important; }
  .terminalRoot > header.topBar .langToggle > span:nth-child(2) {
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: center;
  }
  .terminalRoot > header.topBar .langToggle > span:last-child { display: none; }

  /* The ASI-Evolve button (round, brain icon): in the bar, just above Logout;
     its panel opens beside the bar. Its position is an inline style, hence
     !important. */
  .asiEvolveOverlayMinimized {
    left: calc((var(--purifi-left-rail) - 48px) / 2) !important;
    right: auto !important;
    bottom: 58px !important;
  }
  .asiEvolveOverlay {
    left: calc(var(--purifi-left-rail) + 10px) !important;
    right: auto !important;
    bottom: 16px !important;
  }
  /* Keep Logout clear of the button above it. */
  .terminalRoot > header.topBar { padding-bottom: 12px; }
}

/* 2026-09-30: phones. The top bar was wider than the screen -- language and
 * Logout were off the right edge with no way to reach them -- and took ~15% of
 * the height for the build line. Now one compact row that always fits (and
 * scrolls sideways on a very narrow phone rather than hiding anything). */
@media (max-width: 760px) {
  .terminalRoot > header.topBar {
    flex-wrap: nowrap;
    gap: 6px;
    padding: 6px 8px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .terminalRoot > header.topBar::-webkit-scrollbar { display: none; }
  .terminalRoot > header.topBar > .brand,
  .terminalRoot > header.topBar > div:not(.status) { display: none !important; }
  .terminalRoot > header.topBar > .status {
    flex: 1 1 auto;
    flex-wrap: nowrap;
    gap: 6px;
    min-width: 0;
  }
  .terminalRoot > header.topBar > .status .pill { font-size: 10px; padding: 3px 7px; white-space: nowrap; }
  .terminalRoot > header.topBar > .status button { font-size: 12px; padding: 4px 8px; white-space: nowrap; margin-right: 0 !important; }
  /* Language: the globe only; the list still opens on tap. */
  .terminalRoot > header.topBar .langToggle { min-width: 0 !important; padding: 4px 8px !important; gap: 0 !important; }
  .terminalRoot > header.topBar .langToggle > span:nth-child(2),
  .terminalRoot > header.topBar .langToggle > span:last-child { display: none; }
  /* Logout at the far right. */
  .terminalRoot > header.topBar > .status > :last-child { margin-left: auto; }

  /* Less chrome around the tab content, so the Assistant gets the width. */
  .terminalRoot > .grid { padding: 0 !important; gap: 0 !important; }
  .terminalRoot > .grid .panel { padding: 2px !important; border-radius: 0 !important; border-left: none !important; border-right: none !important; }

  /* Command bar: the input takes the width; the "PURIFI>" label and the voice
     picker (cut off at the right) are dropped; mic and voice toggle stay. */
  .terminalRoot footer.cmdBar { gap: 6px; padding: 6px 8px; }
  .terminalRoot footer.cmdBar > .prompt,
  .terminalRoot footer.cmdBar > select { display: none; }
  .terminalRoot footer.cmdBar > .cmdInput { min-width: 0; font-size: 16px; padding: 8px 10px; }
  .terminalRoot footer.cmdBar > button { flex: 0 0 auto; padding: 6px 8px; }

  /* iOS zooms in on any input under 16px; that made the page jump on tap. */
  .terminalRoot input,
  .terminalRoot textarea,
  .terminalRoot select { font-size: 16px; }

  /* The ASI-Evolve button: in the top bar, centred between the globe and
     Logout -- send-to-assistant.js measures the gap and sets these two
     variables (fallback until it runs: top right, clear of everything). Its
     panel opens as a sheet under the bar. */
  .asiEvolveOverlayMinimized {
    width: 34px !important;
    height: 34px !important;
    left: var(--asi-phone-left, calc(100% - 44px)) !important;
    top: var(--asi-phone-top, 8px) !important;
    right: auto !important;
    bottom: auto !important;
  }
  .asiEvolveOverlay {
    left: 8px !important;
    right: 8px !important;
    width: auto !important;
    top: calc(var(--asi-phone-top, 8px) + 44px) !important;
    bottom: auto !important;
    max-height: 70vh;
    overflow-y: auto;
  }
}
