// SETTINGS
.panel-settings-set-fb-px {
  $divider-W: 70px;

  .panel-heading .tit::before {
    @include material-icons(settings);
  }

  .panel-body {
    @include flexbox;
    @include flexbox-align-items(stretch);
    @include flex-wrap(wrap);
    padding: 0;
  }

  .panel-footer .form-group {
    margin-top: 0;
    padding-bottom: 0;
  }

  .sub-panel {
    @include flex(1 0 100%);
    padding: $panel-body-padding;

    &:first-child {
      position: relative;
      order: 2;
      padding-top: $divider-W/2;
    }

    &-fb-connect {
      background: lighten($blue,45%);
      padding-bottom: $divider-W/2;
      border-bottom: 1px solid $panel-inner-border;
      order: 1;
    }

    @media screen and (min-width: $screen-sm-min) {
      @include flex(1 0 49%); //it was (0 0 50%) but was broken in Safari

      &:first-child {
        padding-right: floor($divider-W * 0.65);
        border-right: 1px solid $panel-inner-border;
        border-bottom: 0;
        padding-top: $panel-body-padding;
        order: 1;
      }

      &-fb-connect {
        padding-left: floor($divider-W * 0.65);
        order: 2;
        padding-bottom: $panel-body-padding;
      }
    }

  }

  .divider {
    $W: $divider-W;

    display: block;
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    margin: auto;
    width: $W;
    height: $W;
    line-height: $W;
    border-radius: 50%;
    background: $white;
    border: 1px solid $panel-inner-border;
    margin-top: -$W/2;
    text-align: center;
    text-transform: uppercase;
    font-style: normal;
    font-weight: $font-weight-bold;
    color: darken($panel-inner-border,20%);

    @media screen and (min-width: $screen-sm-min) {
      top: 50%;
      right: -($W + 1)/2;
      left: auto;
    }
  }

  .btn-fb-connect {
    padding-left: floor($btn-padding-vertical * 1.5);
    padding-right: floor($btn-padding-vertical * 1.5);
    font-size: 1.2em;

    &::before {
      width: $btn-fb-connect-icon-W * 0.8;
      height: $btn-fb-connect-icon-W * 0.8;
      margin: -4px 0.5em 0 0;
    }

    @media screen and (min-width: $screen-md-min) {
      font-size: 1.5em;

      &::before {
        width: $btn-fb-connect-icon-W;
        height: $btn-fb-connect-icon-W;
      }
    }
  }

  .sub-panel-px-id {
    .control-wrap {
      $this__icon-W: 40px;

      position: relative;
      padding-left: 0;

      &::before {
        position: absolute;
        top: 0;
        right: 0;
        @include material-icons(check);
        width: $this__icon-W;
        height: $this__icon-W;
        line-height: $this__icon-W;
        font-size: 2em;
        text-align: center;
        color: $brand-success;
        display: none;
      }

      .form-control {
        padding-right: $this__icon-W;
      }
    }

    &.active {
      .control-wrap {
        &::before {
          display: block;
        }
      }

      .form-control {
        background-image: linear-gradient($brand-success, $brand-success), linear-gradient($mdb-input-underline-color, $mdb-input-underline-color);
        background-size: 100% 2px, 100% 1px;
        border-bottom-color: $brand-success;
        color: $brand-success;

      }
    }
  }

  .sub-panel-fb-connect {
    @media screen and (min-width: $screen-sm-min) {
      border-bottom: none;
    }

    .user-actions {
      display: none;
      overflow: hidden;
      font-size: $font-size-small;

      .user-disconnect {
        display: inline-block;
        padding-right: $padding-small-horizontal;
        margin-right: $padding-small-horizontal;
        border-right: 1px dotted $brand-success;
        @include translate(-100%,0);

        @media screen and (min-width: $screen-md-min) {
          border-right: none;
        }
      }
      .user-edit {
        font-weight: $default-font-weight-semibold;
        @include translate(100%,0);

        @media screen and (min-width: $screen-md-min) {
          float: right;
        }
      }
    }

    .user-info {
      @include flexbox;
      @include flexbox-align-items(flex-start);
    }

    .user-avatar {
      width: $btn-fb-connect-avatar-W * 0.7;
      height: $btn-fb-connect-avatar-W * 0.7;
      margin-right: $padding-small-horizontal;
      border: 3px solid $white;
    }

    .sub-panel-actions {
      float: right;
    }

    &.to-set-up {
      background: lighten($brand-warning,40%);

      .form-group {
        .select2-container:not(.select2-container-disabled) {
          background-color: $white;
          background-image: linear-gradient($brand-warning, $brand-warning), linear-gradient(lighten($brand-warning,30%), lighten($brand-warning,30%));
          background-position: center bottom, center bottom;
        }

        label.control-label {
          color: darken($brand-warning,5%);
        }
      }

      .user-info {
        float: left;
        margin: 10px 0;
        font-size: $font-size-small;
        color: lighten($black,20%);
      }

      .user-disconnect {
        display: block;
      }
    }

    &.active {
      background: lighten($brand-success,50%);

      .fb-connect-info {
        $this__btn-icon-W: $btn-fb-connect-avatar-W;

        background: $brand-success;
        padding: $btn-padding-vertical * 2;
        border-radius: $border-radius-base;
        margin-top: $btn-margin-vertical;
        margin-bottom: $btn-margin-vertical;
        white-space: normal;
        font-weight: $font-weight-bold;
        line-height: 1.2em;
        text-transform: none;
        color: $white;

        .user-info {
          @include flexbox-align-items(flex-start);
          @include flexbox-justify-content(flex-start);
          margin-top: $btn-padding-vertical * 2;
          position: relative;

          @media screen and (min-width: $screen-xs-min) {
            &::after {
              position: absolute;
              top: 50%;
              margin-top: -$this__btn-icon-W/2;
              right: $btn-padding-vertical * 2;
              width: $this__btn-icon-W;
              height: $this__btn-icon-W;
              line-height: $this__btn-icon-W;
              @include material-icons(check);
              color: inherit;
              font-size: 3.8em;
            }

            .user-info-account {
              margin-right: $this__btn-icon-W + $btn-padding-horizontal;
            }

            .user-avatar {
              display: block;
            }
          }

          @media screen and (min-width: $screen-sm-min) {
            &::after {
              display: none;
            }
            .user-avatar {
              display: none;
            }
            .user-info-account {
              margin-right: 0;
            }
          }
          @media screen and (min-width: $screen-md-min) {
            &::after {
              display: block;
            }
            .user-avatar {
              display: block;
            }
            .user-info-account {
              margin-right: $this__btn-icon-W + $btn-padding-horizontal;
            }
          }
        }

        .user-avatar {
          display: none;
          width: $btn-fb-connect-avatar-W;
          height: $btn-fb-connect-avatar-W;
        }

        .user-ad-account,
        .user-name {
          font-size: $font-size-base;
          line-height: normal;
        }

        .user-ad-account {
          display: block;
          text-transform: uppercase;
          font-size: $font-size-base - 2px;
        }

        .pixel-id,
        .user-ad-account {
          font-weight: $default-font-weight-light;
        }

        .pixel-id {
          font-style: normal;
          color: $white;
          font-size: 1.3em;
        }

        .pixel-id-value,
        .user-ad-account-value {
          font-weight: $default-font-weight-semibold;
          word-break: break-all;
        }

        .user-ad-account-value {
          display: block;
          text-transform: none;
          font-size: $font-size-base;
        }

        .user-name {
          font-weight: $default-font-weight-light;
          color: lighten($brand-success, 45%);
        }
      }

      .user-actions {
        display: block;

        .user-edit {
          @include translate(0,0);
        }
        .user-disconnect {
          @include translate(0,0);
        }
      }
    }
  }
}

