/* Autoloaded options tab (panel world; tokens from admin.css). */

.apwc-al-summary {
	display: grid;
	gap: 12px;
}

/* Stats: value over label (the Scheduled actions look). */
.apwc-app .apwc-al-stats {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
	gap: 12px;
	margin: 0;
}

.apwc-al-stat {
	display: flex;
	flex-direction: column-reverse;
	justify-content: flex-end;
	gap: 2px;
	padding: 12px 16px;
	border: 1px solid var(--apwc-border);
	border-radius: var(--apwc-radius);
	background: var(--apwc-subtle);
}

.apwc-app .apwc-al-stat dt {
	color: var(--apwc-muted-fg);
	font-size: 12px;
	font-weight: 500;
	line-height: 16px;
}

.apwc-app .apwc-al-stat dd {
	margin: 0;
	color: var(--apwc-fg);
	font-size: 20px;
	font-weight: 600;
	line-height: 28px;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.apwc-app .apwc-al__muted {
	margin: 0;
	color: var(--apwc-muted-fg);
	font-size: 13px;
}

.apwc-app .apwc-al__title {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	margin: 0 0 8px;
	color: var(--apwc-fg);
	font-size: 14px;
	font-weight: 600;
	line-height: 20px;
}

/* Own first-column width (never the shared table's first-cell width). */
.apwc-app .apwc-al__table :is(th, td):first-child {
	font-variant-numeric: normal;
}

.apwc-app .apwc-al__table .apwc-al__option {
	min-width: 180px;
}

/* Option names are machine identifiers: mono, like hook names in Scheduled actions. They break
   after _ - . / : (the view adds <wbr>); break-word only as a last resort. */
.apwc-app .apwc-al__name {
	padding: 0;
	background: none;
	color: var(--apwc-fg);
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 12px;
	font-weight: 500;
	overflow-wrap: break-word;
}

.apwc-al__option .apwc-badge {
	margin-left: 6px;
	vertical-align: middle;
}

.apwc-app .apwc-al__owner {
	min-width: 140px;
}

.apwc-app .apwc-al__sub {
	display: block;
	font-size: 12px;
}

.apwc-al__num {
	font-variant-numeric: tabular-nums;
	text-align: right;
	white-space: nowrap;
}

.apwc-al__table th {
	white-space: nowrap;
}

.apwc-al__table th.apwc-al__num {
	text-align: right;
}

/* Fixed slots: view · stop (button + badge, or Protected) · delete, so they line up row to row. */
.apwc-al__actions {
	display: grid;
	grid-template-columns: 30px minmax(min-content, max-content) 30px;
	align-items: center;
	gap: 4px;
}

.apwc-al__stop {
	display: inline-flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	min-width: 0;
}

.apwc-app .apwc-al__protected {
	padding: 0 12px;
	cursor: help;
}

.apwc-app .apwc-al-legend {
	display: flex;
	flex-wrap: wrap;
	gap: 16px;
}

.apwc-al-legend > span {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

/* Recent changes */

.apwc-al__changes-wrap {
	border-top: 1px solid var(--apwc-border);
}

.apwc-app .apwc-al-changes__list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.apwc-app .apwc-al-changes__item {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 8px 16px;
	margin: 0;
	padding: 10px 0;
	border-top: 1px solid var(--apwc-border);
}

.apwc-al-changes__item:first-child {
	border-top: 0;
}

.apwc-al-changes__text {
	display: grid;
	gap: 2px;
	min-width: 0;
}

.apwc-app .apwc-al__action {
	display: inline-flex;
	align-items: center;
	gap: 8px;
}

/* Value viewer */

/* The title is the option name: a machine identifier, so mono. */
.apwc-app .apwc-al-modal__name {
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 14px;
	white-space: normal;
	overflow-wrap: break-word;
}

.apwc-app .apwc-al-modal__status {
	margin: 0;
	padding: 16px 24px;
	color: var(--apwc-muted-fg);
	font-size: 13px;
}

.apwc-app .apwc-al-modal__status:empty {
	display: none;
}

.apwc-app .apwc-al-modal__facts {
	padding: 16px 24px;
	border-top: 0;
}

.apwc-al-modal__section {
	display: grid;
	gap: 12px;
	padding: 16px 24px 20px;
	border-top: 1px solid var(--apwc-border);
}

.apwc-al-modal__tools {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.apwc-app .apwc-al-modal__note[hidden] {
	display: none;
}

.apwc-app .apwc-al-modal__pre {
	max-height: 480px;
	margin: 0;
	padding: 12px;
	overflow: auto;
	border: 1px solid var(--apwc-border);
	border-radius: var(--apwc-radius);
	background: var(--apwc-bg);
	color: var(--apwc-fg);
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 12px;
	line-height: 18px;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

@media (max-width: 782px) {

	/* Rows stack: option · size, then owner, then the actions. */
	.apwc-app .apwc-al__table,
	.apwc-app .apwc-al__table :is(thead, tbody) {
		display: block;
	}

	.apwc-app .apwc-al__table thead th:nth-child(n+3) {
		display: none;
	}

	.apwc-app .apwc-al__table :is(thead tr, tbody tr) {
		display: grid;
		grid-template-columns: minmax(0, 1fr) auto;
		grid-template-areas:
			"option size"
			"owner owner"
			"actions actions";
		column-gap: 12px;
		padding: 12px 16px;
		border-bottom: 1px solid var(--apwc-border);
	}

	.apwc-app .apwc-al__table thead tr {
		grid-template-areas: "option size";
		padding-block: 8px;
		background: var(--apwc-subtle);
	}

	.apwc-app .apwc-al__table tbody tr:last-child {
		border-bottom: 0;
	}

	.apwc-app .apwc-al__table :is(th, td),
	.apwc-app .apwc-al__table :is(th, td):first-child,
	.apwc-app .apwc-al__table :is(th, td):last-child {
		display: block;
		width: auto;
		min-width: 0;
		height: auto;
		padding: 0;
		border: 0;
		background: transparent;
	}

	.apwc-app .apwc-al__table .apwc-al__option {
		grid-area: option;
	}

	.apwc-app .apwc-al__table .apwc-al__num {
		grid-area: size;
	}

	.apwc-app .apwc-al__table .apwc-al__owner {
		grid-area: owner;
		margin-top: 4px;
		color: var(--apwc-muted-fg);
		font-size: 12px;
	}

	.apwc-app .apwc-al__table .apwc-al__autoload {
		display: none;
	}

	.apwc-app .apwc-al__table .apwc-log__row-actions {
		grid-area: actions;
		margin-top: 8px;
	}
}
