@import "vars";
$dropify-width: 100%;
$dropify-height: 200px;
$dropify-font-family: $font-family-sans-serif;
$dropify-font-size: 14px;
$dropify-line-height: 22px;
$dropify-text-color: $text-color;
$dropify-icon-color: #ccc;
$dropify-background: #fff;
$dropify-border-size: 2px;
$dropify-border-color: $border-color-base;
$dropify-infos-background: rgba(#000, (70/100));
$dropify-infos-color: #fff;
$dropify-clear-color: #fff;
$dropify-error-color: $brand-danger;
$dropify-stripes: #f6f6f6;
$dropify-font-path: "./";

@font-face {
  font-family: "dropify";
  font-style: normal;
  font-weight: normal;
  src: url("#{$dropify-font-path}/dropify.eot");
  src: url("#{$dropify-font-path}/dropify.eot#iefix") format("embedded-opentype"), url("#{$dropify-font-path}/dropify.woff") format("woff"), url("#{$dropify-font-path}/dropify.ttf") format("truetype"), url("#{$dropify-font-path}/dropify.svg#dropify") format("svg");
}

[class^="dropify-font-"]:before, [class*=" dropify-font-"]:before, .dropify-font:before {
  display: inline-block;
  width: 1em;
  margin-right: .2em;
  margin-left: .2em;
  font-family: "dropify";
  font-style: normal;
  font-weight: normal;
  font-variant: normal;
  line-height: 1em;
  text-align: center;
  text-decoration: inherit;
  text-transform: none;
  speak: none;
}

.dropify-font-upload:before {
  content: "\e800";
}

.dropify-font-file:before {
  content: "\e801";
}

.dropify-wrapper {
  position: relative;
  display: block;
  width: $dropify-width;
  max-width: 100%;
  height: $dropify-height;
  padding: 5px 10px;
  overflow: hidden;
  font-family: $dropify-font-family;
  font-size: $dropify-font-size;
  line-height: $dropify-line-height;
  color: $dropify-text-color;
  text-align: center;
  cursor: pointer;
  background-color: $dropify-background;
  background-image: none;
  border: $dropify-border-size solid $dropify-border-color;

  &:hover {
    background-image: linear-gradient(-45deg, $dropify-stripes 25%, transparent 25%, transparent 50%, $dropify-stripes 50%, $dropify-stripes 75%, transparent 75%, transparent);
    background-size: 30px 30px;
    animation: stripes 2s linear infinite;
  }

  &.has-preview {
    .dropify-clear {
      display: block;
    }
  }

  &.has-error {
    .dropify-message .dropify-error {
      display: block;
    }
  }

  &.disabled {
    input {
      cursor: not-allowed;
    }

    &:hover {
      background-image: none;
      animation: none;
    }

    .dropify-message {
      text-decoration: line-through;
      opacity: .5;
    }

    .dropify-infos-message {
      display: none;
    }
  }

  input {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 5;
    width: 100%;
    height: 100%;
    cursor: pointer;
    opacity: 0;
  }

  .dropify-message {
    position: relative;
    top: 50%;
    transform: translateY(-50%);

    span.file-icon {
      @extend .dropify-font;
      @extend .dropify-font-upload;
      font-size: 50px;
      color: $dropify-icon-color;
    }

    p {
      margin: 5px 0 0;

      &.dropify-error {
        display: none;
        font-weight: $font-weight-medium;
        color: $dropify-error-color;
      }
    }
  }

  .dropify-clear {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 7;
    display: none;
    padding: 4px 8px;
    font-family: $dropify-font-family;
    font-size: 11px;
    font-weight: $font-weight-medium;
    color: $dropify-clear-color;
    text-transform: uppercase;
    background: none;
    border: 2px solid $dropify-clear-color;
    opacity: 0;
    transition: all .15s linear;

    &:hover {
      background: rgba($dropify-clear-color, (20/100));
    }
  }

  .dropify-preview {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1;
    display: none;
    width: 100%;
    height: 100%;
    padding: 5px;
    overflow: hidden;
    text-align: center;
    background-color: $dropify-background;

    .dropify-render {
      img {
        position: relative;
        top: 50%;
        max-width: 100%;
        max-height: 100%;
        background-color: $dropify-background;
        transition: border-color .15s linear;
        transform: translate(0, -50%);
      }

      i {
        position: absolute;
        top: 50%;
        left: 50%;
        font-size: 70px;
        color: #777;
        transform: translate(-50%, -50%);
      }

      .dropify-extension {
        position: absolute;
        top: 50%;
        left: 50%;
        width: 42px;
        margin-top: 10px;
        overflow: hidden;
        font-size: 13px;
        font-weight: $font-weight-bold;
        text-overflow: ellipsis;
        text-transform: uppercase;
        letter-spacing: -0.03em;
        white-space: nowrap;
        transform: translate(-50%, -50%);
      }
    }

    .dropify-infos {
      position: absolute;
      top: 0;
      right: 0;
      bottom: 0;
      left: 0;
      z-index: 3;
      background: $dropify-infos-background;
      opacity: 0;
      transition: opacity .15s linear;

      .dropify-infos-inner {
        position: absolute;
        top: 50%;
        width: 100%;
        padding: 0 20px;
        transition: all .2s ease;
        transform: translate(0, -40%);
        backface-visibility: hidden;

        p {
          position: relative;
          width: 100%;
          padding: 0;
          margin: 0;
          overflow: hidden;
          line-height: 25px;
          color: $dropify-infos-color;
          text-align: center;
          text-overflow: ellipsis;
          white-space: nowrap;
          // font-weight: bold;

          &.dropify-filename {
            span.file-icon {
              @extend .dropify-font;
              //@extend .dropify-font-empty;
              margin-right: 2px;
            }
          }

          &.dropify-infos-message {
            position: relative;
            padding-top: 15px;
            margin-top: 15px;
            font-size: 12px;
            opacity: .5;

            &::before {
              position: absolute;
              top: 0;
              left: 50%;
              width: 30px;
              height: 2px;
              content: "";
              background: $dropify-infos-color;
              transform: translate(-50%, 0);
            }
          }
        }
      }
    }
  }

  &:hover {
    .dropify-clear {
      opacity: 1;
    }

    .dropify-preview {
      .dropify-infos {
        opacity: 1;

        .dropify-infos-inner {
          margin-top: -5px;
        }
      }
    }
  }

  &.touch-fallback {
    height: auto !important;

    &:hover {
      background-image: none;
      animation: none;
    }

    .dropify-preview {
      position: relative;
      padding: 0;

      .dropify-render {
        position: relative;
        display: block;

        .dropify-font-file {
          position: relative;
          top: 0;
          left: 0;
          transform: translate(0, 0);

          &::before {
            margin-top: 30px;
            margin-bottom: 30px;
          }
        }

        img {
          position: relative;
          transform: translate(0, 0);
        }
      }

      .dropify-infos {
        position: relative;
        background: transparent;
        opacity: 1;

        .dropify-infos-inner {
          position: relative;
          top: 0;
          padding: 5px 90px 5px 0;
          transform: translate(0, 0);

          p {
            position: relative;
            width: 100%;
            padding: 0;
            margin: 0;
            overflow: hidden;
            line-height: 25px;
            color: $dropify-text-color;
            text-align: left;
            text-overflow: ellipsis;
            white-space: nowrap;

            &.dropify-filename {
              font-weight: $font-weight-medium;
            }

            &.dropify-infos-message {
              position: relative;
              padding-top: 0;
              margin-top: 0;
              font-size: 11px;
              opacity: 1;

              &::before {
                display: none;
              }
            }
          }
        }
      }
    }

    .dropify-message {
      padding: 40px 0;
      transform: translate(0, 0);
    }

    .dropify-clear {
      top: auto;
      bottom: 23px;
      color: $dropify-text-color;
      border-color: rgba($dropify-text-color, (70/100));
      opacity: 1;
    }

    &.has-preview {
      .dropify-message {
        display: none;
      }
    }

    &:hover {
      .dropify-preview {
        .dropify-infos {
          .dropify-infos-inner {
            margin-top: 0;
          }
        }
      }
    }
  }
}

@keyframes stripes {
  from {
    background-position: 0 0;
  }

  to {
    background-position: 60px 30px;
  }
}
