.main-card {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 6.1rem);
  border-radius: 0.75rem;
  overflow: hidden;
  background: var(--card-background);
  border: 1px solid var(--p-content-border-color);

  @media (max-width: 768px) {
    height: calc(100dvh - 4.4rem);
    border-radius: 0;
    border-width: 1px 0 0;
  }
}

.header {
  padding: 1.5rem;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--p-content-border-color);
  gap: 1rem;
  
  @media (max-width: 768px) {
    padding: 1rem;
  }
}

.header-content {
  h2 {
    font-size: 1.25rem;
    font-weight: 600;
    padding-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  p {
    font-size: 0.875rem;
    color: rgb(156, 163, 175);
    
    strong {
      color: var(--primary-color);
    }
  }

  @media (max-width: 768px) {
    flex-shrink: 1;

    p {
      display: none;
    }
  }
}

.header-actions {
  @media (max-width: 768px) {
    display: flex;
  }
}

.external-link-icon {
  color: rgb(2, 132, 199);
  cursor: pointer;
  font-size: 0.9rem;
}

.card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  overflow: auto;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  border-radius: 0.75rem;
}

.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;

  > * + * {
    margin-top: 0.75rem;
  }

  span {
    color: var(--text-color-secondary);
  }

  p-progressSpinner {
    width: 2rem;
    height: 2rem;
  }
}

.controls-section {
  padding: 1rem;
  margin: 0;
  border-bottom: 1px solid var(--p-content-border-color);
}

.saving-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 50;
  border-radius: 0.75rem;

  > * + * {
    margin-top: 0.75rem;
  }

  p-progressSpinner {
    width: 2rem;
    height: 2rem;
  }
}

.saving-message {
  background: rgba(17, 24, 39, 0.9);
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;

  span {
    font-size: 0.875rem;
    color: rgb(229, 231, 235);
    text-align: center;
  }
}

.controls-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;

  label {
    font-size: 0.875rem;
    color: var(--text-color-secondary);
    font-weight: 500;
  }
}

.default-controls {
  display: flex;
  flex-grow: 1;
  gap: 1rem;
  align-items: center;
  justify-content: flex-end;

  p-select {
    width: 8rem;
  }

  @media (max-width: 768px) {
    width: 100%;

    label {
      display: none;
    }

    p-select {
      flex-basis: 50%;
    }
  }
}

::ng-deep .p-select-overlay {
  @media (max-width: 768px) {
    max-width: 70vw;

    .p-select-option {
      white-space: normal;
    }
  }
}

.default-controls i.pi {
  color: var(--p-button-outlined-info-color);
}

p-inputgroup-addon {
  background-color: transparent;
  border-color: var(--p-button-outlined-info-border-color) !important;
  color: var(--p-button-outlined-info-color);
  padding: 0 0.5em;

  label {
    display: flex;
    color: var(--p-button-outlined-info-color) !important;
  }
}

p-inputgroup.disabled {
  p-inputgroup-addon {
    opacity: var(--p-disabled-opacity) !important;
  }
}

.action-buttons {
  display: flex;
  gap: 1rem;
  align-items: center;
  
  @media (max-width: 640px) {
    flex-wrap: wrap;
    width: 100%;

    p-inputgroup.importmetadata {
      width: 100%;

      p-button {
        flex-grow: 1;

        ::ng-deep button {
          width: 100%;
        }
      }
    }

    p-button.bulkedit, p-button.extractpattern {
      width: calc(50% - 0.5rem);

      ::ng-deep button {
        width: 100%;
      }
    }
  }
}

.content-area {
  flex: 1;
  padding: 0 0 1px;
}

.empty-state {
  height: 100%;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgb(156, 163, 175);
  font-style: italic;
  padding: 2rem 0;
}

.file-item {
  display: flex;
  flex-direction: column;
}

.file-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  border-bottom: 1px solid var(--border-color);
  padding: 1rem;
  flex-wrap: wrap;
}
.file-row.expanded {
  border-bottom-style: dotted;
}

.status-indicator {
  font-size: 0.75rem;
}

.cover-image {
  width: 1.5rem;
  height: 2rem;
  border-radius: 0.125rem;
  object-fit: cover;
  cursor: pointer;
  transition: transform 0.2s;

  &:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  }

  @media (max-width: 768px) {
    display: none !important;
  }
}

div.cover-image {
  display: block;
  background-color: rgba(255, 255, 255, 0.1);
  text-align: center;
  line-height: 2rem;
}

.file-name {
  flex: 1;
  font-weight: 500;
  font-size: 0.875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: wrap;

  @media (max-width: 768px) {
    max-width: 100%;
  }
}

.metadata-status {
  &.copied {
    color: rgb(34, 197, 94);
  }

  &.no-metadata {
    color: rgb(59, 130, 246);
  }

  &.not-applied {
    color: rgb(239, 68, 68);
  }
}

.file-library {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  align-items: center;

  @media (max-width: 768px) {
    width: 100%;
  }
}

.library-select,
.path-select {
  width: 8rem;

  @media (max-width: 768px) {
    flex-basis: 50%;
  }
}

.details-section {
  border-bottom: 1px solid var(--border-color);
}

.footer, .footer-mobile {
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.footer {
  @media (max-width: 768px) {
    flex-wrap: wrap;

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

    ::ng-deep .p-button {
      width: var(--p-button-icon-only-width);
      padding-inline-start: 0;
      padding-inline-end: 0;
      gap: 0;
    }
  }
}

.footer-left,
.footer-right {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.footer-left {
  justify-content: flex-start;

  @media (max-width: 540px) {
    order: 2;
  }
}

.footer-right {
  justify-content: flex-end;

  @media (max-width: 540px) {
    order: 3;
  }
}

.footer-center {
  flex-grow: 1;
  display: flex;
  justify-content: center;

  .p-paginator {
    flex-wrap: nowrap;
    padding: 0;
  }

  @media (max-width: 768px) {
    ::ng-deep .p-paginator .p-paginator-jtp-dropdown span {
      font-size: var(--p-select-sm-font-size);
      padding-block: var(--p-select-sm-padding-y);
      padding-inline: var(--p-select-sm-padding-x);
    }
  }
  
  @media (max-width: 540px) {
    order: 1;
    width: 100%;
  }

}

.spacer {
  min-width: 10rem;
}

.icon-padding-left {
  padding-left: 0.5rem;
}

.cover-placeholder {
  font-size: 0.875rem;
}

.selected-count-label {
  font-size: 0.875rem;
}
