:host {
  width: 100%;
  height: 100%;
  display: block;
  container-type: size;
  transition: all 0.3s 0s ease;
  border-radius: var(--border-radius);
  overflow: hidden;
}

.jb-file-input-web-component {
  background-color: var(--bg-color);
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
  transition: all 0.3s 0s ease;

  :where(.placeholder-section, .file-wrapper, .reselect-button) {
    all: unset;
    box-sizing: border-box;
  }

  :where(.placeholder-section, .file-wrapper, .reselect-button):disabled {
    cursor: default;
  }

  :where(.placeholder-section, .file-wrapper, .reselect-button):focus-visible {
    outline: 2px solid var(--jb-file-input-focus-ring-color, Highlight);
    outline-offset: 2px;
  }

  &.--has-error {
    border: solid 1px var(--border-color-error);
    border-bottom: solid 3px var(--border-color-error);
    background-color: var(--bg-color-error);
  }

  /*TODO: manage hover and active in disabled and loading state(loading should not have hover state)*/
  &:hover {
    background-color: var(--bg-color-hover);
  }

  &:active {
    background-color: var(--bg-color-pressed);
  }

  .title {
    color: var(--placeholder-title-color);
    font-variation-settings: "wght" 600;
    line-height: 1.5rem;
    text-box-trim: trim-both;
    text-box-edge: ex alphabetic;
    font-size: 1rem;

    @container (max-height:3rem) {
      font-size: 0.75rem;
      line-height: 0.75rem;
    }
  }

  .icon-wrapper {
    height: 4rem;

    @container (max-height: 8rem) {
      height: 100%;
    }

    svg,
    jb-loading {
      height: 100%;
      aspect-ratio: 1 / 1;
      fill: var(--icon-base-color);
      color: var(--icon-base-color);

      .primary-part {
        fill: var(--icon-primary-color);
        color: var(--icon-primary-color);
      }

    }
  }

  .section-wrapper {
    width: 100%;
    height: 100%;
    display: flex;

    justify-content: center;
    align-items: center;
    flex-direction: column;
    padding: var(--padding);
    gap: 0.5rem;
    box-sizing: border-box;

    @container (max-height: 5rem) {
      flex-direction: row;
    }

    @container (max-height: 4rem) {
      padding: 0.5rem;
    }
  }

  .placeholder-section {
    display: var(--display-placeholder);
    width: 100%;
    height: 100%;

    .placeholder-wrapper {
      cursor: pointer;

      .icon-wrapper {}

      .placeholder-title {
        color: var(--placeholder-title-color);
      }
    }
  }

  .upload-section {
    display: var(--display-upload);
    width: 100%;
    height: 100%;
    cursor: default;

    .upload-wrapper {
      position: relative;
      width: 100%;
      height: 100%;

      .upload-bg {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        transition: all 0.3s 0s ease;
        height: 100%;
        background: var(--loading-bg);
        z-index: 0;
        clip-path: polygon(0 0, 0 100%, var(--upload-percent, 0%) 100%, var(--upload-percent, 0%) 0);
      }

      .loading-content {
        position: relative;
        z-index: 1;

        .loading-icon {
          --jb-loading-color: var(--upload-loading-color);
        }

        .uploading-title {
          color: var(--loading-color);
        }
      }
    }
  }

  .file-section {
    display: var(--display-file);
    width: 100%;
    height: 100%;
    position: relative;

    .file-wrapper {
      cursor: pointer;

      .file-name {
        color: var(--file-name-color);
      }
    }

    &:hover .file-overlay,
    &:focus-within .file-overlay {
      opacity: 1;
    }

    .file-overlay {
      cursor: pointer;
      opacity: 0;
      transition: all 0.3s 0s ease;
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background-color: var(--overlay-bg-color);
      backdrop-filter: blur(0.5rem);
      z-index: 1;
      overflow: hidden;
      border-radius: var(--border-radius);

      display: flex;
      justify-content: center;
      align-items: center;
      gap: 1rem;
      flex-wrap: wrap;

      @container (max-height:3rem) {
        font-size: 0.75rem;
        line-height: 0.75rem;


      }

      jb-button {
        @container (max-height:3rem) {
          /*all variables copies from size sm of jb-button*/
          --jb-button-height: var(--overlay-button-height-sm);
          --jb-button-padding: var(--overlay-button-padding-sm);
          --jb-button-border-radius: var(--overlay-button-border-radius-sm);
          --jb-button-icon-size: var(--overlay-button-icon-size-sm)
        }

        @container (max-height:2rem) {
          /*all variables copies from size xs of jb-button*/
          --jb-button-height: var(--overlay-button-height-xs);
          --jb-button-padding: var(--overlay-button-padding-xs);
          --jb-button-border-radius: var(--overlay-button-border-radius-xs);
          --jb-button-icon-size: var(--overlay-button-icon-size-xs)
        }

        &.download-button {
          display: var(--download-button-display, block);
        }
      }

      .reselect-button {
        cursor: pointer;
        background-color: transparent;
        border-radius: 1rem;
        padding: 0.25rem 0.5rem;
        color: var(--reselect-button-color);
      }
    }
  }

}
