::ng-deep .p-tabpanels .custom-tab-padding {
  padding: 1rem 0rem 0rem 0.5rem !important;

  @media (min-width: 640px) {
    padding: var(--p-tabs-tabpanel-padding) !important;
  }
}

::ng-deep .cover-item p-image {
  width: 150px;
}

::ng-deep p-image img {
  margin: 0 auto;
}

::ng-deep .p-autocomplete .p-chip .p-chip-label {
  font-size: 12px;
}

::ng-deep .p-autocomplete-input-chip {
  width: 2rem;
}

::ng-deep .p-autocomplete-clearable ul {
  padding-inline-end: 2rem !important;
}

::ng-deep .p-autocomplete-clearable .p-autocomplete-clear-icon {
  right: 0px;
  margin-top: -1rem;
  width: 2rem;
  height: 2rem;
  padding: 0.5rem;
}

::ng-deep .withbutton input,
::ng-deep .withbutton ul,
::ng-deep .field-with-lock input,
::ng-deep .field-with-lock ul {
  border-radius: 6px 0 0 6px;
}

.withbutton textarea,
.field-with-lock textarea {
  border-radius: 6px 0 6px 6px;
}

::ng-deep .withbutton button,
::ng-deep .field-with-lock button {
  border-color: var(--p-inputtext-border-color) !important;
  border-radius: 0 6px 6px 0 !important;
  border-left: 0px !important;
}

::ng-deep p-fileupload .p-button-label {
  display: none;
}

::ng-deep p-fileupload .p-button {
  padding: 0.6rem 0.5rem;
}

label {
  color: var(--text-color-secondary);
  white-space: nowrap;
}

.metadata-form {
  display: flex;
  flex-direction: column;
  height: 100%;
  animation: fadeIn 0.3s ease-in;

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

.loading-overlay {
  position: absolute;
  inset: 0;
  background-color: black;
  opacity: 0.25;
  z-index: 10;
}

.loading-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.form-content {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  overflow: auto;
  height: 72.5dvh;

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

.main-section {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 1rem;
  margin-bottom: 1rem;

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

.covers-section {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  flex-shrink: 0;
  margin: 0 auto;

  &.dual-covers {
    flex-direction: row;
    gap: 1rem;

    @media (max-width: 767px) {
      flex-direction: column;
      align-items: center;
    }
  }
}

.cover-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  position: relative;
  flex-shrink: 0;

  &.audiobook-cover-section {
    ::ng-deep .square-cover img {
      aspect-ratio: 1;
      object-fit: cover;
      border-radius: 0.5rem;
    }
  }
}

.cover-type-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  border-radius: 0.5rem;
  margin-bottom: 0.25rem;

  i {
    font-size: 0.9rem;
  }

  &.ebook {
    color: var(--primary-color);
    background: color-mix(in srgb, var(--primary-color) 15%, transparent);
  }

  &.audiobook {
    color: var(--purple-500);
    background: color-mix(in srgb, var(--purple-500) 15%, transparent);
  }
}

.upload-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
}

.cover-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-top: 0.75rem;
}

.fields-section {
  display: flex;
  flex-direction: column;
  flex-grow: 1;

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

.field-row {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 1rem;
  margin-top: 0.5rem;
  padding-bottom: 0.25rem;

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

.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;

  label {
    font-size: 0.875rem;
  }
}

.title-field {
  @media (min-width: 768px) {
    flex-basis: 45%;
    flex-shrink: 0;
  }
}

.subtitle-field {
  @media (min-width: 768px) {
    flex-basis: 40%;
  }
}

.language-field {
  @media (min-width: 768px) {
    width: 11rem;
  }
}

.authors-field {
  @media (min-width: 768px) {
    flex-basis: 45%;
    flex-shrink: 0;
  }
}

.author-chips-container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem;
  min-height: 2.25rem;
  border: 1px solid var(--p-inputtext-border-color);
  border-radius: 6px;
  background: var(--p-inputtext-background);
  flex: 1;
  min-width: 0;

  &.disabled {
    opacity: 0.6;
    background: var(--p-inputtext-disabled-background);
    cursor: default;

    .author-chip {
      cursor: default;
    }
  }
}

