@use "sass:string";
@use "sass:list";

@use "../variables" as *;
@use "../utils" as *;

// Padding class worked for all containers (with prefix)
.mie {
  @each $indent-size-type in ("padding", "margin") {
    $indent-size-short-key: string.slice($indent-size-type, 1, 1); // get "p" or "m"

    // indent for all sides.
    @each $name, $size in $indent-size {
      $size-postfix: if($name != "medium", "-" + $name, "");
      $class-name: $indent-size-short-key + $size-postfix;

      &.#{$class-name} {
        #{$indent-size-type}: $size !important;
      }
    }

    // horizontally & vertically sides
    @each $side in ("horizontal", "vertical") {
      $side-short-key: string.slice($side, 1, 1);

      @each $name, $size in $indent-size {
        $size-postfix: if($name != "medium", "-" + $name, "");

        $start: $indent-size-type + "-" + if($side == "horizontal", "left", "top");
        $end: $indent-size-type + "-" + if($side == "horizontal", "right", "bottom");
        $class-name: $indent-size-short-key + $side-short-key + $size-postfix;

        &.#{$class-name} {
          #{$start}: $size !important;
          #{$end}: $size !important;
        }
      }
    }

    // directly side
    @each $side in ("top", "right", "bottom", "left") {
      $side-short-key: string.slice($side, 1, 1);

      @each $name, $size in $indent-size {
        $size-postfix: if($name != "medium", "-" + $name, "");
        $class-name: $indent-size-short-key + $side-short-key + $size-postfix;

        &.#{$class-name} {
          #{$indent-size-type}-#{$side}: $size !important;
        }
      }
    }
  }
}
