@use "../base/mixins";
@use "../vars/variables";

.modal--add-widget {
  // z-index: 2510;
  z-index: var(--uc-vselect-z-index);

  &__select {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    padding: 0 1.25rem 1.25rem;

    @media screen and (min-width: variables.$bp-phone-plus) {
      justify-content: center;
    }

    @media screen and (max-width: variables.$bp-phone) {
      position: relative;
      z-index: 2;
      padding-bottom: 0.625rem;
      overflow-y: auto;
    }

    .widget-card {
      flex: 0 0 calc(33.3333% - 0.8333rem);

      @media screen and (max-width: variables.$bp-phone) {
        flex: 0 0 100%;
      }
    }
  }

  &__edit {
    display: flex;
    flex: 1;
    height: 100%;
    // max-height: 35rem;
    // min-height: 30.35rem;

    @media screen and (max-width: variables.$bp-phone) {
      position: absolute;
      width: 100%;
      z-index: 1;
    }
  }

  .modal-secondary {
    &__container {
      position: relative;
      min-height: 20rem;
      transition: width 0.4s;
      overflow: hidden;
      padding-left: 0;
      padding-right: 0;
      padding-bottom: 0.625rem;

      @media screen and (max-width: variables.$bp-phone) {
        height: 92vh !important;
        height: 92dvh !important;
      }

      @media only screen and (max-height: 650px) {
        margin-top: 0;
      }
    }

    &__header {
      padding-left: 1.25rem;
      padding-right: 1.25rem;
    }

    &__body {
      overflow: visible;
      max-height: 80vh;
      max-height: 80dvh;

      @media screen and (max-width: variables.$bp-tablet) {
        position: relative;
        max-height: 60vh;
        max-height: 60dvh;
      }

      @media screen and (max-width: variables.$bp-phone) {
        position: relative;
        max-height: 100vh;
        max-height: 100dvh;
      }
    }
  }

  &--select {
    .modal-secondary {
      &__body {
        @media screen and (max-width: variables.$bp-phone) {
          overflow: hidden;
        }
      }

      &__container {
        @media screen and (min-width: variables.$bp-phone-plus) {
          min-height: fit-content;
        }
      }
    }
  }
}

