@import "../../../../../styles/index.scss";

.chat-input {
  background: $whiteColor;
  margin: 0px 23px;
  margin-bottom: 12px;

  &.focused {
    border-top-color: $primaryColor;
  }

  .edit-mode-indicator {
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 8px;

    .edit-mode-text {
      display: flex;
      align-items: center;
      justify-content: space-between;
      font-size: 14px;
      color: #856404;

      span {
        display: flex;
        align-items: center;
        gap: 6px;
        font-weight: 500;
      }

      .cancel-edit-btn {
        background: none;
        border: 1px solid #ffeaa7;
        border-radius: 4px;
        color: #856404;
        cursor: pointer;
        font-size: 12px;
        padding: 4px 8px;
        transition: all 0.2s ease;

        &:hover {
          background-color: #ffeaa7;
          color: #6c5400;
        }
      }
    }
  }

  .quick-action-container {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-bottom: 6px;
  }
  .show-formatting-enabled {
    justify-content: space-between;
  }

  .formatting-toolbar {
    display: flex;
    align-items: center;

    .format-button {
      background: none;
      border: none;
      color: $inputInfoColor;
      cursor: pointer;
      padding: 6px;
      border-radius: 4px;
      display: flex;
      align-items: center;
      justify-content: center;

      &:hover {
        background: $lightBlueColor;
        color: $primaryColor;
      }
    }
  }

  .input-container {
    position: relative;

    .input-wrapper {
      display: flex;
      align-items: flex-end;
      gap: 8px;
      padding: 12px 16px;
      border: 1px solid $disabledSecondaryBorder;
      border-radius: 12px;
      background: $whiteColor;
      transition: border-color 0.2s ease;
      box-shadow: 0px 0px 12px 8px $boxShadowSoft;

      &:focus-within {
        border-color: $primaryColor;
      }

      .message-input {
        flex: 1;
        border: none;
        outline: none;
        background: none;
        font-size: $normalFontSize;
        line-height: 1.4;
        color: $mainFontColor;
        font-family: $fontFamily;

        &::placeholder {
          color: $inputInfoColor;
        }
      }

      .image-input-container {
        display: flex;
        gap: 2px;
        flex-direction: column;
        width: 100%;
      }
    }

    .character-count {
      position: absolute;
      bottom: -22px;
      right: -5px;
      font-size: 11px;
      color: $lightGrayColor;
    }
  }

  .formatting-toolbar {
    display: flex;
    gap: 4px;
    padding: 4px;

    .format-button {
      padding: 4px;
      border-radius: 4px;
      transition: all 0.2s ease;

      &:hover {
        background-color: $offWhiteColor;
      }

      &.is-active {
        background-color: $infoBackground; // #e3f2fd → closest info tone
        color: $primaryColor; // #2196f3 → mapped to primary palette
      }
    }
  }

  .upload-container {
    display: flex;
    flex-direction: column;
    width: 100%;

    .image-preview-container {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;

      img {
        border-radius: 8px;
        object-fit: cover;
      }
    }

    .file-preview-container {
      display: flex;
      flex-direction: column;
      gap: 4px;
    }
  }

  .message-input {
    width: 100%;
    padding: 8px;
    border: 1px solid $menuBorderColor; // #e0e0e0
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.5;

    &:focus {
      outline: none;
      border-color: $primaryColor; // #2196f3
    }
  }
  .chat-input-section {
    width: 100%;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: static;

    &.new-chat-screen {
      position: relative;
      width: 100%;
      bottom: 0px;
    }
    &.custom-screen {
      width: 95%;
      bottom: 15px;
    }
  }
  .chat-input-textarea {
    width: 100%;
    border: none;
    outline: none;
    resize: none;
    min-height: 10px;
    max-height: 500px;
    overflow-y: auto;
  }

  .chat-input-container {
    width: 100%;
    position: relative;
    border-radius: 12px;
    padding: 12px;
    background: $whiteColor;
    border: 1px solid $disabledSecondaryBorder;
    box-shadow: 0px 0px 12px 8px $boxShadowSoft; // #0000000f
    &:hover {
      border: 1px solid $accordionBgBackground;
    }
    &:focus-within {
      border: 1px solid $accordionBgBackground;
    }
  }

  .chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    width: 100%;
    max-height: 182px;
    transition: all 0.2s ease-in-out;
  }
  .chat-input-wrapper.stacked {
    flex-direction: column;
    align-items: stretch;
  }
  .chat-input-wrapper.empty {
    flex-direction: row;
    align-items: flex-end;
  }
  .chat-input-wrapper.single-line-textarea {
    align-items: center;
  }
  // Message Input Container Enabled only when File uploaded enabled
  .message-input-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
  }

  .chat-textarea {
    width: 100%;
    flex: 1;
    resize: none;
    border: none;
    outline: none;
    font-size: 14px;
    padding: 0;
    background: transparent;
    line-height: 160%;
    overflow-y: hidden;
    max-height: 142px;
    font-family: $fontFamily;
    font-weight: 400;
    color: $mainFontColor;
    &::placeholder {
      color: $lightGrayColor;
    }
    transition: all 0.2s ease-in-out;
  }

  .chat-textarea.scrollable {
    overflow-y: auto;
  }

  .chat-actions {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    justify-content: flex-end;
    height: 32px;
    &.fixed {
      height: 36px;
    }
    &.not-fixed {
      height: 32px;
    }
  }

  .input-actions {
    display: flex;
    align-items: center;
    gap: 8px;

    .send-actions {
      display: flex;
      align-items: center;
      gap: 8px;
      height: 30px;

      .ia-btn-icon {
        height: 28px;
        margin-bottom: -4px;
      }

      img {
        width: 12px;
      }

      .check-button {
        background: none;
        border: none;
        color: $inputInfoColor;
        border: 3px solid $lightBlueColor; // #eceefd
        cursor: pointer;
        border-radius: 8px;
        width: 32px;
        height: 32px;
        padding: 8px;

        .check-icon {
          width: 12px;
        }
      }

      .send-button {
        background: transparent !important;
        color: $whiteColor !important;
        border: none !important;
        width: 32px !important;
        height: 32px !important;
        min-width: 32px !important;
        padding: 0 !important;
        border-radius: 6px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
      }
    }
  }
}

.tiptap p.is-editor-empty:first-child::before {
  color: $disabledSecondaryBorder; // #adb5bd → closest neutral gray
  content: attr(data-placeholder);
  float: left;
  height: 0;
  pointer-events: none;
}

.quick-action-menu {
  &.MuiPopover-root {
    .MuiPaper-root {
      margin-bottom: 8px !important;
    }
  }
}

.ia-styles.ia-menu.quick-action-container {
  .MuiList-root {
    min-width: 214px !important;
  }
}
.ia-styles.ia-menu.quick-action-container .MuiPaper-root {
  margin-top: -10px !important;
  margin-left: 6px !important;
}
.ia-styles.ia-menu.priority-action-container {
  .MuiList-root {
    min-width: 214px !important;
  }
}
.ia-styles.ia-menu.priority-action-container .MuiPaper-root {
  margin-top: -6px !important;
  margin-left: 36px !important;
}

.input-actions .send-actions .ia-btn-icon-loading {
  margin-bottom: 0px;
  padding-top: 7px;
}

.selected_action_priority {
  border: 1px solid $secondaryColor !important;
}
