/**
 * Translation provider list on the AI Translation settings tab:
 * one row per provider with status, "Set as default", docs link, setup action and on/off switch.
 */
.lmat-engines {
	--lmat-engine-primary: #30b230;
	--lmat-engine-primary-dark: #239d23;
	--lmat-engine-primary-light: #efffef;
	--lmat-engine-border: #ddd;
	--lmat-engine-text: #222;
	--lmat-engine-text-light: #666;
	container-name: lmat-engines;
	container-type: inline-size;
	margin-top: 20px;
}

.lmat-engines,
.lmat-engines * {
	box-sizing: border-box;
}

/* Info strip above the list. */
.lmat-engines .lmat-engine-note {
	align-items: center;
	background: #eef4ff;
	border: 1px solid #cfe0f5;
	border-radius: 8px;
	display: flex;
	gap: 10px;
	margin-bottom: 16px;
	padding: 12px 14px;
}

.lmat-engines .lmat-engine-note-icon {
	color: #2271b1;
	display: inline-flex;
	flex-shrink: 0;
}

.lmat-engines .lmat-engine-note p {
	color: #2271b1;
	font-size: 13px;
	margin: 0;
	padding: 0;
}

.lmat-engines ul.lmat-engine-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.lmat-engines li.lmat-engine-row {
	align-items: center;
	background: #fff;
	border: 1px solid var(--lmat-engine-border);
	border-radius: 8px;
	display: grid;
	gap: 10px 12px;
	grid-template-areas:
		"meta meta"
		"default actions";
	grid-template-columns: minmax(0, 1fr) auto;
	margin: 0 0 10px;
	padding: 12px 16px;
	position: relative;
}

.lmat-engines li.lmat-engine-row:last-child {
	margin-bottom: 0;
}

.lmat-engines li.lmat-engine-row.is-default {
	background: var(--lmat-engine-primary-light);
	border-color: var(--lmat-engine-primary);
}

.lmat-engines .lmat-engine-meta {
	align-items: center;
	display: flex;
	gap: 12px;
	grid-area: meta;
	min-width: 0;
	width: 100%;
}

.lmat-engines .lmat-engine-logo {
	align-items: center;
	display: inline-flex;
	flex-shrink: 0;
	height: 26px;
	justify-content: center;
	width: 26px;
}

.lmat-engines .lmat-engine-logo svg,
.lmat-engines .lmat-engine-logo img {
	height: 24px;
	object-fit: contain;
	width: 24px;
}

