@use './themes/light.scss';
@use './themes/dark.scss';
@use 'normalize.scss';
@use '@/style/schemaForm.scss';
@use './variables.scss';
@use 'sass:math';

@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: normal;
  src: url(../assets/fonts/Roboto-Regular.ttf) format('truetype');
}
@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 700;
  src: url(../assets/fonts/Roboto-Bold.ttf) format('truetype');
}
@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 900;
  src: url(../assets/fonts/Roboto-Black.ttf) format('truetype');
}
@font-face {
  font-family: 'Roboto';
  font-style: italic;
  font-weight: normal;
  src: url(../assets/fonts/Roboto-Italic.ttf) format('truetype');
}
@font-face {
  font-family: 'Roboto';
  font-style: italic;
  font-weight: 700;
  src: url(../assets/fonts/Roboto-BoldItalic.ttf) format('truetype');
}
@font-face {
  font-family: 'Roboto';
  font-style: italic;
  font-weight: 900;
  src: url(../assets/fonts/Roboto-BlackItalic.ttf) format('truetype');
}

body {
  padding: 0;
  margin: 0;
  color: var(--el-text-color-primary);
  font-size: 14px;
  font-family: variables.$font;
  background-color: var(--color-bg);
}

* {
  box-sizing: border-box;
}

a {
  color: var(--el-color-primary);
  text-decoration: none;
  background-color: transparent;
  outline: none;
  cursor: pointer;
  -webkit-transition: color 0.3s;
  transition: color 0.3s;
}

textarea,
code {
  font-family: variables.$font;
}

img {
  max-width: 100%;
}

h1 {
  font-size: 22px;
  color: var(--color-title-primary);
}
h2 {
  font-size: 18px;
  color: var(--color-title-primary);
  margin-top: 14px;
  margin-bottom: 24px;
}
h3 {
  font-size: 16px;
  color: var(--color-title-primary);
}
.tip {
  margin: 0px;
  color: var(--color-text-secondary);
}
p.description {
  line-height: 1.8;
}

#app {
  min-width: 600px;
  margin: 0 auto;
}

#nprogress {
  .bar {
    background: linear-gradient(135deg, #8c4eff 0%, #3f36ec 100%);
  }
}

.container {
  height: 100%;
}

.detail-top {
  padding: 0 24px;
}
.app-wrapper {
  padding: 0 24px;
  &.with-padding-top {
    padding-top: 32px;
  }
  &.with-padding-bottom {
    padding-bottom: 32px;
  }
  > .el-table:last-child {
    margin-bottom: 24px;
  }
}

.app-wrapper-compact {
  padding: 15px 10px;
}

::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar:horizontal {
  height: 6px;
}
::-webkit-scrollbar:vertical {
  height: 6px;
}
::-webkit-scrollbar-track {
  border-radius: 10px;
}
::-webkit-scrollbar-thumb {
  background-color: #0003;
  border-radius: 10px;
  transition: all 0.2s ease-in-out;
}
::-webkit-scrollbar-thumb:hover {
  cursor: pointer;
  background-color: #0000004d;
}

.search-wrapper {
  background-color: var(--color-bg-details);
  padding: 16px 24px 32px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--color-border-card);
  &.without-padding-top {
    padding-top: 0;
  }
  .el-button {
    margin-left: 12px;
  }
  & > .el-col {
    > .el-button:first-child {
      margin-left: 0;
    }
  }
  .el-col {
    margin-top: 16px;
  }
  .el-select {
    width: 100%;
  }
  .el-date-editor {
    width: 100%;
  }
  .col-oper {
    display: flex !important;
    align-items: center;
    justify-content: flex-end;
  }
}

.emq-table-footer {
  display: flex;
  margin-top: 30px;
  margin-bottom: 28px;
  justify-content: flex-end;
}

.page-header-title {
  font-size: 18px;
  color: var(--color-title-primary);
  font-weight: 600;
  margin-bottom: 24px;
}

.field-info {
  margin: 0;
  list-style: none;
  padding: 3px 0;
  line-height: 35px;

  .field-title {
    display: inline-block;
    font-style: normal;
    font-size: 14px;
    color: #999;
    padding-right: 16px;
  }

  .field-value {
    font-size: 14px;
    color: #101010;
  }
}

// Text-align button group
.button-group {
  margin-top: 24px;
  &__center {
    text-align: center;
  }
  &__right {
    text-align: right;
  }
}

.el-button.icon-button {
  font-size: 18px;
}
.enable-btn {
  margin-right: 12px;
}

