/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

/* Shared workbench chat-pill presentation. */
.chat-pill-hover-panel .action-list-submenu-hover-header,
.chat-pill-hover-content {
	max-width: min(420px, 70vw, 100%);
}

.chat-pill-hover-content {
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	gap: var(--vscode-spacing-size80);
	width: 420px;
	padding: var(--vscode-spacing-size120) var(--vscode-spacing-size160);
	color: var(--vscode-editorHoverWidget-foreground);
}

.chat-pill-hover-content.content-sized {
	/* Let the hover host include footer actions in its intrinsic width. */
	width: auto;
}

.chat-pill-hover-content.compact {
	padding: var(--vscode-spacing-size80) var(--vscode-spacing-size120);
}

.chat-pill-hover-content a {
	color: var(--vscode-textLink-foreground);
}

.chat-pill-hover-content a:hover,
.chat-pill-hover-content a:active {
	color: var(--vscode-textLink-activeForeground);
}

.chat-pill-hover-content :is(a, button):focus-visible {
	outline: var(--vscode-strokeThickness) solid var(--vscode-focusBorder);
	outline-offset: var(--vscode-spacing-size20);
}

.chat-pill-location-hover {
	box-sizing: border-box;
	white-space: normal;
	overflow-wrap: anywhere;
}

.chat-pills,
.chat-pills .monaco-toolbar,
.chat-pills .monaco-action-bar,
.chat-pills .monaco-action-bar .actions-container {
	display: flex;
	align-items: center;
	min-width: 0;
}

.chat-pills.hidden {
	display: none;
}

/* Take hit-testing back from the click-through row the pills may float in. */
.chat-pills .monaco-action-bar .action-item {
	pointer-events: auto;
}

.chat-pills .monaco-action-bar .actions-container {
	gap: var(--vscode-spacing-size60);
}

.chat-pills .monaco-action-bar .chat-pill-item,
.chat-pills .monaco-action-bar .chat-pill-segmented {
	display: inline-flex;
	align-items: center;
	flex-shrink: 0;
}

.chat-pill-item .monaco-button.chat-pill-button {
	display: inline-flex;
	align-items: center;
	width: auto;
	gap: var(--vscode-spacing-size40);
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
	touch-action: manipulation;
}

.chat-pill-item .monaco-button.chat-pill-button,
.chat-pill-item.chat-pill-segmented {
	border-radius: var(--vscode-cornerRadius-medium);
}

/* Tint the opaque base `chatPills.ts` sets, so a translucent pill color never
	shows the content behind the pill. */
.chat-pill-item .monaco-button.chat-pill-button.secondary {
	background-image: linear-gradient(var(--vscode-button-secondaryBackground), var(--vscode-button-secondaryBackground));
}

.chat-pill-item .monaco-button.chat-pill-button.secondary:hover,
.chat-pill-item .monaco-button.chat-pill-button.secondary:focus {
	background-image: linear-gradient(var(--vscode-button-secondaryHoverBackground), var(--vscode-button-secondaryHoverBackground));
}

/* Inset the focus ring so it sits on the pill's own border rather than the
	bloated ring the base `outline-offset: 2px` would draw. */
.chat-pill-item .monaco-button.chat-pill-button:focus {
	outline-offset: -1px !important;
}

/* Inset the focus ring so it sits on the pill's own border rather than the
	bloated ring the base `outline-offset: 2px` would draw. Applies to every pill
	in the row, including hosted ones. */
.chat-pills .monaco-button:focus {
	outline-offset: -1px !important;
}

.chat-pill-sections {
	display: flex;
	align-items: center;
	min-width: 0;
	border-radius: inherit;
}

.chat-pill-sections[hidden] {
	display: none;
}

.chat-pill-item.chat-pill-segmented .monaco-button.chat-pill-button {
	border-radius: 0;
	border-inline-width: 0;
}

.chat-pill-item.chat-pill-segmented > .monaco-button.chat-pill-button {
	border-start-start-radius: inherit;
	border-end-start-radius: inherit;
	border-inline-start-width: var(--vscode-strokeThickness);
}

.chat-pill-item.chat-pill-segmented .chat-pill-sections > .monaco-button.chat-pill-button:last-child {
	border-start-end-radius: inherit;
	border-end-end-radius: inherit;
	border-inline-end-width: var(--vscode-strokeThickness);
}

.chat-pill-sections > .chat-pill-button {
	position: relative;
	min-width: 0;
}

.chat-pill-sections > .chat-pill-button::before {
	content: '';
	position: absolute;
	inset-inline-start: 0;
	top: 25%;
	bottom: 25%;
	width: var(--vscode-strokeThickness);
	background-color: var(--vscode-widget-border, var(--vscode-descriptionForeground));
}

.hc-black .chat-pill-sections > .chat-pill-button::before,
.hc-light .chat-pill-sections > .chat-pill-button::before {
	background-color: var(--vscode-contrastBorder);
}

