// @use '../focus';
@use '../partials/mixin' as mx;

.CSS_START_components_annotations {
  display: none;
}

.annotations_tab {
  display: flex;
  flex-direction: column;
  gap: 5px;

  ol {
    padding: 0;
    margin: 0;
  }
}

.popover_dialog_reader .settings_tab.annotations_tab {
  margin-top: 15px !important;
}

.separator {
  border-bottom: 1px solid var(--color-extralight-grey-alt);
  padding-bottom: 10px;
}

.annotations_options {
  z-index: 10;
  width: fit-content;
  display: flex;
  align-items: center;
  justify-content: start;
  color: var(--color-blue);
  font-size: 14px;

  span svg {
    fill: var(--color-blue);
    width: 20px;
    height: 20px;
    margin: 0 0.75em;
    padding-top: 5px;
    padding-bottom: 0;
  }

  svg {
    fill: var(--color-blue);
    width: 14px;
    height: 14px;
    margin-right: 0.5em;
  }

  &[open] > span svg {
    transform: rotate(180deg);
    padding-bottom: 5px;
    padding-top: 0;
  }

  .annotations_checkbox {
    display: flex;
    align-items: start;
    padding: 5px;
    height: fit-content;
    margin-left: 15px;

    label {
        margin: 0;
        height: fit-content!important;
    }
  }
}

.annotations_sorting {
  &_container {
    background-color: var(--color-extralight-grey);
    width: fit-content;
    // border: 1px solid var(--color-light-grey);
    padding: 15px 5px;
    box-shadow: 0 0 5px var(--color-light-grey);
    z-index: 1000;
    border-radius: 5px;

    @include mx.scrollbar_styling;

    &::-webkit-scrollbar-track {
      background-color: var(--color-extralight-grey);
    }

    & .my_item {
      font-weight: 600;
      outline: solid 2px transparent !important;
      border-radius: 4px;

      &::before {
        background-color: var(--color-blue) !important;
      }
    }
  }
}

.annotations_filter {
  &_container {
    background-color: var(--color-extralight-grey);
    width: 290px;
    // border: 1px solid var(--color-light-grey);
    padding: 15px;
    padding-right: 5px;
    padding-bottom: 0;
    box-shadow: 0 0 5px var(--color-light-grey);
    z-index: 1000;
    border-radius: 5px;
    overflow-y: scroll;

    .annotations_checkbox {
      color: var(--color-primary);
    }

    .button_primary_blue:hover {
      // color: var(--color-secondary);
      background-color: var(--color-blue);
    }

    @include mx.scrollbar_styling;

    &::-webkit-scrollbar-track {
      background-color: var(--color-extralight-grey);
    }
  }

  &_nbOfFilters {
    position: absolute;
    color: var(--color-secondary);
    width: 10px;
    height: 10px;
    padding: 4px;
    border-radius: 50px;
    background-color: var(--color-blue);
    top: -8px;
    right: -8px;
    margin: 0;
    line-height: 0.9;
  }

  &_button {
    border: 1px solid var(--color-primary);
    border-radius: 5px;
    padding: 0 10px;
  }

  &_line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: calc(100%);
    gap: 20px;
    padding-right: 10px;
  }

  &_trigger_button {
    width: 30px;
    height: 30px;
    position: relative;
    padding: 5px;

    svg {
      width: 20px;
      height: 20px;
      color: var(--color-blue);
      cursor: pointer;
    }
  }

  &_taglist {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin: 20px 0;
  }

  &_tagGroup {
    font-family: inherit;
    background-color: var(--color-secondary);
    border-radius: 5px;
    padding: 0 20px;
    height: 45px;
    font-size: 15px;
    line-height: 1;
    box-shadow: 0 3px 3px var(--color-verylight-grey-alt2);
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--color-primary);

    &:hover {
      background-color: var(--color-light-blue);
    }
  }

  &_tag {
    font-size: 13px;
    padding: 2px 4px;
    border-radius: 5px;
    border: 1px solid var(--color-blue);
    background-color: var(--color-light-blue);
    color: var(--color-blue);

    &[data-selected], &:has(input:checked), &[data-state="checked"] {
      color: var(--color-secondary);
      background-color: var(--color-blue);

        &:focus {
            outline: var(--color-blue) solid 2px !important;
            outline-offset: 2px;
        }
    }
  }

  &_color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--color-extralight-grey);

    &[data-selected] {
      outline: 2px solid;
      outline-offset: 2px;
    }
  }

  &_drawtype {
    width: 20px;
    height: 20px;
    padding: 5px;
    border-radius: 5px;

    svg {
      width: 20px;
      height: 20px;
      color: var(--color-primary);
    }

    &[data-selected] {
      background-color: var(--color-blue);

      svg {
        color: var(--color-secondary);
      }
    }
  }
}

