/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */

.search-container {
  position: absolute;
  top: var(--editor-header-height);
  left: 0;
  width: calc(100% - 1px);
  height: calc(100% - var(--editor-header-height));
  display: flex;
  flex-direction: column;
  z-index: 20;
  overflow-y: hidden;

  /* Using the same colors as the Netmonitor's --table-selection-background-hover */
  --search-result-background-hover: rgba(209, 232, 255, 0.8);
}

.theme-dark .search-container {
  --search-result-background-hover: rgba(53, 59, 72, 1);
}

.project-text-search {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow-y: hidden;
  height: 100%;
}

.project-text-search .result {
  display: contents;
  cursor: default;
  line-height: 16px;
  font-size: 11px;
  font-family: var(--monospace-font-family);
}

.project-text-search .result:hover > * {
  background-color: var(--search-result-background-hover);
}

.project-text-search .result .line-number {
  grid-column: 1;
  padding-block: 1px;
  padding-inline-start: 4px;
  padding-inline-end: 6px;
  text-align: end;
  color: var(--theme-text-color-alt);
}

.unavailable-source {
  white-space: pre;

  .tooltip-panel {
    padding: 1em;
  }
}

.project-text-search .result .line-value {
  grid-column: 2;
  padding-block: 1px;
  padding-inline-end: 4px;
  text-overflow: ellipsis;
  overflow-x: hidden;
  outline-offset: -2px;
}

.project-text-search .result .query-match {
  border-bottom: 1px solid var(--theme-search-results-border-color);
  color: var(--theme-search-results-color);
  background-color: var(--theme-search-results-background);
}

.project-text-search .tree-indent {
  display: none;
}

.project-search-results-toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  background-color: var(--theme-toolbar-alternate-background);
  border-bottom: 1px solid var(--theme-splitter-color);
  padding: 2px 8px;
  align-items: center;
  gap: 4px;
}

.project-text-search .refresh-btn {
  background-color: transparent;
  padding: 2px;
  display: grid;
  --size: 16px;
  --highlight-size: 5px;
  --remain-size: calc(var(--size) - var(--highlight-size));
  width: var(--size);
  aspect-ratio: 1;
  box-sizing: content-box;
  grid-template-rows: var(--highlight-size) var(--remain-size);
  grid-template-columns: var(--remain-size) var(--highlight-size);

  &.devtools-button:focus-visible {
    outline: var(--theme-focus-outline);
  }

  &.highlight::after {
    content: "";
    display: block;
    grid-row: 1 / 2;
    grid-column: 2 / 3;
    height: 5px;
    width: 5px;
    background-color: var(--blue-40);
    border-radius: 100%;
    outline: 1px solid var(--theme-sidebar-background);
    z-index: 1;
  }

  .img {
    grid-row: 1 / -1;
    grid-column: 1 / -1;
    transition: rotate 0.2s;
    width: 14px;
    height: 14px;

    .highlight & {
      rotate: 0.75turn;
    }
  }
}

.project-text-search .no-result-msg {
  color: var(--theme-text-color-inactive);
  font-size: 24px;
  padding: 15px;
  max-width: 100%;
  align-self: center;
}

.project-text-search .file-result {
  grid-column: 1/3;
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 24px;
  padding: 2px 4px;
  font-weight: bold;
  font-size: 12px;
  line-height: 16px;
  cursor: default;
}

.project-text-search .file-result .img {
  margin-inline: 2px;
}

.project-text-search .file-result .img.file {
  margin-inline-end: 4px;
}

.project-text-search .file-path {
  flex: 0 1 auto;
  padding-inline-end: 4px;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-text-search .file-path:empty {
  display: none;
}

.project-text-search .search-field {
  display: flex;
  align-self: stretch;
  flex-grow: 1;
  width: 100%;
  border-bottom: none;
}

.project-text-search .tree {
  overflow-x: hidden;
  overflow-y: auto;
  height: 100%;
  display: grid;
  min-width: 100%;
  white-space: nowrap;
  user-select: none;
  align-content: start;
  /* Align the second column to the search input's text value */
  grid-template-columns: minmax(40px, auto) 1fr;
  padding-top: 4px;
}

/* Fake padding-bottom using a pseudo-element because Gecko doesn't render the
   padding-bottom in a scroll container */
.project-text-search .tree::after {
  content: "";
  display: block;
  height: 4px;
}

.project-text-search .tree .tree-node {
  display: contents;
}

/* Focus values */

.project-text-search .file-result.focused,
.project-text-search .result.focused .line-value,
.project-text-search .result.focused .line-number {
  color: var(--theme-selection-color);
  background-color: var(--theme-selection-background);
}

.project-text-search .file-result.focused .img {
  background-color: currentColor;
}
