/* Copyright 2026 The Chromium Authors
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file. */

/* #css_wrapper_metadata_start
 * #type=style-lit
 * #import=//resources/cr_elements/cr_icons_lit.css.js
 * #scheme=relative
 * #include=cr-icons-lit
 * #css_wrapper_metadata_end */

:host {
  /* Embedders should define --cr-searchbox-min-width. */
  --cr-searchbox-border-radius: calc(0.5 * var(--cr-searchbox-height));
  --cr-searchbox-icon-spacing: 11px;
  --cr-searchbox-icon-width: 26px;
  --cr-searchbox-inner-icon-margin: 8px;
  --cr-searchbox-shadow: 0 4px 8px 3px rgba(0, 0, 0, 0.15),
      0 1px 3px 0 rgba(0, 0, 0, 0.30);
  --cr-searchbox-voice-icon-offset: 16px;
  --cr-searchbox-voice-search-button-width: 0px;
  --cr-searchbox-width: var(--cr-searchbox-min-width);
  border-radius: var(--cr-searchbox-border-radius);
  font-size: var(--cr-searchbox-font-size, 16px);
  height: var(--cr-searchbox-height);
  width: var(--cr-searchbox-width);
  z-index: 99;
}

:host([searchbox-chrome-refresh-theming][dropdown-is-visible]) {
  --cr-searchbox-shadow: 0 0 12px 4px var(--color-searchbox-shadow);
}

:host([searchbox-chrome-refresh-theming]:not([searchbox-steady-state-shadow]):not([dropdown-is-visible])) {
  --cr-searchbox-shadow: none;
}

:host([searchbox-voice-search-enabled_]) {
  --cr-searchbox-voice-search-button-width: var(--cr-searchbox-icon-width);
}

:host([searchbox-lens-search-enabled_]) {
  --cr-searchbox-voice-icon-offset: 53px;
}

@media (forced-colors: active) {
  :host {
    border: 1px solid ActiveBorder;
  }
}

#inputWrapper {
  background-color: var(--color-searchbox-background);
  border-radius: var(--cr-searchbox-border-radius);
  box-shadow: var(--cr-searchbox-shadow);
  display: flex;
  flex-direction: column;
  height: auto;
  min-height: var(--cr-searchbox-height);
  position: relative;
  width: 100%;
}

cr-searchbox-input::part(searchbox-input) {
  align-self: center;
  padding-top: 2px;
}

:host([searchbox-chrome-refresh-theming]) cr-searchbox-input::part(searchbox-input)::selection {
  background-color: var(--color-searchbox-selection-background);
  color: var(--color-searchbox-selection-foreground);
}

cr-searchbox-input::part(icon) {
  align-self: center;
}

.searchbox-icon-button {
  background-color: transparent;
  background-position: center;
  background-repeat: no-repeat;
  background-size: 21px 21px;
  border: none;
  border-radius: 2px;
  cursor: pointer;
  height: 100%;
  outline: none;
  padding: 0;
  pointer-events: auto;
  position: static;
  right: 16px;
  width: var(--cr-searchbox-icon-width);
  z-index: 100;
}

/* When voice/lens icons are monochrome, they are webkit mask images.
 * Webkit mask images hide borders so container rules are created to
 * show focus borders on these icons. */
.searchbox-icon-button-container {
  align-items: center;
  border-radius: 50%;
  display: flex;
  flex-shrink: 0;
  height: 36px;
  justify-content: center;
  position: relative;
  width: 36px;
  z-index: 100;
}

@media (forced-colors: active) {
  .searchbox-icon-button-container {
    background-color: ButtonText;
  }
  .searchbox-icon-button-container:focus-within {
    outline: 2px solid Highlight;
    outline-offset: 2px;
  }
}

:host-context(.focus-outline-visible) .searchbox-icon-button-container:focus-within {
  box-shadow: 0 0 0 2px var(--cr-focus-outline-color);
}

:host(:not([use-webkit-search-icons_])) #voiceSearchButton {
  background-image: url(//resources/cr_components/searchbox/icons/mic_old.svg);
}

:host(:not([use-webkit-search-icons_])) #lensSearchButton {
  background-image: url(//resources/cr_components/searchbox/icons/camera.svg);
}

:host([use-webkit-search-icons_]) #voiceSearchButton {
  -webkit-mask-image: url(//resources/cr_components/searchbox/icons/mic_old.svg);
}

:host([use-webkit-search-icons_]) #lensSearchButton {
  -webkit-mask-image: url(//resources/cr_components/searchbox/icons/camera.svg);
}

:host([use-webkit-search-icons_]) #voiceSearchButton,
:host([use-webkit-search-icons_]) #lensSearchButton {
  -webkit-mask-position: center;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-size: 21px 21px;
  background-color: var(--color-searchbox-lens-voice-icon-background);
}

cr-searchbox-dropdown::part(dropdown-content) {
  background-color: unset;
  border-radius: unset;
  box-shadow: unset;
  gap: unset;
  margin-bottom: unset;
  overflow: unset;
  padding-top: unset;
}

.searchbox-icon-button-container.lens {
  margin-inline-end: 10px;
}

.searchbox-icon-button-container.voice {
  margin-inline-end: 4px;
}

:host-context([webui-rounded-icons]):host(:not([use-webkit-search-icons_])) #voiceSearchButton {
  background-image: url(//resources/cr_components/searchbox/icons/mic.svg);
}

:host-context([webui-rounded-icons]):host([use-webkit-search-icons_]) #voiceSearchButton {
  -webkit-mask-image: url(//resources/cr_components/searchbox/icons/mic.svg);
}