.lmat-engines .lmat-engine-name {
	color: var(--lmat-engine-text);
	flex: 1 1 auto;
	font-size: 14px;
	font-weight: 600;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.lmat-engines .lmat-engine-status {
	align-items: center;
	background: var(--lmat-engine-primary-light);
	border-radius: 12px;
	color: var(--lmat-engine-primary-dark);
	display: inline-flex;
	flex-shrink: 0;
	font-size: 12px;
	font-weight: 600;
	justify-content: center;
	margin-left: auto;
	padding: 2px 10px;
	text-align: center;
	white-space: nowrap;
}

/* Default row: drop the Ready pill so the label sits on the row green. */
.lmat-engines li.lmat-engine-row.is-default .lmat-engine-status:not(.is-setup):not(.is-checking):not(.is-unsupported) {
	background: transparent;
	color: var(--lmat-engine-primary-dark);
	padding-inline: 0;
}

.lmat-engines .lmat-engine-status.is-setup {
	background: #fff6ed;
	color: #b45309;
}

.lmat-engines .lmat-engine-status.is-checking,
.lmat-engines .lmat-engine-status.is-unsupported {
	background: #f3f4f6;
	color: #6b7280;
}

.lmat-engines .lmat-engine-unsupported-msg {
	color: #dc2626;
	flex: 1 1 100%;
	font-size: 13px;
	grid-column: 1 / -1;
	line-height: 1.45;
	margin: 0;
	min-width: 0;
	width: 100%;
}

/* "Set as default" picker. */
.lmat-engines .lmat-engine-default {
	align-items: center;
	cursor: pointer;
	display: flex;
	gap: 8px;
	grid-area: default;
	justify-content: flex-start;
	justify-self: start;
	min-width: 0;
	position: relative;
}

.lmat-engines .lmat-engine-default.is-disabled {
	cursor: not-allowed;
	opacity: 0.6;
}

.lmat-engines .lmat-engine-default input[type="radio"].lmat-engine-default-input {
	height: 0;
	margin: 0;
	opacity: 0;
	pointer-events: none;
	position: absolute;
	width: 0;
}

.lmat-engines .lmat-engine-default-mark {
	border: 1px solid #8c8f94;
	border-radius: 50%;
	flex-shrink: 0;
	height: 18px;
	position: relative;
	width: 18px;
}

.lmat-engines .lmat-engine-default-text,
.lmat-engines .lmat-engine-default-active {
	color: var(--lmat-engine-text-light);
	font-size: 13px;
	white-space: nowrap;
}

/* The default row swaps the radio for a star and the label for a status. */
.lmat-engines .lmat-engine-default-active {
	display: none;
}

.lmat-engines li.lmat-engine-row.is-default .lmat-engine-default-text {
	display: none;
}

.lmat-engines li.lmat-engine-row.is-default .lmat-engine-default-active {
	color: var(--lmat-engine-primary);
	display: inline;
	font-weight: 600;
}

.lmat-engines li.lmat-engine-row.is-default .lmat-engine-default-mark {
	border: none;
	color: var(--lmat-engine-primary);
}

.lmat-engines li.lmat-engine-row.is-default .lmat-engine-default-mark::before {
	content: "\2605";
	font-size: 22px;
	left: 50%;
	line-height: 1;
	position: absolute;
	top: 50%;
	transform: translate(-50%, -50%);
}

.lmat-engines .lmat-engine-default-input:focus-visible + .lmat-engine-default-mark {
	box-shadow: 0 0 0 2px var(--lmat-engine-primary-light), 0 0 0 4px var(--lmat-engine-primary);
}

/* Right hand side: docs, setup action and the on/off switch. */
.lmat-engines .lmat-engine-actions {
	align-items: center;
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	grid-area: actions;
	justify-content: flex-end;
	justify-self: end;
	min-width: 0;
}

.lmat-engines .lmat-engine-action-slot {
	align-items: center;
	display: inline-flex;
	flex: 0 1 auto;
	justify-content: flex-end;
	min-height: 30px;
}

.lmat-engines .lmat-engine-docs {
	color: var(--lmat-engine-text-light);
	font-size: 13px;
	text-decoration: underline;
}

.lmat-engines .lmat-engine-docs:hover {
	color: var(--lmat-engine-primary);
}

.lmat-engines .lmat-engine-docs:focus {
	box-shadow: none;
	outline: none;
}

.lmat-engines .lmat-engine-btn {
	align-items: center;
	background: #f8f9fa;
	border: 1px solid var(--lmat-engine-border);
	border-radius: 7px;
	box-shadow: inset 1px 1px 2px #00000010;
	color: var(--lmat-engine-text);
	cursor: pointer;
	display: inline-flex;
	flex-shrink: 0;
	font-size: 13px;
	font-weight: 500;
	gap: 5px;
	line-height: 1.4em;
	padding: 7px 16px;
	text-decoration: none;
	transition: all 0.3s ease-in-out;
	white-space: nowrap;
}

.lmat-engines .lmat-engine-btn:hover,
.lmat-engines .lmat-engine-btn:focus {
	background: var(--lmat-engine-primary-light);
	border-color: var(--lmat-engine-primary);
	color: var(--lmat-engine-primary);
	outline: none;
}

.lmat-engines .lmat-engine-btn.primary {
	background: var(--lmat-engine-primary);
	border-color: var(--lmat-engine-primary-dark);
	color: #fff;
}

.lmat-engines .lmat-engine-btn.primary:hover,
.lmat-engines .lmat-engine-btn.primary:focus {
	background: var(--lmat-engine-primary-dark);
	border-color: var(--lmat-engine-primary-dark);
	color: #fff;
}

/* On/off switch. */
.lmat-engines .lmat-provider-switch {
	display: inline-block;
	flex-shrink: 0;
	height: 24px;
	margin: 0;
	position: relative;
	width: 44px;
}

.lmat-engines .lmat-provider-switch .lmat-input-toggle {
	height: 0;
	margin: 0;
	opacity: 0;
	position: absolute;
	width: 0;
}

.lmat-engines .lmat-switch-slider {
	background-color: #ccc;
	border-radius: 24px;
	bottom: 0;
	cursor: pointer;
	left: 0;
	position: absolute;
	right: 0;
	top: 0;
	transition: 0.3s;
}

.lmat-engines .lmat-switch-slider::before {
	background-color: #fff;
	border-radius: 50%;
	bottom: 3px;
	content: "";
	height: 18px;
	left: 3px;
	position: absolute;
	transition: 0.3s;
	width: 18px;
}

.lmat-engines .lmat-input-toggle:checked + .lmat-switch-slider {
	background-color: var(--lmat-engine-primary);
}

.lmat-engines .lmat-input-toggle:checked + .lmat-switch-slider::before {
	transform: translateX(20px);
}

.lmat-engines .lmat-input-toggle:disabled + .lmat-switch-slider {
	cursor: not-allowed;
	opacity: 0.6;
}

/* The default provider's switch is locked on; keep it looking on. */
.lmat-engines li.lmat-engine-row.is-default .lmat-input-toggle:disabled + .lmat-switch-slider {
	background-color: var(--lmat-engine-primary);
	opacity: 1;
}

.lmat-engines .lmat-input-toggle:focus-visible + .lmat-switch-slider {
	box-shadow: 0 0 1px var(--lmat-engine-primary);
}

/* Extra content under a row (API key form, Chrome/Edge setup card). */
.lmat-engines .lmat-engine-extra {
	grid-column: 1 / -1;
	min-width: 0;
}

/* Gemini API key + model sit side-by-side when space allows. */
.lmat-api-key-row {
	align-items: flex-start;
	display: flex;
	flex-direction: column;
	gap: 1.25rem;
	width: 100%;
}

.lmat-api-key-field,
.lmat-api-key-model {
	min-width: 0;
}

.lmat-api-key-field {
	flex: 1 1 auto;
}

.lmat-api-key-model {
	flex: 0 1 320px;
	max-width: 340px;
	width: 100%;
}

.lmat-api-key-model-select {
	box-sizing: border-box;
	min-height: 40px;
	width: 100%;
}

@media (min-width: 720px) {
	.lmat-api-key-row {
		flex-direction: row;
		gap: 1.5rem;
	}

	.lmat-api-key-row.is-embedded .lmat-api-key-model {
		padding-top: 0.75rem;
	}
}

/* A provider the current browser cannot run: only the message and badge remain. */
.lmat-engines li.lmat-engine-row.is-unsupported .lmat-engine-default,
.lmat-engines li.lmat-engine-row.is-unsupported .lmat-engine-actions {
	display: none;
}

/* Wide layout: single row with aligned status / default / actions. */
@container lmat-engines (min-width: 880px) {
	.lmat-engines li.lmat-engine-row {
		gap: 12px 16px;
		grid-template-areas: "meta default actions";
		grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, auto);
	}

	.lmat-engines .lmat-engine-meta {
		display: grid;
		grid-template-columns: 26px minmax(0, 1fr) 140px;
	}

	.lmat-engines .lmat-engine-name {
		flex: unset;
	}

	.lmat-engines .lmat-engine-status {
		justify-self: center;
		margin-left: 0;
		width: 100%;
	}

	.lmat-engines .lmat-engine-default {
		justify-content: center;
		justify-self: center;
	}

	.lmat-engines .lmat-engine-actions {
		flex-wrap: nowrap;
		justify-self: end;
		white-space: nowrap;
		width: 100%;
	}

	.lmat-engines .lmat-engine-action-slot {
		flex: 0 0 118px;
	}

	.lmat-engines li.lmat-engine-row .lmat-engine-extra {
		grid-column: 1 / -1;
	}
}

