/******************************************************************************/
/* Asset browser toolbar — search (§1.2), view modes (§1.3), sort (§1.4).   */
/* Shared by Templates / Brand assets / Content blocks. §1.1 folders now    */
/* live one level up as the workspace's library switcher — see tabs.css.    */
/******************************************************************************/

.browser-toolbar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.browser-toolbar__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.asset-collection { min-height: 0; }

/* ------------------------------- Search ---------------------------------- */
.browser-search {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--ink-muted);
  font-size: 12.5px;
}
.browser-search__input {
  flex: 1 1 auto;
  min-width: 0;
  border: none;
  padding: 0;
  background: transparent;
  color: var(--ink);
  font-size: 12.5px;
}
.browser-search__input:focus { outline: none; }
.browser-search__input::-webkit-search-cancel-button { cursor: pointer; }

.browser-searching-note {
  font-size: 11.5px;
  color: var(--ink-muted);
  font-style: italic;
  margin: -2px 0 2px;
}

/* ------------------------- Display options popover ------------------------ */
.display-options-trigger {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: var(--ink-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
}
.display-options-trigger:hover { background: var(--brand-verylight); color: var(--brand); }

.display-options-popover {
  /* position: fixed, and top/right set inline by portalPopover.js from the
     trigger's own getBoundingClientRect() — see actionMenu.js/menu.css for
     the same pattern this one is shared with. */
  position: fixed;
  display: none;
  flex-direction: column;
  gap: 10px;
  min-width: 190px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 10px;
  z-index: 1100; /* above the modal overlay (z-index: 1000) too */
}
.display-options-popover--open { display: flex; }
.display-options-popover__group:not(:first-child) {
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.display-options-popover__label {
  color: var(--ink-muted);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 6px;
}
.display-options-popover .view-switch,
.display-options-popover .sort-control { width: 100%; }
.display-options-popover .view-switch__btn { flex: 1 1 auto; }
.display-options-popover .sort-select { flex: 1 1 auto; }

/* ----------------------------- View switch -------------------------------- */
.view-switch {
  display: flex;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.view-switch__btn {
  background: #fff;
  color: var(--ink-muted);
  border: none;
  border-radius: 0;
  padding: 6px 9px;
  font-size: 12px;
}
.view-switch__btn:not(:last-child) { border-right: 1px solid var(--border); }
.view-switch__btn:hover { background: var(--brand-verylight); color: var(--brand); }
.view-switch__btn[aria-pressed="true"] { background: var(--brand); color: #fff; }

/* -------------------------------- Sort ------------------------------------ */
.sort-control {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
}
.sort-select {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 11.5px;
  font-weight: 600;
}
.sort-dir-btn {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink-muted);
  padding: 6px 8px;
  font-size: 11px;
}
.sort-dir-btn:hover { background: var(--brand-verylight); color: var(--brand); }
.sort-dir-btn i { display: inline-block; transition: transform 0.15s ease; }
.sort-dir-btn--asc i { transform: scaleY(-1); }

/* ----------------------------- Details view -------------------------------- */
.details-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.details-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.details-th {
  text-align: left;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.details-th--active { color: var(--brand); }
.details-th__btn {
  width: 100%;
  background: transparent;
  border: none;
  color: inherit;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 8px 10px;
  text-align: left;
}
.details-th__btn:hover { background: var(--brand-verylight); color: var(--brand); }
.details-th__btn--disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.details-th__btn--disabled:hover { background: transparent; color: inherit; }
.details-th--actions { width: 1%; }

.details-td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  color: var(--ink);
}
tr:last-child .details-td { border-bottom: none; }
.details-td--name {
  font-weight: 600;
  white-space: normal;
}
.details-td--name-inner {
  display: flex;
  align-items: center;
  gap: 8px;
}
.details-td--name-inner i { color: var(--brand); flex: 0 0 auto; }
.details-td--name-clickable { cursor: pointer; }
.details-td--name-clickable:hover { color: var(--brand); }
.details-td--actions { width: 1%; }

.browser-actions-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}

/* ------------------------------- Tiles view -------------------------------- */
.tiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  /* Grid's default align-items is already "stretch", so every .tile in a
     row is already the same height (the tallest tile's natural height) —
     declared explicitly here because .tile__cta's bottom-anchoring below
     only lines up across a row *because* of this. */
  align-items: stretch;
  gap: 10px;
}
.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  padding: 12px 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}
.tile__menu {
  position: absolute;
  top: 4px;
  right: 4px;
}
.tile__body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
}
.tile__body--clickable { cursor: pointer; }
.tile__icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--brand-verylight);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
}
.tile__name {
  font-weight: 600;
  font-size: 12px;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.tile__subtitle {
  font-size: 10.5px;
  color: var(--ink-muted);
}
.tile__cta {
  /* Docks the button at the tile's bottom edge instead of directly under
     its content — every tile in a row is already stretched to equal height
     (see .tiles-grid), so this is what actually keeps buttons aligned
     across a row when one neighbor's name wraps to 2 lines and another's
     doesn't. */
  margin-top: auto;
  width: 100%;
  padding: 5px 6px;
  font-size: 11px;
  border-radius: 6px;
}
