/* LoopOS UI legacy tag stack — loopos-ui-v2 role tokens (no Tailwind @apply) */

.tags-dropdown {
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 60;
  margin: 0;
  padding: 4px;
  min-width: 11rem;
  border: 1px solid var(--color-tertiary);
  border-radius: 6px;
  background: var(--color-background);
  color: var(--color-content);
  box-shadow: none;
}

.tags-dropdown ul {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tags-dropdown li {
  margin: 0;
}

.filter-options-container {
  position: relative;
}

.tags-usage-count {
  font-family: var(--font-sans);
  font-size: 11px;
  line-height: 1;
  color: var(--color-content-secondary);
}

/* --- loopos-ui token.css --- */
.lui-token {
  position: relative;
  display: flex;
  height: 18px;
  width: fit-content;
  padding: 2px 4px;
  align-items: center;
  gap: 4px;
  border-radius: 4px;
  background: var(--color-primary);
  overflow: hidden;
  font-family: var(--font-sans);
}

.lui-token__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}

.lui-token__text {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  letter-spacing: 0.02em;
  color: var(--color-content-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: default;
}

.lui-token__key-text {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  color: var(--color-content-secondary);
  cursor: default;
}

.lui-token:has(.lui-token__key-text) .lui-token__text {
  color: var(--color-content);
}

.lui-token__actions {
  position: absolute;
  display: none;
  align-items: center;
  gap: 2px;
  right: 4px;
  top: 1px;
  padding-left: 2px;
  font-size: 12px;
  background: var(--color-primary);
  cursor: pointer;
}

.lui-token__action-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  border: none;
  background: transparent;
  height: 12px;
  width: 12px;
}

.lui-token:not(.locked):hover {
  overflow: visible;
  background: var(--color-secondary);
}

.lui-token:not(.locked):hover .lui-token__actions {
  display: flex;
  background: var(--color-secondary);
}

.lui-token:not(.locked):hover .lui-token__action-icon:hover {
  background: var(--color-tertiary);
  border-radius: 4px;
}

.lui-token--disabled {
  opacity: 0.6;
}

/* --- loopos-ui tag (native — badge sm baseline) --- */
.lui-tag {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 180px;
  padding: 2px 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  white-space: nowrap;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 400;
  line-height: 14px;
  cursor: default;
  overflow: hidden;
}

.lui-tag--hover-remove {
  overflow: hidden;
}

.lui-tag--sm {
  padding: 2px 6px;
  line-height: 14px;
}

.lui-tag__label,
.lui-token.lui-tag .lui-token__text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 400;
  line-height: 14px;
  color: inherit;
  cursor: default;
}

.lui-tag--neutral {
  background: var(--color-secondary);
  border-color: var(--color-tertiary);
  color: var(--color-content-secondary);
}

/* Themed tags — accent hue via --lui-tag-accent (TagThemeService / TagToken); tint like badges */
.lui-tag--themed {
  color: var(--lui-tag-accent);
  background: color-mix(in srgb, var(--lui-tag-accent) var(--color-tint-bg-strength), var(--color-background));
  border-color: color-mix(in srgb, var(--lui-tag-accent) var(--color-tint-border-strength), var(--color-tertiary));
}

:root[data-theme="dark"] .lui-tag--themed {
  color: color-mix(in srgb, var(--lui-tag-accent) 72%, white);
}

/* Remove chip — hover-only; standalone tags use .lui-tag--hover-remove on the root */
.lui-tag__remove {
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  padding: 0;
  border: 1px solid var(--color-tertiary);
  border-radius: 4px;
  background: var(--color-background);
  color: var(--color-content);
  cursor: pointer;
}

.lui-tag--hover-remove > .lui-tag__remove {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  z-index: 1;
}

.lui-tag--hover-remove:not(.locked):hover > .lui-tag__remove {
  display: inline-flex;
}

.lui-tag__remove:hover {
  filter: brightness(0.96);
}

.lui-tag__remove .material-symbols-rounded {
  font-size: 8px;
  width: 8px;
  height: 8px;
  font-variation-settings: "FILL" 0, "wght" 500, "GRAD" 0, "opsz" 8;
}

.lui-tag--themed > .lui-tag__remove {
  background: inherit;
  border-color: color-mix(in srgb, currentColor 25%, transparent);
  color: inherit;
}

