/**
 * MR -> show: Automerge widget
 *
 */

.space-children {
  @include clearfix;

  > * {
    float: left;
  }

  > *:not(:last-child) {
    margin-right: 10px;
  }
}

.mr-widget-heading {
  position: relative;
  border: 1px solid $border-color;
  border-radius: 4px;

  &:not(.deploy-heading)::before {
    content: '';
    border-left: 1px solid $theme-gray-200;
    position: absolute;
    left: 32px;
    top: -17px;
    height: 16px;
  }
}

.mr-section-container {
  border: 1px solid $border-color;
  border-radius: $border-radius-default;
  border-top: 0;
}

.mr-widget-heading,
.mr-widget-section,
.mr-widget-footer {
  padding: $gl-padding;
}

.mr-state-widget {
  color: $gl-text-color;

  .mr-widget-section,
  .mr-widget-footer {
    border-top: solid 1px $border-color;
  }

  .mr-widget-footer {
    padding: 0;
  }

  form {
    margin-bottom: 0;

    .clearfix {
      margin-bottom: 0;
    }
  }

  label {
    margin-bottom: 0;
  }

  .btn {
    font-size: $gl-font-size;

    &[disabled] {
      opacity: 0.3;
    }

    &.dropdown-toggle {
      .fa {
        color: inherit;
      }
    }
  }

  .accept-merge-holder {
    .accept-action {
      display: inline-block;
      float: left;

      .accept-merge-request {
        &.ci-pending,
        &.ci-running {
          @include btn-blue;
        }

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

    .accept-control {
      display: inline-block;
      float: left;
      margin: 0;
      margin-left: 20px;
      padding: 5px;
      padding-top: 8px;
      line-height: 20px;

      &.right {
        float: right;
        padding-right: 0;
      }

      .modify-merge-commit-link {
        padding: 0;

        background-color: transparent;
        border: 0;

        color: $gl-text-color;

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

      .merge-param-checkbox {
        margin: 0;
      }

      a .fa-question-circle {
        color: $gl-text-color-secondary;

        &:hover,
        &:focus {
          color: $link-hover-color;
        }
      }
    }
  }

  .ci-widget {
    color: $gl-text-color;
    display: flex;
    align-items: center;
    justify-content: space-between;

    @include media-breakpoint-down(xs) {
      flex-wrap: wrap;
    }

    .ci-widget-content {
      display: flex;
      align-items: center;
    }
  }

  .mr-widget-icon {
    font-size: 22px;
    margin-right: $status-icon-margin;
  }

  .ci-status-icon svg {
    margin: 3px 0;
    position: relative;
    overflow: visible;
    display: block;
  }

  .mr-widget-pipeline-graph {
    .dropdown-menu {
      z-index: 300;
    }
  }

  .mini-pipeline-graph-dropdown-toggle {
    vertical-align: top;
  }

  .normal {
    flex: 1;
  }

  .capitalize {
    text-transform: capitalize;
  }

  .label-branch {
    @extend .ref-name;

    color: $gl-text-color;
    font-weight: normal;
    overflow: hidden;
    word-break: break-all;

    &.label-truncated {
      position: relative;
      display: inline-block;
      width: 250px;
      margin-bottom: -3px;
      white-space: nowrap;
      text-overflow: clip;
      line-height: 14px;

      &::after {
        position: absolute;
        content: '...';
        right: 0;
        font-family: $regular_font;
        background-color: $gray-light;
      }
    }
  }

  .mr-widget-body {
    line-height: 28px;

    @include clearfix;

    &.media > *:first-child {
      margin-right: 10px;
    }

    .approve-btn {
      margin-right: 5px;
    }

    h4 {
      float: left;
      font-weight: $gl-font-weight-bold;
      font-size: 14px;
      line-height: inherit;
      margin-top: 0;
      margin-bottom: 0;

      &.has-conflicts .fa-exclamation-triangle {
        color: $gl-warning;
      }

      time {
        font-weight: $gl-font-weight-normal;
      }
    }

    .btn-grouped {
      margin-left: 0;
      margin-right: 7px;
    }

    label {
      font-weight: $gl-font-weight-normal;
    }

    .spacing {
      margin: 0 0 0 10px;
    }

    .bold {
      font-weight: $gl-font-weight-bold;
      color: $gl-gray-light;
    }

    .state-label {
      font-weight: $gl-font-weight-bold;
      padding-right: 10px;
    }

    .danger {
      color: $gl-danger;
    }

    .spacing,
    .bold {
      vertical-align: middle;
    }

    .dropdown-menu {
      li a {
        padding: 5px;
      }

      .merge-opt-icon {
        line-height: 1.5;
      }

      .merge-opt-title {
        margin-left: 8px;
      }
    }

    .dropdown-toggle {
      .fa {
        margin-left: 0;
        color: inherit;
      }
    }

    .has-custom-error {
      display: inline-block;
    }

    @include media-breakpoint-down(xs) {
      p {
        font-size: 13px;
      }

      .btn-grouped {
        float: none;
        margin-right: 0;
      }

      .accept-action {
        width: 100%;
        text-align: center;
      }

      .accept-control {
        width: 100%;
        text-align: center;
        margin: 0;
      }
    }

    .commit-message-editor {
      label {
        padding: 0;
      }
    }

    &.mr-widget-empty-state {
      line-height: 20px;

      .artwork {
        margin-bottom: $gl-padding;
      }

      .text {
        span {
          font-weight: $gl-font-weight-bold;
        }

        p {
          margin-top: $gl-padding;
        }
      }
    }
  }

  .mr-widget-help {
    padding: 10px 16px 10px 48px;
    font-style: italic;
  }

  .ci-coverage {
    float: right;
  }

  .stop-env-container {
    color: $gl-text-color;
    float: right;

    a {
      color: $gl-text-color;
    }
  }
}

.mr-widget-body-controls {
  flex-wrap: wrap;
}

.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  0 10px 15px;
    position: relative;
    display: -webkit-flex;
    display: flex;

    .issue-info-container {
      -webkit-flex: 1;
      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;
        }
      }
    }
  }

  .merge-request-labels {
    display: inline-block;
  }
}

