.book-card {
  background-color: var(--card-background);
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  height: 100%;
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: box-shadow 0.25s ease, transform 0.25s ease;

  &:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    transform: translateY(-2px);
  }

  &.selected {
    border: 2px solid var(--primary-color);
  }
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.cover-container {
  position: relative;
  width: 100%;
  aspect-ratio: 5/7;
  background-color: var(--card-background);
  border-radius: 8px 8px 0 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cover-container:not(.loaded) {
  background: linear-gradient(
    90deg,
    var(--surface-ground) 25%,
    var(--surface-hover, rgba(255, 255, 255, 0.08)) 50%,
    var(--surface-ground) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

.cover-container.audiobook-cover {
  aspect-ratio: 5/7;
  background-color: var(--surface-ground);
}

.cover-container.square-library-cover {
  aspect-ratio: 1/1;
  background-color: var(--surface-ground);
}

.book-cover {
  width: 100%;
  height: 100%;
  border-radius: 8px 8px 0 0;
  opacity: 0;
  transition: opacity 0.2s ease-in, transform 0.35s ease;
}

.book-cover.loaded {
  opacity: 1;
}

.book-card:hover .book-cover.loaded {
  transform: scale(1.04);
}

.book-cover.square-cover {
  object-fit: contain;
}

.cover-container::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(0, 0, 0, 0) 25%, rgba(0, 0, 0, 0.6) 100%);
  opacity: 0;
  transition: opacity 0.15s ease-in-out;
  pointer-events: none;
}

.cover-container:hover::after {
  opacity: 1;
}

.book-title-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.book-title {
  flex-grow: 1;
  font-size: 0.9rem;
  color: var(--text-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  margin: 0;
  padding-left: 0.5rem;

  @media (max-width: 767px) {
    font-size: 0.75rem;
    padding-left: 0.25rem;
  }
}

.info-btn,
.read-btn {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  z-index: 2;
  will-change: opacity, visibility;

  ::ng-deep .p-button {
    box-shadow:
      0 2px 8px rgba(0, 0, 0, 0.4),
      inset 0 1px 0 rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.15s ease, box-shadow 0.15s ease;

    &:hover {
      transform: scale(1.08);
      box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    }

    @media (max-width: 767px) {
      width: clamp(1.5rem, 8vw, 2.5rem);
      height: clamp(1.5rem, 8vw, 2.5rem);
      padding: 0;

      .pi {
        font-size: clamp(0.65rem, 3.5vw, 1rem);
      }
    }
  }
}

.info-btn {
  top: 21%;
}

.read-btn {
  bottom: 21%;
}

.cover-container:hover .info-btn,
.cover-container:hover .read-btn {
  opacity: 1;
  visibility: visible;
}

.cover-container.center-info-btn .info-btn {
  top: 50%;
  transform: translate(-50%, -50%);
}

.select-checkbox {
  position: absolute;
  top: 8px;
  right: 8px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  z-index: 2;
  will-change: opacity, visibility;

  @media (max-width: 767px) {
    top: 4px;
    right: 4px;
  }
}

.select-checkbox .p-checkbox {
  vertical-align: top;
}

.cover-container:hover .select-checkbox,
.book-card.selected .select-checkbox {
  opacity: 1;
  visibility: visible;
}

.cover-progress-bar-container {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 7.5px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.cover-progress-bar {
  left: 0;
  right: 0;
  height: 2.5px;
  z-index: 1;
  opacity: 0.9;
}

.series-number-overlay {
  position: absolute;
  top: 8px;
  left: 8px;
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  font-size: 0.75rem;
  padding: 1px 3px;
  border-radius: 3px;
  z-index: 3;
}

.series-items-count-overlay {
  position: absolute;
  background-color: var(--primary-color);
  color: var(--primary-text-color-dark);
  font-size: 0.7rem;
  padding: 0 5px;
  border-radius: 6px;
  z-index: 3;
  white-space: nowrap;
  user-select: none;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  gap: 2px;
}

.series-items-count-icon {
  font-size: 0.6rem;
  margin-right: 2px;
}

.book-type-pill-overlay {
  position: absolute;
  background: var(--primary-color, #6366f1);
  color: var(--primary-text-color-dark, #fff);
  font-size: 0.675rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 6px;
  z-index: 3;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  letter-spacing: 0.03em;
  user-select: none;
  pointer-events: none;
  text-transform: uppercase;
  transition: background 0.2s;
}

.top-left-overlay-stack {
  position: absolute;
  top: 7px;
  left: 7px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  z-index: 4;

  @media (max-width: 767px) {
    top: 4px;
    left: 4px;
    gap: 2px;
  }
}

.book-type-pill-overlay,
.series-number-overlay,
.series-items-count-overlay {
  position: static;
  margin: 0;

  @media (max-width: 767px) {
    font-size: 0.6rem;
    padding: 1px 4px;
  }
}

.book-type-epub {
  background: var(--book-type-epub-color);
  color: #fff;
}

.book-type-pdf {
  background: var(--book-type-pdf-color);
  color: #fff;
}

.book-type-cbx {
  background: var(--book-type-cbx-color);
  color: #fff;
}

.book-type-mobi {
  background: var(--book-type-mobi-color);
  color: #fff;
}

.book-type-azw3 {
  background: var(--book-type-azw3-color);
  color: #fff;
}

.book-type-fb2 {
  background: var(--book-type-fb2-color);
  color: #fff;
}

.book-type-audiobook {
  background: var(--book-type-audiobook-color);
  color: #fff;
}

.book-type-m4b {
  background: var(--book-type-m4b-color);
  color: #fff;
}

.book-type-mp3 {
  background: var(--book-type-mp3-color);
  color: #fff;
}

.book-type-m4a {
  background: var(--book-type-m4a-color);
  color: #fff;
}

.book-type-opus {
  background: var(--book-type-opus-color);
  color: #fff;
}

.book-type-cbz {
  background: var(--book-type-cbz-color);
  color: #fff;
}

.book-type-cbr {
  background: var(--book-type-cbr-color);
  color: #fff;
}

.book-type-cb7 {
  background: var(--book-type-cb7-color);
  color: #fff;
}

.book-type-phy {
  background: var(--book-type-physical-color);
  color: #fff;
}

.read-status-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  margin-left: 0.5rem;
  cursor: pointer;
  border-radius: 4px;
  transition: opacity 0.15s ease;

  &:hover {
    opacity: 0.7;
  }
}

.status-read {
  color: #22c55e;
}

.status-reading {
  color: #3b82f6;
}

.status-re-reading {
  color: #06b6d4;
}

.status-partially-read {
  color: #f59e0b;
}

.status-paused {
  color: #eab308;
}

.status-abandoned {
  color: #ef4444;
}

.status-wont-read {
  color: #ec4899;
}

.status-unset {
  color: var(--text-color-secondary);
}

::ng-deep .progress-incomplete .p-progressbar-value {
  background-color: #3b82f6;
}

::ng-deep .progress-complete .p-progressbar-value {
  background-color: #22c55e;
}

::ng-deep .progress-incomplete-ko .p-progressbar-value {
  background-color: #fbbf24;
}

::ng-deep .progress-complete-ko .p-progressbar-value {
  background-color: #8b5cf6;
}

::ng-deep .progress-incomplete-kobo .p-progressbar-value {
  background-color: #bf0000;
}

::ng-deep .progress-complete-kobo .p-progressbar-value {
  background-color: #f65c9c;
}

::ng-deep .cover-progress-bar {
  --p-progressbar-border-radius: 0 !important;
}

::ng-deep .custom-button-padding .p-button {
  padding-block: 0.25rem !important;
}

::ng-deep .book-details-dialog .p-dialog-header {
  padding: 1rem 1.25rem !important;
}