.chat-pills .monaco-action-bar .chat-hosted-pill {
	display: inline-flex;
	align-items: center;
	min-width: 0;
}

.monaco-workbench .chat-pill-icon.codicon[class*=codicon-] {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: var(--vscode-codiconFontSize-compact);
	height: var(--vscode-codiconFontSize-compact);
	margin: 0;
	font-size: var(--vscode-codiconFontSize-compact);
	flex-shrink: 0;
}

/* Section-backed pills (artifacts, customizations, browsers, subagents) can
	carry a long entry label, so they cap their width and ellipsize rather than
	pushing their neighbours out of the row. */
.chat-pills .monaco-action-bar .chat-dropdown-pill,
.chat-pills .monaco-action-bar .chat-resource-pill {
	max-width: 280px;
}

.chat-pill-item .monaco-button.chat-dropdown-pill-button,
.chat-pill-item .monaco-button.chat-resource-pill-button {
	min-width: 0;
	max-width: 280px;
	overflow: hidden;
}

.chat-pill-button .chat-pill-label {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* A lone entry can mirror its promoted action onto the pill, like the remove
	action of a chat attachment: quiet until hovered. It rides on trailing padding
	its button reserves, adding no width of its own. */
.chat-pill-item.has-promoted-action > .monaco-button.chat-pill-button {
	padding-right: calc(var(--vscode-spacing-size40) + var(--vscode-spacing-size160) + var(--vscode-spacing-size20));
}

.monaco-workbench .chat-pill-item > .chat-pill-promoted-action.codicon {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	width: var(--vscode-spacing-size160);
	height: var(--vscode-spacing-size160);
	margin: 0 calc(var(--vscode-spacing-size20) + var(--vscode-strokeThickness)) 0 calc(-1 * (var(--vscode-spacing-size160) + var(--vscode-spacing-size20) + var(--vscode-strokeThickness)));
	border-radius: var(--vscode-cornerRadius-small);
	color: var(--vscode-descriptionForeground);
	font-size: var(--vscode-codiconFontSize-compact);
	line-height: var(--vscode-spacing-size160);
	cursor: pointer;
}

.monaco-workbench .chat-pill-item > .chat-pill-promoted-action.codicon:hover {
	background-color: var(--vscode-toolbar-hoverBackground);
	outline: var(--vscode-strokeThickness) dashed var(--vscode-toolbar-hoverOutline);
	outline-offset: calc(-1 * var(--vscode-strokeThickness));
}

/* Compact pills keep only their icon; the compact padding rules also drop the reserved space. */
.monaco-workbench .chat-pills-row.compact .chat-pill-item > .chat-pill-promoted-action.codicon,
.monaco-workbench .chat-pill-item > .chat-pill-button.compact + .chat-pill-promoted-action.codicon {
	display: none;
}

/* The chevron shares the leading glyph's compact box. `chevron-down-compact` is
	drawn on that box's centre, so it needs no nudge to sit on the label. */
.monaco-workbench .chat-pill-chevron.codicon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: var(--vscode-codiconFontSize-compact);
	height: var(--vscode-codiconFontSize-compact);
	margin: 0;
	font-size: var(--vscode-codiconFontSize-compact);
	flex-shrink: 0;
}

/* The themed file icon carries its own leading gap, so the pill adds barely any. */
.chat-pill-item .monaco-button.chat-resource-pill-button {
	padding-left: var(--vscode-spacing-size20);
}

.chat-pill-item .monaco-button.chat-resource-pill-button .chat-resource-pill-compact-icon {
	display: none;
}

.chat-resource-pill-button .monaco-icon-label {
	align-items: center;
	min-width: 0;
	overflow: hidden;
	font-size: var(--vscode-fontSize-body2);
}

.chat-resource-pill-button .monaco-icon-label::before {
	background-size: var(--vscode-codiconFontSize-compact);
	width: var(--vscode-codiconFontSize-compact);
	height: 14px;
}

/* File rows render a themed file icon in the same slot codicon rows use, so
	every label in the dropdown starts on the same vertical line. The icon paints
	through `::before`, which would otherwise sit on the row's text baseline and
	ride high, so the slot takes the row's height and centres the icon in it. */
.action-widget .monaco-list-row.action .icon.file-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	width: var(--vscode-codiconFontSize);
	height: var(--vscode-spacing-size240);
}

.action-widget .monaco-list-row.action .icon.file-icon::before {
	width: var(--vscode-codiconFontSize);
	background-size: var(--vscode-codiconFontSize);
	background-repeat: no-repeat;
	background-position: center center;
}

.action-widget.chat-pill-dropdown .monaco-list .monaco-list-row.has-toolbar:not(.has-standalone-toggle):not(.has-inline-toggle):not(.has-detail) {
	padding-right: 0;
}

.action-widget.chat-pill-dropdown .monaco-list .monaco-list-row.has-toolbar:not(.has-standalone-toggle):not(.has-inline-toggle):not(.has-detail) .action-list-item-toolbar {
	margin-right: 0;
}

