@import '../../styles/common';

$image-size: rem(20px);
$item-min-height: rem(40px);
$item-vertical-padding: ($item-min-height - line-height(body)) / 2;

.ActionList {
  list-style: none;
  margin: 0;
  padding: spacing(tight) 0;
}

.Section-withoutTitle:not(:first-child) {
  border-top: border();
  margin-top: spacing(tight);
  padding-top: spacing(tight);
}

.Actions {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: border();
}

.ActionList,
.Section:first-child {
  // stylelint-disable-next-line selector-max-class, selector-max-combinators, selector-max-specificity
  > .Section-withoutTitle .Actions {
    border-top: none;
  }
}

.Title {
  @include text-style-subheading;
  padding: (spacing(tight) * 1.5) spacing();
}

.Item {
  @include unstyled-button;
  @include unstyled-link;
  display: block;
  width: 100%;
  min-height: $item-min-height;
  padding: $item-vertical-padding spacing();
  text-align: left;
  cursor: pointer;
  border-radius: 0;

  &.active {
    @include state(active);
  }

  &:active {
    @include state(active);

    &:hover {
      @include state(active, hover);

      // stylelint-disable-next-line selector-max-specificity
      &:focus {
        @include state(active, hover, focused);
      }
    }
  }

  &:hover {
    @include state(hover);

    &:focus {
      @include state(hover, focused);
    }
  }

  &:focus {
    @include state(focused);
  }

  &.destructive {
    @include recolor-icon(color('red', 'dark'));
    color: color('red', 'dark');

    &:active {
      @include state(active-destructive);

      // stylelint-disable-next-line selector-max-specificity
      &:hover {
        @include state(active-destructive, hover-destructive);

        // stylelint-disable-next-line selector-max-specificity, max-nesting-depth
        &:focus {
          @include state(
            active-destructive,
            hover-destructive,
            focused-destructive
          );
        }
      }
    }

    &:hover {
      @include state(hover-destructive);

      // stylelint-disable-next-line selector-max-specificity
      &:focus {
        @include state(hover-destructive, focused-destructive);
      }
    }

    &:focus {
      @include state(focused-destructive);
    }
  }

  &.disabled {
    @include state(disabled);
    color: color('ink', 'lightest');
    pointer-events: none;

    .Image {
      @include recolor-icon(color('ink', 'lightest'), color('white'));
    }
  }

  &::-moz-focus-inner {
    border: none;
  }
}

.Content {
  display: flex;
  align-items: center;
}

.Image {
  @include recolor-icon(color('ink', 'light'), color('white'));
  display: flex;
  flex: 0 0 auto;
  justify-content: center;
  align-items: center;
  height: $image-size;
  width: $image-size;
  border-radius: border-radius();

  // We need the negative margin to ensure that the image does not set
  // the minimum height of the action item.
  margin: (-0.5 * $image-size) spacing() (-0.5 * $image-size) 0;
  background-size: cover;
  background-position: center center;
}

.Text {
  @include layout-flex-fix;
  flex: 1 1 auto;
}

.BadgeWrapper {
  margin-left: spacing();
}
