/**
 * @file
 * Styling for AI Context module.
 */

/* Add custom icon to toolbar menu item using mask-image */
:is(#ai_context, .toolbar-icon-ai-context-overview, .toolbar-button--icon--ai-context-overview, .toolbar-link--ai-context-overview)::before {
  background-color: currentColor;
  mask-image: url('data:image/svg+xml,%3Csvg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"%3E%3Cg fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round"%3E%3Cpath fill="currentColor" fill-opacity=".15" d="M12.928 1.4861C12.3468 1.18165 11.6532 1.18165 11.072 1.4861L1.5 6.5L11.072 11.5139C11.6532 11.8183 12.3468 11.8183 12.928 11.5139L22.5 6.5L12.928 1.4861Z"/%3E%3Cpath d="M1.5 12L11.072 17.0139C11.6532 17.3183 12.3468 17.3183 12.928 17.0139L22.5 12"/%3E%3Cpath d="M1.5 17.5L11.072 22.5139C11.6532 22.8183 12.3468 22.8183 12.928 22.5139L22.5 17.5"/%3E%3C/g%3E%3C/svg%3E');
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
}

.action-link.action-link--icon-trash {
  padding-block: calc(var(--gin-spacing-xs) - var(--gin-spacing-xxxs)) !important;
}

/* Truncated description - indicate that hovering reveals full text */
.description-truncate {
  display: inline;
  cursor: help;
  color: var(--gin-color-text, currentColor);
  border-bottom: 1px dotted var(--gin-color-text-light, #6c7985);
}

/* Subtle inline links for debug/explore actions */
.ai-context-inline-link {
  text-decoration: none;
  color: var(--color-gray-800, #55565b);
  font-size: 0.9em;
}

.ai-context-inline-link:hover {
  text-decoration: underline;
  color: var(--color-gray, #232429);
}

/* AI Context Usage view - compact exposed filters */
.view-ai-context-usage .views-exposed-form .form--inline {
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
}

.view-ai-context-usage .views-exposed-form .form-item {
  margin-block: 0;
}

.view-ai-context-usage .views-exposed-form .form-item input[type="text"],
.view-ai-context-usage .views-exposed-form .form-item input[type="number"] {
  width: 20ch;
  min-width: 10ch;
}

.view-ai-context-usage .views-exposed-form .form-item-target-entity-id input {
  width: 6ch;
}

/* Preserve whitespace in target entity lists */
.ai-context-target {
  white-space: normal;
}

/* Tags display - each tag on its own line */
.ai-context-tag,
.ai-context-tags {
  display: block;
}

/* Scope display in agent form table - each scope type on its own line */
.ai-context-scope-cell {
  display: block;
}

/**
 * Diff visual inline layout accessibility improvements.
 *
 * Scoped to diff comparison pages (which have .diff-header).
 * Darkens the background colors for better contrast with white text.
 */

/* Deleted content - dark red background */
.diff-header ~ del,
.diff-header ~ * del {
  color: #fff;
  background-color: #c43c3c;
}

/* Inserted content - dark green background */
.diff-header ~ ins,
.diff-header ~ * ins {
  color: #fff;
  background-color: #2e7d32;
}

/* Context items search input */
#ai-context-items-search {
  max-width: 30ch;
  margin-block-end: var(--gin-spacing-m, 1rem);
}

/* Consistent spacing for AI Context Item entity view pages only */
.page-ai-context-item-view .field--name-langcode .field__label,
.page-ai-context-item-view .field--name-scope .field__label,
.page-ai-context-item-view .field--name-target-entities .field__label,
.page-ai-context-item-view .field--name-uid .field__label,
.page-ai-context-item-view .field--name-tags .field__label,
.page-ai-context-item-view .field--name-parent .field__label,
.page-ai-context-item-view .field--name-subcontext-type .field__label {
  margin-block-start: 1em;
}

.page-ai-context-item-view .field--name-langcode .field__item,
.page-ai-context-item-view .field--name-scope .field__item,
.page-ai-context-item-view .field--name-target-entities .field__item,
.page-ai-context-item-view .field--name-uid .field__item,
.page-ai-context-item-view .field--name-tags .field__item,
.page-ai-context-item-view .field--name-parent .field__item,
.page-ai-context-item-view .field--name-subcontext-type .field__item {
  margin-block-start: 0.5em;
  margin-block-end: 1em;
}

/* Remove default list margins since we're adding them to field__item */
.page-ai-context-item-view .field--name-scope .field-item > ul,
.page-ai-context-item-view .field--name-target-entities .field-item > ul {
  margin-block: 0;
}

.ai-context-item-list [class*="ai-icon-"] {
  display: inline-block;
  width: 20px;
  height: 20px;
  background-repeat: no-repeat;
  background-size: contain;
}

.ai-context-item-list .ai-icon--arrow-left-up,
.ai-context-item-list .ai-icon--option {
  margin-inline-end: 5px;
  background-position: bottom;
}

:is(#ai_context, .ai-pill).light {
  color: var(--gin-color-primary-active, var(--color-gray-900));
  background: var(--gin-color-primary-light, #eee);
}

.ai-context-item-list tbody .ai-pill {
  overflow: hidden;
  max-width: 17ch;
  margin-inline-start: 8px;
  vertical-align: middle;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ai-context-scope-row {
  display: flex;
  align-items: center;
  margin-bottom: 0.25rem;
  gap: 0.1rem;
}

:is(.ai-context-scope-row, .ai-context-item-list) .ai-pill:first-child {
  margin-inline-start: 0;
}

.ai-context-scope-label {
  flex: 0 0 130px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-size: 0.875rem;
  font-weight: 600;
}

.ai-context-item-list :is(.ai-context-use-cases, .ai-context-target) {
  white-space: nowrap;
}

.ai-context-item-list tbody tr {
  border-width: 0;
}

.ai-context-item-list tbody tr:has(+ tr .ai-icon--file),
.ai-context-item-list tbody tr:last-child {
  border-width: 1px;
}