.panel-settings-ca,
.panel-settings-ss {
  .panel-heading .tit::before {
    @include material-icons(person)
  }

  .form-track {
    @include clearfix;
    margin: $form-group-space-bottom 0;

    .control-label,
    .control-wrap {
      @include make-md-column(12);
      padding-left: 0;
      padding-right: 0;
    }
  }

  .control-label {
    padding-top: 0;
    text-align: left;

    .tit {
      font-size: $sub-headings-font-size;
    }
  }

  .sub-panel-adv-opt {
    .form-group {
      @include make-md-column(6);
      padding-left: 0;
    }

    .control-wrap {
      @include make-md-column(12);
      padding-left: 0;
      padding-right: 0;
    }

    label {
      text-align: left;
    }
  }
}

.panel-settings-conversions {
  .panel-heading .tit::before {
    @include material-icons(shopping_cart);
  }

  .ecomm-detect,
  .ecomm-conversions {
    .tit {
      font-size: $sub-headings-font-size;
    }
  }

  .ecomm-detect {
    margin: $panel-body-padding 0 $panel-body-padding * 2;

    .tit {
      display: inline-block;
      margin-top: 0;
      margin-bottom: 0;
    }

    .info {
      display: block;
      margin-top: $general-margin;

      a {
        font-weight: $font-weight-bold;
        text-decoration: underline;
        text-transform: uppercase;
        color: inherit;
      }
    }
  }

  .ecomm-conversions {
    $this__arrow-H-max: 20px;

    border-top: 1px solid $panel-inner-border;

    &::after,
    &::before {
      content: '';
      display: block;
      position: absolute;
      top: 0;
      left: 40px;
      width: 0;
      height: 0;
      border-style: solid;
   }

   &::after {
    top: -$this__arrow-H-max * 2;
    border-color: transparent transparent $white transparent ;
    border-width: $this__arrow-H-max 18px;
    margin-left: 1px;
    }

    &::before {
      top: -$this__arrow-H-max * 2 - 2;
      border-color: transparent transparent $panel-inner-border transparent;
      border-width: $this__arrow-H-max + 1 18px + 1;
    }

    .checkbox label {
      margin-right: $general-margin * 2;
    }

    .checkbox {
      display: inline-block;
    }

    .checkbox-material {
      margin-right: $general-margin/2;
    }
  }

  // TEMPORARY
  .ecomm-conversions {
    display: none;
  }

  &.detected {
    .ecomm-detect {
      .info { display: none; }
    }
    .ecomm-conversions {
      display: block;
    }
  }

  &.not-detected {
    .ecomm-detect {
      color: $brand-danger;

      &::before {
        @include material-icons(error);
        font-size: 2.5em;
        margin-right: $general-margin;
      }
    }
  }

  .ecomm-plugin-logo {
    img {
      max-width: 130px;
      max-height: 70px;
    }
  }

  .sub-panel-supported-plugin {
    .tit,
    .list-supported-plugin {
      display: inline-block;
      vertical-align: middle
    }
    .list-supported-plugin {
      margin-bottom: 0;
      margin-left: 5px;
      .item {
        display: inline-block;
        margin-right: 10px;
        margin-bottom: 0;
        transition: transform 0.2s ease-in-out;
        &:hover {
          transform: scale(1.1);
        }
      }
      .ecomm-plugin-logo {
        display: block;
      }
    }
  }
}

