/**
  @prop --fw-file-uploader-border: border color for file uploader
  @prop --max-attachment-width: max width for the attachment block
  @prop --max-attachment-height: max-height for the attachment block
**/

:host {
  display: block;
  --max-attachment-block-width: 320px;
  --max-attachment-block-height: auto;
}

.file-uploader {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 360px;

  &__header {
    display: flex;
    flex-direction: column;
    gap: 16px;

    &__block {
      display: flex;
      flex-direction: row;
      flex-wrap: wrap;
      justify-content: space-between;
      line-height: 24px;

      &__title {
        font-weight: 600;
        font-size: 16px;
        letter-spacing: -0.32px;
        color: $color-elephant-900;
        flex-grow: 0;

        &--uniform {
          font-size: 12px;
          color: $color-smoke-700;
        }

        &.required::after {
          content: '*';
          position: relative;
          display: inline-block;
          inset-block-start: 2px;
          font-size: 14px;
          color: $color-persimmon-800;
          -webkit-padding-start: 2px;
          padding-inline-start: 2px;
          font-weight: 700;
        }
      }

      &__option {
        flex-grow: 0;

        a {
          text-decoration: none;
          color: $color-azure-800;
          font-size: 12px;
          letter-spacing: 0.07px;

          &:hover,
          &:focus {
            cursor: pointer;
          }
        }
      }
    }
  }

  &__body {
    display: flex;
    width: 100%;
    min-width: 320px;
    min-height: 153px;
    background: $color-milk;
    justify-content: center;
    border-radius: 8px;

    &--uniform {
      margin-block-start: -12px;
    }

    &--hide {
      display: none;
    }

    &__dropzone,
    &__files {
      position: relative;
      display: flex;
      flex-direction: column;
      width: 100%;
      justify-content: center;
    }

    &__dropzone {
      align-items: center;
      cursor: pointer;
      border: 1px dashed var(--fw-file-uploader-border, $color-smoke-200);
      border-radius: 8px;

      &--disabled {
        opacity: 0.8;
      }

      &--error {
        border: 1px dashed
          var(--fw-file-uploader-error-border, $color-persimmon-800);

        &:hover,
        &:focus {
          border: 1px solid
            var(--fw-file-uploader-error-border, $color-persimmon-800);
        }

        /* stylelint-disable-next-line a11y/no-outline-none */
        &:focus-visible {
          outline: 0;
        }
      }

      &:hover,
      &:focus {
        position: cursor;
      }

      &__center {
        display: flex;
        flex-direction: column;
        width: 100%;
        height: 100%;
        justify-content: space-between;

        &__clickable {
          display: flex;
          flex-direction: column;
          align-items: center;
          justify-content: center;
          margin-inline: 0;
          margin-block: auto;
          padding-block-start: 28px;
          padding-block-end: 32px;

          &__icon {
            margin-block-end: 7px;
          }

          &__text,
          &__error {
            line-height: 20px;
            font-size: 14px;
            font-weight: 500;
            color: $color-elephant-900;
            margin-block-start: 9px;
            margin-block-end: 3px;

            .highlight {
              color: $color-azure-800;

              &:hover,
              &:focus {
                cursor: pointer;
              }
            }
          }

          &__error {
            color: $color-persimmon-900;
          }

          &__description {
            line-height: 20px;
            font-size: 12px;
            color: $color-smoke-300;
          }
        }
      }
    }

    &__files {
      box-sizing: border-box;
      justify-content: center;

      &__center {
        display: flex;
        flex-direction: column;
        gap: 12px;
      }

      &__restrict {
        max-width: var(--max-attachment-block-width);
        max-height: var(--max-attachment-block-height);
        overflow-y: auto;
      }
    }

    &--on-drag {
      border: 1px dashed var(--fw-file-uploader-border, $color-azure-800);
      background: $color-azure-50;
    }
  }
}