.widget-card {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border-radius: 0.5rem;
  padding: 0.625rem;
  gap: 0.625rem;
  background: var(--uc-bg-bg-surface-1);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.3s;

  i {
    transition: all 0.3s;
  }

  @media (pointer: fine) {
    &:hover {
      border-color: var(--uc-foreground);
      transition: all 0.3s;

      i {
        transform: scale(1.2);
        transform-origin: center;
        transition: all 0.3s;
      }

      .widget-card__image--media::before,
      .widget-card__image--slider::before {
        transform: scale(1.05);
        transform-origin: center;
        transition: all 0.3s;
      }
    }
  }

  &__image {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 0.75rem;
    background: var(--uc-bg-bg-surface-2);
    width: 100%;
    height: 6.25rem;

    i {
      font-size: 1.66669rem;
      color: var(--uc-theme-color-90);
    }

    &--media {
      &::before {
        content: "";
        position: absolute;
        bottom: 1rem;
        width: 83.6%;
        height: 0.5rem;
        background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAXAAAAARCAYAAADExvd0AAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAGGSURBVHgB7dw/TgJBFMfxt+MfqJDehVBaegRuIDfAG0ipldBJJYYYS7BVSJDKkk5KlAYbsgFMKJGEiuA4A66h8AAMfj/JZHZntv7l7bzNigAAnOT9tai1jpspZcaxAG4IPM9rCfCP7K7fmOBOmenSjIwZcQEc8dbtTvxEoiPAljFVdudL5HUxn7fG43Gwvvcb4Ca8s2YqCcENB81ms7h4XlqALaNF0vaoZG9/P/CTyepoMCiEe2r5gNa24q4K4Q0AG0mvjrXzh4lEJVxTP8cm1wIA2Him13NqQnyZ2bYCT8sq2QEADjAhnvN9P20DPCsAANdkbIDzqSAAOMZT6sQGOI1LAHCMbWqq6XQqAAD3qH6/HwgAwCmmAu+oZrP5JAAA13TUXaVSemm3BQDgjoVSBTUOguCqWLwZjUYCAHBCwWb38l8ozUYjZ+fbcvnM930BAGwmrfX9x3CYt9c74eJ7r/f8UK9/GkfRaDR+EItJJBIRwAX2DfKxVhNgi01M4/LChPd5uPANiMRyX5sz5ccAAAAASUVORK5CYII=);
        background-position: center;
        background-size: 100%;
        transition: all 0.3s;
      }

      i {
        margin-bottom: 1rem;
      }
    }

    &--slider {
      &::before {
        content: "";
        position: absolute;
        top: 2.625rem;
        width: 83.6%;
        height: 1rem;
        background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAWgAAAAiCAYAAAByUUNrAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAQlSURBVHgB7d2tUxtbGMfxJwkCmXszHXBsFUiqwBEUOKhCwlVIbv8C7nUwg+iVqBKJai2K4EA114FqJKK0wcFMs9vnt8kyIS/kFYj4fmbOnIU9O3W/efqcs0vKBhBFUeBTMjAG9vb27ODgwACMlUq1Wq34XKo469NErws9lPM+bfpY95E1jJVUOm2RARg36Uwmnv/M5co+FcNqteBZXezp2W4LPJi3fHzzy1MfW0Y4A8AgAh9bHtinHtbfcrncVrcHOga02hg+FMqfjFYGAIxS4P/j/fRHLneazWaDTovaBnS9nfHVR94AAM8i5Rmrijr75s18u/stAe3hrD6zKmdaGQDw/IJ0GH7N5nKbzTceBbSHs1L8owEAXpSH8cfmSvohoOtH5z4blTMAvIasV9KfvSf9kMGNFfSusRkIAK8pSE9M7CY/xAFdr563bASur69tgPPYAACJor+9iM7rMqmgd20ESqWSHR4e2vHxsQEABpPKZHY0T4yqei4Wi3Z2dhZf393dGQBgMCmzdfWiVUHnbUgnJydxOM/Pz9vs7GzLfVXW+/v7cfsDANBdJpNZV0Av9fOQqmMFbblcjofaGefn57a4uGhra2s2OTnZ8kwQBPHvtZbqGgC68+7Gkj6WNN/rA9r8KxQKLZuA+XzelpaW2q6/uLiI7ym89WzyMwCgs8izWQEd9PpAckJjZWXloVLWkT1VyO1oraprrVUoa53aHQQ0ADwtlUoFCuieX0xJ2hNzc3PWcJa6IwWyetIKaYXy1NRU3BYBAHSV7fq50WHd39/3FOYAgMdUQauh3FOCJm0NndpIrqenp21hYaHt+svLy7hiVo9arq6u4vUAgK4qCuiy9bhRqNaGwlhBm1BPWb3pxr50QmG8sbERP6c2h3rS2iwEADwtiqKyAvp/6+Mkx+rqajwSyQsqCmmFcSO1NjRUSavq1rXOSgMAnuabhCX1oIs2BLUvVBUroHWM7vb2tu06bRZubm4aAKC70OxMFfQXq/1Zq4GpKlY7QwGtnnPzpqBaHBoAgB5Vq8W0l9HaJPxiQ1JAb29vx+E8MzNjAICBHfmeXdyDlv98rNuQFM47OzsGABhcWK3+qzk+B+1VdNFqIQ0AeF1x9ayLxhdV/rHakTsAwCvQ0bqkepaHgK73ot9b7cUVAMBLiqJKFIbvk+pZHr3qrXN3Pn0wAMCLClOpDx7OpcbftXyLw0P6yKd3RrsDAJ6fV84ezsuVm5uj5lttP5ZUr6SXbciXWAAAnUWesWEYvqt8/15sd7/j1+w8pMs+FNJ/GdU0AIxMvBno2frz5ma5sefcrOvnRtXy8PHWahV1wQhrAOiftzJ8HKmd8fPHj7ftWhrNJqxH9bPSxdq/E+ldbn31KGt9fPAfz8d3f/WXgAGMmap3I+zXr/JTlXInvwHgRoaY9jcE6wAAAABJRU5ErkJggg==);
        background-position: center;
        background-size: 100%;
        transition: all 0.3s;
      }
    }
  }

  &__title {
    @include mixins.body-large;
    display: block;
    width: 100%;
    overflow: hidden;
    color: var(--uc-text-text-primary);
    text-overflow: ellipsis;
    text-align: left;
  }

  &__description {
    @include mixins.body-extrasmall;
    display: block;
    width: 100%;
    color: var(--uc-text-text-secondary);
    margin-bottom: 0.25rem;
  }

  &__error {
    @include mixins.body-small;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    opacity: 1;
    color: var(--uc-error-error-60);
    padding: 0 1rem 1rem;
    gap: 0.625rem;

    i {
      display: flex;
      justify-content: center;
      align-items: center;
      color: var(--uc-black);
      background-color: var(--uc-error-error-60);
      border-radius: 50%;
      font-size: 1.5rem;
      width: 2.5rem;
      height: 2.5rem;
    }
  }

  &--disabled {
    cursor: not-allowed;
    background: rgba(0, 0, 0, 0.9);

    .widget-card__error {
      opacity: 1;
      background: rgba(0, 0, 0, 0.9);
    }

    @media (pointer: fine) {
      &:hover {
        border-color: transparent;

        .widget-card__image--media::before,
        .widget-card__image--slider::before,
        i {
          transform: scale(1);
        }
      }
    }
  }
}

