/*
 * Copyright (C) 2026 Fluxer Contributors
 *
 * This file is part of Fluxer.
 *
 * Fluxer is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Fluxer is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
 */

.page {
	display: flex;
	flex-direction: column;
	gap: var(--spacing-4);
	padding: var(--spacing-6) var(--spacing-5) var(--spacing-4);
	width: 100%;
	max-width: 1200px;
	margin: 0 auto;
	min-height: 100%;
	background: var(--background-secondary);
}

.pageHeader {
	display: flex;
	flex-direction: column;
	gap: var(--spacing-2);
	padding-bottom: var(--spacing-1);
}

.breadcrumbRow {
	display: flex;
	margin-bottom: var(--spacing-4);
}

.heroCard {
	display: flex;
	flex-direction: column;
	gap: var(--spacing-3);
	padding: 0;
	border: none;
	border-radius: 0;
	background: transparent;
}

.heroTop {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	gap: var(--spacing-3);
	flex-wrap: wrap;
}

.heroTop > div {
	flex: 1;
	min-width: 320px;
}

.eyebrow {
	margin: 0;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	font-size: 0.78rem;
	color: var(--text-primary-muted);
	font-weight: 700;
}

.heroTitle {
	margin: 0 0 var(--spacing-2) 0;
	font-size: 1.35rem;
	font-weight: 750;
	color: var(--text-primary);
	display: flex;
	align-items: center;
	gap: var(--spacing-2);
}

.heroMeta {
	display: flex;
	flex-direction: column;
	gap: var(--spacing-1);
	color: var(--text-primary-muted);
}

.metaValue {
	padding: 0.55rem 0.9rem;
	border-radius: var(--radius-lg);
	background: var(--background-primary);
	border: 1px solid var(--background-modifier-accent);
	color: var(--text-primary);
	font-family: var(--font-mono);
	font-size: 0.9rem;
	word-break: break-all;
	min-width: 240px;
}

.metaInput {
	width: 100%;
	max-width: none;
	font-family: var(--font-mono);
}

.pill {
	display: inline-flex;
	align-items: center;
	gap: var(--spacing-1);
	padding: 0.35rem 0.75rem;
	border-radius: 999px;
	background: var(--background-tertiary);
	color: var(--text-primary);
	font-weight: 700;
	font-size: 0.85rem;
}

.actions {
	display: flex;
	gap: var(--spacing-2);
	flex-wrap: wrap;
}

.actions > * {
	flex: 1;
	min-width: fit-content;
}

.detailGrid {
	display: grid;
	gap: var(--spacing-6);
	grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
	align-items: start;
}

.columnStack {
	display: flex;
	flex-direction: column;
	align-self: stretch;
	gap: var(--spacing-5);
}

.builderSection {
	display: flex;
	flex-direction: column;
	gap: var(--spacing-4);
}

.sectionSpacer {
	height: var(--spacing-5);
	flex: 0 0 auto;
}

.card {
	display: flex;
	flex-direction: column;
	gap: var(--spacing-3);
	padding: 0;
	border: none;
	border-radius: 0;
	background: transparent;
}

.cardDanger {
	border-color: transparent;
	background: transparent;
}

.cardHeader {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	gap: var(--spacing-2);
	flex-wrap: wrap;
	padding-bottom: var(--spacing-2);
	border-bottom: 1px solid var(--background-modifier-accent);
}

.cardTitle {
	margin: 0;
	font-size: 1.05rem;
	font-weight: 750;
	color: var(--text-primary);
}

.cardSubtitle {
	margin: 0.35rem 0 0 0;
	color: var(--text-primary-muted);
	font-size: 0.95rem;
	line-height: 1.5;
}

.cardActions {
	display: flex;
	gap: var(--spacing-2);
	flex-wrap: wrap;
}

.cardBody {
	display: flex;
	flex-direction: column;
	gap: var(--spacing-3);
	padding-top: var(--spacing-2);
}

.secretRow {
	display: flex;
	flex-direction: column;
	gap: var(--spacing-2);
}

.secretLabel {
	font-weight: 700;
	color: var(--text-primary);
	display: flex;
	align-items: center;
	gap: var(--spacing-1);
}

.secretInputRow {
	display: flex;
	align-items: center;
	gap: var(--spacing-2);
}

.secretActions {
	display: flex;
	align-items: center;
	gap: var(--spacing-2);
	flex-wrap: wrap;
}

.fieldStack {
	display: flex;
	flex-direction: column;
	gap: var(--spacing-3);
}

.toggleRow {
	display: flex;
	align-items: flex-start;
	gap: var(--spacing-2);
}

.toggleSwitch {
	width: 100%;
}

