// stylelint-disable declaration-no-important

// Margin and Padding

@each $breakpoint in map-keys($grid-breakpoints) {
  @include media-breakpoint-up($breakpoint) {
    $infix: breakpoint-infix($breakpoint, $grid-breakpoints);

    @each $prop, $abbrev in (margin: m, padding: p) {
      @each $size, $length in $spacers {

        .#{$abbrev}#{$infix}-#{$size} { #{$prop}: $length !important; }
        .#{$abbrev}t#{$infix}-#{$size},
        .#{$abbrev}y#{$infix}-#{$size} {
          #{$prop}-top: $length !important;
        }
        html[dir="ltr"] .#{$abbrev}r#{$infix}-#{$size}{
            #{$prop}-right: $length !important;
        }
        html[dir="rtl"] .#{$abbrev}r#{$infix}-#{$size}{
            #{$prop}-left: $length !important;
        }
        .#{$abbrev}x#{$infix}-#{$size} {
          #{$prop}-right: $length !important;
        }
        .#{$abbrev}b#{$infix}-#{$size},
        .#{$abbrev}y#{$infix}-#{$size} {
          #{$prop}-bottom: $length !important;
        }
        html[dir="ltr"] .#{$abbrev}l#{$infix}-#{$size}{
            #{$prop}-left: $length !important;
        }
        html[dir="rtl"] .#{$abbrev}l#{$infix}-#{$size}{
            #{$prop}-right: $length !important;
        }
        .#{$abbrev}x#{$infix}-#{$size} {
          #{$prop}-left: $length !important;
        }
      }
    }

    // Some special margin utils
    .m#{$infix}-auto { margin: auto !important; }
    .mt#{$infix}-auto,
    .my#{$infix}-auto {
      margin-top: auto !important;
    }
    .mr#{$infix}-auto,
    .mx#{$infix}-auto {
      html[dir="ltr"] &{
        margin-right: auto !important;
      }
      html[dir="rtl"] &{
        margin-left: auto !important;
      }
    }
    .mb#{$infix}-auto,
    .my#{$infix}-auto {
      margin-bottom: auto !important;
    }
    .ml#{$infix}-auto,
    .mx#{$infix}-auto {
      html[dir="ltr"] &{
        margin-left: auto !important;
      }
      html[dir="rtl"] &{
        margin-right: auto !important;
      }
    }
  }
}