.author-add-input {
  flex: 1 1 6rem;
  min-width: 6rem;

  ::ng-deep input {
    border: none !important;
    background: transparent !important;
    padding: 0.25rem;
    box-shadow: none !important;
    outline: none !important;
  }
}

.author-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  border-radius: 1rem;
  background: var(--p-chip-background);
  color: var(--p-chip-color);
  font-size: 0.875rem;
  cursor: grab;
  user-select: none;
}

.main-author-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: var(--p-primary-color);
  color: var(--p-primary-contrast-color);
  font-size: 0.6rem;
  font-weight: 700;
  flex-shrink: 0;
}

.author-chip-remove {
  font-size: 0.65rem;
  cursor: pointer;
  opacity: 0.6;
  padding: 0.15rem;
  &:hover { opacity: 1; }
}

.cdk-drag-preview {
  box-sizing: border-box;
  border-radius: 1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.cdk-drag-placeholder {
  opacity: 0.4;
}

.cdk-drag-animating {
  transition: transform 200ms ease;
}

.publisher-field {
  @media (min-width: 768px) {
    flex-basis: 35%;
  }
}

.date-field {
  @media (min-width: 768px) {
    flex-basis: 20%;

    p-datepicker {
      width: 100%;
      min-width: 7.5rem;
    }
  }
}

.full-width {
  width: 100%;
}

.half-width {
  width: 100%;

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

.series-name-field {
  @media (min-width: 768px) {
    flex: 4.75;
    min-width: 0;
  }
}

.small-field {
  @media (min-width: 768px) {
    flex: 1;
    min-width: 0;
  }
}

.metadata-ids-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  width: 100%;

  .metadata-id-field {
    min-width: 0;
  }
}

.metadata-id-field {
  @media (min-width: 768px) {
    min-width: 0;
  }
}

.collapsible-section {
  margin-top: 1rem;
  width: 100%;
  background: var(--card-background);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;

  .collapsible-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    min-height: 2.5rem;
    background: var(--surface-ground);
    border-radius: 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-color);
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;

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

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

    .section-toggle {
      margin-left: auto;
      font-size: 0.75rem;
      color: var(--text-secondary-color);
    }
  }

  &.expanded .collapsible-header {
    border-radius: 0.75rem 0.75rem 0 0;
  }

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

.comic-text-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;

  @media (max-width: 767px) {
    grid-template-columns: repeat(2, 1fr);
  }
}

.comic-array-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;

  @media (max-width: 767px) {
    grid-template-columns: 1fr;
  }
}

.description-section {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  width: 100%;
  gap: 1rem;
  margin-top: 1rem;
  margin-bottom: 1rem;

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

.description-field {
  width: 100%;
  height: 100%;
}

.description-with-lock {
  display: flex;
  flex-grow: 1;
  width: 100%;

  textarea {
    width: 100%;
    height: 100%;
  }
}

.field-with-lock {
  display: flex;

  input,
  p-autocomplete,
  p-datepicker,
  p-select {
    width: 100%;
  }
}

.autocomplete-wrapper {
  width: 100%;

  p-autocomplete {
    width: 100%;
  }
}

.form-footer {
  margin-top: auto;
}

.footer-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0;
  padding-top: 1rem;
  z-index: 10;

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

.desktop-actions {
  display: none;
  justify-content: space-between;
  width: 100%;
  gap: 1rem;

  @media (min-width: 640px) {
    display: flex;
  }
}

.navigation-left {
  display: flex;
  gap: 1rem;
}

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

.navigation-position {
  font-size: 0.875rem;
  color: var(--surface-600);

  :host-context(.dark) & {
    color: var(--surface-400);
  }
}

.actions-right {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-left: auto;
}

.mobile-actions {
  display: flex;
  justify-content: space-between;
  width: 100%;
  flex-wrap: wrap;

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

.mobile-nav-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.mobile-actions-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  gap: 1rem;
}

.embeddable-indicator {
  font-size: 0.65rem;
  color: var(--p-green-500);
  margin-left: 0.25rem;
  vertical-align: super;
}

.mobile-lock-actions {
  display: flex;
  gap: 1rem;
}

.mobile-save-action {
  display: flex;
}
