@import "variables.scss";

.box {
  position: relative;
  width: 100%;

  .box-header {
    margin: 0 10px 5px 10px;
    text-transform: uppercase;
    display: flex;

    @include themify($themes) {
      color: themed("headingColor");
    }

    button {
      background-color: transparent;
      border: none;
      text-transform: uppercase;

      @include themify($themes) {
        color: themed("headingColor");
      }
    }

    .toggle {
      background-color: transparent;
      margin-left: 4px;
      font-size: $font-size-small;
      @include themify($themes) {
        color: themed("headingColor");
      }
    }
  }

  .box-header-expandable {
    border: none;
    padding: 5px 0px;
    text-transform: uppercase;
    display: flex;
    width: 100%;
    box-sizing: border-box;

    @include themify($themes) {
      color: themed("headingColor");
      background-color: themed("boxBackgroundColor");
    }

    &:hover,
    &:focus,
    &.active {
      @include themify($themes) {
        background-color: themed("boxBackgroundHoverColor");
      }
    }

    .icon {
      display: flex;
      align-items: flex-end;
      margin-left: 5px;

      @include themify($themes) {
        color: themed("headingColor");
      }
    }
  }

  .box-content {
    border-radius: $border-radius;
    box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 3px 1px -2px rgba(0, 0, 0, 0.12),
      0 1px 5px 0 rgba(0, 0, 0, 0.2);

    @include themify($themes) {
      background-color: themed("boxBackgroundColor");
    }

    &.box-content-padded {
      padding: 10px 15px;
    }

    &.condensed .box-content-row,
    .box-content-row.condensed {
      padding-top: 5px;
      padding-bottom: 5px;
    }

    &.no-hover .box-content-row,
    .box-content-row.no-hover {
      &:hover,
      &:focus {
        background-color: initial;
      }
    }
  }

  .box-footer {
    margin: 5px 10px;
    font-size: $font-size-small;

    @include themify($themes) {
      color: themed("mutedColor");
    }
  }
}

