.sf-metadata-card-item {
  min-width: 0;
  height: fit-content;
  background: #f9f9f9;
  border: 1px solid var(--bs-border-secondary-color);
  border-radius: 6px;
  box-shadow: 0 0 3px #0000001f;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
  transition: box-shadow .15s ease, border-color .15s ease, background-color .15s ease;
  cursor: pointer;
}

.sf-metadata-card-item.selected {
  border-color: #ff9800;
}

.sf-metadata-card-item:hover {
  box-shadow: 0 0 6px #0000002e;
}

.sf-metadata-card-item-image-container {
  position: relative;
  width: 100%;
  overflow: hidden;
  min-height: 150px;
}

/* Use pseudo-element to establish aspect ratio (3:2) so height is always reserved */
.sf-metadata-card-item-image-container::before {
  content: '';
  display: block;
  padding-top: 66.6667%;
}

.sf-metadata-card-item-image-container .sf-metadata-card-item-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.sf-metadata-card-item-text-container {
  padding: 10px;
  background-color: var(--bs-body-bg);
}

.sf-metadata-card-item-text-container .sf-metadata-file-name {
  font-weight: 500;
}

.sf-metadata-card-item-text-container .sf-metadata-card-last-modified-info {
  width: 100%;
  display: flex;
  justify-content: space-between;
}

.sf-metadata-card-item-text-container .sf-metadata-card-last-modified-info .collaborator-item {
  color: var(--bs-body-color);
  background-color: transparent;
}

.sf-metadata-card-item-text-container .sf-metadata-card-last-modified-info .ctime-formatter {
  color: #666;
  flex-shrink: 0;
}

.sf-metadata-card-item .sf-metadata-card-item-field {
  margin-top: 10px;
}

.sf-metadata-card-item .sf-metadata-card-item-field-name {
  display: block;
  color: #666;
  font-size: 12px;
  margin-bottom: 4px;
}

.sf-metadata-card-item .sf-metadata-card-item-field .sf-metadata-record-cell-empty {
  display: inline-block;
  background-color: #f0f0f0;
  border-radius: 4px;
  height: 8px;
  width: 20px;
}

.sf-metadata-card-item .sf-metadata-ui {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
  font-size: 14px;
}

.sf-metadata-card-item .sf-metadata-date-formatter,
.sf-metadata-card-item .sf-metadata-number-formatter {
  text-align: left;
}

.sf-metadata-card-item .sf-metadata-text-formatter {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sf-metadata-card-item .file-name-formatter {
  margin-bottom: 10px;
}

.sf-metadata-card-item .file-name-formatter:not(.sf-metadata-image-file-formatter) {
  margin-left: -4px;
}

.sf-metadata-card-item .sf-metadata-special-file-name-formatter:not(.sf-metadata-image-file-formatter) {
  margin-left: -2px;
}

.sf-metadata-card-item .file-name-formatter .sf-metadata-file-icon {
  transform: translateY(-1px);
  max-width: 100%;
  height: auto;
}

.sf-metadata-card-item .sf-metadata-card-item-field .collaborators-formatter {
  display: flex;
  flex-wrap: wrap;
}

.sf-metadata-card-item .sf-metadata-card-item-field .collaborators-formatter .collaborator-item {
  margin-top: 2px;
  margin-bottom: 2px;
}

.sf-metadata-card-item .sf-metadata-card-item-field .sf-metadata-checkbox-formatter {
  justify-content: flex-start;
  padding-left: 2px;
}

.sf-metadata-card-item .sf-metadata-card-item-field .sf-metadata-multiple-select-formatter {
  flex-wrap: wrap;
}

.sf-metadata-card-item .sf-metadata-card-item-field .sf-metadata-multiple-select-formatter .sf-metadata-ui-select-option {
  margin-top: 2px;
  margin-bottom: 2px;
}

.sf-metadata-view-card-items-container-text-wrap .sf-metadata-card-item-field .text-formatter {
  white-space: normal;
  max-height: 68px;
}

.sf-metadata-card-item .long-text-formatter,
.sf-metadata-view-card-items-container-text-wrap .sf-metadata-card-item-field .long-text-formatter {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  line-height: 1.5;
  white-space: normal;
}

[data-bs-theme="dark"] .sf-metadata-card-item {
  background-color: rgba(19, 19, 19, 1);
  border-color: var(--bs-border-secondary-color);
}

[data-bs-theme="dark"] .sf-metadata-card-item.selected {
  border-color: #ff9800;
}

[data-bs-theme="dark"] .sf-metadata-card-item:hover {
  box-shadow: none;
  border-color: rgba(255, 255, 255, 0.2);
}