.section-header {
  font-size: 18px;
  color: var(--color-title-primary);
  font-weight: 600;
  margin-top: 32px;
  padding-bottom: 24px;
  width: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  &:not(:first-of-type) {
    margin-top: 16px;
  }

  & .section-desc {
    font-size: 14px;
    font-weight: normal;
    color: #999;
    margin: 5px 0;
  }

  & > :first-child {
    display: flex;
    align-items: center;
    flex-grow: 1;
    overflow: hidden;
  }

  & > :not(:first-child) {
    margin-left: 10px;
  }

  span,
  i {
    vertical-align: middle;
  }
}

.part-header {
  color: var(--color-title-primary);
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  &:not(:first-of-type) {
    margin-top: 30px;
  }
}

.bold {
  font-weight: 600;
}

.no-dropdown-arrow {
  .popper__arrow {
    display: none;
  }
}

.el-input-group--append .el-input-group__append {
  width: 120px;
  padding: 0;
  .el-select {
    margin: -10px 0;
  }
}
.el-input-group--prepend .el-input-group__prepend {
  width: 120px;
  padding: 0;
  .el-select {
    margin: -10px 0;
  }
}
input:disabled {
  -webkit-text-fill-color: var(--el-disabled-text-color);
  -webkit-opacity: 1;
  opacity: 1;
  color: var(--el-disabled-text-color);
}

.el-button.link-btn {
  padding: 0;
  a {
    display: flex;
    align-items: center;
    padding: 9px 15px;
    color: inherit;
  }
}
.el-button.el-button--primary.confirm-danger {
  color: var(--el-color-danger);
  background: var(--el-color-danger-light-9);
  border: 1px solid var(--el-color-danger-light-5);
  &:hover {
    color: var(--el-color-white);
    background: var(--el-color-danger);
    border-color: var(--el-color-danger);
  }
}

.el-date-editor {
  --el-date-editor-datetimerange-width: 100%;
}

.text-status {
  &.success {
    color: var(--el-color-success);
  }
  &.warning {
    color: var(--el-color-warning);
  }
  &.danger {
    color: var(--el-color-danger);
  }
  &.info {
    color: var(--el-color-info);
  }
}

.icon {
  width: 1em;
  height: 1em;
  vertical-align: -0.15em;
  fill: currentColor;
  overflow: hidden;
}
.iconfont {
  font-size: 21px;
  color: var(--color-title-primary);
}

.el-select .el-input .el-input__suffix .el-input__validateIcon {
  display: none;
}

.el-form-item.label-whole-line {
  .el-form-item__label {
    position: relative;
    width: 100%;
  }
}

.el-form-item__content {
  p.value {
    margin: 0;
    color: var(--color-text-secondary);
    padding-left: 12px;
    word-break: break-all;
  }
}

.form-item-desc {
  margin-left: 4px;
  font-size: 14px;
  cursor: pointer;
}

.form-item-desc-popper {
  width: 300px;
}

.monaco-container {
  height: 300px;
  border: 1px solid var(--color-border-primary);
  width: 100%;
  &.is-small {
    height: 200px;
  }
}

.block {
  margin-bottom: 24px;
}
.block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.el-card.table-card {
  margin-bottom: 26px;
  .el-table {
    border-top-left-radius: 0px;
    border-top-right-radius: 0px;
    .el-table__inner-wrapper:after {
      content: none;
    }
    &:after,
    &:before {
      top: 0;
      height: 100%;
    }
    .el-table__cell {
      padding: 8px 12px;
    }
    th.el-table__cell > .cell {
      font-size: 16px;
    }
    th.el-table__cell.is-sortable {
      padding: 8px 5px !important;
    }
  }
  .el-card__body {
    padding: 0px;
    padding-top: 4px;
  }
}
.el-tabs.detail-tabs {
  .el-tabs__header {
    background-color: var(--color-bg-details);
    padding: 0 24px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--color-border-primary);
    .el-tabs__item.is-active {
      border-bottom: 1px solid var(--color-border-card);
    }
  }
  .app-wrapper {
    padding-top: 0px;
  }
}
.el-card {
  &.app-card {
    margin-bottom: 24px;
  }
  .el-tabs.detail-tabs {
    .el-tabs__header {
      margin-bottom: 24px;
      .el-tabs__item.is-active {
        border-bottom: 1px solid var(--color-bg-content);
      }
    }
  }
}
.block-title {
  margin-top: 0;
  margin-bottom: 0;
  margin-right: 12px;
  font-size: 16px;
  font-weight: 600;
  line-height: 22px;
  color: var(--color-title-primary);
}

.space-between {
  display: flex;
  justify-content: space-between;
}

.gap-2 {
  gap: 8px;
}

.vertical-align-center {
  display: flex;
  align-items: center;
}

@keyframes scaleAnimate {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 0;
  }
}

