@use "../abstracts/variables.scss" as *;
@use "../abstracts/mixins.scss" as *;

// Main Container
.realTime-viz {
  background-color: #131313;
  border-radius: 20px;
  box-shadow: $box-shadow-medium;
  width: calc(100% - (320px + 270px + 90px));
  height: calc(100% - (250px));
  position: absolute;
  top: 50%;
  left: calc(270px + 45px);
  transform: translate(0, -50%);
  border-radius: #{$border-radius-medium};
  transition: all 0.2s;
  z-index: #{$z-index-default};

  .realTime-viz-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    z-index: -1;
  }

  .floating {


    width: calc(var(--realTimeViz-container-width) * 0.2);
    height: calc(var(--realTimeViz-container-width) * 0.05);

    min-width: 250px;
    max-width: 300px;

    // min-height: 83px !important;
    // max-height: 100px !important;

    background: var(--background-color);
    border: 1.23px solid var(--border-color);
    box-shadow: 0px 4.91px 4.91px 0px #0000001c;
    border-radius: $border-radius-medium;
    padding: 18px;
    position: absolute;
    z-index: 1;
  }

  .scene-container {
    overflow: hidden;
  }

  .icon {
    display: flex;
    align-items: center;
    position: relative;
  }

  .icons-container {
    .icon {
      &:first-child {
        &::after {
          display: none;
        }
      }
    }
  }

  .zone-wrapper {
    display: flex;
    background-color: var(--background-color);
    position: absolute;
    bottom: 0px;
    left: 50%;
    gap: 6px;
    border-radius: 8px;
    max-width: 80%;
    overflow: auto;
    max-width: calc(100% - 500px);
    min-width: 150px;
    z-index: 3;
    transform: translate(-50%, -10%);

    &::-webkit-scrollbar {
      display: none;
    }

    .arrow {
      background-color: var(--highlight-accent-color);
      color: var(--background-color);
    }

    .zones-wrapper {
      padding: 6px;
      display: flex;
      gap: 6px;
      border-radius: #{$border-radius-medium};
      overflow-x: auto;

      &::-webkit-scrollbar {
        display: none;
      }
    }

    .no-zone {
      @include flex-center;
      gap: 4px;
      padding: 4px;
      color: var(--text-disabled);
    }

    .zone {
      width: auto;
      background-color: var(--background-color);
      border-radius: 6px;
      padding: 4px 8px;
      white-space: nowrap;
      font-size: $small;
    }

    .active {
      background-color: var(--accent-color);
      color: var(--background-color);
      // color: #FCFDFD !important;
    }
  }

  .zone-wrapper.bottom {
    bottom: var(--bottomWidth);
    // bottom: 200px;
  }

  .content-container {
    display: flex;
    height: 100vh;
    transition: all 0.3s ease;
  }

  .main-container {
    position: relative;
    flex: 1;
    height: 600px;
    background-color: rgb(235, 235, 235);
    margin: 0 30px;
    transition: height 0.3s ease, margin 0.3s ease;

    .zone-wrapper {
      display: flex;
      background-color: rgba(224, 223, 255, 0.5);
      position: absolute;
      // bottom: 10px;
      left: 50%;
      transform: translate(-50%, 0);
      gap: 6px;
      padding: 4px;
      border-radius: 8px;
      max-width: 80%;
      overflow: auto;
      transition: transform 0.3s ease;

      &::-webkit-scrollbar {
        display: none;
      }

      .zone {
        width: auto;
        background-color: $background-color;
        border-radius: 6px;
        padding: 4px 8px;
        white-space: nowrap;
        cursor: pointer;
        transition: background-color 0.3s ease;

        &.active {
          background-color: var(--primary-color);
          color: var(--accent-color);
        }
      }

      &.bottom {
        bottom: 210px;
      }
    }
  }

  .panel {
    position: absolute;
    background: var(--background-color);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    border-radius: 6px;
    overflow: auto;
    z-index: $z-index-tools;
    overflow: auto;

    &::-webkit-scrollbar {
      display: none;
    }

    .panel-content {
      position: relative;
      height: 100%;
      width: 100%;
      padding: 10px;
      display: flex;
      flex-direction: column;
      gap: 6px;
      background-color: var(--background-color);

      &::-webkit-scrollbar {
        display: none;
      }

      .chart-container {
        width: 100%;

        max-height: 100%;
        border: 1px dashed var(--background-color-gray);
        border-radius: 8px;
        box-shadow: var(--box-shadow-medium);
        padding: 6px 0;
        background-color: var(--background-color);
        position: relative;
        padding: 0 10px;

        .kebab {
          width: 30px;
          height: 30px;
          position: absolute;
          top: 0px;
          right: 0px;
          z-index: 10;
          cursor: pointer;
          @include flex-center;
        }

        .kebab-options {
          position: absolute;
          top: 18px;
          right: 5px;
          transform: translate(0px, 0);
          background-color: var(--background-color);
          z-index: 10;

          display: flex;
          flex-direction: column;
          gap: 6px;
          border-radius: 4px;

          box-shadow: var(--box-shadow-medium);

          .btn {
            display: flex;
            gap: 6px;
            align-items: center;
            padding: 5px 10px;
            color: var(--text-color);

            &:hover {
              .label {
                color: var(--accent-color);
              }
            }

            &:hover {
              background-color: var(--highlight-accent-color);
              width: 100%;

              svg {
                &:first-child {
                  fill: var(--accent-color);
                }

                &:last-child {
                  fill: auto;
                  stroke: var(--accent-color);
                }
              }
            }
          }

          .btn-blur {
            color: var(--text-disabled);
            cursor: not-allowed;
            pointer-events: none;
          }
        }
      }


      .close-btn {
        position: absolute;
        top: 5px;
        right: 5px;
        background: none;
        border: none;
        cursor: pointer;
        color: var(--primary-color);
      }
    }

    &.top-panel,
    &.bottom-panel {
      left: 0;
      right: 0;
      min-height: 150px;

      .panel-content {
        display: flex;
        flex-direction: row;
        height: 100%;
        width: 100%;
        min-height: 150px;

        .chart-container {
          min-width: 160px;
        }
      }
    }

    &.top-panel {
      top: 0;
    }

    &.bottom-panel {
      bottom: 0;
    }

    &.left-panel {
      left: 0;
      top: 0;
      bottom: 0;
    }

    &.right-panel {
      right: 0;
      top: 0;
      bottom: 0;
    }

    &.left-panel,
    &.right-panel {
      min-width: 150px;

      .panel-content {
        flex-direction: column;
        width: 100%;

        gap: 6px;

        .chart-container {
          width: 100%;
          min-height: 150px;
          max-height: 100%;
          border-radius: 8px;
          box-shadow: var(--box-shadow-medium);
          padding: 6px 0;
          background-color: var(--background-color);
          position: relative;
        }
      }
    }
  }

  .panel.hidePanel {
    pointer-events: none;
    opacity: 0;
  }
}