.box-content-row {
  display: block;
  width: 100%;
  padding: 10px 15px;
  position: relative;
  z-index: 1;
  text-align: left;

  &:before {
    content: "";
    position: absolute;
    right: 0;
    bottom: 0;
    height: 1px;
    width: calc(100% - 10px);
    border-bottom: 1px solid #000000;

    @include themify($themes) {
      border-bottom-color: themed("boxBorderColor");
    }
  }

  &:first-child,
  &:last-child {
    border-radius: $border-radius;

    .progress {
      border-bottom-left-radius: $border-radius;
      border-bottom-right-radius: $border-radius;
    }
  }

  &:last-child {
    &:before {
      border: none;
      height: 0;
    }
  }

  &:after {
    content: "";
    display: table;
    clear: both;
  }

  &:hover,
  &:focus,
  &.active {
    @include themify($themes) {
      background-color: themed("boxBackgroundHoverColor");
      > * {
        background-color: themed("boxBackgroundHoverColor");
      }
    }
  }

  &.pre {
    white-space: pre;
    overflow-x: auto;
  }

  &.pre-wrap {
    white-space: pre-wrap;
    overflow-x: auto;
  }

  .row-label,
  label:not(.unstyled) {
    font-size: $font-size-small;
    display: block;
    width: 100%;
    margin-bottom: 5px;

    @include themify($themes) {
      color: themed("mutedColor");
    }

    .sub-label {
      margin-left: 10px;
    }
  }

  .text,
  .detail {
    display: block;

    @include themify($themes) {
      color: themed("textColor");
    }
  }

  .detail {
    font-size: $font-size-small;

    @include themify($themes) {
      color: themed("mutedColor");
    }
  }

  .img-right {
    float: right;
    margin-left: 10px;
  }

  .row-main {
    flex-grow: 1;
    min-width: 0;
  }

  &.box-content-row-flex,
  .box-content-row-flex,
  &.box-content-row-checkbox,
  &.box-content-row-input,
  &.box-content-row-slider,
  &.box-content-row-multi {
    display: flex;
    align-items: center;
    word-break: break-word;
  }

  &.box-content-row-multi {
    width: 100%;

    input:not([type="checkbox"]):not([type="radio"]) {
      width: 100%;
    }

    input + label.sr-only + select {
      margin-top: 5px;
    }

    > a,
    > button {
      padding: 8px 8px 8px 4px;
      margin: 0;

      @include themify($themes) {
        color: themed("dangerColor");
      }
    }
  }

  &.box-content-row-checkbox,
  &.box-content-row-input,
  &.box-content-row-slider {
    label,
    .row-label {
      font-size: $font-size-base;
      display: inline;
      width: initial;
      margin-bottom: 0;

      @include themify($themes) {
        color: themed("textColor");
      }
    }

    > span {
      @include themify($themes) {
        color: themed("mutedColor");
      }
    }

    > input {
      margin: 0 0 0 auto;
      padding: 0;
    }

    > * {
      margin-right: 15px;

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

  &.box-content-row-input {
    label {
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    input {
      text-align: right;
      width: 45px !important;
    }
  }

  &.box-content-row-slider {
    input[type="range"] {
      height: 10px;
      width: 220px !important;
    }

    input[type="number"] {
      text-align: right;
      width: 45px !important;
    }

    label {
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
  }

  &.box-content-row-radio {
    display: flex;
    flex-direction: column;
    .item {
      display: flex;
      flex: 1;
      align-items: center;

      > .radio {
        margin-right: 5px;
        margin-top: 0;
      }
    }
  }

  input:not([type="checkbox"]):not([type="radio"]),
  textarea {
    border: none;
    width: 100%;
    background-color: transparent;

    &::-webkit-input-placeholder {
      @include themify($themes) {
        color: themed("inputPlaceholderColor");
      }
    }

    &:focus {
      outline: none;
    }
  }

  select {
    width: 100%;
    border: 1px solid #000000;
    border-radius: $border-radius;

    @include themify($themes) {
      border-color: themed("inputBorderColor");
    }
  }

  .action-buttons {
    display: flex;
    margin-left: 5px;

    .row-btn {
      @extend .icon-btn;
    }

    &.no-pad .row-btn {
      padding-top: 0;
      padding-bottom: 0;
    }
  }

  &:not(.box-draggable-row) {
    .action-buttons .row-btn:last-child {
      margin-right: -6px !important;
    }
  }

  &.box-draggable-row {
    &.box-content-row-checkbox {
      input[type="checkbox"] + .drag-handle {
        margin-left: 10px;
      }
    }
  }

  .drag-handle {
    cursor: move;
    padding: 10px 2px 10px 8px;
    user-select: none;

    @include themify($themes) {
      color: themed("mutedColor");
    }
  }

  &.cdk-drag-preview {
    position: relative;
    display: flex;
    align-items: center;
    opacity: 0.8;

    @include themify($themes) {
      background-color: themed("boxBackgroundColor");
    }
  }

  select.field-type {
    margin: 5px 0 0 25px;
    width: calc(100% - 25px);
  }

  .row-sub-icon {
    @include themify($themes) {
      color: themed("disabledIconColor");
    }
  }

  .row-sub-label {
    margin: 0 15px;
    white-space: nowrap;

    @include themify($themes) {
      color: themed("mutedColor");
    }
  }

  .progress {
    display: flex;
    height: 5px;
    overflow: hidden;
    margin: 5px -15px -10px;

    .progress-bar {
      display: flex;
      flex-direction: column;
      justify-content: center;
      white-space: nowrap;
      background-color: $brand-primary;
    }
  }

  .icon {
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 34px;
    height: 100%;
    margin-left: -5px;

    @include themify($themes) {
      color: themed("mutedColor");
    }

    &.icon-small {
      min-width: 25px;
    }
  }

  .radio-group {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-bottom: 5px;

    input {
      flex-grow: 0;
    }

    label {
      margin: 0 0 0 5px;
      flex-grow: 1;
      font-size: $font-size-base;
      display: block;
      width: 100%;

      @include themify($themes) {
        color: themed("textColor");
      }
    }

    &.align-start {
      align-items: start;
      margin-top: 10px;

      label {
        margin-top: -4px;
      }
    }
  }
}
