@use 'normalize';
@use 'scrollbar';
@use 'colors' as *;
@use "sass:color";
@use 'modal';
@use 'nav';
@use 'code_mirror';

@font-face {
  font-family: 'ProximaNova-Regular';
  src: url('/assets/font/ProximaNova-Regular.otf') format('opentype');
  font-weight: normal;
  font-style: normal;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: "ProximaNova-Regular", sans-serif;
}

body {
  height: 100vh;
  width: 100vw;
  margin-top: 100px;
  background-color: $light-1;
}

.animate__animated.animate__fadeInDown, .animate__animated.animate__fadeOutUp {
  --animate-duration: 500ms;
}

body.modal-open {
  overflow: hidden;
}

.stale {
  color: #E12D39;
  margin-top: 8px;
  text-align: center;
  width: 100%;
}

.row {
  display: flex;
  flex-direction: row;
  justify-content: center;
  gap: 10px;
  align-items: center;
}

.row-3 {
  display: flex;
  flex-direction: row;
  justify-content: center;
  gap: 10px;
  align-items: center;
}

.text-on-line {
  position: relative;
  width: 100%;
  text-align: center;
  margin: 20px 0 5px;

  &::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: $light-4;
    z-index: 1;
  }

  > span {
    background: $light-3;
    color: $light-5;
    padding: 0 10px;
    position: relative;
    z-index: 2;
    font-size: 1.75em;
  }
}

.card-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 40px;
  min-width: 220px;

  &.line-chan-style {
    margin-bottom: 20px;
  }

  .meter-cards, .output-cards {
    display: flex;
    flex-direction: row;
    gap: 15px;
    margin-bottom: 30px;
    width: 100%;

    .meter-card, .output-card {
      background: $light-3;
      border-radius: 3px;
      padding: 10px;
      box-shadow: 0 4px 12px $light-9;
      width: 100%;
      min-width: 150px;

      .buffer-info {
        font-size: 1em;
        color: $light-2;
        margin-bottom: -1px;
      }
      .meter-container {
        width: 100%;
      }

    }
  }

  .proc-card {
    background: $light-3;
    border-radius: 3px;
    width: 100%;
    display: inline-block;
    position: relative;
    transition: all 0.4s ease-in-out;
    //overflow: hidden;
    will-change: height;
    margin-bottom: 55px;

    &.expanded {
      .expanded-view {
        max-height: 500px;
        opacity: 1;
        visibility: visible;
      }

      .collapsed-view-container {
        max-height: 0;
        opacity: 0;
        visibility: hidden;
      }

    }

    &.collapsed {
      .expanded-view {
        max-height: 0;
        opacity: 0;
        visibility: hidden;
      }

      .collapsed-view-container {
        max-height: 100px;
        opacity: 1;
        visibility: visible;
      }
    }

    .chevron-icon {
      position: absolute;
      top: 8px;
      right: 10px;
      cursor: pointer;
      z-index: 10;

      img {
        height: 15px;
        transition: transform 0.3s ease-in-out;
        &.up {
            filter: brightness(0) saturate(100%) invert(100%);
        }
      }
    }

    .expanded-view {
      transition: all 0.4s ease-in-out;
      max-height: 0; // start collapsed
      opacity: 0;
      overflow: hidden;
      visibility: hidden;

      .chevron-icon {
        position: absolute;
        top: 8px;
        right: 10px;
        cursor: pointer;

        img {
          height: 15px;
        }
      }

      .header-labels {
        display: flex;
        justify-content: center;
        padding: 0 15px;

        .header-label {
          font-size: 1.75em;
          font-weight: 500;
          color: $light-5;
          text-align: center;
          width: 150px;
        }
      }

      .middle-section-one-container {
        box-sizing: border-box;
        background: $light-20;
        color: $light-21;
        border-radius: 2px;
        position: relative;
        padding: 10px 0;
        width: calc(100% - 20px);
        margin: auto;

        .status-icon {
          position: absolute;
          top: 5px;
          left: 3px;
          cursor: pointer;

          img {
            height: 30px;
          }
        }
      }


      .title-container {
        text-align: center;

        .title {
          font-size: 2.3em;
          font-weight: 600;
          margin: 0;
          color: white;
        }
      }

      .call-count {
        text-align: center;
        margin-top: 5px;
      }

      .action-buttons {
        display: flex;
        justify-content: center;
        gap: 15px;
        margin-top: 10px;

        .action-button {
          background: color.adjust($light-20, $lightness: 10%);
          border-radius: 4px;
          min-width: 40px;
          height: 30px;
          display: flex;
          align-items: center;
          justify-content: center;
          cursor: pointer;
          transition: background 0.2s;
          z-index: 10;

          &.error {
            background: $light-14;
            &:hover {
              background: color.adjust($light-14, $lightness: 5%);
            }
          }

          &:hover {
            background: color.adjust($light-20, $lightness: 15%);
          }

          img {
            width: 20px;
            height: 20px;
          }
        }
      }
    }

    .collapsed-view-container {
      transition: all 0.4s ease-in-out;
      max-height: 0;
      opacity: 0;
      overflow: hidden;
      visibility: hidden;

      .header-els {
        display: flex;
        justify-content: center;
        background: $light-20;

        .header-label {
          color: $light-20;
          text-align: center;
          width: 150px;
        }
      }
      .collapsed-view {
        background: $light-20;
        color: $light-21;
        border-radius: 3px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0 20px;
        height: 60px;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);

        .title-container {
          .title {
            font-size: 2em;
            font-weight: 600;
            color: $light-21;
            margin: 0;
            letter-spacing: 1px;
          }
        }

        .action-buttons {
          display: flex;
          justify-content: flex-start;
          align-items: center;
          gap: 2px;
          flex-grow: 1;
          padding-left: 10px;

          .action-button {
            background: transparent;
            min-width: 40px;
            height: 40px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;

            img {
              width: 20px;
              height: 20px;
              filter: brightness(0) saturate(100%) invert(100%); // White icons
            }

            &:hover {
              transform: scale(1.1);
            }
          }
        }

      }

      .output-section-collapsed {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        box-sizing: border-box;

        .output-container {
          display: flex;
          flex-direction: row;
          gap: 15px;
          justify-content: center;
          align-items: center;
          width: calc(100% - 14px);
          margin: 0 7px;
          padding: 0 0;
          box-sizing: border-box;

          .output {
            flex: 1;
            min-width: 110px;
            color: $light-5;
            text-align: center;
            display: flex;
            justify-content: center;
            align-items: center;
            white-space: nowrap;
          }
        }
      }
    }

    .output-section {
      width: 100%;
      display: flex;
      flex-direction: column;
      align-items: center;
      box-sizing: border-box;

      .output-container {
        display: flex;
        flex-direction: row;
        gap: 15px;
        justify-content: center;
        align-items: center;
        width: calc(100% - 14px);
        margin: 0 7px;
        padding: 0 0;
        box-sizing: border-box;

        .output {
          flex: 1;
          min-width: 110px;
          padding: 0 8px;
          font-size: 1.75em;
          color: $light-5;
          text-align: center;
          height: 40px;
          display: flex;
          justify-content: center;
          align-items: center;
          white-space: nowrap;
        }
      }
    }
  }
}

