@import "../../../themes/ionic.globals.wp";

// Windows Searchbar
// --------------------------------------------------

/// @prop - Padding top of the searchbar
$searchbar-wp-padding-top: 8px !default;

/// @prop - Padding end of the searchbar
$searchbar-wp-padding-end: $searchbar-wp-padding-top !default;

/// @prop - Padding bottom of the searchbar
$searchbar-wp-padding-bottom: $searchbar-wp-padding-top !default;

/// @prop - Padding start of the searchbar
$searchbar-wp-padding-start: $searchbar-wp-padding-end !default;

/// @prop - Background of the searchbar
$searchbar-wp-background-color: transparent !default;

/// @prop - Border width of the searchbar
$searchbar-wp-border-width: 2px !default;

/// @prop - Border color of the searchbar
$searchbar-wp-border-color: $input-wp-border-color !default;

/// @prop - Border color of the searchbar on focus
$searchbar-wp-border-color-focused: color($colors-wp, primary) !default;

/// @prop - Color of the searchbar input search icon
$searchbar-wp-input-search-icon-color: #858585 !default;

/// @prop - Svg for the searchbar input search icon
$searchbar-wp-input-search-icon-svg: "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'><path fill='" + $searchbar-wp-input-search-icon-color + "' d='M337.509,305.372h-17.501l-6.571-5.486c20.791-25.232,33.922-57.054,33.922-93.257C347.358,127.632,283.896,64,205.135,64C127.452,64,64,127.632,64,206.629s63.452,142.628,142.225,142.628c35.011,0,67.831-13.167,92.991-34.008l6.561,5.487v17.551L415.18,448L448,415.086L337.509,305.372z M206.225,305.372c-54.702,0-98.463-43.887-98.463-98.743c0-54.858,43.761-98.742,98.463-98.742c54.7,0,98.462,43.884,98.462,98.742C304.687,261.485,260.925,305.372,206.225,305.372z'/></svg>" !default;

/// @prop - Size of the searchbar input search icon
$searchbar-wp-input-search-icon-size: 20px !default;

/// @prop - Padding top/bottom of the searchbar input
$searchbar-wp-input-padding-vertical: 0 !default;

/// @prop - Padding start/end of the searchbar input
$searchbar-wp-input-padding-horizontal: 8px !default;

/// @prop - Height of the searchbar input
$searchbar-wp-input-height: auto !default;

/// @prop - Line height of the searchbar input
$searchbar-wp-input-line-height: 30px !default;

/// @prop - Color of the searchbar input placeholder
$searchbar-wp-input-placeholder-color: #858585 !default;

/// @prop - Color of the searchbar input text
$searchbar-wp-input-text-color: #141414 !default;

/// @prop - Background of the searchbar input
$searchbar-wp-input-background-color: #fff !default;

/// @prop - Border radius of the searchbar input
$searchbar-wp-input-border-radius: 0 !default;

/// @prop - Font size of the searchbar input
$searchbar-wp-input-font-size: 14px !default;

/// @prop - Font weight of the searchbar input
$searchbar-wp-input-font-weight: 400 !default;

/// @prop - Color of the searchbar input clear icon
$searchbar-wp-input-clear-icon-color: #858585 !default;

/// @prop - Svg for the searchbar input clear icon
$searchbar-wp-input-clear-icon-svg: "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'><polygon fill='" + $searchbar-wp-input-clear-icon-color + "' points='405,136.798 375.202,107 256,226.202 136.798,107 107,136.798 226.202,256 107,375.202 136.798,405 256,285.798 375.202,405 405,375.202 285.798,256'/></svg>" !default;

/// @prop - Size of the searchbar input clear icon
$searchbar-wp-input-clear-icon-size: 22px !default;

// Searchbar
// -----------------------------------------

.searchbar-wp {
  background: $searchbar-wp-background-color;
  
  @include padding($searchbar-wp-padding-top, $searchbar-wp-padding-end, $searchbar-wp-padding-bottom, $searchbar-wp-padding-start);
}

.searchbar-wp .searchbar-input-container {
  border: $searchbar-wp-border-width solid $searchbar-wp-border-color;
}

// Searchbar Search Icon
// -----------------------------------------

.searchbar-wp .searchbar-search-icon {
  position: absolute;
  width: $searchbar-wp-input-search-icon-size + 1;
  height: $searchbar-wp-input-search-icon-size + 1;
  background-repeat: no-repeat;
  background-size: $searchbar-wp-input-search-icon-size;
  
  @include position(5px, $searchbar-wp-input-padding-horizontal, null, null);
  @include svg-background-image($searchbar-wp-input-search-icon-svg, true);
}

.searchbar-wp .searchbar-search-icon:active {
  background-color: transparent;
}

// Searchbar Input Field
// -----------------------------------------

.searchbar-wp .searchbar-input {
  height: $searchbar-wp-input-height;
  font-size: $searchbar-wp-input-font-size;
  font-weight: $searchbar-wp-input-font-weight;
  line-height: $searchbar-wp-input-line-height;
  color: $searchbar-wp-input-text-color;
  background-color: $searchbar-wp-input-background-color;
  
  @include placeholder($searchbar-wp-input-placeholder-color);
  @include padding($searchbar-wp-input-padding-vertical, $searchbar-wp-input-padding-horizontal);
  @include border-radius($searchbar-wp-input-border-radius);
  @include background-position(start, $searchbar-wp-input-padding-horizontal, center);
}

// Searchbar Clear Input Icon
// -----------------------------------------

.searchbar-wp .searchbar-clear-icon {
  position: absolute;
  width: $searchbar-wp-input-clear-icon-size;
  height: 100%;
  background-repeat: no-repeat;
  background-size: $searchbar-wp-input-clear-icon-size;
  
  @include position(0, $searchbar-wp-input-padding-horizontal, null, null);
  @include svg-background-image($searchbar-wp-input-clear-icon-svg);
  @include padding(0);
  @include background-position(center);
}

.searchbar-wp .searchbar-clear-icon:active {
  background-color: transparent;
}

// Searchbar Focused
// -----------------------------------------

.searchbar-wp.searchbar-has-focus .searchbar-input-container {
  border-color: $searchbar-wp-border-color-focused;
}

// Searchbar Left Aligned
// -----------------------------------------

.searchbar-wp.searchbar-has-value .searchbar-search-icon {
  display: none;
}

// Searchbar Cancel Icon (iOS only)
// -----------------------------------------

.searchbar-wp .searchbar-ios-cancel {
  display: none;
}

// Searchbar Cancel Icon (MD only)
// -----------------------------------------

.searchbar-wp .searchbar-md-cancel {
  display: none;
}

// Searchbar in Toolbar
// -----------------------------------------

.toolbar .searchbar-wp {
  @include padding(2px);
}

// Generate Default Windows Search Bar Colors
// --------------------------------------------------

@each $color-name, $color-base, $color-contrast in get-colors($colors-wp) {
  .searchbar-wp-#{$color-name}.searchbar-has-focus .searchbar-input-container {
    border-color: $color-base;
  }
  
}