/* Narrow card: stack rows so controls do not squeeze. */
@container lmat-engines (max-width: 879px) {
	.lmat-engines li.lmat-engine-row {
		gap: 8px;
		grid-template-areas:
			"meta"
			"default"
			"actions";
		grid-template-columns: minmax(0, 1fr);
		padding: 12px;
	}

	.lmat-engines .lmat-engine-default {
		justify-content: flex-start;
		justify-self: stretch;
		width: 100%;
	}

	.lmat-engines .lmat-engine-actions {
		align-items: center;
		flex-wrap: wrap;
		gap: 8px 12px;
		justify-content: flex-start;
		justify-self: stretch;
		width: 100%;
	}

	.lmat-engines .lmat-engine-actions .lmat-provider-switch {
		margin-left: auto;
	}

	.lmat-engines .lmat-engine-action-slot {
		flex: 0 1 auto;
		min-height: 0;
	}
}

@container lmat-engines (max-width: 420px) {
	.lmat-engines .lmat-engine-meta {
		align-items: start;
		display: grid;
		gap: 8px 12px;
		grid-template-areas:
			"logo name"
			"status status";
		grid-template-columns: 26px minmax(0, 1fr);
	}

	.lmat-engines .lmat-engine-logo {
		grid-area: logo;
	}

	.lmat-engines .lmat-engine-name {
		grid-area: name;
		white-space: normal;
	}

	.lmat-engines .lmat-engine-status {
		grid-area: status;
		justify-self: start;
		margin-left: 0;
	}
}

/* Chrome / Edge AI setup card shown above the list. */
.lmat-chrome-ai-setup {
	margin-bottom: 16px;
}
