@import "drawer";
@import "tabs";
@import "previewer";

.builder {
  width: 90%;
  margin-bottom: 50px;
}

.brick {
  position: relative;
  padding: 0;
  min-height: 47px;
  display: flex;
  border: 2px solid #3444BF;
  border-radius: 4px 4px 0 0;
  margin-bottom: 15px;

  &.is-hide {
    border: 0;
    margin-bottom: 0;
    > .inner {
      padding: 0;
    }
  }

  &[data-brick-type="brick.column"] {
    padding: 10px;
  }

  .actions {
    display: flex;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: #3444BF;
    height: 43px;
    overflow: hidden;
    font-size: 20px;
    padding: 0 10px;

    .title {
      display: block;
      width: 100%;
      text-align: center;
      pointer-events: none;
      touch-action: none;
      color: #fff;
      position: absolute;
      left: 0;
      top: 0;
      line-height: 43px;
    }

    > .btn {
      padding: 0 5px;
      border-radius: 0;
      text-align: center;
      color: #ffffff;
    }
  }

  .inner {
    padding: calc(43px + 5px) 5px 5px 5px;
    display: flex;
    flex-direction: column;
    width: 100%;
    align-items: center;

    .children {
      flex-grow: 1;
      position: relative;
      width: 100%;

      &.drag-receiver:before {
        border: 5px dashed #cecece;
        display: block;
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        margin-left: -5px;
        margin-top: -5px;
        margin-right: -5px;
        margin-bottom: -5px;
      }
    }
  }

  .brick-add-section {
    width: 90%;
    position: relative;
    .brick-action {
      z-index: 1;
      border: 1px solid #707070;
      &:hover {
        background: rgba(100, 100, 100, .1);
      }
      i {
        margin: 0 15px;
        background: #8E8EA9;
        color: #fff;
        font-size: 10px;
        border-radius: 50%;
        min-width: 20px;
        max-width: 20px;
        min-height: 20px;
        max-height: 20px;
        line-height: 20px;
      }
    }

    .layout {
      border: 0;
      margin: 10px;
      cursor: pointer;
      z-index: 1;
    }

    .description {
      font-size: 14px;
    }
  }

  .brick-add {
    width: 100%;
    .brick-action {
      z-index: 1;
    }
    .add-brick-widget {
      .close-overlay, .inner {
        display: none;
      }

      .close-overlay {
        background: rgba(0, 0, 0, .15);
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 50;
      }

      .inner {
        position: absolute;
        z-index: 100;
        background: #fff;
        margin-top: 25px;
        box-shadow: 0 0 67px 2px rgba(0, 0, 0, 0.75);
        padding: 0;
        opacity: 0;
        border: 1px solid #8E8EA9;
        border-radius: 4px 4px 0 0;
        height: 450px;
        .brick-add-header {
          width: 100%;
          text-align: center;
          background-color: #8E8EA9;
          color: #fff;
          font-size: 20px;
          height: 40px;
          line-height: 40px;
          border-radius: 4px 4px 0 0;
          .title {
            text-align: center;
            width: 100%;
          }
          .btn-secondary {
            background-color: #8e8ea9;
            border-color: #8e8ea9;
          }
        }
      }

      &.opened {
        .close-overlay {
          display: block;
          z-index: 2000;
          opacity: 1;
        }

        .inner {
          display: flex;
          opacity: 1;
        }
      }

      &.inverted {
        .inner {
          transform: translate(0, -100%);
          top: calc(-100% + 30px);

          &:before {
            top: auto;
            bottom: 0;
            margin-top: auto;
            margin-bottom: -11px;
          }
        }
      }

      .brick-cat-tabs {
        width: 100%;
        .btn.selected {
          background: #8E8EA9;
          color: #fff;
        }

        .btn {
          box-shadow: none;
        }

        .btn-group {
          display: block;
          text-align: center;
        }
        .brick-cat-contents {
          .brick-cat-content {
            display: none;

            &.selected {
              display: block;
            }

            .brick-types {
              display: flex;
              flex-wrap: wrap;
              justify-content: center;
              max-height: 300px;
              overflow: auto;
              margin: 0 5px;

              &::-webkit-scrollbar {
                width: 4px;
              }

              &::-webkit-scrollbar-thumb {
                background: #8e8ea9;
                border-radius: 2px;
              }

              .brick-type {
                margin: 10px;
                overflow: hidden;
                cursor: pointer;
                border: 1px solid #8e8ea9;
                box-shadow: none;
                min-width: 200px;
                max-width: 200px;
                min-height: 90px;
                display: flex;
                flex-direction: column;
                align-items: center;

                &:focus {
                  cursor: pointer;
                  border: 1px solid rgba(0, 0, 0, .2);
                  box-shadow: none;
                }

                &.disabled {
                  opacity: .3;
                  pointer-events: none;
                  touch-action: none;
                }

                &.active {
                  border-color: #35bc9d;
                  color: #35bc9d;
                }

                i {
                  font-size: 48px;
                }
              }
            }
          }
        }
      }

      .brick-cat-tabs button.disabled, .brick-cat-contents .brick-cat-content.disabled {
        display: none;
      }

      .btn-close,
      .btn-close:focus,
      .btn-validate,
      .btn-validate:focus {
        box-shadow: none;
      }

      .btn-close {
        background: #e65a5a;
        color: #fff;
      }

      .btn-close:hover {
        background: #a84242;
        color: #fff;
      }

      .btn-validate {
        background: #35bc9d;
        color: #fff;
        margin-left: 25px;
        .text-holder {
          white-space: nowrap;
          text-overflow: ellipsis;
          overflow: hidden;
        }
      }

      .btn-validate:hover {
        background: #24806a;
        color: #fff;
      }

      .loading-button {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        .loader-holder {
          display: none;
          margin-right: 1rem;
          padding: 1px;
          filter: brightness(5);
          svg {
            width: 20px;
            height: 20px;
          }
        }
        &.is-loading {
          .loader-holder {
            display: block;
          }
        }
      }
    }
    &:hover {
      background-color: #6464641a;
    }
  }

  .border-dashed {
    overflow: hidden;
    position: relative;
    &:before {
      content: "";
      position: absolute;
      border: 5px dashed #8E8EA9;
      top: -4px;
      bottom: -4px;
      left: -4px;
      right: -4px;
    }
    &.active {
      &:before {
        border-color: #3D3D8F;
        border-width: 6px;
      }
    }
  }
}

