/* DB-PRODUCT-UX-18: permanent identity filters, controlled layout only.
   Filter IDs, data attributes and option state remain owned by app-v02.js. */

.filter-bar .asset-filter-menu-row {
  align-items: flex-start;
  flex-wrap: wrap;
}

.filter-bar .identity-filter-group {
  align-items: center;
  flex: 1 1 auto;
  flex-wrap: wrap;
  row-gap: 2px;
  column-gap: 2px;
}

.filter-bar .identity-filter-group > .filter-popover {
  flex: 0 1 auto;
  min-width: 0;
}

/* All filter labels use one compact menu scale and one selected-state language. */
.filter-bar .filter-popover-trigger,
.filter-bar .filter-popover-menu button,
.filter-bar .filter-subgroup-trigger,
.filter-bar .filter-more-trigger,
.filter-bar #assetColorSearchTrigger {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
}

.filter-bar .filter-popover-menu button[aria-selected="true"],
.filter-bar .filter-popover-menu button.selected {
  color: #405f9f;
  background: rgba(218, 230, 247, .78);
  font-weight: 600;
}

.filter-bar .visual-type-menu {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
  width: min(280px, calc(100vw - 24px));
  max-height: min(420px, calc(100vh - 150px));
  overflow: auto;
  padding: 6px;
}

.filter-bar .visual-type-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  text-align: left;
}

.filter-bar .visual-type-menu .filter-check {
  display: inline-grid;
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  place-items: center;
  border: 1px solid rgba(109, 128, 157, .3);
  border-radius: 5px;
  color: #405f9f;
  font-size: 11px;
}

.filter-bar .visual-type-menu button[aria-selected="true"] .filter-check {
  border-color: #7896c8;
  background: rgba(218, 230, 247, .92);
}

.filter-bar .asset-color-popover > header,
.filter-bar .asset-color-controls,
.filter-bar .asset-color-mode,
.filter-bar .asset-color-hex-row,
.filter-bar .asset-color-preset-row,
.filter-bar .asset-color-actions {
  align-items: center;
}

