/* "Quản lý tệp": every uploaded file as a grid of tiles + the file trash (pages/files.js) */
.fm-filters {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.fm-tabs {
  max-width: 420px;
}
.fm-tabs button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.fm-tabs .icon {
  width: 16px;
  height: 16px;
}
.fm-tabs .n {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.fm-filters .filter-row > .fm-search {
  flex: 2 1 260px;
  min-width: 0;
}
.fm-filters .filter-row > select.input {
  flex: 1 1 170px;
  max-width: 280px;
  width: auto;
  min-width: 0;
}
@media (max-width: 719px) {
  .fm-filters .filter-row > .fm-search {
    flex-basis: 100%;
  }
  .fm-filters .filter-row > select.input {
    flex: 1 1 140px;
    max-width: none;
  }
}

.fm-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.fm-note {
  margin: 0;
}
.fm-selbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  padding: 0 2px;
}

/* Tiles */
.fm-grid {
  display: grid;
  align-items: start;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 12px;
  transition: opacity 0.15s;
}
.fm-grid.fm-loading {
  opacity: 0.6;
}
@media (max-width: 479px) {
  .fm-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
}
.fm-tile {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  cursor: pointer;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.fm-tile:hover {
  border-color: var(--line-2);
  box-shadow: var(--shadow);
}
.fm-tile:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.fm-tile.sel {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary);
}
.fm-thumb {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--surface-3);
  display: grid;
  place-items: center;
}
.fm-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.fm-doc-ic {
  display: grid;
  place-items: center;
  gap: 2px;
  color: var(--muted);
}
.fm-doc-ic .icon {
  width: 30px;
  height: 30px;
}
.fm-doc-ic small {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.fm-cb {
  position: absolute;
  top: 6px;
  left: 6px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  box-shadow: var(--shadow);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
.fm-cb input {
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
}
.fm-tile:hover .fm-cb,
.fm-tile.sel .fm-cb,
.fm-grid.picking .fm-cb,
.fm-cb:focus-within {
  opacity: 1;
}
@media (hover: none) {
  .fm-cb {
    opacity: 1;
  }
}
.fm-tag {
  position: absolute;
  left: 6px;
  bottom: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}
.fm-tag.main {
  background: var(--primary);
  color: var(--on-primary);
}
.fm-tag.warn {
  background: color-mix(in srgb, var(--ink) 72%, transparent);
  color: var(--surface);
}
.fm-cap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px 10px;
  min-width: 0;
}
.fm-kind {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}
.fm-kind .icon {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}
.fm-owner {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.fm-meta {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* One file */
.fm-detail {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.fm-big {
  display: grid;
  place-items: center;
  background: var(--surface-3);
  border-radius: var(--r);
  overflow: hidden;
  min-height: 160px;
}
.fm-big img {
  display: block;
  max-width: 100%;
  max-height: 56vh;
  max-height: 56dvh;
  object-fit: contain;
}
.fm-doc {
  gap: 6px;
  padding: 28px;
  color: var(--ink);
  text-decoration: none;
}
.fm-doc .icon {
  width: 36px;
  height: 36px;
  color: var(--muted);
}
.fm-main-tag {
  margin-left: 8px;
}
.fm-open {
  align-self: flex-start;
}

/* Catalog item picker for "Gắn vào vật dụng" */
.fm-pick {
  display: flex;
  flex-direction: column;
  max-height: 46vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.fm-pick-it {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  font: inherit;
}
.fm-pick-it:last-child {
  border-bottom: 0;
}
.fm-pick-it .grow {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.fm-pick-it small {
  font-size: 11px;
  color: var(--muted);
}
.fm-pick-it.on {
  background: var(--surface-3);
}
.fm-pick-it:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

@media (prefers-reduced-motion: reduce) {
  .fm-grid,
  .fm-tile,
  .fm-cb {
    transition: none;
  }
}

/* Shorter button labels in the phone action bar */
.fm-narrow {
  display: none;
}
@media (max-width: 719px) {
  .fm-wide {
    display: none;
  }
  .fm-narrow {
    display: inline;
  }
}
