.metadata-viewer-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 0;
  width: 100%;
  min-height: 100%;
  animation: fadeIn 0.3s ease-in;

  @media (min-width: 768px) {
    padding: 0.5rem;
  }
}

.metadata-header {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);

  @media (min-width: 768px) {
    flex-direction: row;
    gap: 1.5rem;
  }
}

.cover-section {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
  gap: 1rem;

  @media (min-width: 768px) {
    justify-content: flex-start;
    align-items: flex-start;
  }
}

.cover-wrapper {
  position: relative;
  width: 250px;
  overflow: hidden;

  @media (min-width: 768px) {
    width: 250px;
  }
}

.series-badge {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  background: var(--overlay-background);
  color: var(--text-color);
  padding: 0.25rem 0.5rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--border-color);
  backdrop-filter: blur(8px);
  z-index: 2;
}

.cover-progress-bar-container {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 2;
  border-radius: 9999px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: calc(var(--progress-count, 0) * 6px);
}

.cover-progress-bar {
  z-index: 2;
  pointer-events: none;
  height: 6px;
  flex-shrink: 0;
}

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

::ng-deep .progress-incomplete .p-progressbar-value {
  background-color: var(--primary-color);
}

::ng-deep .progress-complete .p-progressbar-value {
  background-color: var(--primary-hover-color);
}

::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;
}

.info-section {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex-grow: 1;
  gap: 1rem;
  min-width: 0;
}

.info-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.title-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  text-align: center;

  @media (min-width: 768px) {
    text-align: left;
  }
}

.series-link {
  color: var(--primary-color);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  font-style: italic;
  transition: color 0.2s ease;

  &:hover {
    color: var(--primary-hover-color);
    text-decoration: underline;
  }
}

.title-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  align-items: center;

  @media (min-width: 768px) {
    align-items: flex-start;
  }
}

.title-content {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;

  @media (min-width: 768px) {
    justify-content: flex-start;
  }
}

.book-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-color);
  line-height: 1.2;
  margin: 0;

  @media (min-width: 768px) {
    font-size: 1.875rem;
  }
}

.lock-icon {
  font-size: 1.1rem;
  transition: transform 0.2s ease;
}

.lock-icon.locked {
  color: orangered;
}

.lock-icon.unlocked {
  color: limegreen;
}

.lock-icon:hover {
  transform: scale(1.1);
}

.authors {
  font-size: 1.125rem;
  color: var(--text-color-secondary);
  margin: 0;
}

.author-link {
  color: cornflowerblue;
  cursor: pointer;
  transition: color 0.2s ease;
  font-weight: 400;
}

.author-link:hover {
  color: dodgerblue;
  text-decoration: underline;
}

.first-author-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.55rem;
  font-weight: 700;
  color: #DAA520;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-left: 0.25rem;
  padding: 0.1rem 0.3rem;
  border: 1px solid #DAA520;
  border-radius: 3px;
  line-height: 1;
  vertical-align: middle;
}

.formats-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;

  @media (min-width: 768px) {
    justify-content: flex-start;
  }
}

.format-pipe {
  color: var(--text-color-secondary);
  font-weight: 300;
  font-size: 1rem;
  line-height: 1;
  user-select: none;

}

.author-separator {
  color: var(--text-secondary-color);
}

.ratings-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;

  @media (min-width: 640px) {
    flex-direction: row;
    justify-content: flex-start;
  }
}

.personal-rating {
  display: flex;
  align-items: center;
}

.rating-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.rating-icon {
  color: orange;
  font-size: 1rem;
}

.reset-button ::ng-deep .p-button {
  padding: 0.375rem;
}

.divider {
  display: none;
  width: 1px;
  height: 2rem;
  background: var(--border-color);
}

@media (min-width: 640px) {
  .divider {
    display: block;
  }
}

.external-ratings {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;

  @media (min-width: 640px) {
    justify-content: flex-start;
  }
}

.rating-link {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  text-decoration: none;
  color: var(--text-color);
  transition: transform 0.2s ease;
}

.rating-link:hover {
  transform: translateY(-2px);
}

.rating-link:hover .rating-favicon {
  transform: scale(1.2);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.rating-favicon {
  width: 1.25rem;
  height: 1.25rem;
  object-fit: contain;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.rating-value {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-color);
}

.tags-section {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.tag-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-height: 1.75rem;
}

.tag-label {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-color);
  flex: 0 0 56px;
  min-width: 56px;
}