.merge-request-angle {
  text-align: center;
  margin: 0 auto;
  font-size: 2em;
  line-height: 1.1;
}

// hide mr close link for inline diff comment form
.diff-file .close-mr-link,
.diff-file .reopen-mr-link {
  display: none;
}

#modal_merge_info .modal-dialog {
  .dark {
    margin-right: 40px;
  }

  .btn-clipboard {
    margin-right: 20px;
    margin-top: 5px;
    position: absolute;
    right: 0;
  }
}

.mr-links {
  padding-left: $status-icon-size + $status-icon-margin;
}

.mr-info-list {
  clear: left;
  position: relative;
  padding-top: 4px;

  p {
    margin: 0;
    position: relative;
    padding: 4px 0;

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

  &.mr-memory-usage {
    p {
      float: left;
    }

    .memory-graph-container {
      float: left;
      margin-left: 5px;
    }
  }
}

.merge-request-details .content-block {
  border-bottom: 0;
}

.mr-source-target {
  display: flex;
  flex-wrap: wrap;
  border-radius: $border-radius-default;
  padding: $gl-padding;
  border: 1px solid $border-color;
  min-height: 69px;

  @include media-breakpoint-up(md) {
    align-items: center;
  }

  .dropdown-toggle .fa {
    color: $gl-text-color;
  }

  .git-merge-icon-container {
    border: 1px solid $theme-gray-400;
    border-radius: 50%;
    height: 32px;
    width: 32px;
    color: $theme-gray-700;
    line-height: 28px;

    .ic-git-merge {
      vertical-align: middle;
      width: 31px;
    }
  }

  .git-merge-container {
    justify-content: space-between;
    flex: 1;
    flex-direction: row;
    align-items: center;

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

      .branch-actions {
        margin-top: 16px;
      }
    }

    @include media-breakpoint-up(lg) {
      .branch-actions {
        align-self: center;
      }
    }
  }

  .diverged-commits-count {
    color: $gl-text-color-secondary;
    font-size: 12px;
  }
}

