/********************************************************************************
 * Copyright (C) 2026 Safi Seid-Ahmad, K2view and others.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v. 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0.
 *
 * This Source Code may also be made available under the following Secondary
 * Licenses when the conditions for such availability set forth in the Eclipse
 * Public License v. 2.0 are satisfied: GNU General Public License, version 2
 * with the GNU Classpath Exception which is available at
 * https://www.gnu.org/software/classpath/license.html.
 *
 * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
 ********************************************************************************/

/* The widget sits as a zero-height flex item right before the chat tree; the bar overlays the tree's top-right corner. */
.theia-chat-find-widget {
  position: relative;
  flex: 0 0 0;
  height: 0;
  overflow: visible;
  z-index: 10;
}

/* Input, toggles and buttons use the core `theia-input` and `action-label` styles; this only lays them out. */
.theia-chat-find-bar {
  position: absolute;
  top: 4px;
  right: 20px;
  max-width: calc(100% - 28px);
  box-sizing: border-box;
  display: flex;
  /* In a narrow view, the count and buttons wrap below the input rather than squeezing it. */
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 2px;
  padding: 2px 4px;
  background: var(--theia-editorWidget-background);
  color: var(--theia-editorWidget-foreground);
  border: var(--theia-border-width) solid var(--theia-widget-border);
  border-radius: 4px;
  box-shadow: 0 0 8px 2px var(--theia-widget-shadow);
}

.theia-chat-find-input-box {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  align-items: center;
  background: var(--theia-input-background);
  border: var(--theia-border-width) solid var(--theia-input-border, var(--theia-input-background));
  border-radius: 2px;
}

.theia-chat-find-input-box:focus-within {
  border-color: var(--theia-focusBorder);
}

.theia-chat-find-input-box.no-results {
  border-color: var(--theia-inputValidation-errorBorder);
}

.theia-chat-find-input-box .theia-input {
  width: 140px;
  min-width: 0;
  flex: 1 1 auto;
  min-height: unset;
  padding: 1px 4px;
  border: none;
  outline: none;
}

.theia-chat-find-option {
  flex: none;
  border: var(--theia-border-width) solid transparent;
  background: none;
  color: inherit;
}

.theia-chat-find-option.enabled {
  color: var(--theia-inputOption-activeForeground);
  border-color: var(--theia-inputOption-activeBorder);
  background-color: var(--theia-inputOption-activeBackground);
}

.theia-chat-find-count {
  /* Wide enough for 'No results' and most counts, so the bar does not change width while typing. */
  min-width: 64px;
  margin: 0 4px;
  text-align: center;
  white-space: nowrap;
  font-size: var(--theia-ui-font-size0);
}

.theia-chat-find-count.no-results {
  color: var(--theia-errorForeground);
}

::highlight(theia-chat-find-match) {
  background-color: var(--theia-editor-findMatchHighlightBackground);
}

::highlight(theia-chat-find-current) {
  background-color: var(--theia-editor-findMatchBackground);
}
