﻿/* Library search notice */
.library-search-notice {
  background: #fff8e1;
  border: 1px solid rgba(0, 0, 0, 0.06);
  color: #6b4f00;
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.95rem;
  display: block;
  width: fit-content;
  max-width: 720px;
  text-align: center;
  margin: 0 auto;
}

/* Library search bar modern look */
.search-bar-wrapper .form-control,
#bookQuery {
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 6px 16px rgba(0,0,0,0.06);
}

.search-bar-wrapper .form-control:focus,
#bookQuery:focus {
  border-color: var(--primary-color);
  box-shadow: 0 8px 20px rgba(22, 107, 67, 0.15);
}

#searchBooks {
  border-radius: 999px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.08);
  transition: all .2s ease;
}

#searchBooks:hover {
  transform: translateY(-1px);
}

#searchBooks:disabled,
#searchBooks.is-loading {
  opacity: 0.85;
  cursor: wait;
  transform: none;
}

/* Library UI polish: match community buttons + dropdowns */
.book-card .library-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.book-card .library-actions .btn,
.book-card .library-actions .dropdown-toggle {
    flex: 1 1 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 0.72rem;
    padding: 0.28rem 0.55rem;
    min-height: 36px;
    border-radius: 999px;
    line-height: 1.25;
    font-weight: 600;
    box-shadow: 0 6px 16px rgba(0,0,0,0.08);
    transition: all .2s ease;
    white-space: nowrap;
    box-sizing: border-box;
}

.book-card .library-actions .btn i,
.book-card .library-actions .btn svg,
.book-card .library-actions .dropdown-toggle i,
.book-card .library-actions .dropdown-toggle svg {
    font-size: 0.9em;
    width: 1em;
    height: 1em;
    vertical-align: -0.1em;
}

.book-card .btn.btn-outline-primary,
.book-card .btn.btn-outline-secondary {
    border-width: 1px;
}

.book-card .btn.btn-outline-primary:hover,
.book-card .btn.btn-outline-primary:focus,
.book-card .btn.btn-outline-primary:active,
.book-card .btn.btn-outline-secondary:hover,
.book-card .btn.btn-outline-secondary:focus,
.book-card .btn.btn-outline-secondary:active {
    border-color: var(--primary-color) !important;
    color: var(--primary-color) !important;
    background: rgba(22, 107, 67, 0.08) !important;
    box-shadow: none !important;
}

.book-card .library-actions .btn:hover,
.book-card .library-actions .dropdown-toggle:hover {
    transform: translateY(-1px);
}

.archive-source-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    border-radius: 999px;
    min-width: 96px;
    font-size: 0.74rem;
    line-height: 1;
    padding: 0.38rem 0.58rem;
    text-align: center;
}

