:host {
  display: block;
  font-family: sans-serif;
}

.juno-chat-area {
  background-color: #ffffff;
  width: 100%;
  height: 70svh;
  max-width: 30svw;
  color: #000;
  border: 1px solid #f8fafc;
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  transform: scale(1);
  transition: all 300ms ease-in-out;
  transform-origin: bottom;
  border-radius: 1.5rem;
  box-shadow:
    rgba(150, 150, 150, 0.2) 0px 10px 30px 0px,
    rgba(150, 150, 150, 0.2) 0px 0px 0px 1px;
  display: flex;
  flex-direction: column;
  width: 100%;
  z-index: 999999;

  @starting-style {
    transform: scale(0);
  }

  &:is(.left) {
    right: auto;
    left: 1rem;
  }
  &:is(.right) {
    right: 1rem;
    left: auto;
  }
  &:is(.top) {
    inset: 0;
    width: 100%;
    max-width: 100svw;
    border-radius: 0;
  }

  &:is(.bottom) {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100svw;
    border-radius: 0;
  }

  .juno-chat-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 1px solid #f1f5f9;
    padding: 0.725rem 1rem;

    .juno-brand-logo svg {
      width: 1.5rem;
      height: 1.5rem;
    }

    .brand-info {
      small {
        font-size: 80%;
        opacity: 0.5;
        text-transform: capitalize;
      }
    }

    .flex-group {
      display: flex;
      align-items: center;
      gap: 0.35rem;
    }

    p {
      margin: 0;
    }

    .juno-status-indicator {
      cursor: pointer;
      position: relative;

      .status {
        width: 0.5rem;
        height: 0.5rem;
        border-radius: 100%;
        scale: 1;
        transition: all 0.3s ease-in-out;
        @starting-style {
          scale: 0;
        }
      }

      &:is(.online) {
        background-color: oklch(0.967 0.067 122.328);

        .status {
          background-color: oklch(0.768 0.233 130.85);
        }
      }
      &:is(.offline) {
        background-color: oklch(0.984 0.003 247.858);

        .status {
          background-color: oklch(0.704 0.04 256.788);
        }
      }
      &:is(.reconnecting) {
        background-color: oklch(0.973 0.071 103.193);
        .status {
          background-color: oklch(0.795 0.184 86.047);

          &::before {
            position: absolute;
            width: 0.625rem;
            height: 0.625rem;
            border-radius: 100%;
            background-color: oklch(0.795 0.184 86.047);
            opacity: 0.75;
            content: '';
            animation: ping 1s ease infinite;
            top: 50%;
            left: 50%;
            translate: -50% -50%;
          }
        }
      }
    }

    .juno-buttons-container {
      margin-left: auto;
      display: flex;
      gap: 0.25rem;
    }
    .juno-size-button {
      width: 2rem;
      height: 2rem;
      border: 0;
      background-color: oklch(0.968 0.007 247.896);
      border-radius: 0.5rem;
      display: flex;
      justify-content: center;
      align-items: center;
      cursor: pointer;
      svg {
        fill: oklch(0.554 0.046 257.417);
        width: 1rem;
        height: 1rem;
        margin-bottom: 0;
      }
    }

    .action-wrapper {
      position: relative;

      .popup-content {
        z-index: 200;
        position: absolute;
        background: #fff;
        min-width: 180px;
        right: 0;
        transform: translateY(8%);
        transition: all 0.2s ease-in-out;
        border-radius: 0.5rem;
        box-shadow:
          rgba(150, 150, 150, 0.2) 0px 10px 30px 0px,
          rgba(150, 150, 150, 0.2) 0px 0px 0px 1px;
        @starting-style {
          scale: 0;
        }
        transform-origin: top;
        scale: 0;

        &:is(.active) {
          scale: 1;
        }

        .block-group {
          padding: 0.5rem 1rem;

          .block {
            margin-bottom: 0.5rem;
          }

          small {
            font-size: 0.75rem;
            color: rgba(0, 0, 0, 0.6);
          }
        }

        .actions {
          display: flex;
          width: 100%;
          gap: 0.5rem;
          margin-top: 1rem;
          button {
            width: 100%;
            background-color: transparent;
            border: 1px solid rgba(150, 150, 150, 0.2);
            display: inline-flex;
            justify-content: center;
            align-items: center;
            padding: 0.25rem;
            border-radius: 0.25rem;
            cursor: pointer;
          }
          svg {
            width: 1.25rem;
            height: 1.25rem;
            fill: oklch(0.554 0.046 257.417);
            user-select: none;
            pointer-events: none;
          }
        }
      }

      .popup-action {
        background: transparent;
        border: 0;
        border-bottom: 1px solid rgba(150, 150, 150, 0.2);
        width: 100%;
        text-align: left;
        display: block;
        padding: 0.725rem 1rem;
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 0.5rem;
        color: oklch(0.554 0.046 257.417);

        svg {
          width: 0.8rem;
          height: 0.8rem;
        }

        &:is(:disabled) {
          opacity: 0.5;
          cursor: not-allowed;
        }
      }
    }
  }

  .juno-chat-container {
    height: 80%;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.725rem;
    scroll-behavior: smooth;

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

    .juno-disclaimer {
      text-align: center;
      max-width: 20rem;
      margin: 0 auto;
      opacity: 0.35;
      font-size: 0.75rem;
      display: block;
      margin-block: 0.5rem 2rem;
    }
  }

  .juno-chat-footer {
    padding: 1rem;
    border-top: 1px solid #f1f5f9;

    form {
      position: relative;
      display: flex;
      width: 100%;
      border: 1px solid #cad5e2;
      background-color: #fff;
      transition: all 0.3s ease-in-out;
      border-radius: 5rem;
      justify-content: center;
      align-items: center;
      input {
        width: 100%;
        padding: 0.925rem 1rem;
        border: 0;
        outline: none;
        font-size: 0.825rem;
        background-color: transparent;
        box-sizing: border-box;
        background-clip: padding-box;

        &::placeholder {
          font-size: 0.825rem;
        }
      }

      button {
        background-color: transparent;
        border: 0;
        background-color: #000;
        width: 2rem;
        height: 2rem;
        flex-shrink: 0;
        border-radius: 50%;
        display: flex;
        justify-content: center;
        align-items: center;
        margin-right: 0.5rem;
        cursor: pointer;
        svg {
          width: 1rem;
          height: 1rem;
          fill: white;
          user-select: none;
          pointer-events: none;
        }

        &:disabled {
          opacity: 0.7;
          cursor: not-allowed;
        }
      }
    }
  }

  &:is(.maximized) {
    max-width: 100svw;
    height: 100svh;
    bottom: 0;
    right: 0;
  }
}

@media (max-width: 600px) {
  .juno-chat-area {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 100svh;
    max-width: none;
    border-radius: 0;

    .juno-chat-header {
      .maximize-button {
        display: none;
      }

      .close-button {
        display: block;
      }
    }
  }

  .juno-chat-area.maximized {
    width: 100vw;
    height: 100svh;
    max-width: none;
  }
}

@media (min-width: 768px) and (max-width: 1100px) and (orientation: landscape) {
  .juno-chat-area {
    bottom: 4.5rem;
    right: 1rem;
    width: 35vw;
    max-width: none;
    height: 75svh;
    border-radius: 1.2rem;
  }

  .juno-chat-area.maximized {
    width: 65vw;
    height: 85svh;
  }
}

.spin {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes ping {
  75%,
  100% {
    transform: scale(2);
    opacity: 0;
  }
}
