@import 'ctl_base_ui/variables';
@import 'ctl_base_ui/mixins';
@import 'ctl_base_ui/colors';
@import 'ctl_base_ui/icons';
@import 'panamax/buttons';

.service-details {
  padding-bottom: 20px;

  .metrics {
    float: right;
    padding-left: 0;
    padding-right: 15px;
  }

  .state {
    width: 370px;
    float: right;

    .metric-details {
      float: right;
      font-size: 13px;
      margin-right: 15px;
      padding: 4px 15px 0 0;
      border-right: 1px solid $grey;
    }
  }

  a.button-add {
    margin: 10px 0;
    padding-left: 40px;
    padding-right: 20px;
    font-size: 14px;
  }

  .note {
    color: $grey;
    text-transform: lowercase;
    font-style: italic;
  }

  .inspect {
    float: right;
    font-size: 0.8em;
    margin-left: 10px;
    padding-top: 4px;
    display:none;

    a {
      text-decoration: underline;
    }
  }
}

.service-help-icon {
  display: block;
  position: relative;
  width: 22px;
  height: 22px;
  float: right;
  border-radius: 11px;
  margin-top: -4px;
  background-color: #293b47;

  &:before {
    content: '?';
    display: block;
    position: absolute;
    top: 5px;
    font-size: 13px;
    color: $white;
    font-weight: normal;
    left: 7px;
  }

  &:hover {
    cursor: pointer;
  }
}

.service-status {
  float: right;
  padding-left: 25px;
  font-style: italic;
  font-size: 0.8em;
  color: $medium_grey;
  white-space: nowrap;
  height: 20px;
  line-height: 22px;
  background-repeat: no-repeat;
  background-position: left center;
  position: relative;

  .panamax-state {
    cursor: pointer;
    min-width: 60px;
  }

  em {
    text-decoration: underline;
    cursor: help;
  }

  &.stopped {
    background-image: image-url('icon_status_stopped.png');
  }

  &.running {
    background-image: image-url('icon_status_running.png');

    em {
      display: none;
    }
  }

  &.loading {
    background-image: image-url('icon_loading_green.gif');
  }

  .tooltip {
    font-size: 12px;
    display: none;
    left: -70px;
    top: 25px;

    &:before {
      right: 6px;
    }

    ul {
      padding: 5px;

      li {
        font-style: normal;
        font-weight: bold;

        span {
          font-weight: normal;
        }
      }
    }
  }
}

.restart-action {
  float: right;
  margin-left: 10px;
  @extend .button-minor;
}

.service-attributes {
  clear: both;
  padding-top: 10px;
  margin-bottom: 20px;

  &:after {
    content: '';
    display: block;
    clear: both;
  }

  .column-left,
  .column-right {
    width: 48%;

    > div:last-child {
      margin-bottom: 0;
    }
  }

  .column-left {
    float: left;
  }

  .column-right {
    float: right;
  }
}


.base-image-detail {
  position: relative;
  margin-bottom: 20px;
  width: 70%;

  * {
    display: inline-block;
  }

  .image-details {
    h6 {
      color: $dark_grey;
      font-weight: bold;
      padding-bottom: 0;
    }

    span {
      margin-right: 6px;
    }
  }

  .documentation {
    padding: 0;
    display: block;

    a {
      text-decoration: underline;
      font-size: 0.9em;
      padding-right: 5px;
      &:last-child {
        padding-left: 36px;
        border-left: 1px solid #AAAAAA;
        &:after {
          top: -2px;
          left: 11px;
        }
      }
    }
  }
}

.service-detail {
  width: 100%;
  font-size: 13px;

  > dl {
    border-bottom: 1px solid $light_grey;
  }

  h3 {
    @include border-radius(3px);
    background: $blue_grey;
    color: $white;
    font-weight: normal;
    padding: 13px 15px;
  }

  h4 {
    color: #000;
    font-weight: bold;
    font-size: 1em;
    margin: 10px 0 0;
  }

  li.legend {
    color: $grey;
    font-style: italic;
  }

  ul li,
  dl dt,
  dl dd {
    padding-top: 16px;
    padding-bottom: 16px;
  }

  ul li {
    border-bottom: $light_grey 1px solid;
  }

  ul li:hover .actions,
  dl dt:hover + dd + .actions,
  dl dd:hover + .actions,
  dl dd.actions:hover,
  tr:hover .actions {
    > * {
      visibility: visible;
    }
  }

  dl {
    overflow: auto;

    dt,
    dd {
      @include border-box;
      float: left;
      padding-left: 0;

      input[type='text'] {
        @include border-box;
      }
    }

    dt {
      font-weight: bold;
    }
  }

  a.cancel {
    text-decoration: underline;
  }

  .actions {
    float: right;
    width: 20px;
    > * {
      visibility: hidden;
    }
    a.delete-action:after {
      top: 0;
    }
  }
}

.volumes {
  @extend .service-detail;

  input[type='text'] {
    width: 180px;
  }
}