.output-cards {
  display: flex;
  flex-direction: row;
  gap: 15px;
  margin-top: 15px;

  .collapsible-element {
    overflow: hidden;
  }

  .collapsible-meter {
    overflow: hidden;
  }

  .collapsing {
    transition: height 0.3s ease;
  }

  .output-card {
    background: $light-3;
    border-radius: 5px;
    padding: 10px;
    box-shadow: 0 4px 12px $light-9;
    width: 100%;
    min-width: 150px;

    .output {
      font-size: 1.75em;
      color: $light-5;
      white-space: nowrap;
    }
  }
}

.meter-wrapper {
  width: 100%;

  .label-container {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-top: 5px;
    margin-bottom: -1px;
    color: $light-2;
  }

  .diverging-meter-container {
    width: 100%;
    height: 1.2em;
    border: 1px solid $light-17;
    border-radius: 2px;
    position: relative;
    display: inline-block;
    overflow: hidden;

    .meter-left {
      position: absolute;
      left: 0;
      top: 0;
      width: 50%;
      height: 100%;
      background: linear-gradient(to right,
              #E12D39 0%,
              #F0B429 50%,
              #014D40 100%);
    }
    .meter-right {
      position: absolute;
      right: 0;
      top: 0;
      width: 50%;
      height: 100%;
      background: linear-gradient(to right,
              #014D40 0%,
              #F0B429 50%,
              #E12D39 100%);
    }
    .meter-cover-left {
      position: absolute;
      left: 0;
      top: 0;
      width: 50%;
      height: 100%;
      background: white;
      transition: width 0.3s linear;
    }
    .meter-cover-right {
      position: absolute;
      right: 0;
      top: 0;
      width: 50%;
      height: 100%;
      background: white;
      transition: width 0.3s linear;
    }
    .meter-center {
      position: absolute;
      left: 49.5%;
      top: 0;
      width: 2px;
      height: 100%;
      background: #333;
      z-index: 1;
    }
  }
}

.meter-container {
  text-align: center;
  background: rgb(230,244,234);
  background: linear-gradient(90deg, #014D40 0%, #F0B429 50%, #E12D39 100%);
  width: 90%;
  height: 1.2em;
  border: 1px solid black;
  border-radius: 2px;
  overflow: hidden;
  position: relative;
  .meter {
    position: absolute;
    right: 0;
    top: 0;
    width: 90%;
    height: 100%;
    background: white;
    transition: width 0.3s linear;
  }
}

.tabs {
  display: flex;
  align-items: center;
  flex-direction: row;
  flex: 0 0 auto;
  font-family: "ProximaNova-Regular", sans-serif;
  .tab {
    flex-grow: 1;
    font-size: 1em;
    height: 50px;
    background: $light-4;
    border-bottom: 1px solid $light-7;
    border-left: 1px solid $light-7;
    border-right: 1px solid $light-7;
    border-top: 2px solid $light-4;
    display: flex;
    align-items: center;
    padding-left: 12px;
    span {
      left: 15px;
      position: relative;
      cursor: pointer;
    }
    &.active {
      background: $light-3;
      font-weight: bold;
      border: none;
      border-top: 3px solid $light-2;
    }
  }
}

.panel-contents {
  flex: 1;
  min-height: 0;
  overflow: hidden;

  #error-display {
    height: 99.9%;
    overflow-y: auto;
    background: $light-3;
    padding: 10px;

    &::after {
      content: '';
      display: block;
      height: 20px;
    }

    pre {
      font-family: 'Source Code Pro', monospace;
      margin: 0;
      padding: 0 10px;
      overflow: visible;
      height: auto;
      &:not(:last-child) {
        border-bottom: 1px solid $light-7;
        margin-bottom: 15px;
        padding-bottom: 15px;
      }
    }
  }

  #log-display {
    height: 99.9%;
    overflow-y: auto;
    background: $light-3;
    padding: 10px;
    margin: 20px 0;

    &::after {
      content: '';
      display: block;
      height: 20px;
    }

    pre {
      font-family: 'Source Code Pro', monospace;
      margin: 0;
      padding: 0 10px;
      overflow: visible;
      height: auto;
      &:not(:last-child) {
        border-bottom: 1px solid $light-7;
        margin-bottom: 15px;
        padding-bottom: 15px;
      }
    }
  }
}

.code-block {
  background-color: lighten($light-20, 8%);
  border-radius: 2px;
  padding: 5px;
  margin: 10px;
  overflow-x: auto;
  overflow-y: auto;
  max-height: 145px;
  code {
    display: block;
    //font-family: monospace;
    white-space: pre;
    line-height: 1.3;
    overflow-x: auto;
    overflow-y: auto;
    scrollbar-width: auto;
  }
}

.centered-button-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.button {
  padding: 12px 24px;
  font-weight: 600;
  background-color: $light-15;
  color: $light-17;
  border: none;
  border-radius: 2px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  text-align: center;
  transition: all 0.3s ease;
  font-size: 1.2em;

  &:hover {
    background-color: lighten($light-15, 5%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  }

  &:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  }
}

#alerts {
  display: flex;
  position: absolute;
  flex-direction: column;
  font-weight: bold;
  font-size: 1.2em;
  right: 32px;
  z-index: 999;
  top: 40px;
  &:hover {
    cursor: pointer;
  }
  .notification {
    margin-top: 15px;
    padding: 20px;
    text-align: center;
    border: 1px solid #3e3e3e;
    box-shadow: 1px 6px 9px 0 rgba(0, 0, 0, 0.18), 0 6px 15px 0 rgba(0, 0, 0, 0.15);
    position: relative;
    &.is-success {
      background: $light-6;
      color: $light-3;
    }
    &.is-error {
      background-color: #A88B47;
      color: #000000;
    }
    &.is-danger {
      background-color: #771C14;
      color: #D9CAC1;
    }
    span {
      position: absolute;
      right: 5px;
      top: 2px;
    }
  }
}