.settings_tab .annotation_actions {
  @media screen and (width <= 800px) {
    flex-direction: column!important;
    align-items: start!important;
  }
}

.popover_dialog_reader .annotation_actions {
  flex-direction: column;
  align-items: start;
  gap: 10px;
}

.annotation_form {
    background-color: var(--color-extralight-grey);
    max-width: 450px;
    border-radius: 6px;
    border: 1px solid var(--color-light-grey);
    display: flex;
    flex-direction: column;
    padding: 5px 10px;
    color: var(--color-primary);

    // gap: 10px;

    h4 {
      margin: 5px 0;
    }

    label {
      margin: 5px;
    }

    &_textarea{
      width: 420px;
      min-width: 420px;
      height: 100px;
      min-height: 100px;
      max-width: 420px;
      border: 1px solid rgb(118 118 118);
      border-radius: 3px;
      font-family: Nunito, sans-serif;
      background-color: var(--color-annotations-txt-area);
      color: var(--color-primary);


      &_container {
      display: flex;
      flex-direction: column;
      }

      &_buttons {
        margin: 5px 0;
        display: flex;
        gap: 5px;

        button {
          min-width: unset;
          width: fit-content;
          height: 25px;

          &.button_primary_blue {
            color: var(--color-secondary);

            &:hover, &:focus:hover {
              color: var(--color-blue)!important;
            }
          }

          svg {
            fill: var(--color-secondary);
            color: var(--color-secondary);
          }

          &:hover svg {
            fill: var(--color-blue);
            color: var(--color-blue);
          }
        }
      }
    }
  }

  .annotation_actions {
    display: flex;
    align-items: center;
    gap: 30px;
    margin: 10px 0 20px;
    flex-wrap: wrap;

    &_container {
      display: flex;
      flex-direction: column;
      justify-content: start;

      .react_aria_ComboBox {
        margin: 0;
        padding: 0;
        width: inherit;

        .react_aria_Label {
          width: 100%;
          text-align: left;
        }

        .my_combobox_container {
          background-color: var(--color-secondary);
          width: inherit;

          input {
            padding: 0 10px 0 30px !important;
            width: 100%;
          }

          button {
            margin-left: 0;
            padding-left: 0!important;
          }
        }
      }
    }

    >div {
      display: inherit;

      >div {
        display: flex;
        // gap: 5px;
        align-items: center;
      }

      p {
        margin: 0;
      }

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

    &_buttons {
      button:disabled {
        border-radius: 5px;
        background-color: var(--color-verylight-grey-alt);

        svg {
          fill: var(--color-primary);
          color: var(--color-primary);
        }
      }

      svg {
        fill: var(--color-blue-alt);
        color: var(--color-blue-alt);
      }
    }
  }

  .annotation_edit_form {
    display: flex;
    flex-direction: column;

    p {
      background-color: var(--color-extralight-grey);
      // width: 95%!important;
      border-radius: 5px;
      margin-bottom: 10px!important;
    }

    &_textarea{
      min-width: 95%;
      max-width: 95%;
      min-height: 30px;
      border: 1px solid var(--color-primary);
      border-radius: 3px;
      font-family: Nunito, sans-serif;
      overflow: hidden;
      color: var(--color-primary);
      background-color: var(--color-secondary);

      &_container {
      display: flex;
      flex-direction: column;
      }

      &_buttons {
        margin: 5px 0;
        display: flex;
        gap: 5px;
      }
    }
  }

  .colorPicker {
    display: flex;
    background-color: var(--color-button-hover);
    padding: 2px;
    gap: 1px;
    border: 1px solid var(--color-dark-grey);
    border-radius: 6px;

    &:has(input:focus) {
      @include mx.R2_MIXIN_FOCUS_OUTLINE;
    }

    div {
        input {
            position: absolute;
            z-index: -1;
        }

        label {
            z-index: 20;
            width: 25px;
            height: 25px;
            margin: 0;
            border: 1px solid var(--color-secondary);
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 5px;
            cursor: pointer;
        }
    }

    svg {
      color: #4d4d4d;
    }
  }

  .stylePicker {
  display: flex;
  padding: 2px;
  gap: 10px;
  border-radius: 5px;

  &:has(input:focus) {
    @include mx.R2_MIXIN_FOCUS_OUTLINE;
  }

  div {
      input {
          position: absolute;
          z-index: -1;
      }

      label {
          z-index: 20;
          width: 27px;
          height: 27px;
          margin: 0;
          background-color: inherit;
          cursor: pointer;
          border-radius: 3px;
          display: flex;
          align-items: center;
          justify-content: center;

          svg {
            color: var(--color-blue-alt);
          }
      }
  }
  }

  .drawType_active {
    background-color: var(--color-blue)!important;

    svg {
      color: var(--color-secondary)!important;
      fill: var(--color-secondary)!important;
    }
  }

  .settings_tab .annotations_line {
    width: 100%;
    list-style-type: none;
  }

  .annotations_line {
    // width: 100%;
    position: relative;
    text-align: left;
    font-size: 1rem;
    border-left: 2px solid var(--color-blue);
    padding-left: 10px;
    margin: 0;
    margin-bottom: 10px;
    background-color: var(--color-annotations-bg);
    margin-top: 10px;

    p {
      text-align: left;
      // background-color: var(--color-annotations-txt);

      // overflow: hidden;
      // text-overflow: ellipsis;
      // width: calc(100% - 15px);
      width: fit-content;

      // display: -webkit-box;
      // -webkit-box-orient: vertical;
      // -webkit-line-clamp: 3;
      padding: 8px;
      margin: 5px 0;
    }

    // @media (prefers-color-scheme: dark) {
    //   background-color: #2D2D2D;
    // }

    .annnotation_container {
      // margin-top: 10px;
      margin-right: 10px;
      padding-top: 10px;

      .tag a {
        font-size: 14px;
      }

    }

    .annnotation_container:has(.annotation_name:focus) {
      outline: 2px solid var(--color-blue);
      border-radius: 5px;
    }

    .annotation_name {
      background-color: var(--color-annotations-txt);
      border-bottom: 8px solid var(--color-annotations-txt);
      height: unset;
      font-family: Nunito, sans-serif;
      border-radius: 5px;
      width: 100%;

      p {
        text-align: left;
        overflow: hidden;
        text-overflow: ellipsis;
        width: 100%;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 4;
        margin: 0;
        padding: 8px;
        padding-bottom: 0;
      }

      // &:focus {
      //   outline: 2px solid var(--color-blue);
      // }
    }

    .update_form input {
      width: 100%;
      border-radius: 6px;
    }

    & > button {
      border: none;
      background-color: transparent;
      cursor: pointer;
      padding: 0;

      & svg {
        width: 24px;
      }
    }

    & img {
      width: 30px;
      height: 30px;
      display: inline-block;
      vertical-align: top;
    }

    // & .chapter_marker {
    //   vertical-align: top;
    //   position: relative;
    //   display: inline-block;
    //   flex: 1;
    //   font-size: 0.9rem;
    //   margin-right: 0.5rem;
    // }

    & span {
      display: inline-block;
      vertical-align: top;
      margin-top: 5px;
      word-break: normal;
      /* overflow-wrap: break-word; */
      overflow-wrap: anywhere;
      white-space: normal;
    }

    .annotation_edit {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0 5px;

      p {
        padding-left: 0;
        max-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
      }

      >div {
        display: inherit;
        align-items: center;
        overflow: hidden;
        padding: 2px;

        button {
          padding: 5px;
          border-radius: 5px;
        }

        >div {
          display: flex;
          gap: 5px;
          align-items: center;

          a {
            &:hover {
              cursor: pointer;
              text-decoration: underline;
            }
          }
        }

        svg {
          width: 18px;
          height: 18px;
        }
      }
    }
  }

.docked_annotation_line {
  border-left: 2px solid var(--color-blue);
  padding: 0 10px;
  margin-top: 5px;
}

.annotationsTitle_form {
  &_container {
    width: fit-content;
    height: fit-content;
    border: none;
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 0 15px;
    color: var(--color-primary);

    .form_group {
      width: unset;
      border-radius: 6px;
      background-color: var(--color-secondary);
    }

    input {
      width: 100%;
      padding: 0;
      height: 22px;
      margin-left: 10px;
      margin-right: 1px;
      border-radius: 6px;
      background-color: var(--color-secondary);
    }

    label {
      background: linear-gradient(180deg, var(--color-extralight-grey) 0%, var(--color-extralight-grey) 50%, var(--color-secondary) 50%, var(--color-secondary) 100%);
      top: -5px;
    }

    button {
      width: 100%;
      height: 25px;
    }

    p {
      margin: 0;
    }

    select {
      background-color: var(--color-secondary);
      color: var(--color-primary);
    }

  }
}

.CSS_END_components_annotations {
  display: none;
}
