@import "ui-variables";
@import "syntax-variables";

.option-button() {
  font-size: 14px;
  font-family: courier, monospace;
}

// result markers
atom-text-editor,
atom-text-editor::shadow {
  .find-result .region {
    background-color: transparent;
    border-radius: @component-border-radius;
    border: 1px solid @syntax-result-marker-color;
    box-sizing: border-box;
  }

  .current-result .region {
    border-radius: @component-border-radius;
    border: 1px solid @syntax-result-marker-color-selected;
    box-sizing: border-box;
  }

  .find-result,
  .current-result {
    display: none;
  }
}

atom-workspace.find-visible {
  atom-text-editor,
  atom-text-editor::shadow {
    .find-result,
    .current-result {
      display: block;
    }
  }
}

// Both project and buffer FNR styles
.find-and-replace,
.project-find {
  @min-width: 200px; // min width before it starts scrolling

  -webkit-user-select: none;
  padding: @component-padding/2;
  overflow-x: scroll;

  .header {
    padding: @component-padding/4 @component-padding/2;
    min-width: @min-width;
  }
  .header-item {
    margin: @component-padding/4 0;
  }

  .input-block {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    min-width: @min-width;
  }
  .input-block-item {
    display: flex;
    flex: 1;
    padding: @component-padding / 2;
  }

  .btn-group {
    display: flex;
    flex: 1;
    .btn {
      flex: 1;
    }
    & + .btn-group {
      margin-left: @component-padding;
    }
  }

  .description {
    display: inline-block;
    .subtle-info-message {
      padding-left: 5px;
      color: @text-color-subtle;
      .highlight {
        color: @text-color;
        font-weight: normal;
      }
    }
  }

  .options-label {
    color: @text-color-subtle;
    position: relative;
    .options {
      color: @text-color;
    }
  }

  .editor-container {
    position: relative;
    atom-text-editor {
      width: 100%;
    }
  }

}

// Buffer find and replace
.find-and-replace {
  @button-width: 120px;        // Find + Replace buttons
  @option-button-width: 200px; // Replace All + option buttons
  @item-width: 260px;          // wrap block width

  .input-block-item {
    flex: 1 1 @item-width;
  }
  .input-block-item--flex {
    flex: 100 1 @item-width;
  }

  .btn-group-find,
  .btn-group-replace {
    flex: 1 1 @button-width;
  }
  .btn-group-replace-all,
  .btn-group-options {
    flex: 1 1 @option-button-width;
  }

  .btn-group-options {
    .btn {
      .option-button();
      flex: 1 1 25%;
      padding: 0;
      text-align: center;
      &.option-selection {
        font-family: "Times New Roman";
        font-size: 20px;
        padding-top: 3px;
      }
      &.option-whole-word {
        font-size: 13px;
      }
    }
  }

  .find-container atom-text-editor {
    padding-right: 64px; // leave some room for the results count
  }

  // results count
  .find-meta-container {
    position: absolute;
    top: 1px;
    right: 0;
    margin: @component-padding/2 @component-padding/2 0 0;
    z-index: 2;
    font-size: .9em;
    line-height: @component-line-height;
    pointer-events: none;
    .result-counter {
      margin-right: @component-padding;
    }
  }
}

// Project find and replace
.project-find {
  @project-input-width: 260px;
  @project-button-width: 100px;

  .input-block-item {
    flex: 1 1 @project-button-width;
  }
  .input-block-item--flex {
    flex: 100 1 @project-input-width;
  }

  .loading,
  .preview-block,
  .error-messages,
  .filter-container {
    display: none;
  }

  .btn-group-options {
    width: @project-button-width;
    .btn {
      .option-button();
    }
  }

  .btn-group-replace-all {
    width: @project-button-width;
  }
}

.preview-pane {
  position: relative;
  display: -webkit-flex;
  -webkit-flex-direction: column;

  .panel-heading {
    -webkit-flex-shrink: 0;
  }

  .no-results-overlay {
    visibility: hidden;
  }

  &.no-results .no-results-overlay {
    visibility: visible;
  }

  .results-view {
    overflow: auto;
    position: relative;
    padding: 0 @component-padding;
    -webkit-flex: 1;

    .search-result {
      padding-top: 2px;
      padding-bottom: 2px;
    }

    .line-number {
      margin-right: 1ex;
      text-align: right;
      display: inline-block;
    }
    .selected .line-number {
      color: @text-color-selected;
    }

    .path-match-number {
      padding-left: @component-padding;
      color: @text-color-subtle;
    }

    .preview {
      word-break: break-all;
      font-family: monospace;
    }

    .selected {
      .highlight-info {
        box-shadow: inset 0 0 1px lighten(@background-color-info, 50%);
      }

      .highlight-error {
        box-shadow: inset 0 0 1px lighten(@background-color-error, 25%);
      }

      .highlight-success {
        box-shadow: inset 0 0 1px lighten(@background-color-success, 25%);
      }
    }
  }
}
