@mixin rtl-make-col($size, $columns: $grid-columns) {
  @if not($enable-flex) {
    float: right;
  }
}

@mixin rtl-make-col-offset($size, $columns: $grid-columns) {
  margin-left: inherit;
  margin-right: percentage($size / $columns);
}

@mixin rtl-make-col-push($size, $columns: $grid-columns) {
  left: auto;
  right: if($size > 0, percentage($size / $columns), auto);
}

@mixin rtl-make-col-pull($size, $columns: $grid-columns) {
  right: auto;
  left: if($size > 0, percentage($size / $columns), auto);
}

@mixin rtl-make-col-modifier($type, $size, $columns) {
  @if $type == push {
    @include rtl-make-col-push($size, $columns);
  } @else if $type == pull {
    @include rtl-make-col-pull($size, $columns);
  } @else if $type == offset {
    @include rtl-make-col-offset($size, $columns);
  }
}

@mixin rtl-make-grid-columns($columns: $grid-columns, $gutters: $grid-gutter-widths, $breakpoints: $grid-breakpoints) {
  
  $breakpoint-counter: 0;
  @each $breakpoint in map-keys($breakpoints) {
    $breakpoint-counter: ($breakpoint-counter + 1);

    @include media-breakpoint-up($breakpoint, $breakpoints) {
      
      @for $i from 1 through $columns {
        .col-#{$breakpoint}-#{$i} {
          @include rtl-make-col($i, $columns);
        }
      }

      @each $modifier in (pull, push) {
        @for $i from 0 through $columns {
          .#{$modifier}-#{$breakpoint}-#{$i} {
            @include rtl-make-col-modifier($modifier, $i, $columns)
          }
        }
      }

      // `$columns - 1` because offsetting by the width of an entire row isn't possible
      @for $i from 0 through ($columns - 1) {
        @if $breakpoint-counter != 1 or $i != 0 { // Avoid emitting useless .offset-xs-0
          .offset-#{$breakpoint}-#{$i} {
            @include rtl-make-col-modifier(offset, $i, $columns)
          }
        }
      }
    }
  }
}

// TRL Columns
//
// Overrides the Bootstrap's gird system
// Not all of it but jsut the necessary ones
@if $enable-grid-classes {
  @include rtl-make-grid-columns();
}