.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%;
  }
}

.target-branch-select-dropdown-container {
  position: relative;
}

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

.table-holder {
  .ci-table {

    th {
      background-color: $white-light;
      color: $gl-text-color-secondary;
    }
  }
}

.merged-buttons {
  .btn {
    float: left;
  }
}

.mr-version-controls {
  position: relative;
  background: $gray-light;
  color: $gl-text-color;

  .mr-version-menus-container {
    display: flex;
    align-items: center;
    padding: 16px;
    z-index: 199;
  }

  .content-block {
    padding: $gl-padding-top $gl-padding;
  }

  .comments-disabled-notif {
    line-height: 28px;

    .btn {
      margin-left: 5px;
    }
  }

  .mr-version-dropdown,
  .mr-version-compare-dropdown {
    margin: 0 7px;
  }

  .dropdown-title {
    color: $gl-text-color;
  }

  .fa-info-circle {
    color: $orange-500;
    padding-right: 5px;
  }
}

.merge-request-tabs-holder {
  top: $header-height;
  z-index: 200;
  background-color: $white-light;
  border-bottom: 1px solid $border-color;

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

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

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

    .merge-request-tabs-container {
      padding-left: $gl-padding;
      padding-right: $gl-padding;
    }
  }

  .nav-links {
    border: 0;
  }
}

.with-performance-bar .merge-request-tabs-holder {
  top: $header-height + $performance-bar-height;
}

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

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

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

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

  @include media-breakpoint-down(xs) {
    flex-direction: column-reverse;
  }
}

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

.mr-memory-usage {
  width: 100%;

  p.usage-info-loading .usage-info-load-spinner {
    margin-right: 10px;
    font-size: 16px;
  }
}

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

.deploy-heading {
  margin-top: -19px;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  background-color: $gray-light;

  @include media-breakpoint-up(md) {
    padding: $gl-padding-8 $gl-padding;
  }

  .media-body {
    min-width: 0;
    font-size: 12px;
    margin-left: 48px;
  }
}

.deploy-body {
  display: flex;
  align-items: center;
  flex-wrap: wrap;

  @include media-breakpoint-up(xs) {
    flex-wrap: nowrap;
    white-space: nowrap;
  }

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

    .deployment-info {
      margin-bottom: $gl-padding;
    }
  }

  > *:not(:last-child) {
    margin-right: .3em;
  }

  svg {
    vertical-align: text-top;
  }

  .deployment-info {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 100px;

    @include media-breakpoint-up(xs) {
      min-width: 0;
      max-width: 100%;
    }
  }

  .btn svg {
    fill: $theme-gray-700;
  }
}

// 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: .65;

    &:hover {
      color: $file-mode-changed;
      text-decoration: none;
    }
  }
}

.ci-widget-container {
  justify-content: space-between;
  flex: 1;
  flex-direction: row;

  @include media-breakpoint-down(md) {
    flex-direction: column;

    .stage-cell .stage-container {
      margin-top: 16px;
    }

    .dropdown .mini-pipeline-graph-dropdown-menu.dropdown-menu {
      transform: initial;
    }
  }

  .coverage {
    font-size: 12px;
    color: $theme-gray-700;
    line-height: initial;
  }

  .mini-pipeline-graph-dropdown-toggle,
  .stage-cell .mini-pipeline-graph-dropdown-toggle svg {
    height: $ci-action-icon-size-lg;
    width: $ci-action-icon-size-lg;
  }
}