.tag-scroll {
  overflow-x: auto;
  flex: 1;
  min-width: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.tag-scroll::-webkit-scrollbar {
  display: none;
}

@media (min-width: 768px) {
  .tag-scroll {
    max-width: 1150px;
  }
}

.tag-container {
  display: flex;
  gap: 0.375rem; /* slightly smaller gap between tags */
  width: max-content;
  max-width: 1150px;
}

.tag-clickable {
  flex-shrink: 0;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.tag-clickable:hover {
  transform: translateY(-2px);
}

.metadata-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  padding: 0.5rem 0;
  font-size: 0.875rem;
}

@media (min-width: 768px) {
  .metadata-grid {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 0.5rem;
  }
}

.metadata-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-color-secondary);
  white-space: nowrap;
  overflow: hidden;
  min-height: 1.5rem;
}

.metadata-key {
  font-weight: 600;
  color: var(--text-color);
  flex-shrink: 0;
}

.metadata-value {
  color: var(--text-color-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
}

.metadata-value-group {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

.format-tags {
  flex-wrap: wrap;
}

.format-tag-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  transition: transform 0.15s ease;

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

  &.primary-format {
    .format-badge {
      display: inline-flex;
    }
  }
}

.format-badge {
  display: none;
  align-items: center;
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--primary-color);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-left: 0.25rem;
  padding: 0.1rem 0.3rem;
  border: 1px solid var(--primary-color);
  border-radius: 3px;
  line-height: 1;
}

.metadata-link {
  color: var(--primary-text-color);
  cursor: pointer;
  transition: color 0.2s ease;
  font-weight: 500;

  &:hover {
    color: var(--primary-hover-color);
    text-decoration: underline;
  }
}

.edit-icon {
  color: var(--primary-text-color);
  cursor: pointer;
  font-size: 0.875rem;
  transition: color 0.2s ease, transform 0.2s ease;
}

.edit-icon:hover {
  color: var(--primary-hover-color);
  transform: scale(1.1);
}

.inline-action-button ::ng-deep .p-button {
  padding: 0 !important;
}

.file-path-section {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: -1.25rem;
  padding: 0.5rem 0;
  border-top: none;
  font-size: 0.875rem;
}

.eye-icon {
  color: var(--text-color-secondary);
  cursor: pointer;
  transition: color 0.2s ease;
}

.eye-icon:hover {
  color: var(--primary-color);
}

.file-path-code {
  font-size: 0.85rem;
  color: var(--text-secondary-color);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.action-buttons-container {
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
}

.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.action-group {
  display: flex;
  align-items: center;
  gap: 0.375rem;

  &.navigation-group {
    padding-right: 0.5rem;
    border-right: 1px solid var(--border-color);
    margin-right: 0.25rem;

    @media (max-width: 767px) {
      display: none;
    }
  }

  &.primary-actions {
    @media (min-width: 768px) {
      padding-right: 0.5rem;
      border-right: 1px solid var(--border-color);
      margin-right: 0.25rem;
    }
  }

  &.secondary-actions {
    display: flex;
    gap: 0.375rem;
  }
}

@media (max-width: 767px) {
  ::ng-deep .mobile-icon-only .p-button-label {
    display: none !important;
    padding: 10px !important;
  }

  ::ng-deep .mobile-icon-only .p-button {
    min-width: auto !important;
    padding: 10px !important;
  }

  ::ng-deep .mobile-icon-only.p-splitbutton .p-button-label {
    display: none !important;
    padding: 10px !important;
  }

  ::ng-deep .mobile-icon-only.p-splitbutton .p-button {
    min-width: auto !important;
    padding: 10px !important;
  }

  ::ng-deep .read-button-responsive .p-button-label,
  ::ng-deep .read-button-responsive.p-splitbutton .p-button-label {
    font-size: 0 !important;
  }

  ::ng-deep .read-button-responsive .p-button-label::after,
  ::ng-deep .read-button-responsive.p-splitbutton .p-button-label::after {
    content: "Read";
    font-size: 0.875rem;
  }
}

.navigation-buttons-mobile {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;

  @media (min-width: 768px) {
    display: none;
  }
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.625rem 0.875rem;
  background: var(--surface-ground);
  border-bottom: 1px solid var(--border-color);
  border-radius: 0.75rem 0.75rem 0 0;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-color);

  &.clickable {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;

    &:hover {
      background: var(--surface-hover);
    }
  }

  i:first-child {
    color: var(--primary-color);
    margin-right: 0.5rem;
  }
}

.section-header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;

  i {
    font-size: 0.95rem;
    color: var(--primary-color);
  }
}