.running-status,
.stop-status {
  position: relative;
  padding: 0 6px;
}
.running-status::before,
.running-status::after,
.stop-status::before,
.stop-status::after {
  position: absolute;
  content: '';
  border-radius: 50%;
}
.running-status::before {
  left: -14px;
  top: 0px;
  width: 18px;
  height: 18px;
  background-color: #5e4eff50;
  animation: scaleAnimate 1.5s ease-out infinite;
}
.running-status::after {
  width: 6px;
  height: 6px;
  background-color: #5e4eff;
  top: 6px;
  left: -8px;
  z-index: 3;
}

.stop-status::after {
  width: 6px;
  height: 6px;
  background-color: #e44242;
  top: 6px;
  left: -11px;
  z-index: 3;
}

.resource-item-overview {
  p {
    margin-top: 0;
    margin-bottom: 0;
  }
  .overview-sub-block {
    margin-bottom: 28px;
  }
  .el-card {
    &.success-bg {
      background-color: rgba(0, 168, 143, 0.1);
    }
    &.failed-bg {
      background-color: rgba(118, 119, 137, 0.1);
    }
    &.matched-bg {
      background-color: rgba(93, 78, 255, 0.1);
    }
    &.rate-bg {
      background-color: rgba(61, 127, 249, 0.1);
    }
    &.no-result-bg {
      background-color: rgba(13, 91, 97, 0.1);
    }
    &.last-five-rate-bg {
      background-color: rgba(103, 206, 218, 0.1);
    }
    &.max-rate-bg {
      background-color: rgba(191, 115, 255, 0.1);
    }
  }
  .overview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    font-size: 16px;
    font-weight: bold;
    p {
      color: var(--color-title-primary);
    }
  }
  .card-hd {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 16px;
    .el-icon {
      cursor: pointer;
      font-size: 18px;
      padding-top: 2px;
    }
  }
  .card-sub-desc {
    margin-bottom: 16px;
    font-size: 14px;
    color: var(--el-text-color-secondary);
    line-height: 20px;
  }
  .rule-statistic {
    .el-col {
      padding-bottom: 20px;
    }
  }
  .statistic-label {
    margin-bottom: 20px;
  }
  .statistic-num {
    $height: 25px;
    min-height: $height;
    line-height: $height;
    font-size: 24px;
    font-weight: 600;
    color: var(--color-title-primary);
    .unit {
      font-size: 16px;
      margin-left: 4px;
      font-weight: normal;
    }
  }
  .text-status {
    margin-right: 8px;
  }
}

.table-with-draggable {
  tbody {
    tr {
      cursor: move;
    }
  }
}

.pointer {
  cursor: pointer;
}

.table-dropdown-btn {
  padding: 1px 9px;

  .icon-arrow {
    vertical-align: top;
    margin-left: 4px;
    &.rotate {
      transform: rotate(180deg);
    }
  }
}

.table-dropdown-popper {
  .el-dropdown-menu__item {
    &.disabled {
      opacity: 0.6;
      cursor: not-allowed;
    }
    &.danger {
      color: #e34242;
    }
  }
}

.table-data-without-break {
  display: block;
  overflow: hidden;
  margin: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.first-column-with-icon-type {
  display: flex;
  align-items: center;
  .icon-type {
    width: 48px;
    height: 48px;
    margin-right: 6px;
  }
  .name-type-block {
    line-height: 2;
  }
  .name-data {
    display: block;
    line-height: 16px;
    color: var(--el-color-primary);
  }
  .type-data {
    font-size: 14px;
    color: var(--color-text-secondary);
    line-height: 16px;
  }
}

.with-dividing-line-bottom {
  position: relative;
  &::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    display: block;
    width: 100%;
    height: 1px;
    background-color: var(--color-border-primary);
  }
}

.collapse-border {
  $collapse-border: 1px solid var(--color-border-primary);
  border-top: $collapse-border;
  .el-collapse-item__header {
    min-height: var(--el-collapse-header-height);
    height: auto;
    padding: 4px 0 4px 16px;
    border-bottom: $collapse-border;
    &.is-active {
      border-bottom: $collapse-border;
    }
  }
  .el-collapse-item {
    border-right: $collapse-border;
    border-left: $collapse-border;
  }
  .el-collapse-item__content {
    padding: 16px 16px;
    section {
      margin-bottom: 16px;
    }
  }
}

.el-col.col-need-row {
  // To squeeze the next column down
  margin-right: 40%;
}

.keep-spaces {
  white-space: pre-wrap;
}

code {
  padding: 0.25rem 0.5rem;
  margin: 0;
  color: var(--color-text-mdcode);
  font-size: 0.85em;
  border-radius: 3px;
  background-color: var(--color-bg-mdcode);
  font-family:
    Menlo,
    Monaco,
    Consolas,
    Courier New,
    monospace;
}

[data-theme='dark'] {
  .img-black {
    filter: invert(1);
  }
}