.lui-tag--hover-remove:not(.locked):hover .lui-tag__label,
.lui-tag.lui-tag--hover-remove:not(.locked):hover .lui-token__text {
  -webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 14px), transparent 100%);
  mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 14px), transparent 100%);
}

.lui-tag-list {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  align-content: center;
  gap: 8px;
  width: fit-content;
}

.lui-show-header__tags {
  margin-top: 8px;
  padding-left: 0;
}

.lui-show-header-hero {
  width: 100%;
}

.lui-show-header-hero > .lui-show-header__tags {
  width: 100%;
  margin-top: 0;
  padding-left: 0;
}

.lui-show-header-hero > .lui-show-header__tags .lui-tag-list {
  width: 100%;
  max-width: 100%;
}

.lui-show-header__tags .lui-tag-list {
  width: 100%;
  max-width: 100%;
}

.lui-tag-list__items {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

/* Empty items shell must not consume the list's 8px gap (looks like padding-left on Add). */
.lui-tag-list__items:not(:has(.lui-tag)) {
  display: none;
}

.lui-tag-list__items > div:has(.lui-tag),
.lui-tag-list__items form:has(.lui-tag) {
  display: contents;
}

.lui-tag-list__add {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: auto;
  height: auto;
  min-height: 18px;
  padding: 2px 8px 2px 6px;
  border: 1px dashed var(--color-tertiary);
  border-radius: 6px;
  background: transparent;
  color: var(--color-content-secondary);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 400;
  line-height: 14px;
  white-space: nowrap;
  flex-shrink: 0;
}

.lui-tag-list__add:hover {
  background: var(--color-secondary);
  color: var(--color-content);
}

.lui-tag-list__add:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--color-background), 0 0 0 4px var(--color-chrome-accent);
}

.lui-tag-list__add .material-symbols-rounded {
  font-size: 14px;
  width: 14px;
  height: 14px;
}

.lui-tag-list .lui-dropdown {
  position: relative;
  display: inline-flex;
  align-items: center;
  align-self: center;
  width: fit-content;
  flex-shrink: 0;
}

/* --- Identifiers (lui-identifier) --- */
.lui-identifier {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0;
  max-width: none;
  padding: 2px 6px;
  border: 1px solid var(--color-tertiary);
  border-radius: 6px;
  background: var(--color-background);
  color: var(--color-content-secondary);
  white-space: nowrap;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 400;
  line-height: 14px;
  cursor: default;
  overflow: visible;
}

.lui-identifier--hover-remove { overflow: visible; }

.lui-identifier-token__wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}

.lui-identifier-token__trigger {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.lui-identifier-token__trigger .lui-identifier {
  cursor: pointer;
}

.lui-identifier-token__remove-form {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  margin: 0;
  padding: 0;
  display: none;
  line-height: 0;
}

.lui-identifier-token__wrap:hover .lui-identifier-token__remove-form {
  display: block;
}

.lui-identifier-token__wrap:hover .lui-identifier--hover-remove {
  z-index: 2;
}

.lui-identifier-token__wrap:hover .lui-identifier--hover-remove .lui-identifier__content {
  -webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 14px), transparent 100%);
  mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 14px), transparent 100%);
}

.lui-identifier--editable {
  cursor: pointer;
  gap: 0;
}

.lui-identifier__key,
.lui-identifier__label {
  flex-shrink: 0;
  color: var(--color-content-secondary);
}

.lui-identifier__icon {
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 400;
  line-height: 14px;
  width: 14px;
  height: 14px;
  overflow: hidden;
  color: var(--color-content-secondary);
}

.lui-identifier__content:has(.lui-identifier__icon) {
  gap: 4px;
}

.lui-identifier__value {
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
  min-width: max-content;
  color: var(--color-content);
}

.lui-identifier__content {
  display: inline-flex;
  align-items: center;
  min-width: max-content;
  max-width: none;
}

.lui-identifier__remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  padding: 0;
  border: 1px solid var(--color-tertiary);
  border-radius: 4px;
  background: var(--color-background);
  color: var(--color-content);
  cursor: pointer;
}

.lui-identifier__remove:hover {
  filter: brightness(0.96);
}

.lui-identifier__remove .material-symbols-rounded {
  font-size: 8px;
  width: 8px;
  height: 8px;
  font-variation-settings: "FILL" 0, "wght" 500, "GRAD" 0, "opsz" 8;
}

.lui-identifier-list {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  align-content: center;
  gap: 8px;
  width: fit-content;
}

