@import "variables";
@import "mixins";

// Icomoon
@import "../fonts/icomoon/style.css";

// Import all the components
//@import "../../src/XXX/scss/style.scss";

:root {
    --webien-ai-color-primary: #000;
    --webien-ai-color-primary-light: #f1f6e9;
    --webien-ai-color-secondary: #5897fb;
    --webien-ai-color-border: #ccc;
    --webien-ai-color-white: #fff;
    --webien-ai-color-black: #000;
    --webien-ai-font-size: 18px;
    --webien-ai-input-height: 50px;
    --webien-ai-border-radius: 20px;
    --webien-ai-box-shadow-big: rgba(0, 0, 0, 0.1) 0px 20px 25px -5px, rgba(0, 0, 0, 0.04) 0px 10px 10px -5px;
    --webien-ai-link-color: var(--webien-ai-color-secondary);
}


html.webien-chat-open,
body.webien-chat-open {
    overflow: hidden;
    height: 100%;
}

.webien-ai {

  button.openChat {
    position: fixed;
    bottom: 30px;
    right: 30px;
    @include normalize-button;
    width: 60px;
    height: 60px;
    background: var(--webien-ai-color-primary);
    color: var(--webien-ai-color-white);
    border-radius: 50%;
    z-index: 1000;
    box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;

    i {
      font-size: 28px;
    }
  }

  .chat {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba($white, 0.9);
    z-index: 9999999;
    display: none;
    overflow-y: auto;
    backdrop-filter: blur(10px);

    &.active {
      display: block;
    }


    .header {
      position: sticky;
      top: 0;
      padding: 20px;
      width: calc(100% - 40px);
      z-index: 1000;
      display: flex;
      justify-content: flex-end;
      align-items: center;


      button.closeChat {
        @include normalize-button;
        width: 60px;
        height: 60px;
        color: $black;
        font-size: 30px;
      }


      .info {
        font-size: 80%;
        padding: 5px 10px;
        background: var(--webien-ai-color-white);
        border: 1px solid var(--webien-ai-color-border);
        border-radius: 8px;

        .meta {
          display: flex;
          gap: 2px;
          flex-direction: column;
          padding-bottom: 5px;


          span {
            display: inline-block;
            font-size: 10px;
            line-height: 10px;
          }
        }

        .buttons {
          border-top: 1px solid $gray-light;
          padding-top: 5px;
          display: flex;
          gap: 10px;
          flex-wrap: wrap;

          button {
            @include normalize-button;
            color: $black;
            font-weight: normal;
            text-decoration: underline;
            font-size: 10px;
          }
        }

      }
    }



    .conversation {
      display: flex;
      flex-direction: column;
      gap: 20px;
      max-width: 1000px;
      margin: 0 auto;
      padding: 20px 20px 60px 20px;
      min-height: 100%;
      justify-content: flex-end;
      overflow-y: auto;
      font-size: var(--webien-ai-font-size);


      .user {
        align-self: flex-end;
        background: var(--webien-ai-color-white);
        border-radius: var(--webien-ai-border-radius);
        border: 1px solid var(--webien-ai-color-border);
        padding: 10px 20px;
      }

      .assistant {
        padding: 10px 0;
        display: flex;
        gap: 20px;
        align-items: baseline;

        a {
          text-decoration: underline;
          font-weight: bold;
          color: var(--color-text-link, var(--webien-ai-link-color));

          &:hover {
            color: var(--color-text-link, var(--webien-ai-link-color-hover));
          }
        }

        .avatar {
          flex-shrink: 0;
          width: 50px;
          height: 50px;
          border-radius: var(--webien-ai-border-radius);
          background: var(--webien-ai-color-white);
          color: var(--webien-ai-color-primary);
          border: 1px solid var(--webien-ai-color-border);
          display: grid;
          place-items: center;
          font-size: 24px;
        }


        &.initial-msg {
          background: var(--webien-ai-color-primary-light);
          padding: 15px 30px;
          border-radius: var(--webien-ai-border-radius);

          .avatar {
            display: none;
          }
        }

        &.loading {
          align-items: center;

          svg {
            width: 50px;
            height: auto;

            circle {
                fill: var(--webien-ai-color-primary);
            }

          }

        }
      }



    }




    .input-form {
      position: sticky;
      bottom: 50px;
      width: calc(100% - 40px);
      display: flex;
      gap: 20px;
      left: 20px;
      user-select: none;
      max-width: 600px;

      @include desktop {
        transform: translateX(-50%);
        left: 50%;
      }


      input {
        flex-grow: 1;
        border-radius: 50px;
        height: var(--webien-ai-input-height);
        padding: 0 20px;
        background: var(--webien-ai-color-white);
        border: 1px solid var(--webien-ai-color-border);
        box-shadow: var(--webien-ai-box-shadow-big);

        &:focus {
          outline: 1px solid var(--webien-ai-color-primary);
          border-color: var(--webien-ai-color-primary);
        }
      }

      button.submit {
        position: absolute;
        right: 5px;
        top: 50%;
        transform: translateY(-50%);
        @include normalize-button;
        width: calc(var(--webien-ai-input-height) - 8px);
        height: calc(var(--webien-ai-input-height) - 8px);
        background: var(--webien-ai-color-white);
        border: 1px solid var(--webien-ai-color-border);
        color: var(--webien-ai-color-primary);
        border-radius: 50%;
        display: grid;
        place-items: center;

        @include hover {
          background: var(--webien-ai-color-primary);
          color: var(--webien-ai-color-white);
          border-color: var(--webien-ai-color-primary);
        }
      }


      button.reset-thread {
        position: absolute;
        @include normalize-button;
        font-size: 0.7rem;
        top: calc(var(--webien-ai-input-height) + 10px);
        right: 50%;
        transform: translateX(50%);

        @include hover {
          text-decoration: underline;
        }

      }



    }
  }




  // Widget version
  &.widget {

    button.openChat,
    .header {
      display: none;
    }

    .chat {
      position: relative;
      background: transparent;
      z-index: auto;
      display: block;
      backdrop-filter: none;
      overflow-y: hidden;

      .first-msg {
        opacity: 0;
      }

      .conversation {
        max-width: 640px;
      }

      .reset-thread {
        display: none;
      }

      &.started,
      &.has-thread {
        position: fixed;
        overflow-y: auto;

        .first-msg {
            opacity: 1;
        }

        /*
        button.closeChat {
          display: block;
        }
         */

        .reset-thread {
          display: block;
        }
      }

      &.has-thread {
        .conversation {
          max-width: 1000px;
        }
      }

    }
  }



}




.elementor-widget-webien_ai_prompt {
  width: 100%;
  height: 100%;

}