.section-toggle-icon {
  font-size: 0.8rem;
  color: var(--text-color-secondary);
  transition: transform 0.3s ease;
}

.description-section {
  background: var(--card-background);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  overflow: hidden;
  transition: box-shadow 0.3s ease;

  &:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }
}

.description-body {
  padding: 0.875rem;
}

.description-content {
  overflow: hidden;
  transition: max-height 0.3s ease-in-out;
}

.description-content.line-clamp-7 {
  max-height: 37px;
}

.description-content:not(.line-clamp-7) {
  max-height: none;
}

.expand-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  margin-top: 0.5rem;
  padding: 0.25rem 0.5rem;
  background: transparent;
  border: none;
  border-radius: 0.25rem;
  color: var(--primary-color);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;

  &:hover {
    background: var(--surface-hover);
    color: var(--primary-hover-color);
  }

  i {
    font-size: 0.7rem;
  }
}

.description-html {
  color: var(--text-color-secondary);
  line-height: 1.6;
  font-size: 0.9375rem;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.loading-state {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100%;
  gap: 1rem;
  padding: 2rem;
}

.loading-text {
  color: var(--primary-color);
  font-size: 1rem;
  font-weight: 500;
}

::ng-deep p-togglebutton.my-visibility-toggle span[data-pc-section="label"] {
  display: none;
  padding: 0 !important;
}

::ng-deep .p-inputchips {
  width: 100%;
}

.navigation-position {
  font-size: 0.875rem;
  color: var(--text-secondary-color);
}

// Comic Metadata Section Styles
.comic-metadata-section {
  background: var(--card-background);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  overflow: hidden;
  transition: box-shadow 0.3s ease;

  &:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }
}

.comic-metadata-content {
  padding: 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 1000px;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
  opacity: 1;

  &.collapsed {
    max-height: 0;
    padding: 0 0.875rem;
    opacity: 0;
  }
}

.comic-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

.comic-info-item {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.comic-info-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-color-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.comic-info-value {
  font-size: 0.95rem;
  color: var(--text-color);
  font-weight: 500;
}

.comic-volume-number,
.comic-arc-number {
  color: var(--text-color-secondary);
  font-weight: 400;
  margin-left: 0.25rem;
}

.comic-subsection {
  border-top: 1px solid var(--border-color);
  padding-top: 0.75rem;
}

.comic-subsection-title {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-color);
  margin-bottom: 0.5rem;

  i {
    font-size: 0.9rem;
    color: var(--primary-color);
  }
}

.comic-creators-grid {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.comic-creator-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.comic-creator-role {
  flex: 0 0 95px;
  font-weight: 500;
  color: var(--text-color-secondary);
  font-size: 0.85rem;
}

.comic-creator-names {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
}

.comic-creator-link {
  color: cornflowerblue;
  cursor: pointer;
  transition: color 0.2s ease;
  font-size: 0.9rem;

  &:hover {
    color: dodgerblue;
    text-decoration: underline;
  }

  &:not(:last-child)::after {
    content: ',';
    color: var(--text-color-secondary);
  }
}

.comic-tags-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.comic-tag-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.comic-tag-label {
  flex: 0 0 80px;
  font-weight: 500;
  color: var(--text-color-secondary);
  font-size: 0.85rem;
  padding-top: 0.125rem;
}

.comic-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.comic-tag-clickable {
  cursor: pointer;
  transition: transform 0.15s ease;

  &:hover {
    transform: translateY(-2px);
  }
}

.comic-properties {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-color);
}

.comic-property-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;

  i {
    font-size: 0.7rem;
  }

  &.manga {
    background: linear-gradient(135deg, #ec4899 0%, #db2777 100%);
    color: white;
  }

  &.bw {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    color: white;
  }

  &.rtl {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
  }
}

.comic-web-link {
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-color);
}

.comic-external-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  color: var(--primary-color);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s ease;

  i {
    font-size: 0.85rem;
  }

  &:hover {
    color: var(--primary-hover-color);
    text-decoration: underline;
  }
}

.comic-notes {
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-color);
}

.comic-notes-label {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-color);
  margin-bottom: 0.375rem;

  i {
    font-size: 0.9rem;
    color: var(--primary-color);
  }
}

.comic-notes-content {
  font-size: 0.9rem;
  color: var(--text-color-secondary);
  line-height: 1.5;
  margin: 0;
  white-space: pre-wrap;
}

// Audiobook Metadata Section Styles
.detach-dialog-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;

  .detach-dialog-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }
}
