.mfm_file_grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 104px));
  gap: 10px 12px;
  align-items: start;
  justify-content: start;
  min-height: 84px;
  padding: 10px;
  border: 1px dashed #d8e2f1;
  border-radius: 6px;
  background: #fbfdff;
}

[data-mfm-upload-surface] {
  cursor: pointer;
}

.mfm_file_card {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 5px;
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 10px 5px 6px;
  background: transparent;
  color: inherit;
  cursor: default;
}

.mfm_file_card:hover {
  border-color: #bed0f5;
  background: #eef4ff;
}

.mfm_file_card.is-selected {
  border-color: #1d7dfa;
  background: #eaf3ff;
  box-shadow: inset 0 0 0 1px #1d7dfa;
}

.mfm_file_delete {
  position: absolute;
  top: -7px;
  right: -7px;
  z-index: 2;
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 0;
  border-radius: 999px;
  padding: 0;
  background: #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
  color: #ef4444;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.92);
  transition: opacity 0.14s ease, transform 0.14s ease, box-shadow 0.14s ease;
}

.mfm_file_card:hover .mfm_file_delete,
.mfm_file_card:focus-within .mfm_file_delete {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

.mfm_file_delete:hover {
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.28);
}

.mfm_file_delete svg {
  width: 20px;
  height: 20px;
  fill: #fff;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.mfm_file_thumb {
  position: relative;
  width: 42px;
  height: 52px;
  border: 1px solid #d9dee6;
  border-radius: 7px;
  background: linear-gradient(180deg, #ffffff 0%, #f4f6f8 100%);
  background-position: center;
  background-size: cover;
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.08);
}

.mfm_file_thumb::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 9px;
  right: 9px;
  height: 4px;
  border-radius: 999px;
  background: #d7dde6;
  box-shadow: 0 9px 0 #e1e6ed, 0 18px 0 #e1e6ed, 0 27px 0 #e1e6ed;
}

.mfm_file_thumb span {
  position: absolute;
  right: 4px;
  bottom: 4px;
  max-width: 34px;
  overflow: hidden;
  border-radius: 4px;
  padding: 2px 3px;
  background: #eef1f5;
  color: #64748b;
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
  text-overflow: ellipsis;
}

.mfm_file_card.has-preview .mfm_file_thumb {
  overflow: hidden;
  border-color: #cbd5e1;
  background-color: #f8fafc;
}

.mfm_file_card.has-preview .mfm_file_thumb::before {
  display: none;
}

.mfm_file_card.has-preview .mfm_file_thumb span {
  background: rgba(15, 23, 42, 0.76);
  color: #fff;
}

.mfm_file_card strong {
  display: -webkit-box;
  width: 100%;
  min-height: 28px;
  overflow: hidden;
  color: #111827;
  font-size: 10px;
  font-weight: 500;
  line-height: 1.28;
  text-align: center;
  word-break: break-all;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.mfm_file_badges {
  position: absolute;
  top: 3px;
  right: 3px;
  display: flex;
  max-width: calc(100% - 6px);
  justify-content: flex-end;
}

.mfm_file_badge {
  min-height: 18px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  padding: 0 5px;
  background: #f1f5f9;
  color: #475569;
  font-size: 10px;
  font-weight: 800;
  line-height: 16px;
  white-space: nowrap;
}

.mfm_file_badge.is-success {
  border-color: #bbf7d0;
  background: #dcfce7;
  color: #15803d;
}

.mfm_file_badge.is-warn {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #c2410c;
}

.mfm_file_badge.is-danger {
  border-color: #fecaca;
  background: #fef2f2;
  color: #dc2626;
}

.mfm_file_badge.is-info {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.mfm_file_empty {
  display: grid;
  min-height: 62px;
  place-items: center;
  color: #64748b;
  font-size: 12px;
}