.action-widget.chat-pill-dropdown .monaco-list-row.chat-pill-reference .action-item-badge {
	margin-left: 0;
	margin-right: var(--vscode-spacing-size40);
	padding: 0;
	border-radius: 0;
	background: transparent;
	color: var(--vscode-descriptionForeground);
	font-size: inherit;
	line-height: inherit;
}

.chat-pill-image-preview .chat-image-hover {
	padding: 0;
}

.chat-pill-image-preview-unavailable {
	overflow-wrap: anywhere;
	color: var(--vscode-descriptionForeground);
}

/* Horizontally scrollable status pills above a chat input. */
.chat-pills-row {
	width: 100%;
	min-width: 0;
}

.chat-pills-row-content {
	display: flex;
	align-items: center;
	justify-content: flex-start;
	gap: var(--vscode-spacing-size60);
	width: 100%;
	min-width: 0;
	box-sizing: border-box;
	padding: var(--vscode-spacing-size20) 0 var(--vscode-spacing-size40) 0;
}

.chat-pills-row.can-scroll-left > .chat-pills-row-content {
	mask-image: linear-gradient(to right, transparent, black var(--vscode-spacing-size160));
}

.chat-pills-row.can-scroll-right > .chat-pills-row-content {
	mask-image: linear-gradient(to left, transparent, black var(--vscode-spacing-size160));
}

.chat-pills-row.can-scroll-left.can-scroll-right > .chat-pills-row-content {
	mask-image: linear-gradient(to right, transparent, black var(--vscode-spacing-size160), black calc(100% - var(--vscode-spacing-size160)), transparent);
}

.monaco-workbench.hc-black .chat-pills-row > .chat-pills-row-content,
.monaco-workbench.hc-light .chat-pills-row > .chat-pills-row-content {
	mask-image: none;
}

.chat-pills-row-content > .chat-pills {
	flex-shrink: 0;
}

.chat-pills-row-content > * {
	pointer-events: auto;
}

.chat-pills-row.hidden {
	display: none;
}

.chat-pills-row.compact .chat-pills-row-content,
.chat-pills-row.compact .chat-pills .monaco-action-bar .actions-container {
	gap: var(--vscode-spacing-size40);
}

.chat-pills-row.compact .chat-pill-item .monaco-button.chat-pill-button,
.chat-pills-row .chat-pill-item .monaco-button.chat-pill-button.compact {
	gap: var(--vscode-spacing-size20);
	padding-left: var(--vscode-spacing-size40);
	padding-right: var(--vscode-spacing-size40);
}

/* Compact pills retain their icons, tooltips, and accessible names. */
.chat-pills-row.compact .chat-pill-label,
.chat-pills-row.compact .changes-stats-files,
.chat-pills-row.compact .monaco-animated-counter,
.chat-pills-row.compact .chat-pill-chevron,
.chat-pills-row.compact .chat-resource-pill-button .monaco-icon-label,
.chat-pills-row .chat-pill-button.compact .chat-pill-label,
.chat-pills-row .chat-pill-button.compact .changes-stats-files,
.chat-pills-row .chat-pill-button.compact .monaco-animated-counter,
.chat-pills-row .chat-pill-button.compact .chat-pill-chevron,
.chat-pills-row .chat-resource-pill-button.compact .monaco-icon-label {
	display: none;
}

.chat-pills-row.compact .chat-pill-item .monaco-button.chat-resource-pill-button .chat-resource-pill-compact-icon,
.chat-pills-row .chat-pill-item .monaco-button.chat-resource-pill-button.compact .chat-resource-pill-compact-icon {
	display: inline-flex;
}

/* Keep the visibility menu reachable when every pill with data is hidden. */
.chat-pills-row.empty {
	pointer-events: auto;
}

.chat-pills-row.empty .chat-pills-row-content {
	min-height: var(--vscode-spacing-size120);
}

.chat-pills-row.empty .chat-pills-row-content:focus-visible {
	outline: var(--vscode-strokeThickness) solid var(--vscode-focusBorder);
	outline-offset: calc(-1 * var(--vscode-strokeThickness));
	border-radius: var(--vscode-cornerRadius-small);
}

/* The floating row is click-through, so its slider is informational only. */
.chat-pills-row > .scrollbar > .slider {
	background: transparent;
}

.chat-pills-row > .scrollbar.horizontal > .slider::before {
	content: '';
	position: absolute;
	inset: var(--vscode-strokeThickness);
	border-radius: var(--vscode-cornerRadius-circle);
	background: var(--vscode-scrollbarSlider-background);
}

.chat-pills-row > .scrollbar > .slider:hover::before {
	background: var(--vscode-scrollbarSlider-hoverBackground);
}

.chat-pills-row > .scrollbar > .slider.active::before {
	background: var(--vscode-scrollbarSlider-activeBackground);
}