.port-detail {
  @extend .service-detail;

  table {
    width: 100%;
    &.port-bindings {
      colgroup {
        col {
          &.ports {
            width: 40%;
          }
          &.actions {
            width: 20%
          }
        }
      }
    }

    &.exposed-ports {
      colgroup {
        col {
          &.ports {
            width: 100px;
          }
        }
      }
      tr {
        &.loading {
          td {
            font-weight: normal;
            color: #a1a1a1;
          }
        }
        td {
          &:last-child {
            margin-left: 0;

            .actions {
              position: relative;
              top: 3px;
              float: left;
            }
          }
        }
      }
    }

    &.service-loading {
      td a.view-action {
        color: #a1a1a1;
        text-decoration: none;
        pointer-events: none;
        position: relative;
      }
      tr.auto-assigned-host {
        color: #a1a1a1;
        td {
          font-weight: normal;
        }
      }
    }

    thead th, tbody tr td {
      padding: 15px 5px;
      text-align: left;
      @include border-box;
    }
    thead {
      th {
        color: $grey;
        font-style: italic;
      }
    }
    tr {
      border-bottom: 1px solid #f1f1f1;
      td {
        font-weight: bold;

        .info {
          font-size: 10px;
          color: #ccc;
          font-style: italic;
          font-weight: normal;
          margin-top: -6px;
        }

        a {
          font-weight: normal;
        }
      }
    }
  }

  .port-detail-forms {
    overflow: hidden;
  }

  div.port-bindings {

    a + a#copy-endpoint {
      margin-left: 6px;
    }

    select {
      width: 80px;
    }

    .chosen-container {
      top: -1px;
      li {
        border-bottom: 0;
      }
      .chosen-single span {
        margin-right: 20px;
      }
    }

    input[type='number'] {
      @include border-box;
      width: 23%;
      padding-right: 0px;
    }

  }

  .exposed-ports {
    input[type='number'] {
      @include border-box;
      width: 68px;
    }
  }

  h4 {
    color: #000;
    font-weight: bold;
    font-size: 1em;
    margin: 10px 0 0;
  }

  .optional {
    color: $medium_grey;
    font-style: italic;
    margin-top: 3px;
    font-size: 11px;
  }
}

.docker-run-command {
  @extend .service-detail;

  input[type='text'] {
    @include border-box;
    width: 100%;
  }
}

.environment-variables {
  @extend .service-detail;

  dl {
    dt, dd {
      &.editing {
        padding: 5px 0;
        width: 90%;
      }

      input[type="text"] {
        width: 100%;
      }


      &:hover .actions {
        display: inline-block;

        > .edit-action {
          visibility: visible;

          &:after {
            left: 2px;
            top: 0;
          }
        }
      }

      .actions {
        float: none;
        display: none;
        width: 10px;
        height: 10px;
      }
    }

    dt {
      width: 100%;
      padding-bottom: 0;

      &.editing {
        padding: 10px 0 0;
        input[type='text'] {
          font-weight: bold;
        }
      }
    }
    dd {
      width: 90%;
      padding-left: 5%;

      &.actions {
        padding-left: 0;
        width: 5%;
      }
    }

    a.cancel {
      text-decoration: underline;
      display: inline-block;
      margin: 46px 0 0 6px;
      height: 15px;
    }
  }
}

.service-links {
  @extend .service-detail;

  .title {
    color: darken($blue_grey_dark, 10%);
  }

  .service-icon {
    display: inline-block;
    float: left;
    background-color: $light_grey;
    width: 40px;
    height: 40px;
    margin: -10px 6px 0 -6px;
    border-radius: 4px;
    img {
      margin: 3px;
    }
  }

  > ul {
    margin-top: 20px;
  }

  > ul > li {
    margin-left: 20px;
    padding-left: 30px;
    position: relative;
    border: 0;

    span[title] {
      cursor: help;

      &:hover {
        background: $yellow;
      }
    }

    span.link-name {
      display: inline-block;
      margin-top: 3px;
    }

    &:before {
      z-index: -1;
      position: absolute;
      content: '';
      border: $blue_grey 1px solid;
      border-width: 0 0 1px 1px;
      height: 47px;
      width: 30px;
      top: -20px;
      left: 0;
    }

    &.editing {
      padding: 10px 0 0;
      margin: 0 0 20px 0;
      border-top: 1px solid $light_grey;

      &:before {
        display: none;
      }

      select,
      input[type='text'] {
        @include border-box;
        width: 200px;
      }

      input[type='text'] {
        position: relative;
        top: 1px;
      }
    }

    &:hover .remove-link {
      visibility: visible;
    }

    .remove-link {
      visibility: hidden;
      @include hide-text;
      @include border-radius(11px);
      position: absolute;
      left: -11px;
      top: 13px;
      width: 22px;
      height: 22px;
      display: block;
      background-color: $blue_grey;

      &:hover {
        background-color: $dark_red;
      }

      &:before {
        position: absolute;
        left: 6px;
        top: 6px;
        content: '';
        @extend .icon-x;
        @include icon-white;
      }

    }
  }
}

.additional-entries {
  dl:first-child,
  li:first-child {
    display: none;
  }
}

form.service-edit-form {
  margin-bottom: 70px;

  input[type="submit"] {
    float: right;
  }
  .button-primary[disabled]:hover {
    background-color: $light_grey;
  }
}

.mounted-containers {
  ul:not(.additional-entries) li {
    overflow: auto;
  }

  .mount-point {
    float: left;

    &:after {
      content: ' : ';
    }
  }

  select.mount-point {
    min-width: 190px;
  }

  dl {
    float: left;
    padding-left: 5px;
    display: inline-block;

    dd {
      float: none;
      padding: 0 0 5px 0;
      display: block;
    }
  }
}

#docker-string {
  background-color: #F1F1F1;
  margin: 10px 0;
  padding: 10px;
  font-family: Consolas, "Andale Mono WT", "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Liberation Mono", "Nimbus Mono L", Monaco, "Courier New", Courier, monospace;

  .run-segment {
    white-space: nowrap;
  }
}

input.empty {
  border: $orange 2px solid;
}

#docker-inspect {
  color: $blue_grey;
  font-size: 0.9em;
  display: none;
}
