/*!
 * CoreUI Docs (https://coreui.io/bootstrap/docs/)
 * Copyright 2025 creativeLabs Łukasz Holeczek
 * Licensed under the Creative Commons Attribution 3.0 Unported License.
 * For details, see https://creativecommons.org/licenses/by/3.0/.
 */

@use "../../../scss/mixins/border-radius" as *;
@use "../../../scss/mixins/box-shadow" as *;
@use "../../../scss/mixins/breakpoints" as *;
@use "../../../scss/mixins/color-mode" as *;
@use "../../../scss/mixins/transition" as *;
@use "../../../scss/vendor/rfs" as *;
@use "../../../scss/variables" as *;

@forward "@docsearch/css/dist/style";


// stylelint-disable selector-class-pattern
:root {
  --docsearch-primary-color: var(--cui-primary);
  --docsearch-muted-color: var(--cui-secondary-color);
  --docsearch-logo-color: var(--cui-primary);
  --docsearch-key-color: var(--cui-secondary-color);
}

@include color-mode(dark, true) {
  // From here, the values are copied from https://cdn.jsdelivr.net/npm/@docsearch/css@3
  // in html[data-theme="dark"] selector
  // and are slightly modified for formatting purpose
  --docsearch-text-color: #f5f6f7;
  --docsearch-container-background: rgba(9, 10, 17, .8);
  --docsearch-modal-background: #15172a;
  --docsearch-modal-shadow: inset 1px 1px 0 0 #2c2e40, 0 3px 8px 0 #000309;
  --docsearch-searchbox-background: #090a11;
  --docsearch-searchbox-focus-background: #000;
  --docsearch-hit-color: #bec3c9;
  --docsearch-hit-shadow: none;
  --docsearch-hit-background: #090a11;
  --docsearch-key-gradient: linear-gradient(-26.5deg, #565872, #31355b);
  --docsearch-key-shadow: inset 0 -2px 0 0 #282d55, inset 0 0 1px 1px #51577d, 0 2px 2px 0 rgba(3, 4, 9, .3);
  --docsearch-footer-background: #1e2136;
  --docsearch-footer-shadow: inset 0 1px 0 0 rgba(73, 76, 106, .5), 0 -4px 8px 0 rgba(0, 0, 0, .2);
  --docsearch-muted-color: #7f8497;
}

.DocSearch-Container {
  --docsearch-hit-shadow: none;

  position: fixed;
  z-index: 2000; // Make sure to be over all components showcased in the documentation
  cursor: auto; // Needed because of [role="button"] in Algolia search modal. Remove once https://github.com/algolia/docsearch/issues/1370 is tackled.

  @include media-breakpoint-up(lg) {
    padding-top: 4rem;
  }
}

.DocSearch-Button {
  --docsearch-searchbox-background: #{rgba($black, .1)};
  --docsearch-searchbox-focus-background: #{rgba($black, .25)};

  margin: 0;
  font-family: $input-font-family;
  font-weight: $input-font-weight;
  line-height: $input-line-height;
  @include font-size($input-font-size);
  color: $input-color;
  background-color: $input-bg;
  background-clip: padding-box;
  border: $input-border-width solid $input-border-color;

  // Note: This has no effect on <select>s in some browsers, due to the limited stylability of `<select>`s in CSS.
  @include border-radius($btn-border-radius);
  @include box-shadow($input-box-shadow);
  @include transition($input-transition);

  &:focus,
  &:hover {
    color: $input-focus-color;
    background-color: $input-focus-bg;
    border-color: $input-focus-border-color;
    outline: 0;
    @if $enable-shadows {
      @include box-shadow($input-box-shadow, $input-focus-box-shadow);
    } @else {
      // Avoid using mixin so we can pass custom focus shadow properly
      box-shadow: $input-focus-box-shadow;
    }
  }

  @include media-breakpoint-down(md) {
    &,
    &:hover,
    &:focus {
      background: transparent;
      border: 0;
      box-shadow: none;
    }
  }

  .DocSearch-Search-Icon {
    opacity: .65;
  }
}

.DocSearch-Button-Keys {
  min-width: 0;
  padding: 0 .25rem;
  background: var(--cui-secondary-bg);
  @include border-radius(.25rem);
}

.DocSearch-Button-Key {
  width: auto;
  padding: 0;
  background: none;
  border: 0;
  box-shadow: none;

  &:first-child {
    margin-right: 0;
  }
}

// .DocSearch-Commands-Key {
//   padding-left: 1px;
//   font-size: .875rem;
//   background-color: rgba($black, .1);
//   background-image: none;
//   box-shadow: none;
// }

.DocSearch-Hits {
  mark {
    padding: 0;
  }
}

.DocSearch-Hit {
  padding-bottom: 0;
  @include border-radius(0);

  a {
    @include border-radius(0);
    border: solid var(--cui-border-color);
    border-width: 0 1px 1px;
  }

  &:first-child a {
    @include border-top-radius(var(--cui-border-radius));
    border-top-width: 1px;
  }
  &:last-child a {
    @include border-bottom-radius(var(--cui-border-radius));
  }
}

.DocSearch-Hit-icon {
  display: flex;
  align-items: center;
}

// Fix --docsearch-logo-color that doesn't do anything
.DocSearch-Logo svg .cls-1,
.DocSearch-Logo svg .cls-2 {
  fill: var(--docsearch-logo-color);
}