.toggleLabel {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.toggleTitle {
	font-weight: 700;
	color: var(--text-primary);
}

.toggleDescription {
	font-size: 0.85rem;
	color: var(--text-primary-muted);
}

.redirectList {
	display: flex;
	flex-direction: column;
	gap: var(--spacing-2);
}

.redirectRow {
	display: grid;
	grid-template-columns: 1fr auto;
	gap: var(--spacing-2);
	align-items: center;
}

.redirectActions {
	display: flex;
	gap: var(--spacing-1);
	align-self: center;
	align-items: center;
	justify-content: flex-end;
}

.redirectRow[data-first='true'] .redirectActions {
	flex-direction: column;
	justify-content: center;
}

.redirectRow[data-first='true'] .redirectActions::before {
	content: '';
	display: block;
	height: 1.25rem;
	flex: 0 0 auto;
}

.redirectRemoveButton {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border: none;
	border-radius: var(--radius-md);
	background: transparent;
	color: var(--text-primary-muted);
	cursor: pointer;
	transition:
		color 0.1s ease,
		background-color 0.1s ease;
}

.redirectRemoveButton:hover:not(:disabled) {
	color: var(--text-primary);
	background: var(--background-modifier-hover);
}

.redirectRemoveButton:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

.addRedirectButton {
	align-self: flex-start;
}

.scopeGrid {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
}

.fieldLabel {
	margin: 0;
	font-weight: 500;
	font-size: 0.875rem;
	line-height: 1.25rem;
	color: var(--text-primary);
}

.scopeList {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: var(--spacing-2);
}

.botPermissionList {
	grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 1080px) {
	.botPermissionList {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 720px) {
	.botPermissionList {
		grid-template-columns: 1fr;
	}
}

.scopeItem {
	display: flex;
	align-items: center;
	gap: var(--spacing-2);
	padding: 0.35rem 0;
	min-width: 0;
}

.scopeLabel {
	display: inline-flex;
	align-items: center;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-size: 0.875rem;
	line-height: 1.25rem;
	font-weight: 500;
	color: var(--text-primary);
}

.avatarRow {
	display: flex;
	gap: var(--spacing-3);
	align-items: center;
	flex-wrap: wrap;
}

.avatarPreview {
	width: 96px;
	height: 96px;
	border-radius: var(--radius-full);
	object-fit: cover;
	border: 1px solid var(--background-modifier-accent);
	background: var(--background-tertiary);
}

.avatarPlaceholder {
	width: 96px;
	height: 96px;
	border-radius: var(--radius-full);
	display: flex;
	align-items: center;
	justify-content: center;
	background: linear-gradient(
		135deg,
		rgba(var(--brand-primary-rgb), 0.9),
		rgba(var(--brand-secondary-rgb, 95, 125, 255), 0.85)
	);
	color: white;
	font-weight: 800;
	font-size: 1.85rem;
}

.tagRow {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	column-gap: var(--spacing-2);
	row-gap: var(--spacing-2);
	align-items: end;
	width: 100%;
}

.discriminatorInput {
	width: 6rem;
	display: flex;
	align-items: center;
	align-self: end;
}

.metaRow {
	display: flex;
	flex-wrap: wrap;
	gap: var(--spacing-2);
	align-items: center;
	color: var(--text-primary-muted);
}

.validationBox {
	margin-top: -0.25rem;
}

.bannerRow {
	display: flex;
	flex-direction: column;
	gap: var(--spacing-2);
	align-items: flex-start;
}

.builderResult {
	display: flex;
	flex-direction: column;
	gap: var(--spacing-1);
}

.loadingState {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 320px;
	padding: var(--spacing-5);
}

.loadingCard,
.errorCard {
	padding: var(--spacing-4);
	border: 1px solid var(--background-modifier-accent);
	border-radius: var(--radius-xl);
	background-color: var(--background-primary);
	display: flex;
	flex-direction: column;
	gap: var(--spacing-2);
	align-items: flex-start;
	justify-content: center;
	min-height: 320px;
}

.errorState {
	width: 100%;
	min-height: 320px;
	display: flex;
	flex-direction: column;
	gap: var(--spacing-3);
	align-items: center;
	justify-content: center;
	text-align: center;
}

.statusActions {
	display: flex;
	gap: var(--spacing-2);
	flex-wrap: wrap;
	justify-content: center;
	width: 100%;
}

.spinnerRow {
	display: flex;
	align-items: center;
	gap: var(--spacing-2);
}

.errorTitle {
	margin: 0;
	font-size: 1.05rem;
	font-weight: 700;
	color: var(--text-primary);
}

.errorSubtitle {
	margin: 0;
	color: var(--text-primary-muted);
}

.errorActions {
	display: flex;
	gap: var(--spacing-2);
	flex-wrap: wrap;
}

.helperText {
	color: var(--text-primary-muted);
	font-size: 0.9rem;
}

.dangerContent {
	display: flex;
	flex-direction: column;
	gap: var(--spacing-3);
	align-items: flex-start;
	justify-content: flex-start;
}

.dangerActions {
	display: flex;
	align-items: center;
	gap: var(--spacing-2);
	align-self: flex-start;
	width: 100%;
}

.dangerActions > * {
	flex: 0 0 auto;
}

.error {
	color: var(--text-danger);
	font-size: 0.95rem;
	padding: var(--spacing-2);
	border-radius: var(--radius-lg);
	background: rgba(var(--status-danger-rgb), 0.12);
	border: 1px solid rgba(var(--status-danger-rgb), 0.35);
}

.srOnly {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	border: 0;
}
