@import '../../sass/_custom-variables/libs';

$minicolors-padding: .25rem !default;

.minicolors,
.minicolors-input {
  display: block;
  width: 100%;
}

.minicolors {
  position: relative;
  height: auto;
}

.minicolors-sprite {
  background-image: url(jquery.minicolors.png);
}

.minicolors-swatch {
  position: absolute;
  display: inline-block;
  margin: 0;
  padding: 0;
  border: solid 1px #ccc;
  background-position: -80px 0;
  vertical-align: middle;
  cursor: text;
}

.minicolors-swatch-color {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

.minicolors input[type=hidden] {
  +.minicolors-swatch {
    position: static;
    width: 28px;
    cursor: pointer;
  }

  &[disabled]+.minicolors-swatch {
    cursor: default;
  }
}

// Panel

.minicolors-panel {
  position: absolute;
  z-index: 99999;
  display: none;
  box-sizing: content-box;
  padding: $minicolors-padding;
  width: 173px;
  border: solid 1px #ccc;
  box-shadow: 0 0 20px rgba(0, 0, 0, .2);

  &.minicolors-visible {
    display: block;
  }

  // Panel positioning

  .minicolors-position-top {
    top: -154px;
    transform: translate(0, (-$minicolors-padding * 2) - .125rem);
  }

  .minicolors-position-right {
    right: 0;
  }

  .minicolors-position-bottom {
    top: auto;
  }

  .minicolors-position-left {
    left: 0;
  }

  .minicolors-with-opacity {
    width: 194px;
  }
}

.minicolors {
  .minicolors-grid {
    position: relative;
    margin-bottom: 2px;
    width: 150px;
    height: 150px;
    background-position: -120px 0;
    cursor: crosshair;
  }

  .minicolors-grid-inner {
    position: absolute;
    top: 0;
    left: 0;
    width: 150px;
    height: 150px;
  }
}

.minicolors-slider-saturation {
  .minicolors-grid {
    background-position: -420px 0;
  }

  .minicolors-grid-inner {
    background-image: inherit;
    background-position: -270px 0;
  }
}

.minicolors-slider-brightness {
  .minicolors-grid {
    background-position: -570px 0;
  }

  .minicolors-grid-inner {
    background-color: black;
  }
}

.minicolors-slider-wheel .minicolors-grid {
  background-position: -720px 0;
}

.minicolors-slider,
.minicolors-opacity-slider {
  position: absolute;
  left: 152px;
  width: 20px;
  height: 150px;
  background-color: white;
  background-position: 0 0;
  cursor: row-resize;
  transform: translate($minicolors-padding, 0);

  @include feature-rtl {
    right: 152px;
    left: auto;
    transform: translate(-$minicolors-padding, 0);
  }
}

.minicolors-slider-saturation .minicolors-slider {
  background-position: -60px 0;
}

.minicolors-slider-brightness .minicolors-slider,
.minicolors-slider-wheel .minicolors-slider {
  background-position: -20px 0;
}

.minicolors-opacity-slider {
  left: 173px;
  display: none;
  background-position: -40px 0;

  @include feature-rtl {
    right: 173px;
    left: auto;
  }
}

.minicolors-with-opacity .minicolors-opacity-slider {
  display: block;
}

// Pickers

.minicolors-grid .minicolors-picker {
  position: absolute;
  top: 70px;
  left: 70px;
  margin-top: -6px;
  margin-left: -6px;
  width: 12px;
  height: 12px;
  border: solid 1px black;
  border-radius: 10px;
  background: none;

  >div {
    position: absolute;
    top: 0;
    left: 0;
    box-sizing: content-box;
    width: 8px;
    height: 8px;
    border: solid 2px white;
    border-radius: 8px;
  }
}

.minicolors-picker {
  position: absolute;
  top: 0;
  left: 0;
  box-sizing: content-box;
  margin-top: -2px;
  width: 18px;
  height: 2px;
  border: solid 1px black;
  background: white;
}

// Swatches

.minicolors-swatches {
  overflow: hidden;
  margin: 5px 0 3px 5px;
  padding: 0;
  list-style: none;

  @include feature-rtl {
    margin: 5px 5px 3px 0;
  }

  li {
    overflow: hidden;
    margin: 5px 0 3px 5px;
    padding: 0;
    list-style: none;

    @include feature-rtl {
      margin: 5px 5px 3px 0;
    }
  }
}

.minicolors-swatches .minicolors-swatch {
  position: relative;
  float: left;
  margin: 0 4px 0 0;
  cursor: pointer;

  @include feature-rtl {
    float: right;
    margin: 0 0 0 4px;
  }
}

.minicolors-with-opacity .minicolors-swatches .minicolors-swatch {
  margin-right: 7px;

  @include feature-rtl {
    margin-right: 0;
    margin-left: 7px;
  }
}

.minicolors-swatch.selected {
  border-color: #000;
}

// Inline controls

.minicolors-inline {
  display: inline-block;

  .minicolors-input {
    display: none !important;
  }

  .minicolors-panel {
    position: relative;
    top: auto;
    left: auto;
    z-index: auto;
    display: inline-block;
    box-shadow: none;

    @include feature-rtl {
      right: auto;
    }
  }
}

@if $enable-light-style {
  .light-style {
    @import "../../sass/_appwork/include";

    $swatch-size: 1.125rem;
    $swatch-position: (($input-height-inner - $swatch-size) / 2) + px-to-rem($input-btn-border-width);

    .minicolors-panel {
      z-index: $zindex-dropdown;
      margin: .125rem 0;
      border: $dropdown-border-width solid $dropdown-border-color;
      background-clip: padding-box;
      box-shadow: $dropdown-box-shadow;
      background: $dropdown-bg;

      @include border-radius($border-radius);
    }

    .minicolors-swatch {
      top: $swatch-position;
      left: $swatch-position;
      width: $swatch-size;
      height: $swatch-size;
      border: 0;
    }

    .minicolors-position-right .minicolors-swatch {
      right: $swatch-position;
      left: auto;
    }

    .minicolors-input {
      padding-left: $swatch-size + ($swatch-position * 2);
    }

    .minicolors-position-right .minicolors-input {
      padding-right: $swatch-size + ($swatch-position * 2);
      padding-left: $input-padding-x;
    }
  }
}

@if $enable-material-style {
  .material-style {
    @import "../../sass/_appwork/include-material";

    $swatch-size: 1.125rem;
    $swatch-position: ($input-height-inner - $swatch-size) / 2;

    .minicolors-panel {
      z-index: $zindex-dropdown;
      margin: .125rem 0;
      border: $dropdown-border-width solid $dropdown-border-color;
      background-clip: padding-box;
      box-shadow: $dropdown-box-shadow;
      background: $dropdown-bg;

      @include border-radius($border-radius);
    }

    .minicolors-swatch {
      top: $swatch-position;
      left: 0;
      width: $swatch-size;
      height: $swatch-size;
      border: 0;
    }

    .minicolors-position-right .minicolors-swatch {
      right: 0;
      left: auto;
    }

    .minicolors-input {
      padding-left: $swatch-size + $swatch-position !important;
    }

    .minicolors-position-right .minicolors-input {
      padding-right: $swatch-size + $swatch-position !important;
      padding-left: 0 !important;
    }
  }
}

@if $enable-dark-style {
  .dark-style {
    @import "../../sass/_appwork/include-dark";

    $swatch-size: 1.125rem;
    $swatch-position: (($input-height-inner - $swatch-size) / 2) + px-to-rem($input-btn-border-width);

    .minicolors-panel {
      z-index: $zindex-dropdown;
      margin: .125rem 0;
      border: $dropdown-border-width solid $dropdown-border-color;
      background: $dropdown-bg;
      background-clip: padding-box;
      box-shadow: $dropdown-box-shadow;
      @include border-radius($border-radius);
    }

    .minicolors-swatch {
      top: $swatch-position;
      left: $swatch-position;
      width: $swatch-size;
      height: $swatch-size;
      border: 0;
    }

    .minicolors-position-right .minicolors-swatch {
      right: $swatch-position;
      left: auto;
    }

    .minicolors-input {
      padding-left: $swatch-size + ($swatch-position * 2);
    }

    .minicolors-position-right .minicolors-input {
      padding-right: $swatch-size + ($swatch-position * 2);
      padding-left: $input-padding-x;
    }
  }
}
