.bookmarks-page.grid {
  grid-gap: $unit-10;
}

/* Bookmark area header controls */
.bookmarks-page .content-area-header {
  --searchbox-max-width: 350px;
  --searchbox-height: 1.8rem;

  @media (max-width: $size-sm) {
    --searchbox-max-width: initial;
    flex-direction: column;
  }
}

.bookmarks-page .search-container {
  flex: 1 1 0;
  display: flex;
  justify-content: flex-end;

  // Regular input
  input[type='search'] {
    height: var(--searchbox-height);
    -webkit-appearance: none;
  }

  // Enhanced auto-complete input
  // This needs a bit more wrangling to make the CSS component align with the attached button
  .form-autocomplete {
    height: var(--searchbox-height);

    .form-autocomplete-input {
      width: 100%;
      height: var(--searchbox-height);

      input[type='search'] {
        width: 100%;
        height: 100%;
        margin: 0;
        border: none;
      }
    }
  }

  .input-group {
    flex: 1 1 0;
    min-width: var(--searchbox-min-width);
    max-width: var(--searchbox-max-width);
  }

  .input-group > :first-child {
    flex: 1 1 0;
  }

  // Group search options button with search button
  .input-group input[type='submit'] {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
  }

  .dropdown-toggle {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
  }

  .dropdown {
    margin-left: -1px;
  }

  // Search option menu styles
  .dropdown {
    .menu {
      padding: $unit-4;
      min-width: 250px;
    }

    .menu .actions {
      margin-top: $unit-4;
      display: flex;
      justify-content: space-between;
    }

    .radio-group {
      margin-bottom: $unit-1;
      .form-label {
        padding-bottom: 0;
      }
      .form-radio.form-inline {
        margin: 0 $unit-2 0 0;
        padding: 0;
        display: inline-flex;
        align-items: center;
        column-gap: $unit-1;
      }
      .form-icon {
        top: 0;
        position: relative;
      }
    }
  }
}

/* Bookmark list */
ul.bookmark-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Bookmarks */
li[ld-bookmark-item] {
  position: relative;

  [ld-bulk-edit-checkbox].form-checkbox {
    display: none;
  }

  .title a {
    display: inline-block;
    vertical-align: top;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  &.unread .title a {
    font-style: italic;
  }

  .title img {
    width: 16px;
    height: 16px;
    margin-right: $unit-h;
    vertical-align: text-top;
  }

  .url-display {
    color: $secondary-link-color;
  }

  .description {
    color: $gray-color-dark;

    a, a:visited:hover {
      color: $alternative-color;
    }
  }

  .actions, .extra-actions {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    column-gap: $unit-2;
  }

  @media (max-width: $size-sm) {
    .extra-actions {
      width: 100%;
      margin-top: $unit-1;
    }
  }

  .actions {
    a, button.btn-link {
      color: $gray-color;
      padding: 0;
      height: auto;
      vertical-align: unset;
      border: none;
      transition: none;
      text-decoration: none;

      &:focus,
      &:hover,
      &:active,
      &.active {
        color: $gray-color-dark;
      }
    }

    .separator {
      align-self: flex-start;
    }
  }
}

.bookmark-pagination {
  margin-top: $unit-4;
}

.tag-cloud {

  .selected-tags {
    margin-bottom: $unit-4;

    a, a:visited:hover {
      color: $error-color;
    }
  }

  .unselected-tags {
    a, a:visited:hover {
      color: $alternative-color;
    }
  }

  .group {
    margin-bottom: $unit-2;
  }

  .highlight-char {
    font-weight: bold;
    text-transform: uppercase;
    color: $alternative-color-dark;
  }
}

/* Bookmark notes */
ul.bookmark-list {
  .notes {
    display: none;
    max-height: 300px;
    margin: $unit-1 0;
    overflow-y: auto;
  }

  &.show-notes .notes,
  li.show-notes .notes {
    display: block;
  }
}

/* Bookmark notes markdown styles */
ul.bookmark-list .notes-content {
  & {
    padding: $unit-2 $unit-3;
  }

  p, ul, ol, pre, blockquote {
    margin: 0 0 $unit-2 0;
  }

  > *:first-child {
    margin-top: 0;
  }

  > *:last-child {
    margin-bottom: 0;
  }

  ul, ol {
    margin-left: $unit-4;
  }

  ul li, ol li {
    margin-top: $unit-1;
  }

  pre {
    padding: $unit-1 $unit-2;
    background-color: $code-bg-color;
    border-radius: $unit-1;
    overflow-x: auto;
  }

  pre code {
    background: none;
    box-shadow: none;
    padding: 0;
  }

  > pre:first-child:last-child {
    padding: 0;
    background: none;
    border-radius: 0;
  }
}

/* Bookmark bulk edit */
$bulk-edit-toggle-width: 16px;
$bulk-edit-toggle-offset: 8px;
$bulk-edit-bar-offset: $bulk-edit-toggle-width + (2 * $bulk-edit-toggle-offset);
$bulk-edit-transition-duration: 400ms;

[ld-bulk-edit] {
  .bulk-edit-bar {
    margin-top: -1px;
    margin-left: -$bulk-edit-bar-offset;
    margin-bottom: $unit-4;
    max-height: 0;
    overflow: hidden;
    transition: max-height $bulk-edit-transition-duration;
  }

  &.active .bulk-edit-bar {
    max-height: 37px;
    border-bottom: solid 1px $border-color;
  }

  /* remove overflow after opening animation, otherwise tag autocomplete overlay gets cut off */
  &.active:not(.activating) .bulk-edit-bar {
    overflow: visible;
  }

  /* All checkbox */
  [ld-bulk-edit-checkbox][all].form-checkbox {
    display: block;
    width: $bulk-edit-toggle-width;
    margin: 0 0 0 $bulk-edit-toggle-offset;
    padding: 0;
    min-height: 1rem;
  }

  /* Bookmark checkboxes */
  li[ld-bookmark-item] [ld-bulk-edit-checkbox].form-checkbox {
    display: block;
    position: absolute;
    width: $bulk-edit-toggle-width;
    left: -$bulk-edit-toggle-width - $bulk-edit-toggle-offset;
    top: 0;
    padding: 0;
    margin: 0;
    visibility: hidden;
    opacity: 0;
    transition: all $bulk-edit-transition-duration;

    .form-icon {
      top: $unit-1;
    }
  }

  &.active li[ld-bookmark-item] [ld-bulk-edit-checkbox].form-checkbox {
    visibility: visible;
    opacity: 1;
  }

  /* Actions */
  .bulk-edit-actions {
    display: flex;
    align-items: baseline;
    padding: $unit-1 0;
    border-top: solid 1px $border-color;
    gap: $unit-2;

    button {
      padding: 0 !important;
    }

    button:hover {
      text-decoration: underline;
    }

    > input, .form-autocomplete, select {
      width: auto;
      max-width: 140px;
      -webkit-appearance: none;
    }

    .select-across {
      margin: 0 0 0 auto;
      font-size: $font-size-sm;
    }
  }
}