.dot-pattern {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(127, 127, 127, 0.5) radial-gradient(black 33%, transparent 33%);
  background-size: 3px 3px;
  pointer-events: none;
  z-index: 5;
}

.table-container {
  width: 100%;
  overflow-x: auto;
  overflow-y: auto;
  margin: 20px 0;
  font-size: 1em;
  border: 1px solid $light-11;
  position: relative;
}

.data-table {
  width: 100%;
  border-collapse: collapse;

  th, td {
    padding: 10px 15px;
    border-bottom: 1px solid $light-11;
    text-align: left;
    white-space: nowrap;
  }

  th {
    background-color: $light-7;
    color: $light-3;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
  }

  tr {
    background-color: $light-3;
  }

  tr:hover {
    background-color: color.adjust($light-3, $lightness: 10%);;
  }
}

.controls-row {
  display: flex;
  align-items: stretch;
  margin-bottom: 15px;
  width: 100%;
  gap: 12px;
  padding: 0 2px;
}

.filter-container {
  flex: 1 1 70%;

  input {
    width: 100%;
    height: 36px;
    padding: 8px 12px;
    border: 1px solid $light-12;
    border-radius: 2px;
    box-sizing: border-box;
    font-size: 14px;
  }
}

.filter-container-full {
  flex: 1 1 100%;
}

.dropdown-select {
  flex: 0 0 28%;
  min-width: 80px;
  max-width: 180px;
  height: 36px;
  padding: 8px 24px 8px 12px;
  border: 1px solid $light-12;
  border-radius: 2px;
  background-color: white;
  font-size: 14px;
  box-sizing: border-box;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px;
}

.modal-body-pad {
  padding: 16px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  height: 70vh;

  .panel-contents {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    position: relative;
  }
}