.lui-show-header__text { padding-left: 0; }

.lui-show-header__identifiers {
  margin-top: 8px;
  padding-left: 0;
}

.lui-show-header--editable-title .lui-show-header__identifiers {
  padding-left: 4px; /* match .lui-inline-edit__heading .lui-forms__control--heading horizontal padding */
}

.lui-show-header__identifiers .lui-identifier-list {
  width: 100%;
  max-width: 100%;
}

.lui-identifier-list__items {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.lui-identifier-list__items:not(:has(.lui-identifier)) {
  display: none;
}

.lui-identifier-list__add {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: auto;
  height: auto;
  min-height: 18px;
  padding: 2px 8px 2px 6px;
  border: 1px dashed var(--color-tertiary);
  border-radius: 6px;
  background: transparent;
  color: var(--color-content-secondary);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 400;
  line-height: 14px;
  white-space: nowrap;
  flex-shrink: 0;
}

.lui-identifier-list__add:hover {
  background: var(--color-secondary);
  color: var(--color-content);
}

.lui-identifier-list__add:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--color-background), 0 0 0 4px var(--color-chrome-accent);
}

.lui-identifier-list__add .material-symbols-rounded {
  font-size: 14px;
  width: 14px;
  height: 14px;
}

.lui-identifier-list .lui-dropdown,
.lui-identifier-list .lui-association-dropdown {
  position: relative;
  display: inline-flex;
  align-items: center;
  align-self: center;
  width: fit-content;
  flex-shrink: 0;
}

.lui-identifier-token__wrap .lui-association-dropdown {
  width: fit-content;
}

.lui-identifier-value-menu {
  width: 220px;
  padding: 8px;
  border: 1px solid var(--color-tertiary);
  border-radius: 6px;
  background: var(--color-background);
  color: var(--color-content);
}

.lui-identifier-value-menu__form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
}

.lui-identifier-value-menu__label {
  color: var(--color-content-secondary);
}

.lui-identifier-value-menu__input {
  width: 100%;
}

/* --- Association overlay (native) — dropdown menu parity --- */
.lui-tag-picker,
.lui-association-overlay {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 288px;
  min-width: 12rem;
  margin: 0;
  padding: 0;
  border: 1px solid var(--color-tertiary);
  border-radius: 6px;
  background: var(--color-background);
  color: var(--color-content);
  box-shadow: none;
  z-index: 50;
}

.lui-association-overlay__divider {
  height: 1px;
  margin: 0;
  width: 100%;
  background: var(--color-tertiary);
  flex-shrink: 0;
}

.lui-association-overlay__selected_list {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 4px;
}

.lui-association-overlay__search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px;
  padding: 6px 8px;
  border-radius: 6px;
  align-self: stretch;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 400;
  line-height: 18px;
  color: var(--color-foreground);
}

.lui-association-overlay__search-icon {
  font-size: 14px;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--color-content-secondary);
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 14;
}

.lui-association-overlay__search input {
  flex: 1;
  min-width: 0;
  width: 100%;
  border: none;
  padding: 0;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 400;
  line-height: 18px;
  color: var(--color-content);
  background: transparent;
  outline: none;
}

.lui-association-overlay__search input::placeholder {
  color: var(--color-content-secondary);
  opacity: 1;
}

.lui-association-overlay__results {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  max-height: 8rem;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 4px;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--color-content) 24%, transparent) transparent;
}

.lui-association-overlay__results::-webkit-scrollbar {
  width: 6px;
}

.lui-association-overlay__results::-webkit-scrollbar-track {
  background: transparent;
}

.lui-association-overlay__results::-webkit-scrollbar-thumb {
  background-color: color-mix(in srgb, var(--color-content) 24%, transparent);
  background-clip: content-box;
  border: 1px solid transparent;
  border-radius: 9999px;
}

.lui-association-overlay__results__cell--hidden,
.lui-association-overlay__results__cell[hidden] {
  display: none !important;
}

.lui-association-overlay__results form,
.lui-association-overlay form.contents {
  display: contents;
}

.lui-association-overlay__results__cell[type="submit"],
button.lui-association-overlay__results__cell {
  appearance: none;
  -webkit-appearance: none;
}

.lui-association-overlay__results__cell {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--color-content);
  align-self: stretch;
  justify-content: flex-start;
  cursor: pointer;
  text-align: left;
  transition: background 100ms ease;
}