@media (max-width: 575px) {
    .archive-source-badge {
        min-width: 84px;
        font-size: 0.62rem;
        padding: 0.28rem 0.4rem;
    }

    .book-card .d-flex.justify-content-between {
        align-items: center;
        gap: 8px;
    }

    .book-card .d-flex.justify-content-between h5 {
        flex: 1 1 auto;
        min-width: 0;
        margin-bottom: 0;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .book-card .d-flex.justify-content-between .badge {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .book-card .library-actions {
        flex-wrap: wrap !important;
        gap: 6px;
        justify-content: flex-start;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    .book-card .library-actions .btn {
        flex: 0 0 auto;
        padding: 0.28rem 0.5rem;
        font-size: 0.68rem;
        min-height: 36px;
        white-space: nowrap;
        line-height: 1.2;
    }

    .library-search-card .library-actions--compact .library-action-btn,
    .saved-library-page .saved-book-actions--compact .saved-book-action-btn {
        flex: 0 0 auto;
        min-width: max-content;
    }

    .library-search-card .book-card-top,
    .saved-library-page .saved-book-card .book-card-top {
        flex-direction: row;
        align-items: flex-start;
    }

    .library-search-card .book-cover,
    .saved-library-page .saved-book-cover,
    .saved-library-page .saved-book-placeholder {
        width: 96px;
        height: 144px;
        max-height: none;
        flex: 0 0 auto;
        object-fit: cover;
    }

    .library-search-card .book-card-header,
    .saved-library-page .saved-book-card .book-card-header {
        flex-direction: row;
        align-items: flex-start !important;
    }

    .library-search-card .book-card-title,
    .saved-library-page .saved-book-title {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        white-space: normal;
        line-height: 1.55;
        max-height: calc(1.55em * 2);
    }
}

/* Saved Library */
.saved-library-page .saved-books-grid {
  align-items: stretch;
}

.saved-library-page .saved-book-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: hidden;
  border: 1px solid #e5ebe7;
  border-radius: 22px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.saved-library-page .saved-book-card:hover {
  transform: translateY(-3px);
  border-color: #dbe3de;
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.1);
}

.saved-library-page .saved-book-badges {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
}

.saved-library-page .saved-book-main {
  align-items: center;
  flex: 1 1 auto;
}

.saved-library-page .saved-book-visual {
  position: relative;
  flex: 0 0 auto;
}

.saved-library-page .saved-book-cover {
  width: 100px;
  height: 150px;
  object-fit: cover;
  flex: 0 0 auto;
  border-radius: 14px;
}

.saved-library-page .saved-book-placeholder {
  width: 100px;
  height: 150px;
  border-radius: 14px;
  background: linear-gradient(135deg, #166b43, #1f8557);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  text-align: center;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.15);
}

.saved-library-page .saved-book-icon {
  font-size: 2.1rem;
  line-height: 1;
}

.saved-library-page .saved-book-placeholder-text {
  font-weight: 700;
  font-size: 0.92rem;
}

.saved-library-page .saved-book-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}

.saved-library-page .saved-book-source {
  width: fit-content;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

.saved-library-page .saved-book-title {
  width: 100%;
  overflow-wrap: anywhere;
  line-height: 1.55;
  white-space: normal;
  text-align: center;
}

.saved-library-page .saved-book-author {
  width: 100%;
  overflow-wrap: anywhere;
  font-size: 0.94rem;
  text-align: center;
}

.saved-library-page .saved-book-actions {
  width: 100%;
  margin-top: auto !important;
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  overflow: visible !important;
}

.saved-library-page .saved-book-actions .btn {
  min-height: 36px;
  font-weight: 700;
}

.saved-library-page .saved-book-actions--compact .saved-book-action-btn {
  width: 100%;
  min-width: 0;
  white-space: nowrap;
  line-height: 1.25;
  padding-inline: 0.55rem;
  min-height: 36px;
  box-sizing: border-box;
}

@media (max-width: 575px) {
  .saved-library-page .saved-book-card .book-card-top {
    flex-direction: column;
    align-items: center;
  }

  .saved-library-page .saved-book-cover,
  .saved-library-page .saved-book-placeholder {
    width: min(150px, 62vw);
    height: 220px;
    min-height: 0;
  }

  .saved-library-page .saved-book-title {
    white-space: normal;
    overflow: visible;
    line-height: 1.6;
  }

  .saved-library-page .saved-book-source {
    width: fit-content;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .saved-library-page .saved-book-actions {
    gap: 0.35rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .saved-library-page .saved-book-actions--compact .saved-book-action-btn {
    min-width: 0;
    font-size: 0.7rem;
    min-height: 36px;
    padding-top: 0.28rem;
    padding-bottom: 0.28rem;
  }
}

/* Search result cards */
.library-search-card {
  overflow: hidden;
  border: 1px solid #e5ebe7;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
}

.library-search-card:hover {
  border-color: #dbe3de;
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.1);
}

.library-search-card .book-card-top {
  align-items: flex-start;
}

.library-search-card .book-cover {
  width: 100px;
  height: 150px;
  object-fit: cover;
  flex: 0 0 auto;
  border-radius: 14px;
}

.library-search-card .book-card-header {
  min-width: 0;
}

.library-search-card .book-card-title {
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.55;
  white-space: normal;
}

.library-search-card .book-card-author {
  overflow-wrap: anywhere;
}

.library-search-card .book-source-badge {
  flex: 0 0 auto;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: center;
}

.library-search-card .library-actions--compact {
    justify-content: flex-start;
}

.library-search-card .library-actions--compact .library-action-btn {
    flex: 0 0 auto;
    width: 130px;
    min-width: 130px;
    white-space: nowrap;
    line-height: 1.25;
    padding-inline: 0.55rem;
    min-height: 36px;
    box-sizing: border-box;
}

@media (max-width: 575px) {
  .library-search-card .book-card-top {
    flex-direction: column;
  }

  .library-search-card .book-cover {
    width: 100%;
    height: auto;
    max-height: 220px;
  }

  .library-search-card .book-card-header {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.35rem;
  }

  .library-search-card .book-card-title {
    white-space: normal;
    overflow: visible;
  }

  .library-search-card .book-source-badge {
    white-space: normal;
    min-width: 0;
    max-width: 100%;
    width: fit-content;
    text-align: start;
  }

  .library-search-card .library-actions--compact {
    gap: 0.35rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .library-search-card .library-actions--compact .library-action-btn {
    flex: 0 0 130px;
    width: 130px;
    min-width: 130px;
    font-size: 0.68rem;
    min-height: 36px;
    padding-top: 0.28rem;
    padding-bottom: 0.28rem;
  }
}

/* Library pagination */
#pagination .pagination {
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem;
}

#pagination .page-item {
  margin: 0;
}

#pagination .page-link {
  min-width: 42px;
  min-height: 42px;
  padding: 0.35rem 0.65rem;
  border-radius: 10px;
  font-weight: 700;
}

#pagination .page-item.active .page-link,
#pagination .page-link.current {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: #fff;
}

#pagination .page-link:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

#pagination .page-link.prev,
#pagination .page-link.next {
  min-width: 96px;
  padding-inline: 14px;
}

@media (max-width: 575px) {
  #pagination .page-link {
    min-width: 36px;
    min-height: 36px;
    padding: 0.28rem 0.45rem;
    font-size: 0.78rem;
  }

  #pagination .page-item.active .page-link,
  #pagination .page-link.current {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
  }

  #pagination .page-link.prev,
  #pagination .page-link.next {
    min-width: 84px;
    padding-inline: 10px;
  }
}