.filter-bar .asset-color-popover {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.filter-bar .asset-color-controls {
  justify-items: stretch;
}

.filter-bar .asset-color-mode,
.filter-bar .asset-color-hex-row,
.filter-bar .asset-color-preset-row,
.filter-bar .asset-color-actions {
  display: flex;
  width: 100%;
  justify-content: center;
  gap: 12px;
  margin-inline: auto;
}

.filter-bar .asset-color-actions button {
  flex: 0 0 auto;
  min-width: 116px;
}

.filter-bar .asset-color-actions .asset-color-apply {
  min-width: 150px;
  flex: 0 1 190px;
}
.filter-bar .asset-color-actions .asset-color-clear {
  min-width: 150px;
  flex: 0 1 150px;
}

/* Explicit shortest-column placement; cards never participate in shared grid rows. */
.masonry:not(.is-grouped), .masonry-group { display: block !important; position: relative; }
.masonry:not(.is-grouped) > .asset-card, .masonry-group > .asset-card { position: absolute; margin: 0 !important; }
.asset-color-popover > .asset-color-actions {
  grid-column: 1 / -1;
  width: 100%;
  justify-content: center;
  gap: 12px;
  margin-top: 2px;
}
.asset-color-popover > .asset-color-actions button,
.asset-color-popover > .asset-color-actions .asset-color-apply,
.asset-color-popover > .asset-color-actions .asset-color-clear {
  box-sizing: border-box;
  flex: 0 0 172px;
  width: 172px;
  min-width: 172px;
  max-width: 172px;
  height: 34px;
  min-height: 34px;
  padding-inline: 12px;
}

.asset-thumb.long-preview { aspect-ratio: 1 / 3.56 !important; max-height: none; overflow: hidden; }
.asset-thumb.long-preview > img {
  width: 100% !important;
  height: auto !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  object-fit: initial !important;
  object-position: top center !important;
  display: block !important;
}

/* Card previews use the source aspect ratio and fill the masonry column.
   The global complete-preview rule intentionally keeps images at their
   intrinsic size, which leaves tall thumbnails as narrow strips. Preserve
   the transparent checkerboard path; normal card media must scale to the
   column before the long-preview cap is applied. */
.asset-card .asset-thumb:not(.transparent) > img {
  width: 100% !important;
  height: auto !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  object-fit: initial !important;
  object-position: top center !important;
  display: block !important;
}

.asset-color-popover > .asset-color-controls {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  row-gap: 10px;
  width: 100%;
}

.asset-color-popover > .asset-color-controls > .asset-color-mode,
.asset-color-popover > .asset-color-controls > .asset-color-hex-row,
.asset-color-popover > .asset-color-controls > .asset-color-preset-row {
  width: 100%;
  min-width: 0;
  justify-content: center;
  margin-inline: auto;
}

.creative-agent-composer :is(textarea, button)[disabled],
.creative-agent-composer button[disabled] {
  opacity: .62;
  cursor: not-allowed;
}

.filter-bar .asset-color-actions {
  justify-content: center;
}

.filter-bar .asset-color-index-tools[hidden] { display: none !important; }

/* Content categories are a real two-pane cascade: fixed first-level rail on
   the left, selected family's second-level options on the right. */
.filter-bar .filter-type-menu {
  display: grid;
  grid-template-columns: minmax(128px, 34%) minmax(220px, 1fr);
  width: min(560px, calc(100vw - 24px));
  min-width: min(390px, calc(100vw - 24px));
  max-height: min(480px, calc(100vh - 180px));
  overflow: hidden;
  padding: 6px;
}

.filter-bar .filter-type-menu.direct-choice {
  display: block;
  min-width: 220px;
  width: min(300px, calc(100vw - 24px));
  max-height: none;
  overflow: visible;
}

.filter-bar .filter-type-family-list {
  display: grid;
  align-content: start;
  gap: 2px;
  min-width: 0;
  padding-right: 6px;
  border-right: 1px solid rgba(109, 128, 157, .14);
}

.filter-bar .filter-type-family-list > button,
.filter-bar .filter-type-family-options > button {
  min-width: 0;
  min-height: 32px;
  padding: 5px 9px;
  border: 0;
  border-radius: 8px;
  color: #657184;
  background: transparent;
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.filter-bar .filter-type-family-list > button:hover,
.filter-bar .filter-type-family-list > button:focus-visible,
.filter-bar .filter-type-family-options > button:hover,
.filter-bar .filter-type-family-options > button:focus-visible {
  outline: none;
  background: rgba(226, 235, 248, .54);
  color: #405777;
}

.filter-bar .filter-type-family-list > button[aria-selected="true"],
.filter-bar .filter-type-family-list > button.selected,
.filter-bar .filter-type-family-options > button[aria-selected="true"],
.filter-bar .filter-type-family-options > button.selected {
  background: rgba(218, 230, 247, .78);
  color: #405f9f;
  font-weight: 600;
}

.filter-bar .filter-type-family-list .filter-subgroup-trigger {
  justify-content: space-between;
  width: auto;
  min-height: 34px;
  padding: 5px 9px;
  font-size: 13px;
  font-weight: 500;
}

.filter-bar .filter-type-family-list .filter-subgroup-trigger i {
  color: #8a97ab;
  font-size: 16px;
}

.filter-bar .filter-type-family-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 2px;
  min-width: 0;
  max-height: calc(min(480px, 100vh - 180px) - 12px);
  overflow: auto;
  padding-left: 6px;
}

.filter-bar .filter-type-family-options > button {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

/* The old More surface remains only as a hidden compatibility anchor. */
.filter-bar #moreAssetFiltersButton,
.filter-bar #moreAssetFilters {
  display: none !important;
}

@media (max-width: 760px) {
  .filter-bar .asset-filter-menu-row {
    gap: 3px;
  }

  .filter-bar .identity-filter-group {
    flex-basis: 100%;
  }

  .filter-bar .filter-type-menu {
    grid-template-columns: minmax(104px, 31vw) minmax(0, 1fr);
    min-width: min(340px, calc(100vw - 24px));
  }
}

@media (max-width: 430px) {
  .filter-bar .filter-type-menu {
    grid-template-columns: minmax(94px, 29vw) minmax(0, 1fr);
  }

  .filter-bar .filter-type-family-options {
    grid-template-columns: minmax(0, 1fr);
  }
}