.panel-advanced-settings {
	.panel-heading {
    padding: 0;

		.tit {
      display: block;
      width: 100%;
			position: relative;
			font-size: $headings-font-size * 0.65;
			margin-top: 0;
			padding: $panel-heading-padding;
      font-weight: $default-font-weight-bold;

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

      &:focus {
        outline: none;
        box-shadow: none;
      }

			&:before {
        position: relative;
        top: 0.07em;
				@include material-icons(chevron_right);
        margin-right: floor($panel-body-padding * 0.7);
				color: $blue-light;
        font-size: 1.7em;
        transition: all 0.3s ease-out;
			}

      &:not(.collapsed) {
        &::before {
          transform: rotate(90deg);
        }
      }
		}
	}

  .checkbox {
    &.with-form-control {
      margin-bottom: 0;

      .form-control {
        margin-left: $padding-small-horizontal;
        margin-bottom: 0;
      }

      .checkbox-material {
        top: 0.5em;
      }
    }
  }

  .sub-panel {
    & + .sub-panel {
      border-top: 1px solid $panel-inner-border;
      padding-top: $panel-body-padding;
      margin-top: $panel-body-padding;
    }

    .text {
      display: block;
    }
  }

  .form-group-btn-single {
    .control-wrap {
      @include flexbox();
      @include flexbox-align-items(center);
      margin-bottom: $padding-small-horizontal;
    }

    .btn {
      margin: 0 $padding-small-horizontal 0 0;
    }
  }

  label {
      width: 100%;
  }

  .select2-container-multi {
    margin: 0;
  }
}