.brick .preview {
  max-height: 150px;
  overflow-y: hidden;
  text-overflow: ellipsis;
}

.brick .preview img {
  max-width: 100%;
}

.brick.flash {
  animation: flash linear .5s 4 /* 4x times */
;
}

@keyframes flash {
  0% {
    opacity: 1;
  }
  50% {
    opacity: .1;
  }
  100% {
    opacity: 1;
  }
}

.layout {
  border: 0;
  margin: 10px;
  cursor: pointer;
  z-index: 1;
  background-color: #fff;
  padding: 1px;
  &.smaller {
    border: 1px solid #bc1515;
  }
  &.selected {
    border: 1px solid #3444bf;
  }
}

.cancel-add-section {
  z-index: 10;
  position: absolute;
  right: 10px;
}

.brick-templates {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  max-height: 200px;
  overflow: auto;
  margin: 0 5px;
  z-index: 1;

  &::-webkit-scrollbar {
    width: 4px;
  }

  &::-webkit-scrollbar-thumb {
    background: #8e8ea9;
    border-radius: 2px;
  }

  .brick-template {
    margin: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    border: 1px solid #8e8ea9;
    box-shadow: none;
    min-width: 200px;
    max-width: 200px;
    min-height: 100px;
    max-height: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1;
    position: relative;

    &:focus {
      cursor: pointer;
      border: 1px solid rgba(0, 0, 0, .2);
      box-shadow: none;
    }

    &.disabled {
      opacity: .3;
      pointer-events: none;
      touch-action: none;
    }

    &.active {
      border-color: #35bc9d;
      color: #35bc9d;
    }

    i {
      font-size: 48px;
    }

    .brick-template-delete {
      position: absolute;
      top: -10px;
      right: -10px;
      border: 1px solid #8e8ea9;
      border-radius: 50%;
      width: 30px;
      height: 30px;
      padding: 0;
      text-align: center;
      line-height: 30px;
      background-color: #fff;
      i {
        font-size: 16px;
      }
    }
  }
}