@use "../../../scss/globals.scss";

.download-settings-modal {
  &__container {
    display: flex;
    flex-direction: column;
    gap: calc(globals.$spacing-unit * 3);
    width: 100%;
  }

  &__downloads-path-field {
    display: flex;
    flex-direction: column;
    gap: globals.$spacing-unit;
  }

  &__hint-text {
    font-size: 12px;
    color: globals.$body-color;
  }

  &__downloaders-list-wrapper {
    border: 1px solid globals.$border-color;
    overflow: hidden;
    background-color: globals.$dark-background-color;
  }

  &__downloaders-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-height: 200px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;

    &::-webkit-scrollbar {
      width: 8px;
    }

    &::-webkit-scrollbar-track {
      background: transparent;
    }

    &::-webkit-scrollbar-thumb {
      background: rgba(255, 255, 255, 0.2);
      border-radius: 12px;
    }

    &::-webkit-scrollbar-thumb:hover {
      background: rgba(255, 255, 255, 0.3);
    }
  }

  &__downloader-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: calc(globals.$spacing-unit * 1.5) calc(globals.$spacing-unit * 2);
    border: 1px solid transparent;
    border-bottom: 1px solid globals.$border-color;
    border-radius: 0;
    background-color: transparent;
    cursor: pointer;
    transition:
      background-color 0.15s ease,
      border-color 0.15s ease;
    color: globals.$body-color;
    font-size: 14px;
    text-align: left;
    height: 48px;
    box-sizing: border-box;

    &:hover {
      background-color: rgba(255, 255, 255, 0.05);
    }

    &--selected {
      background-color: rgba(255, 255, 255, 0.08);
    }

    &--last {
      border-bottom: none;
    }

    &:disabled {
      cursor: default;

      &:hover {
        background-color: transparent;
      }

      .download-settings-modal__downloader-name {
        opacity: 0.5;
      }

      .download-settings-modal__availability-indicator-wrapper {
        opacity: 0.5;
      }
    }
  }

  &__downloader-item-wrapper {
    display: flex;
    flex-direction: column;
  }

  &__check-icon {
    color: white;
    flex-shrink: 0;
  }

  &__check-icon-wrapper {
    margin-left: auto;
    display: flex;
    align-items: center;
    width: 20px;
    height: 20px;
    justify-content: center;
    flex-shrink: 0;
  }

  &__recommendation-badge {
    margin-left: auto;
    display: flex;
    align-items: center;
    height: 20px;
    justify-content: center;
    flex-shrink: 0;

    .badge {
      padding: 2px 6px;
      font-size: 10px;
      line-height: 1.2;
      height: 16px;
      display: flex;
      align-items: center;
      white-space: nowrap;
    }
  }

  &__availability-indicator-wrapper {
    display: flex;
    align-items: center;
    flex-shrink: 0;
  }

  &__availability-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;

    &--available {
      background-color: #22c55e;
      box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
    }

    &--unavailable {
      background-color: #ef4444;
      box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
    }

    &--not-present {
      background-color: #6b7280;
      box-shadow: 0 0 6px rgba(107, 114, 128, 0.5);
    }

    &--warning {
      background-color: #eab308;
      box-shadow: 0 0 6px rgba(234, 179, 8, 0.5);
    }
  }

  @keyframes pulse {
    0%,
    100% {
      opacity: 1;
      transform: scale(1);
    }
    50% {
      opacity: 0.7;
      transform: scale(1.1);
    }
  }

  &__availability-indicator--pulsating {
    animation: pulse 2s ease-in-out infinite;
  }

  &__path-error {
    cursor: pointer;

    &:hover {
      text-decoration: underline;
    }
  }

  &__change-path-button {
    align-self: flex-end;
  }

  &__loading-spinner {
    animation: spin 1s linear infinite;
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}
