/* Reset and base styles */
* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

body {
	font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
	background: linear-gradient(135deg, #1e1e2e 0%, #2d2d42 100%);
	color: #e0e0e0;
	min-height: 100vh;
	line-height: 1.2;
}

.container {
	max-width: 1400px;
	margin: 0 auto;
	padding: 20px;
}

/* Header */
.header {
	grid-area: t;
	text-align: center;
	padding: 20px;
	background: rgba(255, 255, 255, 0.05);
	border-radius: 12px;
	border: 1px solid rgba(255, 255, 255, 0.1);
}

.header h1 {
	font-size: 2.5rem;
	font-weight: bold;
	margin-bottom: 10px;
	background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #06b6d4 100%);
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	background-clip: text;
}

.header p {
	font-size: 1.1rem;
	color: #a0a0a0;
}

/* Main content layout */
.main-content {
	display: grid;
	grid-template-areas:
		"t t"
		"l r"
		"b b";
	grid-template-columns: 1fr 1fr;
	gap: 20px;
	width: 100%;
	height: 100%;
}

.left {
	grid-area: l;
}

.right {
	grid-area: r;
}

.stack {
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 20px;
}

@media (max-width: 1024px) {
	.main-content {
		grid-template-columns: 1fr;
	}
}

/* Panel styles */
.panel {
	background: rgba(255, 255, 255, 0.05);
	border-radius: 12px;
	padding: 25px;
	border: 1px solid rgba(255, 255, 255, 0.1);
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.panel h2 {
	font-size: 1.5rem;
	margin-bottom: 20px;
	display: flex;
	align-items: center;
	gap: 10px;
	color: #ffffff;
}

/* Status indicator */
.status-indicator {
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: #ef4444;
	display: inline-block;
	transition: background-color 0.3s ease;
}

.status-indicator.connected {
	background: #22c55e;
	box-shadow: 0 0 10px rgba(34, 197, 94, 0.5);
}

.status-container {
	display: flex;
	flex-direction: column;
	gap: 15px;
	margin-bottom: 5px;
}

/* SwiCC Connection styles */
.swicc-connection {
	background: rgba(255, 255, 255, 0.03);
	border-radius: 8px;
	padding: 20px;
	margin-bottom: 15px;
	border: 1px solid rgba(255, 255, 255, 0.05);
	transition: all 0.3s ease;
}

.swicc-connection:hover {
	background: rgba(255, 255, 255, 0.05);
	border-color: rgba(255, 255, 255, 0.1);
}

.swicc-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 15px;
}

.swicc-header h3 {
	font-size: 1.2rem;
	color: #ffffff;
}

.connection-status {
	padding: 4px 12px;
	border-radius: 20px;
	font-size: 0.85rem;
	font-weight: 500;
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

.connection-status.connected {
	background: rgba(34, 197, 94, 0.2);
	color: #22c55e;
	border: 1px solid rgba(34, 197, 94, 0.3);
}

.connection-status.disconnected {
	background: rgba(239, 68, 68, 0.2);
	color: #ef4444;
	border: 1px solid rgba(239, 68, 68, 0.3);
}

.swicc-controls {
	display: flex;
	gap: 10px;
}

.add-more-section {
	text-align: center;
	margin: 20px 0;
}

.additional-swiccs {
	animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
	from {
		opacity: 0;
		transform: translateY(-20px);
	}

	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* Status grid */
.status-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 15px;
	margin: 20px 0;
}

.status-item {
	background: rgba(255, 255, 255, 0.03);
	padding: 5px;
	border-radius: 8px;
	text-align: center;
	border: 1px solid rgba(255, 255, 255, 0.05);
}

.status-item label {
	display: block;
	font-size: 0.9rem;
	color: #a0a0a0;
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

.status-item .value {
	font-size: 1.2rem;
	font-weight: bold;
	color: #ffffff;
}

/* Gamepad status */
#gamepadName {
	font-size: 1.1rem;
	color: #a0a0a0;
	margin-bottom: 20px;
	padding: 10px;
	background: rgba(255, 255, 255, 0.03);
	border-radius: 6px;
	border: 1px solid rgba(255, 255, 255, 0.05);
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.gamepad-status {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 20px;
	margin-top: 20px;
}

@media (max-width: 768px) {
	.gamepad-status {
		grid-template-columns: 1fr;
	}
}

.button-feedback-grid {
	display: grid;
	grid-template-columns: repeat(8, 1fr);
	gap: 6px;
	max-width: 18rem;
}

.gamepad-buttons h4,
.gamepad-sticks h4 {
	color: #ffffff;
	margin-bottom: 15px;
	font-size: 1.1rem;
}

.button-indicator {
	aspect-ratio: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(255, 255, 255, 0.1);
	border-radius: 8px;
	font-weight: bold;
	font-size: 0.7rem;
	transition: all 0.2s ease;
	border: 2px solid transparent;
}

.button-indicator.pressed {
	background: linear-gradient(135deg, #6366f1, #8b5cf6);
	color: #ffffff;
	border-color: rgba(255, 255, 255, 0.3);
	box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
	transform: scale(0.95);
}

/* Stick display */
.stick-display {
	background: rgba(255, 255, 255, 0.03);
	padding: 8px 15px;
	border-radius: 8px;
	border: 1px solid rgba(255, 255, 255, 0.05);
}

.stick-values {
	margin-bottom: 10px;
	font-family: 'Courier New', monospace;
	color: #a0a0a0;
}

.stick-values:last-child {
	margin-bottom: 0;
}

/* Configuration Panel Styles */
.config-section {
	margin-bottom: 20px;
	padding-bottom: 15px;
	border-bottom: 1px solid #eee;
}

.config-section:last-child {
	border-bottom: none;
}

.config-section h3 {
	margin: 0 0 10px 0;
	font-size: 14px;
	color: #666;
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

.preset-controls,
.save-controls,
.load-controls,
.import-export-controls {
	display: flex;
	gap: 10px;
	align-items: center;
	flex-wrap: wrap;
}

.preset-controls select,
.load-controls select,
.save-controls input {
	flex: 1;
	min-width: 200px;
	padding: 8px;
	border: 1px solid #ddd;
	border-radius: 4px;
	font-size: 13px;
}

.config-status {
	margin-top: 15px;
	padding: 10px;
	border-radius: 4px;
	font-size: 12px;
	display: none;
}

.config-status.success {
	background: #d4edda;
	border: 1px solid #c3e6cb;
	color: #155724;
	display: block;
}

.config-status.error {
	background: #f8d7da;
	border: 1px solid #f5c6cb;
	color: #721c24;
	display: block;
}

.config-status.info {
	background: #d1ecf1;
	border: 1px solid #bee5eb;
	color: #0c5460;
	display: block;
}

/* Collapsible Configuration Panel Styles */
.config-header {
	display: flex;
	align-items: center;
	cursor: pointer;
	user-select: none;
	padding: 15px;
	margin: -15px;
}

.config-header h2 {
	margin: 0;
	flex: 1;
}

.config-toggle {
	background: none;
	color: white;
	border: none;
	font-size: 24px;
	cursor: pointer;
	padding: 0;
	margin-left: 10px;
	transition: transform 0.2s ease;
}

.config-toggle.expanded {
	transform: rotate(90deg);
}

.config-content {
	overflow: hidden;
	transition: max-height 0.3s ease;
}

.config-content.collapsed {
	max-height: 0;
}

.config-content.expanded {
	max-height: 1000px;
	/* Adjust based on your content needs */
}

.config-content-inner {
	padding-top: 20px;
}

.function-enables {
	display: flex;
	gap: 10px;
	margin-bottom: 5px;
	margin-top: 5px;
}

/* Button styles */
.button {
	background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
	color: #fffffff0;
	padding: 10px 20px;
	border-radius: 8px;
	cursor: pointer;
	font-weight: 500;
	transition: all 0.3s ease;
	font-size: 0.9rem;
	border: 1px solid rgba(255, 255, 255, 0.1);
	margin-top: 1px;
	letter-spacing: 0.4px;
}

.button:hover:not(:disabled) {
	background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
	box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.button:active {
	transform: translateY(0);
}

.button:disabled {
	background: rgba(255, 255, 255, 0.1);
	color: #0008;
	cursor: not-allowed;
	transform: none;
	box-shadow: none;
}

.button.danger {
	background: linear-gradient(135deg, #ad2323 0%, #a11f1f 100%);
}

.button.danger:hover:not(:disabled) {
	background: linear-gradient(135deg, #c32a2a 0%, #b42222 100%);
	box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.button.secondary {
	background: linear-gradient(135deg, #64748b 0%, #78716c 100%);
}

.button.secondary:hover:not(:disabled) {
	background: linear-gradient(135deg, #78716c 0%, #8b5a52 100%);
	box-shadow: 0 4px 15px rgba(120, 113, 108, 0.3);
}

.button.small {
	padding: 3px 10px;
	font-size: 0.8rem;
}

/* Pipeline styles */
.info-box {
	background: rgba(59, 130, 246, 0.1);
	padding: 15px;
	border-radius: 8px;
	margin-bottom: 20px;
	border: 1px solid rgba(59, 130, 246, 0.2);
}

.info-box p {
	color: #93c5fd;
	margin: 0;
}

.pipeline-container {
	min-height: 100px;
	border: 2px solid #00000047;
	box-shadow: inset 0 0 5px #ffffff0f;
	border-radius: 8px;
	padding: 12px 10px;
	margin: 18px -12px;
	background: rgba(0, 0, 0, 0.04);
}

.pipeline-container:not(:has(> :nth-child(3)))::before {
	content: "No manipulators in pipeline. Add some using the buttons above.";
	color: #666;
	font-style: italic;
	display: block;
	text-align: center;
	padding: 20px;
}

/* Controller Display Controls */
.broadcast-actions {
	display: flex;
	gap: 10px;
}

.snapshot-controls {
	margin: 20px 0;
}

.snapshot-indicator {
	display: flex;
	align-items: center;
	justify-content: center;
	margin: 8px 0;
	padding: 8px 12px;
	border-radius: 8px;
	position: relative;
	transition: all 0.3s ease;
	min-height: 40px;
}

.snapshot-label {
	display: flex;
	justify-content: center;
	align-items: center;
	height: 30px;
	background-color: #6c757d;
	padding: 3px 10px;
	border-radius: 10px;
}

.snapshot-line {
	position: absolute;
	left: 0;
	right: 0;
	top: 50%;
	height: 2px;
	background: currentColor;
	opacity: 0.3;
	z-index: -1;
}

.inline-with-gap {
	display: flex;
	flex-wrap: wrap;
	gap: 5px;
	align-items: center;
}

/* Manipulator wrapper */
.manipulator-wrapper {
	background: rgba(255, 255, 255, 0.05);
	border-radius: 8px;
	padding: 20px;
	margin-bottom: 15px;
	border: 1px solid rgba(255, 255, 255, 0.1);
	position: relative;
	transition: all 0.3s ease;
}

.manipulator-control-group {
	margin: 0;
	padding: 0;
}

.manipulator-control-group-horizontal {
	margin: 0;
	padding: 0;
	display: flex;
	justify-content: space-between;
}

.manipulator-wrapper:hover {
	background: rgba(255, 255, 255, 0.07);
	border-color: rgba(255, 255, 255, 0.15);
	box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.manipulator-wrapper h3 {
	color: #ffffff;
	margin-bottom: 15px;
	font-size: 1.1rem;
}

.manipulator-controls {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin-top: 15px;
	padding-top: 15px;
	border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.manipulator-footer {
	display: flex;
	flex-direction: row;
	gap: 15px;
	margin-top: 15px;
	padding-top: 15px;
	border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.manipulator-footer * {
	flex-grow: 1;
}

.manipulator-wrapper label {
	display: block;
	color: #e0e0e0;
	margin-bottom: 5px;
	font-weight: 500;
}

.manipulator-wrapper input[type="checkbox"] {
	appearance: none;
	width: 18px;
	height: 18px;
	border: 2px solid rgba(255, 255, 255, 0.3);
	border-radius: 4px;
	background: rgba(255, 255, 255, 0.1);
	cursor: pointer;
	position: relative;
	margin-right: 8px;
	transition: all 0.3s ease;
}

.manipulator-wrapper input[type="checkbox"]:checked {
	background: linear-gradient(135deg, #6366f1, #8b5cf6);
	border-color: #6366f1;
}

.manipulator-wrapper input[type="checkbox"]:checked::after {
	content: '✓';
	position: absolute;
	top: -2px;
	left: 2px;
	color: white;
	font-size: 12px;
	font-weight: bold;
}

select,
::picker(select) {
	appearance: base-select;
}

select {
	background: rgba(255, 255, 255, 0.1);
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 6px;
	padding: 8px 12px;
	color: #ffffff;
	cursor: pointer;
	min-width: 120px;
	line-height: 1.4;
}

option {
	background-color: #2d2d42;
	color: white;
}

option:hover {
	background: #5a53da;
	color: white;
}

option:focus {
	background-color: #4f46e5;
	color: white;
}

select:focus {
	outline: none;
	border-color: #6366f1;
	box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

input[type="number"],
input[type="text"] {
	background: rgba(255, 255, 255, 0.1);
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 6px;
	padding: 8px 12px;
	color: #ffffff;
	min-width: 100px;
}

input[type="number"]:focus,
input[type="text"]:focus {
	outline: none;
	border-color: #6366f1;
	box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.manipulator-wrapper .form-row {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-bottom: 10px;
}

.manipulator-wrapper .form-group {
	margin-bottom: 15px;
}

/* Messages panel */
.messages {
	grid-area: b;
	background: rgba(255, 255, 255, 0.05);
	border-radius: 12px;
	padding: 25px;
	border: 1px solid rgba(255, 255, 255, 0.1);
	max-height: 300px;
	margin-top: 20px;
}

.messages h3 {
	color: #ffffff;
	margin-bottom: 15px;
	font-size: 1.2rem;
}

#messageLog {
	background: rgba(0, 0, 0, 0.3);
	border-radius: 8px;
	padding: 15px;
	height: 200px;
	overflow-y: auto;
	font-family: 'Courier New', monospace;
	font-size: 0.85rem;
	border: 1px solid rgba(255, 255, 255, 0.05);
}

.message {
	margin-bottom: 8px;
	line-height: 1.4;
	color: #e0e0e0;
}

.message .timestamp {
	color: #6b7280;
	margin-right: 8px;
}

/* Scrollbar styling */
#messageLog::-webkit-scrollbar {
	width: 8px;
}

#messageLog::-webkit-scrollbar-track {
	background: rgba(255, 255, 255, 0.05);
	border-radius: 4px;
}

#messageLog::-webkit-scrollbar-thumb {
	background: rgba(255, 255, 255, 0.2);
	border-radius: 4px;
}

#messageLog::-webkit-scrollbar-thumb:hover {
	background: rgba(255, 255, 255, 0.3);
}

/* Responsive design */
@media (max-width: 1020px) {
	.container {
		padding: 15px;
		max-width: 100vw;
	}

	.main-content {
		grid-template-areas:
			"t"
			"l"
			"r"
			"b";
		grid-template-columns: 1fr;
	}

	.header h1 {
		font-size: 2rem;
	}

	.panel {
		padding: 20px;
	}

	.swicc-controls {
		flex-direction: column;
	}

	.pipeline-controls {
		flex-direction: column;
	}

	.manipulator-controls {
		flex-wrap: wrap;
	}

	.status-grid {
		grid-template-columns: 1fr;
	}
}

/* Animation utilities */
@keyframes pulse {

	0%,
	100% {
		opacity: 1;
	}

	50% {
		opacity: 0.5;
	}
}

.pulse {
	animation: pulse 2s infinite;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
	.panel {
		border: 2px solid #ffffff;
	}

	.button {
		border: 2px solid #ffffff;
	}

	.status-indicator.connected {
		background: #00ff00;
	}

	.status-indicator {
		background: #ff0000;
	}
}

/* Pipeline Controls Header */
.pipeline-controls-header {
	display: flex;
	gap: 10px;
	margin-bottom: 15px;
	align-items: center;
}

/* Collapsible Pipeline Controls */
.pipeline-controls {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
	gap: 10px;
	background-color: #00000000;
	margin-bottom: 20px;
	transition: all 0.3s ease;
}

/* Toggle button styling */
#toggleControlsBtn {
	display: flex;
	align-items: center;
	gap: 5px;
}

#toggleControlsIcon {
	transition: transform 0.2s ease;
	display: inline-block;
}

/* Hide controls when collapsed */
.pipeline-controls[style*="display: none"] {
	display: none !important;
}

/* Add visual feedback for the collapsible section */
.pipeline-controls-header button.secondary {
	background-color: #6c757d;
	color: white;
}

.pipeline-controls-header button.secondary:hover {
	background-color: #5a6268;
}

/* Style for when there are many manipulator types */
.pipeline-controls.expanded {
	max-height: 300px;
	overflow-y: auto;
}

/* Ensure manipulator buttons have consistent sizing */
.pipeline-controls .button {
	width: 100%;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}



.manipulator-wrapper label {
	display: block;
	color: #e0e0e0;
	margin-bottom: 5px;
	font-weight: 500;
}

.manipulator-wrapper input[type="checkbox"] {
	appearance: none;
	width: 18px;
	height: 18px;
	border: 2px solid rgba(255, 255, 255, 0.3);
	border-radius: 4px;
	background: rgba(255, 255, 255, 0.1);
	cursor: pointer;
	position: relative;
	margin-right: 8px;
	transition: all 0.3s ease;
}

.manipulator-wrapper input[type="checkbox"]:checked {
	background: linear-gradient(135deg, #6366f1, #8b5cf6);
	border-color: #6366f1;
}

.manipulator-wrapper input[type="checkbox"]:checked::after {
	content: '✓';
	position: absolute;
	top: -2px;
	left: 2px;
	color: white;
	font-size: 12px;
	font-weight: bold;
}

.manipulator-wrapper input[type="checkbox"].manipulator-enable {
	width: 46px;
	height: 24px;
	border-radius: 12px;
	position: relative;
	margin-right: 12px;
}

.manipulator-wrapper input[type="checkbox"].manipulator-enable::before {
	content: '';
	position: absolute;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	top: 1px;
	left: 2px;
	background: #666;
	transition: all 0.3s ease;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.manipulator-wrapper input[type="checkbox"].manipulator-enable:checked::before {
	transform: translateX(20px);
	background: white;
}

.manipulator-wrapper input[type="checkbox"].manipulator-enable::after {
	position: absolute;
	right: 6px;
	top: 4px;
	font-size: 10px;
	color: #666;
	font-weight: bold;
	transition: all 0.3s ease;
}

.manipulator-wrapper input[type="checkbox"].manipulator-enable:checked::after {
	content: 'ON';
	right: auto;
	left: 3px;
	color: white;
}

/* Visual feedback for disabled manipulator */
.manipulator-wrapper:has(input[type="checkbox"].manipulator-enable:not(:checked)) {
	opacity: 0.6;
	background: rgba(255, 255, 255, 0.02);
}

.manipulator-wrapper:has(input[type="checkbox"].manipulator-enable:not(:checked)) h3::after {
	content: ' (Disabled)';
	color: #ef4444;
	font-size: 0.85rem;
	font-weight: normal;
	margin-left: 8px;
}

/* Label styling for enable/disable checkboxes */
.manipulator-wrapper label:has(+ input[type="checkbox"].manipulator-enable),
.manipulator-wrapper label:has(input[type="checkbox"].manipulator-enable) {
	font-weight: 600;
	color: #ffffff;
	display: inline-flex;
	align-items: center;
	cursor: pointer;
	user-select: none;
}

.manipulator-wrapper label:has(+ input[type="checkbox"].manipulator-enable):hover,
.manipulator-wrapper label:has(input[type="checkbox"].manipulator-enable):hover {
	color: #6366f1;
}