.border-checkbox {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--color-border-primary);
  padding: 12px;
  .checkbox-note {
    margin: 0px;
    padding-left: 21px;
    font-size: 13px;
    color: var(--color-text-footer);
    line-height: 1.6;
    word-break: break-word;
  }
}

.overview-visible {
  overflow: visible;
}

.node-status-dot {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 4px;
  &.is-running,
  &.is-success {
    background: var(--color-primary);
  }
  &.is-stopped {
    background: var(--color-text-placeholder);
  }
  &.is-danger {
    background: var(--el-color-danger);
  }
  &.is-warning {
    background: var(--el-color-warning);
  }
}
/* FLOW */
.flow {
  .node-item {
    padding: 9px 16px 9px 9px + 16px;
    margin-bottom: 8px;
    font-size: 14px;
    line-height: 22px;
    border-radius: 8px;
    border-style: solid;
    background: var(--color-bg-content);

    &::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      box-sizing: border-box;
      width: 20px;
      height: 100%;
      border-width: 0px 10px;
      border-style: solid;
      border-right-color: transparent;
      border-top-left-radius: 7px;
      border-bottom-left-radius: 7px;
    }

    &.node-source {
      &::before {
        border-left-color: #00b173;
      }
    }

    &.node-processing {
      &::before {
        border-left-color: #469cf7;
      }
    }

    &.node-sink {
      &::before {
        border-left-color: #906ef2;
      }
    }
    img.is-scaled-up {
      transform: scale(1.5);
    }
  }

  // To increase the weight
  .node-item,
  .vue-flow .node-item {
    border-width: 1px;
    border-color: var(--color-bg-mdcode);
  }

  .editor {
    .vue-flow__node {
      box-sizing: border-box;
      padding: 8px 16px;
    }

    .vue-flow__node.is-disabled {
      filter: grayscale(1);
      opacity: 0.7;
    }
  }

  $handle-size: 8px;
  .vue-flow__handle {
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: content-box;
    width: $handle-size;
    height: $handle-size;
    border: none;
    .icon-add {
      display: none;
      color: #fff;
      font-weight: 600;
      pointer-events: none;
    }
  }

  .vue-flow__handle-left {
    left: math.div(-$handle-size, 2);
  }

  .vue-flow__handle-right {
    right: math.div(-$handle-size, 2);
  }

  .vue-flow__handle {
    --vf-handle: #babcbe;
  }
}

label.custom-required::after {
  content: '*';
  color: var(--el-color-danger);
  margin-left: 4px;
}

.el-table__cell.overflow-visible {
  .cell {
    overflow: visible;
  }
}

.mock-required-label {
  &:after {
    content: '*';
    color: var(--el-color-danger);
    margin-left: 4px;
  }
}

.object-uploader {
  width: 400px;
  margin-left: auto;
  margin-right: auto;
  .icon-plus {
    display: block;
    width: 24px;
    height: 24px;
    margin-right: auto;
    margin-left: auto;
    color: var(--color-text-placeholder);
    margin-bottom: 12px;
  }
  .upload-placeholder {
    color: var(--color-text-placeholder);
    font-size: 16px;
  }
  .el-upload {
    width: 100%;
    .el-upload-dragger {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 100%;
      height: 200px;
    }
  }

  & + .upload-tip {
    width: 540px;
    margin-bottom: 24px;
    font-size: 14px;
    line-height: 20px;
  }
}

.el-table {
  .topic-list {
    margin-bottom: -4px;
    line-height: 1;
    .topic-item {
      box-sizing: border-box;
      display: inline-block;
      max-width: 100%;
      height: 24px;
      padding: 0 10px;
      margin-right: 4px;
      margin-bottom: 4px;
      font-size: 12px;
      line-height: 22px;
      white-space: nowrap;
      color: var(--color-text-primary);
      border: 1px solid var(--color-border-primary);
      border-radius: 8px;
      background-color: var(--color-bg-split);
      --el-tag-hover-color: var(--el-color-info);
      --el-tag-text-color: var(--el-color-info);
    }
  }
}

.form-topic-list-vertical {
  list-style: none;
  padding: 0;
  margin: 0;
  width: 100%;
  .topic-item {
    margin-bottom: 12px;
    .el-form-item {
      width: 100%;
    }
    .el-form-item__content {
      position: relative;
    }
    .el-button {
      padding-left: 8px;
      padding-right: 8px;
      margin-left: 12px;
    }
  }
  .btn-container {
    position: absolute;
    top: 0;
    right: -12px;
    transform: translateX(100%);
  }
}

.is-fallback {
  .col-fallback-actions {
    display: none;
  }
}

.reason-title {
  opacity: 0.6;
  margin: 4px 0 0;
}
.reason-content {
  margin: 4px 0;
}

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

.shrink-0 {
  flex-shrink: 0;
}

.min-w-0 {
  min-width: 0;
}

.flex-1 {
  flex: 1;
}