.widget-popup-wrapper {
  position: fixed;
  top: 0.5rem;
  display: flex;
  align-items: center;
  z-index: var(--uc-vselect-z-index);
  overflow: hidden;
  height: calc(100vh - 1rem);
  height: calc(100dvh - 1rem);
  width: 100%;
  max-width: 22.5rem;

  @media screen and (max-width: variables.$bp-phone) {
    left: 1rem !important;
    top: 2rem;
    max-height: 90vh;
    max-height: 90dvh;
    width: calc(100% - 2rem);
    max-width: 22.5rem;
  }

  &__background {
    content: "";
    background: transparent;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1500;
  }
}

.widget-popup {
  display: flex;
  flex-direction: column;
  position: relative;
  border-radius: 1rem;
  background: var(--uc-background);
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1505;
  padding: 1.25rem 0 0.625rem;
  gap: 0.625rem;
  flex: 1;
  max-height: 100%;

  @media screen and (max-width: variables.$bp-phone) {
    max-width: 100%;
  }

  &:after {
    display: none;
    content: "";
    background: transparent;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
  }

  &--add-item {
    background: transparent;
    border: transparent;
    padding: 0;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    width: 100%;
  }

  &__header {
    position: relative;
    display: flex;
    justify-content: space-between;
    min-height: 1.625rem;
    padding: 0 1.25rem;
  }

  &__body {
    padding: 0.625rem 1.25rem 0.625rem;
    overflow-x: hidden;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    @include mixins.scrollbar;
  }

  &__fields {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    flex: 1;
    max-height: 80vh;
    max-height: 80dvh;
    min-height: 0;
  }

  &__field {
    &--icon,
    &--size {
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      align-items: center;
      gap: 1rem;
      border-radius: 0.5rem;
      background: rgba(0, 0, 0, 0.2);
      padding: 0.75rem;

      label {
        @include mixins.body-extrasmall;
        color: rgba(255, 255, 255, 0.6);
        font-size: 1rem;
      }
    }

    &--icon {
      padding: 0.625rem 0.75rem;

      .selected-icon {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 1rem;
        padding: 0;
        background-color: transparent;
        color: var(--uc-text-text-primary);

        &--custom {
          border-radius: 0.375rem;

          .vue-load-image {
            border-radius: 0.375rem;

            img {
              border-radius: 0.375rem;
            }
          }
        }

        &__edit {
          font-size: 1rem;
        }
      }
    }
  }

  &__command-wrapper,
  &__param-wrapper {
    display: flex;
    width: 100%;
    border-radius: 0.5rem;
  }

  &__command-wrapper {
    flex-direction: column;
    background: var(--uc-bg-bg-surface-1);
    overflow: hidden;
    // max-height: 84%;
    max-height: 100%;
    min-height: 4.75rem;

    &--minimal {
      min-height: 3.75rem;
    }

    &--open {
      min-height: 15.75rem;
    }
  }

  &__params {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;

    &__field-optional {
      width: 1rem;
    }
  }

  &__param-wrapper {
    flex-direction: row;
    align-items: center;
    gap: 1.25rem;

    & > .command-param {
      flex: 1;
      min-width: 2rem;
    }

    &--custom {
      display: flex;
      flex-direction: row;
      align-items: center;
      justify-content: space-between;
      padding: 0.75rem;
      border: 1px solid var(--uc-theme-color-40);
      border-radius: 0.5rem;

      .widget-popup__param-wrapper__label {
        @include mixins.body-small;
        color: var(--uc-text-text-secondary);
      }
    }
  }

  &__button-convert {
    display: flex;
    align-items: center;
    gap: 0.625rem;

    & > span {
      @include mixins.button-label;
      color: rgba(255, 255, 255, 0.8);
      cursor: pointer;
    }
  }

  &__error {
    @include mixins.secondary-body-extrasmall;
    color: var(--uc-error-error-40);
  }

  &__footer {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    gap: 1rem;

    &__right {
      display: flex;
      gap: 0.625rem;
    }
  }

  &__loader {
    position: absolute;
    top: 0;
    right: 1.25rem;
    width: 1.5rem;
    height: 1.5rem;

    img {
      width: 100%;
      height: 100%;
      min-height: 1.375rem;
    }
  }

  &--saving {
    &:after {
      display: block;
    }
  }
}

@include mixins.transition-collapse-command;
