// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
// Copyright (c) KALEIDOS INC

.colorpicker {
  box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
  background-color: $color-white;
}

.colorpicker-content {
  display: flex;
  flex-direction: column;
  padding: $size-2;

  & > * {
    width: 200px;
  }

  .top-actions {
    display: flex;
    margin-bottom: $size-1;
    flex-direction: row-reverse;
    justify-content: space-between;

    .picker-btn {
      background: none;
      border: none;
      cursor: pointer;

      &.active svg,
      &:hover svg {
        fill: $color-primary;
      }

      svg {
        width: 14px;
        height: 14px;
      }
    }

    .element-set-content {
      width: auto;
      padding: 0.25rem 0;
      .custom-select {
        border: none;
        &:hover {
          border: none;
        }
        .custom-select-dropdown {
          left: auto;
          right: 0;
        }
      }
    }
  }

  .select-image {
    .content {
      display: flex;
      justify-content: center;
      background-image: url("/images/colorpicker-no-image.png");
      background-position: center;
      background-size: auto 6.75rem;
      height: 6.75rem;
      img {
        height: fit-content;
        width: fit-content;
        max-height: 100%;
        max-width: 100%;
        margin: auto;
      }
    }
    button {
      width: 100%;
      margin-top: 10px;
    }
  }
  .gradients-buttons {
    .gradient {
      cursor: pointer;
      width: 15px;
      height: 15px;
      padding: 0;
      margin: 0;
      border: 1px solid $color-gray-20;
      border-radius: $br2;
      margin-left: $size-1;
    }

    .active {
      border-color: $color-primary;
    }

    .linear-gradient {
      background: linear-gradient(180deg, $color-gray-20, transparent);
    }

    .radial-gradient {
      background: radial-gradient(transparent, $color-gray-20);
    }
  }

  .gradient-stops {
    height: 10px;
    display: flex;
    margin-top: $size-2;
    margin-bottom: $size-4;

    .gradient-background-wrapper {
      height: 100%;
      width: 100%;
      border: 1px solid $color-gray-10;
      background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAADFJREFUOE9jZGBgEAFifOANPknGUQMYhkkYEEgG+NMJKAwIAbwJbdQABnBCIgRoG4gAIF8IsXB/Rs4AAAAASUVORK5CYII=")
        left center;
    }

    .gradient-background {
      height: 100%;
      width: 100%;
    }

    .gradient-stop-wrapper {
      position: absolute;
      width: calc(100% - 2rem);
      margin-left: 0.5rem;
    }

    .gradient-stop {
      display: grid;
      grid-template-columns: 50% 50%;
      position: absolute;
      width: 15px;
      height: 15px;
      border-radius: $br2;
      border: 1px solid $color-gray-20;
      margin-top: -2px;
      margin-left: -7px;
      box-shadow: 0 2px 2px rgb(0 0 0 / 15%);

      background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAADFJREFUOE9jZGBgEAFifOANPknGUQMYhkkYEEgG+NMJKAwIAbwJbdQABnBCIgRoG4gAIF8IsXB/Rs4AAAAASUVORK5CYII=")
        left center;
      background-color: $color-white;

      &.active {
        border-color: $color-primary;
      }
    }
  }

  .picker-detail-wrapper {
    position: relative;

    .center-circle {
      width: 14px;
      height: 14px;
      border: 2px solid $color-white;
      border-radius: $br8;
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-7px, -7px);
      filter: drop-shadow(0px 4px 4px rgba(0, 0, 0, 0.25));
    }
  }

  #picker-detail {
    border: 1px solid $color-gray-10;
  }

  .slider-selector {
    --gradient-direction: 90deg;
    --background-repeat: left;

    &.vertical {
      --gradient-direction: 0deg;
      --background-repeat: top;
    }

    border: 1px solid $color-gray-10;

    background: linear-gradient(
      var(--gradient-direction),
      rgba(var(--color), 0) 0%,
      rgba(var(--color), 1) 100%
    );
    align-self: center;
    position: relative;
    cursor: pointer;

    width: 100%;
    height: calc(0.5rem + 1px);

    &.vertical {
      width: calc(0.5rem + 1px);
      height: 100%;
    }

    &.hue {
      background: linear-gradient(
        var(--gradient-direction),
        #f00 0%,
        #ff0 17%,
        #0f0 33%,
        #0ff 50%,
        #00f 67%,
        #f0f 83%,
        #f00 100%
      );
    }

    &.saturation {
      background: linear-gradient(
        var(--gradient-direction),
        var(--saturation-grad-from) 0%,
        var(--saturation-grad-to) 100%
      );
    }

    &.opacity {
      background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAADFJREFUOE9jZGBgEAFifOANPknGUQMYhkkYEEgG+NMJKAwIAbwJbdQABnBCIgRoG4gAIF8IsXB/Rs4AAAAASUVORK5CYII=")
        var(--background-repeat) center;

      &::after {
        content: "";
        position: absolute;
        width: 100%;
        height: 100%;
        background: linear-gradient(
          var(--gradient-direction),
          rgba(var(--color), 0) 0%,
          rgba(var(--color), 1) 100%
        );
      }
    }

    &.value {
      background: linear-gradient(var(--gradient-direction), #000 0%, #fff 100%);
    }

    .handler {
      background-color: $color-white;
      box-shadow: rgba(0, 0, 0, 0.37) 0px 1px 4px 0px;
      transform: translate(-6px, -2px);
      left: 50%;
      position: absolute;
      width: 12px;
      height: 12px;
      border-radius: $br6;
      z-index: 1;
    }

    &.vertical .handler {
      transform: translate(-6px, 6px);
    }
  }

  .value-saturation-selector {
    background-color: rgba(var(--hue-rgb));
    position: relative;
    height: 6.75rem;
    cursor: pointer;

    .handler {
      position: absolute;
      width: 12px;
      height: 12px;
      border-radius: $br6;
      z-index: 1;
      border: 1px solid $color-white;
      box-shadow:
        rgb(255, 255, 255) 0px 0px 0px 1px inset,
        rgb(0 0 0 / 0.25) 0px 4px 4px inset,
        rgb(0 0 0 / 0.25) 0px 4px 4px;
      transform: translate(-6px, -6px);
      left: 50%;
      top: 50%;
    }

    &::before {
      content: "";
      position: absolute;
      width: 100%;
      height: 100%;
      background: linear-gradient(to right, #fff, rgba(255, 255, 255, 0));
    }

    &::after {
      content: "";
      position: absolute;
      width: 100%;
      height: 100%;
      background: linear-gradient(to top, #000, rgba(0, 0, 0, 0));
    }
  }

  .shade-selector {
    display: grid;
    justify-items: center;
    align-items: center;
    grid-template-areas:
      "color hue"
      "color opacity";
    grid-template-columns: 2.5rem 1fr;
    height: 3.5rem;
    grid-row-gap: 0.5rem;
    cursor: pointer;
    margin-bottom: 0.25rem;

    .slider-selector.hue {
      grid-area: "hue";
      align-self: flex-end;
    }

    .slider-selector.opacity {
      grid-area: "opacity";
      align-self: flex-start;
    }
  }

  .color-values {
    display: grid;
    grid-template-columns: 3.5rem repeat(4, 1fr);
    grid-row-gap: 0.25rem;
    justify-items: center;
    grid-column-gap: 0.25rem;

    &.disable-opacity {
      grid-template-columns: 3.5rem repeat(3, 1fr);
    }

    input {
      width: 100%;
      margin: 0;
      border: 1px solid $color-gray-10;
      border-radius: $br2;
      font-size: $fs12;
      height: 1.5rem;
      padding: 0 $size-1;
      color: $color-gray-40;
    }

    label {
      font-size: $fs12;
    }
  }

  .libraries {
    border-top: 1px solid $color-gray-10;
    padding-top: 0.5rem;
    margin-top: 0.25rem;
    width: 200px;

    select {
      background-image: url(/images/icons/arrow-down.svg);
      background-repeat: no-repeat;
      background-position: 95% 48%;
      background-size: 10px;
      margin: 0;
      margin-bottom: $size-2;
      width: 100%;
      padding: $size-1 0.25rem;
      font-size: $fs12;
      color: $color-gray-40;
      cursor: pointer;
      border: 1px solid $color-gray-10;
      border-radius: $br2;

      option {
        padding: 0;
      }
    }

    .selected-colors {
      display: grid;
      grid-template-columns: repeat(8, 1fr);
      justify-content: space-between;
      margin-right: -8px;
      max-height: 5.5rem;
      overflow: auto;
      div {
        grid-area: unset;
      }
    }

    .selected-colors::after {
      content: "";
      flex: auto;
    }
  }

  .actions {
    margin-top: 0.5rem;
    display: flex;
    flex-direction: row;
    justify-content: center;

    .btn-primary {
      height: 1.5rem;
      font-size: $fs12;
      width: 100%;
    }
  }

  .harmony-selector {
    display: flex;
    flex-direction: row;
    margin-bottom: 0.5rem;

    .hue-wheel-wrapper {
      position: relative;

      .hue-wheel {
        width: 152px;
        height: 152px;
      }

      .handler {
        position: absolute;
        width: 12px;
        height: 12px;
        border-radius: $br6;
        z-index: 1;
        border: 1px solid $color-white;
        box-shadow:
          rgb(255, 255, 255) 0px 0px 0px 1px inset,
          rgb(0 0 0 / 0.25) 0px 4px 4px inset,
          rgb(0 0 0 / 0.25) 0px 4px 4px;
        transform: translate(-6px, -6px);
        left: 50%;
        top: 50%;
      }

      .handler.complement {
        background-color: $color-white;
        box-shadow: rgb(0 0 0 / 0.25) 0px 4px 4px;
      }
    }

    .handlers-wrapper {
      height: 152px;
      display: flex;
      flex-direction: row;
      flex-grow: 1;
      justify-content: space-around;
      padding-top: 0.5rem;

      & > * {
        height: 100%;
      }
    }
  }

  .hsva-selector {
    display: grid;
    padding: 0.25rem;
    grid-template-columns: 20px 1fr;
    grid-template-rows: repeat(4, 2rem);
    grid-row-gap: 0.5rem;
    margin-bottom: 0.5rem;

    .hue,
    .saturation,
    .value,
    .opacity {
      border-radius: $br10;
    }

    .hsva-selector-label {
      grid-column: 1;
      align-self: center;
    }
  }
}

.colorpicker-tooltip {
  border-radius: $br3;
  display: flex;
  flex-direction: column;
  left: 1400px;
  top: 100px;
  position: absolute;
  z-index: 11;
  width: auto;

  span {
    color: $color-gray-20;
    font-size: $fs12;
  }

  .inputs-area {
    .input-text {
      color: $color-gray-60;
      font-size: $fs12;
      margin: 5px;
      padding: 5px;
      width: 100%;
    }
  }

  .colorpicker-tabs {
    display: flex;
    margin-bottom: $size-2;
    border-radius: $br5;
    border: 1px solid $color-gray-10;
    height: 2rem;

    .colorpicker-tab {
      cursor: pointer;
      display: flex;
      flex-grow: 1;
      justify-content: center;
      align-items: center;

      svg {
        width: 16px;
        height: 16px;
        fill: $color-gray-20;
      }
    }

    .active {
      background-color: $color-gray-10;
      svg {
        fill: $color-gray-60;
      }
    }

    :hover svg {
      fill: $color-primary;
    }
  }
}

.color-data {
  align-items: center;
  display: flex;
  margin-bottom: $size-2;
  position: relative;

  &[draggable="true"] {
    cursor: pointer;
  }

  .color-name {
    font-size: $fs12;
    margin: 5px 6px 0px 6px;
  }

  .color-info {
    flex: 1 1 0;

    input {
      background-color: $color-gray-50;
      border: 1px solid $color-gray-30;
      border-radius: $br3;
      color: $color-white;
      height: 20px;
      margin: 5px 0 0 0;
      padding: 0 $size-1;
      width: 84px;
      font-size: $fs12;

      &:focus {
        border-color: $color-primary !important;
        color: $color-white;
        outline: none;
      }

      &:hover {
        border-color: $color-gray-20;
      }

      &:invalid {
        border-color: $color-danger;
      }
    }
  }

  ::placeholder {
    color: $color-gray-10;
  }

  .type {
    color: $color-gray-10;
    margin-right: $size-1;
  }

  .number {
    color: $color-gray-60;
  }

  .element-set-actions-button svg {
    width: 10px;
    height: 10px;
  }
}