.playingFlase {
  .zone-wrapper.bottom {
    bottom: var(--bottomWidth);
    // bottom: 210px;
  }
}

// Side Buttons
.side-button-container {
  position: absolute;
  display: flex;
  background-color: var(--background-color);
  padding: 2px;
  border-radius: 2px;
  transition: transform 0.3s ease;
  box-shadow: #{$box-shadow-medium};

  .extra-Bs {
    display: flex;
    align-items: center;
    gap: 12px;

    .icon {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 18px;
      height: 18px;
      border-radius: 4px;
    }

    .active {
      background-color: var(--accent-color);
    }

    &:hover {
      cursor: pointer;
    }
  }

  .side-button {
    cursor: pointer;
    transition: background-color 0.3s ease;
    width: 18px;
    height: 18px;
    display: flex;
    justify-content: center;
    // align-items: center;
    background-color: var(--accent-color);
    border: none;
    color: var(--background-color);
    border-radius: 4px;

    .add-icon {
      @include flex-center;
      transition: rotate 0.2s;
    }

    path {
      stroke: var(--primary-color);
      stroke-width: 2;
    }
  }

  .active {
    background: #ffe3e0;

    .add-icon {
      rotate: 45deg;

      path {
        stroke: #f65648;
        stroke-width: 2;
      }
    }
  }

  &.top {
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    flex-direction: row;
    gap: 6px;
  }

  &.right {
    right: -30px;
    top: 50%;
    transform: translateY(-50%);
    flex-direction: column;
    gap: 6px;
  }

  &.bottom {
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    flex-direction: row;
    gap: 6px;
  }

  &.left {
    left: -30px;
    top: 50%;
    transform: translateY(-50%);
    flex-direction: column;
    gap: 6px;
  }
}

.right.side-button-container {
  .extra-Bs {
    flex-direction: column;
  }
}

.left.side-button-container {
  .extra-Bs {
    flex-direction: column;
  }
}

// Theme Container
.theme-container {
  width: 250px;
  padding: 12px;
  box-shadow: 1px -3px 4px 0px rgba(0, 0, 0, 0.11);
  border-radius: 8px;
  background-color: white;
  position: absolute;
  top: 20px;
  right: -100%;
  transform: translate(-0%, 0);

  h2 {
    font-size: var(--font-size-small);
    margin-bottom: 8px;
    color: #2b3344;
  }

  .theme-preset-wrapper {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;

    .theme-preset {
      display: flex;
      gap: 2px;
      margin-bottom: 10px;
      border: 1px solid $border-color;
      padding: 5px 10px;
      border-radius: 4px;
      transition: border 0.3s ease;

      &.active {
        border: 1px solid var(--primary-color);

        &::after {
          content: "";
          position: absolute;
          top: 1px;
          left: 1px;
          width: 10px;
          height: 10px;
          background-color: var(--primary-color);
          border-radius: 50%;
        }
      }
    }
  }

  .custom-color {
    display: flex;
    justify-content: space-between;

    .color-displayer {
      display: flex;
      gap: 5px;
      align-items: center;
      border: 1px solid var(--accent-color);
      border-radius: 4px;
      padding: 0 5px;

      input {
        border: none;
        outline: none;
        border-radius: 50%;
      }
    }
  }
}

.arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  cursor: pointer;
  z-index: 10;
  height: 100%;
}

.left-arrow {
  left: 0;
}

.right-arrow {
  right: 0;
}

.zone {
  padding: 10px;
  border: 1px solid var(--highlight-accent-color);
  border-radius: 5px;
  cursor: pointer;
}

.zone.active {
  background-color: #007bff;
  color: white;
}

.floating-wrapper {
  .icon {
    // width: 25px !important;
    // height: 25px !important;
    // background-color: transparent;
  }

  .kebab {
    width: 25px;
    height: 25px;
    position: absolute !important;
    top: 0px;
    right: 0px;
    z-index: 10;
    cursor: pointer;
    @include flex-center;
    background-color: transparent !important;
  }

  .kebab-options {
    position: absolute;
    top: 18px;
    right: 5px;
    transform: translate(0px, 0);
    background-color: var(--background-color);
    z-index: 10;

    display: flex;
    flex-direction: column;
    gap: 6px;
    border-radius: 4px;

    box-shadow: var(--box-shadow-medium);

    .icon {
      width: 25px !important;
      height: 25px !important;
      background-color: transparent;
    }

    .btn {
      display: flex;
      gap: 6px;
      align-items: center;
      padding: 5px 10px;
      color: var(--text-color);
      cursor: pointer;

      &:hover {
        .label {
          color: var(--accent-color);
        }
      }

      &:hover {
        background-color: var(--highlight-accent-color);
        width: 100%;

        svg {
          &:first-child {
            fill: var(--accent-color);
          }

          &:last-child {
            fill: auto;
            stroke: var(--accent-color);
          }
        }
      }
    }
  }
}

.distance-line {
  position: absolute;
  border-style: dashed;
  border-color: var(--accent-color);
  /* Green color for visibility */
  border-width: 1px;
  pointer-events: none;
  /* Ensure lins don't interfere with dragging */
  z-index: 10000;
}

/* Label styles for displaying distance values */
.distance-label {
  position: absolute;
  background-color: var(--accent-color);
  color: white;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 3px;
  white-space: nowrap;
  transform: translate(-50%, -50%);
  /* Center the label */
}

/* Specific styles for each type of line */

/* Top distance line */
.distance-line.top {
  border-bottom: none;
  /* Remove bottom border for a single line */
  width: 2px;
  /* Thin vertical line */
}

.distance-line.top .distance-label {
  top: -10px;
  /* Position label above the line */
  left: 50%;
  /* Center horizontally */
}

/* Bottom distance line */
.distance-line.bottom {
  border-top: none;
  /* Remove top border for a single line */
  width: 2px;
  /* Thin vertical line */
}

.distance-line.bottom .distance-label {
  bottom: -10px;
  /* Position label below the line */
  left: 50%;
  /* Center horizontally */
}

/* Left distance line */
.distance-line.left {
  border-right: none;
  /* Remove right border for a single line */
  height: 2px;
  /* Thin horizontal line */
}

.distance-line.left .distance-label {
  left: -10px;
  /* Position label to the left of the line */
  top: 50%;
  /* Center vertically */
}

/* Right distance line */
.distance-line.right {
  border-left: none;
  /* Remove left border for a single line */
  height: 2px;
  /* Thin horizontal line */
}

.distance-line.right .distance-label {
  right: -10px;
  /* Position label to the right of the line */
  top: 50%;
  /* Center vertically */
}

.activeChart {
  outline: 2px solid var(--accent-color);
  z-index: 2 !important;
}

.chart-container.notLinked {

  outline: 1px solid red;


}

.connectionSuccess {
  outline-color: #43c06d;
}

.connectionFails {
  outline-color: #ffe3e0;
}

.editWidgetOptions {
  position: absolute;
  background-color: var(--background-color);
  z-index: 3;
  display: flex;
  flex-direction: column;
  border-radius: 6px;
  overflow: hidden;
  padding: 4px;

  min-width: 150px;

  .option {
    padding: 4px 10px;
    border-radius: #{$border-radius-small};
    color: var(--text-color);
    cursor: pointer;

    &:hover {
      background-color: var(--highlight-accent-color);
      color: var(--accent-color);
    }

    &:last-child {
      color: #f65648;

      &:hover {
        background-color: #f65648;
        color: white;
      }
    }
  }
}