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

.resource-upload {
  position: relative;
  display: flex;
  float: left;
  flex-direction: column;
  flex: 0 0 auto;
  max-width: calc(25% - 0.9rem);
  width: 100%;
  border-radius: 0.25rem;
  padding-left: 0.25rem;
  padding-right: 0.25rem;
  padding-bottom: 0.5rem;
  // max-height: 11.6875rem;

  @media screen and (max-width: variables.$bp-phone) {
    display: flex;
    margin-left: auto;
    margin-right: auto;
  }

  input {
    position: absolute;
    width: 0.1rem;
    height: 0.1rem;
    opacity: 0;
    visibility: hidden;
  }

  @media (pointer: fine) {
    &:hover {
      .resource-upload {
        &__drop-area {
          background: var(--uc-bg-bg-surface-1);
          border-color: var(--uc-white);
        }
      }
    }
  }

  &.resource-upload--no-items {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: calc(25% - 0.9rem);
    height: fit-content;
    width: 100%;
    margin: 0;

    @media screen and (max-width: variables.$bp-phone) {
      max-width: 70vw;
      max-height: 10rem;
    }

    label.resource-upload__drop-area {
      gap: 1rem;
      height: fit-content;

      i {
        font-size: 2rem;
      }

      @media screen and (min-width: variables.$bp-phone-plus) {
        aspect-ratio: 170 / 104;
      }

      @media screen and (min-width: variables.$bp-tablet-plus) {
        aspect-ratio: 170 / 102;
      }

      @media screen and (min-width: variables.$bp-laptop-plus) {
        aspect-ratio: 170 / 99;
      }

      @media screen and (max-width: variables.$bp-phone) {
        max-width: 60vw;
        padding: 2rem 0;
        min-width: 10rem;
        margin-left: auto;
        margin-right: auto;
      }
    }
  }

  &--uploading {
    .resource-upload {
      &__drop-area {
        border-color: transparent;
      }

      &__progress {
        display: flex;
      }
    }
  }

  &--error {
    width: 12.37rem;

    .resource-upload {
      &__error-message {
        display: flex;
      }

      &__footer {
        color: var(--uc-error-error-30);
      }
    }
  }

  &--type-icon,
  &--type-tvchannelicon {
    .resource-upload {
      &__drop-area,
      &__error-message,
      &__progress {
        height: 5.625rem;
        min-width: 5.625rem;

        @media screen and (max-width: 400px) {
          min-width: 5.125rem;
        }
      }

      &__drop-area {
        gap: 0.25rem;

        i {
          font-size: 1.5rem;
        }
      }
    }
  }

  &--type-backgroundimage {
    .resource-upload {
      &__drop-area {
        @media screen and (max-width: variables.$bp-phone) {
          max-height: max-content;
        }
      }
    }
  }

  &__drop-area {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 0.35rem;
    border-radius: 0.25rem;
    color: var(--uc-text-text-primary);
    border: 1px dashed var(--uc-theme-color-40);
    gap: 1rem;
    cursor: pointer;

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

    i {
      font-size: 2.25rem;

      @media screen and (max-width: variables.$bp-phone) {
        font-size: 1.5rem;
      }
    }

    label {
      @include mixins.secondary-body-extrasmall;
      text-align: center;
      cursor: pointer;
    }

    &--dragging {
      color: var(--uc-theme-color-80);
      border-color: var(--uc-theme-color-80);
    }
  }

  &__error-message {
    display: none;
    justify-content: space-between;
    align-items: center;
    position: absolute;
    flex-direction: column;
    top: 0;
    left: 0;
    width: 100%;
    height: 5.625rem;
    height: 7rem;
    padding: 0.75rem 0.35rem;
    border-radius: 0.25rem;
    background: #2a0404;
    z-index: 10;
    gap: 0.25rem;

    &__text {
      @include mixins.secondary-body-extrasmall;
      display: inline-block;
      line-height: 100%;
      color: var(--uc-error-error-30);
      text-align: center;
    }
  }

  &__progress {
    display: none;
    justify-content: center;
    align-items: center;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 7rem;
    background: var(--uc-theme-color-10);
    z-index: 10;

    &__item {
      display: flex;
      width: 60%;
      height: 0.65rem;
      border-radius: 4rem;
      background: var(--uc-black);
    }

    &__bar {
      position: relative;
      top: 0;
      display: inline-block;
      width: 0;
      height: 100%;
      background: var(--uc-white);
      border-radius: 4rem;
    }
  }

  &__footer {
    @include mixins.secondary-body-extrasmall;
    color: var(--uc-text-text-secondary);
    text-align: center;
    overflow: hidden;
    height: 0.9rem;
    margin-top: 0.25rem;

    @media screen and (max-width: variables.$bp-tablet) {
      display: none;
    }

    label {
      text-decoration: underline;
      cursor: pointer;
    }
  }
}

.image-crop {
  position: fixed;
  z-index: var(--uc-vselect-z-index);
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-content: center;
  justify-content: center;
  align-items: center;
  transition: opacity 0.3s ease;
  padding: 3.75rem;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);

  @media screen and (max-width: variables.$bp-phone) {
    justify-content: flex-start;
    padding: 0.625rem;
  }

  &__container {
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%;
    max-width: var(--uc-app-max-width);
    height: 100%;
    min-height: calc(50vh + 10rem);
    border-radius: 1.25rem;
    background: var(--uc-background);
    z-index: 2;
    overflow: hidden;
    gap: 1.25rem;

    @media screen and (max-width: variables.$bp-phone) {
      justify-content: flex-start;
      height: 90vh;
      height: 90dvh;
    }
  }

  &__header {
    display: flex;
    justify-content: space-between;
    padding: 1.25rem;
  }

  &__main {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
    padding-left: 1.25rem;
    padding-right: 1.25rem;
    padding-bottom: 1.25rem;
    overflow-x: hidden;
    overflow-y: auto;
  }

  &__body,
  &__footer {
    width: 100%;
    max-width: 44rem;
    margin-left: auto;
    margin-right: auto;
  }

  &__body {
    margin-top: auto;
    margin-bottom: auto;
    padding-top: 0.5rem;
    padding-bottom: 2rem;

    &__cropper {
      border-radius: 0.5rem;
      padding: 2rem 3rem;
      background-color: var(--uc-black);

      @media screen and (max-width: variables.$bp-phone) {
        padding: 1rem 1rem;
      }
    }

    &__metas {
      @include mixins.secondary-body-extrasmall;
      display: flex;
      justify-content: space-between;
      color: var(--uc-text-text-secondary);
      margin-top: 0.5rem;
      gap: 1rem;

      @media screen and (max-width: variables.$bp-phone) {
        margin-top: 1.25rem;
      }
    }

    &__file-name {
      display: -webkit-box;
      -webkit-line-clamp: 1;
      -webkit-box-orient: vertical;
      overflow: hidden;
      text-overflow: ellipsis;
      max-width: 50%;

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

    &__file-data {
      display: inline-flex;
      gap: 2rem;

      @media screen and (max-width: variables.$bp-phone) {
        gap: 1rem;
      }
    }
  }

  &__footer {
    margin-top: auto;
    margin-bottom: 0;

    &__error {
      @include mixins.secondary-body-extrasmall;
      display: inline-block;
      color: var(--uc-error-error-60);
      margin-bottom: 1rem;
    }

    &__triggers {
      display: flex;
      flex-direction: row;
      gap: 2.5rem;

      button {
        width: 100%;
      }
    }
  }
}