.lui-association-overlay__results__cell:hover,
.lui-association-overlay__results__cell:focus-visible {
  background: var(--color-secondary);
  outline: none;
}

.lui-association-overlay__results__cell--missing,
.lui-association-overlay__results__cell--missing * {
  cursor: pointer;
}

.lui-association-overlay__header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 4px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  color: var(--color-content-secondary);
}

.lui-association-overlay__header-icon {
  font-size: 14px;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--color-content-secondary);
}

.lui-association-overlay__empty-search {
  width: 100%;
  padding: 6px 8px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 400;
  line-height: 18px;
  text-align: center;
  color: var(--color-content-secondary);
}

.lui-association-overlay__results__cell[data-model-association-overlay-target="new"]:has([data-model-association-overlay-target="newLabelWrapper"]:empty),
.lui-association-overlay__results__cell[data-model-association-overlay-target="new"]:has(.lui-token__text:empty),
.lui-association-overlay__empty-search:empty {
  max-height: none;
  padding: 0;
}

.lui-association-dropdown__menu {
  padding: 0;
  min-width: 0;
  border: none;
  background: transparent;
  overflow: visible;
  box-shadow: none;
}

.lui-association-dropdown .lui-tag-picker,
.lui-association-dropdown .lui-association-overlay {
  border: 1px solid var(--color-tertiary);
  border-radius: 6px;
  box-shadow: none;
}

/* Legacy token wrapper (admin manifest chips) */
.lui-token.lui-tag,
.lui-token.lui-tag-token {
  height: auto;
  min-height: 18px;
  width: fit-content;
  min-width: 25px;
  max-width: 180px;
  padding: 2px 6px;
  gap: 4px;
  border-radius: 6px;
}

.lui-token.lui-tag .lui-token__icon,
.lui-token.lui-tag-token .lui-tag-token__icon,
.lui-token.lui-tag-token .lui-token__icon {
  display: none;
}

.lui-token.lui-tag .lui-token__actions,
.lui-token.lui-tag-token .lui-tag-token__actions,
.lui-token.lui-tag-token .lui-token__actions {
  position: absolute;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  pointer-events: none;
  z-index: 1;
}

/* Tags: preserve themed background on hover — only reveal remove */
.lui-token.lui-tag:not(.locked):hover,
.lui-token.lui-tag-token:not(.locked):hover,
.lui-tag--hover-remove:not(.locked):hover {
  overflow: visible;
  z-index: 2;
}

.lui-token.lui-tag:not(.locked):hover .lui-token__actions,
.lui-token.lui-tag-token:not(.locked):hover .lui-tag-token__actions,
.lui-token.lui-tag-token:not(.locked):hover .lui-token__actions {
  display: flex;
  pointer-events: auto;
}

.lui-token.lui-tag:not(.locked):hover .lui-token__text,
.lui-token.lui-tag-token:not(.locked):hover .lui-token__text,
.lui-tag--hover-remove:not(.locked):hover .lui-tag__label {
  -webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 14px), transparent 100%);
  mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 14px), transparent 100%);
}

.lui-token.lui-tag .lui-tag__remove,
.lui-token.lui-tag-token .lui-tag__remove {
  display: inline-flex;
  background: var(--color-background);
  color: var(--color-content);
}

.lui-token.lui-tag.lui-tag--themed .lui-tag__remove,
.lui-token.lui-tag-token.lui-tag--themed .lui-tag__remove {
  background: inherit;
  border-color: color-mix(in srgb, currentColor 25%, transparent);
  color: inherit;
}

/* --- loopos-ui token_list.css --- */
.lui-token-list {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.lui-token-list__items {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

/* Empty items shell must not consume the list's 8px gap (looks like padding-left on Add). */
.lui-token-list__items:not(:has(.lui-token)):not(:has(.lui-tag)) {
  display: none;
}

.lui-token-list--vertical .lui-token-list__items {
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

/* --- loopos-ui model_association_list --- */
.lui-model-association-list {
  width: fit-content;
}

/* --- loopos-ui tag_token.css (legacy token shell) --- */
.lui-popover-toggle-wrapper {
  display: flex;
  cursor: pointer;
}

.lui-popover {
  display: contents;
  align-items: center;
}

/* --- counter (overflow +N) --- */
.lui-counter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 4px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  background: var(--color-secondary);
  color: var(--color-content-secondary);
  cursor: default;
}
