/**
 * MR -> show: Automerge widget
 *
 */
$tabs-holder-z-index: 250;

.space-children {
  @include clearfix;

  > * {
    float: left;
  }

  > *:not(:first-child) {
    margin-left: 10px;
  }
}

.media-section {
  @include media-breakpoint-down(md) {
    align-items: flex-start;

    .media-body {
      flex-direction: column;
      align-items: flex-start;
    }
  }

  .code-text {
    @include media-breakpoint-up(lg) {
      align-self: center;
      flex: 1;
    }
  }
}

.mr-state-widget {
  .accept-merge-holder {
    .accept-action {
      .accept-merge-request {
        &.ci-preparing,
        &.ci-pending,
        &.ci-running {
          @include btn-blue;
        }

        &.ci-skipped,
        &.ci-failed,
        &.ci-canceled,
        &.ci-error {
          @include btn-red;
        }
      }
    }
  }
}

.mr_source_commit,
.mr_target_commit {
  margin-bottom: 0;

  .commit {
    margin: 0;
    padding: 10px;
    list-style: none;

    &:hover {
      background: none;
    }
  }
}

.commits-empty {
  text-align: center;

  h4 {
    padding-top: 20px;
    padding-bottom: 10px;
  }

  svg {
    width: 230px;
  }
}

.nothing-here-block {
  img {
    width: 230px;
  }
}

.mr-list {
  .merge-request {
    padding: 10px $gl-padding;
    display: flex;

    .issuable-info-container {
      flex: 1;
    }

    .merge-request-title {
      margin-bottom: 2px;

      .ci-status-link {
        svg {
          height: 16px;
          width: 16px;
          position: relative;
          top: 3px;
        }

        &:hover,
        &:focus {
          text-decoration: none;
        }
      }
    }
  }
}

.card-new-merge-request {
  .card-header {
    padding: 5px 10px;
    font-weight: $gl-font-weight-bold;
    line-height: 25px;
  }

  .card-body {
    padding: 10px 5px;
  }

  .card-footer {
    padding: 0;

    .btn {
      min-width: auto;
    }
  }

  .commit {
    .commit-row-title {
      margin-bottom: 4px;
    }

    .item-title {
      @include media-breakpoint-up(sm) {
        width: 45%;
      }
    }

    .avatar {
      left: 0;
      top: 2px;
    }
  }

  .btn-clipboard {
    margin-right: 5px;
    padding: 0;
    background: transparent;
  }

  .ci-status-link {
    margin-right: 5px;
  }
}

.merge-request-select {
  padding-left: 5px;
  padding-right: 5px;
  margin-bottom: 10px;

  &:last-child {
    margin-bottom: 0;
  }

  @include media-breakpoint-up(xs) {
    float: left;
    width: 50%;
    margin-bottom: 0;
  }

  .dropdown-menu-toggle {
    width: 100%;
  }

  .dropdown-menu {
    left: 5px;
    right: 5px;
    width: auto;
  }
}

.issuable-form-select-holder {
  display: inline-block;
  width: 250px;

  .dropdown-menu-toggle {
    width: 100%;
  }
}

.assign-to-me-link {
  padding-left: 12px;
  white-space: nowrap;
}

.table-holder {
  .ci-table {
    th {
      background-color: $white;
      color: $gl-text-color-secondary;
    }
  }
}

.merge-request-tabs-holder,
.epic-tabs-holder {
  top: $header-height;
  z-index: $tabs-holder-z-index;
  margin-left: -$gl-padding;
  margin-right: -$gl-padding;
  padding-left: $gl-padding;
  padding-right: $gl-padding;
  background-color: $body-bg;
  border-bottom: 1px solid $border-color;

  .with-system-header & {
    top: calc(#{$header-height} + #{$system-header-height});
  }

  .with-system-header.with-performance-bar & {
    top: calc(#{$header-height} + #{$system-header-height} + #{$performance-bar-height});
  }

  @include media-breakpoint-up(sm) {
    position: -webkit-sticky;
    position: sticky;
  }

  &.affix {
    left: 0;
    transition: right 0.15s;

    @include media-breakpoint-down(xs) {
      right: 0;
    }
  }

  .nav-links {
    border: 0;
  }
}

.merge-request-tabs-holder.affix .merge-request-tabs-container,
.epic-tabs-holder.affix .epic-tabs-container {
  padding-left: $gl-padding;
  padding-right: $gl-padding;
}

.with-performance-bar {
  .merge-request-tabs-holder,
  .epic-tabs-holder {
    top: calc(#{$header-height} + #{$performance-bar-height});
  }
}

.merge-request-tabs,
.epic-tabs {
  display: flex;
  flex-wrap: nowrap;
  margin-bottom: 0;
  padding: 0;
}

.limit-container-width {
  .merge-request-tabs-container,
  .epic-tabs-container {
    max-width: $limited-layout-width;
    margin-left: auto;
    margin-right: auto;

    .inner-page-scroll-tabs {
      background-color: $white;
      margin-left: -$gl-padding;
      padding-left: $gl-padding;
    }
  }
}

.merge-request-tabs-container,
.epic-tabs-container {
  display: flex;
  justify-content: space-between;

  @include media-breakpoint-down(xs) {
    .discussion-filter-container,
    .line-resolve-all-container {
      margin-bottom: $gl-padding-4;
    }
  }

  .discussion-filter-container {
    &:not(:only-child) {
      margin: $gl-padding-4;
    }
  }

  .merge-request-tabs {
    height: $grid-size * 6;
  }
}

.container-fluid {
  // Negative margins for mobile/tablet screen
  .diffs.tab-pane {
    margin: 0 (-$gl-padding);
  }
}

// Wrap MR tabs/buttons so you don't have to scroll on desktop
@include media-breakpoint-down(md) {
  .merge-request-tabs-container,
  .epic-tabs-container {
    flex-direction: column-reverse;
  }
}

@include media-breakpoint-down(lg) {
  .right-sidebar-expanded {
    .merge-request-tabs-container,
    .epic-tabs-container {
      flex-direction: column-reverse;
      align-items: flex-start;
    }
  }
}

.limit-container-width:not(.container-limited) {
  .merge-request-tabs-holder:not(.affix) .merge-request-tabs-container,
  .epic-tabs-holder:not(.affix) .epic-tabs-container {
    max-width: $limited-layout-width - ($gl-padding * 2);
  }
}

.fork-sprite {
  margin-right: -5px;
}

// Hack alert: we've rewritten `btn` class in a way that
// we've broken it and it is not possible to use with `btn-link`
// which causes a blank button when it's disabled and hovering
// The css in here is the boostrap one
.btn-link-retry {
  &[disabled] {
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.65;

    &:hover {
      color: $gray-500;
      text-decoration: none;
    }
  }
}

.merge-request-details .file-finder-overlay.diff-file-finder {
  position: fixed;
  z-index: 99999;
  background: $black-transparent;
}

.mr-compare {
  .diff-file .file-title-flex-parent {
    top: calc(#{$header-height} + #{$mr-tabs-height} + 36px);

    .with-performance-bar & {
      top: calc(#{$performance-bar-height} + #{$header-height} + #{$mr-tabs-height} + 36px);
    }
  }
}
