@use 'variables' as *;

$ss-settings-border:     #E8E8EB;
$ss-settings-text:       #212226;
$ss-settings-text-muted: #4F4F4F;
$ss-settings-bg:         #FFFFFF;
$ss-pill-connected:      #27AE60;
$ss-pill-checking:       #F4B400;
$ss-pill-error:          #D32F2F;
$ss-toggle-off:          #D5D7DB;

.simplestats-settings {
	max-width: 1280px;
	margin: 0 auto;
}

.simplestats-settings-title {
	margin: 0 0 24px 0;
	font-size: 24px;
	font-weight: 700;
	line-height: 32px;
	color: $ss-settings-text;
}

.simplestats-settings-card {
	background-color: $ss-settings-bg;
	border: 1px solid $ss-settings-border;
	border-radius: 8px;
	margin-bottom: 24px;
}

.simplestats-settings-card-header {
	padding: 20px 24px;
	border-bottom: 1px solid $ss-settings-border;

	h2 {
		margin: 0;
		font-size: 20px;
		font-weight: 700;
		line-height: 28px;
		color: $ss-settings-text;
	}
}

.simplestats-settings-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 24px;
	gap: 12px;

	& + & {
		border-top: 1px solid $ss-settings-border;
	}

	&--stacked {
		flex-direction: column;
		align-items: flex-start;
		gap: 8px;
	}

	&--account {
		border-top: 1px solid $ss-settings-border;
	}
}

.simplestats-settings-row-label {
	font-size: 14px;
	font-weight: 600;
	color: $ss-settings-text;
}

.simplestats-settings-row-description {
	margin: 0;
	font-size: 14px;
	color: $ss-settings-text-muted;
}

.simplestats-settings-row-value {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	color: $ss-settings-text;
	font-size: 14px;
}

.simplestats-pill {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 4px 12px;
	border-radius: 999px;
	font-size: 14px;
	font-weight: 600;
	line-height: 20px;

	.simplestats-pill-dot {
		width: 7px;
		height: 7px;
		border-radius: 50%;
		display: inline-block;
	}

	&.is-connected {
		background-color: rgba(39, 174, 96, 0.12);
		color: $ss-pill-connected;

		.simplestats-pill-dot { background-color: $ss-pill-connected; }
	}

	&.is-checking {
		background-color: rgba(244, 180, 0, 0.14);
		color: #8A6D00;

		.simplestats-pill-dot { background-color: $ss-pill-checking; }
	}

	&.is-error {
		background-color: rgba(211, 47, 47, 0.10);
		color: $ss-pill-error;

		.simplestats-pill-dot { background-color: $ss-pill-error; }
	}
}

// Brand citron primary button (per simplestats-citron-brand-guidelines .btn-primary):
// brand/300 #FFE57D fill, neutral/900 text.
.simplestats-settings-primary-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 8px 16px;
	background-color: #FFE57D;                // brand/300
	color: #18191D;                           // neutral/900
	border: 0;
	border-radius: 2px;                       // button/radius
	font-size: 14px;
	font-weight: 600;
	line-height: 20px;
	cursor: pointer;
	text-decoration: none;

	// WP admin button styles can swap the bg/color on hover/focus —
	// pin the brand colors across all interactive states.
	&:hover,
	&:focus,
	&:focus-visible,
	&:active {
		background-color: #FFE57D;
		color: #18191D;
	}

	// WP admin styles `a:focus` (and form controls) with outline / box-shadow /
	// border-radius — pin these so the branded button shape stays put on focus.
	&:focus,
	&:focus-visible {
		outline: none;
		box-shadow: none;
		border-radius: 2px;
	}

	&:disabled {
		opacity: 0.6;
		cursor: not-allowed;
	}
}

.simplestats-settings-secondary-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 6px 14px;
	background-color: #fff;
	color: $ss-pill-error;
	border: 1px solid $ss-pill-error;
	border-radius: 2px;
	font-size: 14px;
	font-weight: 600;
	line-height: 20px;
	cursor: pointer;

	&:focus,
	&:focus-visible {
		outline: none;
		box-shadow: none;
		border-radius: 2px;
	}

	&:disabled {
		opacity: 0.6;
		cursor: not-allowed;
	}
}

.simplestats-settings-toggles {
	display: flex;
	flex-direction: column;
}

.simplestats-settings-save-row {
	display: flex;
	align-items: center;
	gap: 16px;
	padding: 16px 24px;
	border-top: 1px solid $ss-settings-border;
	flex-wrap: wrap;
}

.simplestats-settings-save-feedback {
	font-size: 14px;
	font-weight: 600;

	&.is-success { color: $ss-pill-connected; }
	&.is-error { color: $ss-pill-error; }
}

.simplestats-settings-save-note {
	font-size: 14px;
	color: $ss-settings-text-muted;
}

/* Toggle primitive */
.ss-toggle-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 20px 24px;
	gap: 16px;
	cursor: pointer;

	& + & {
		border-top: 1px solid $ss-settings-border;
	}
}

.ss-toggle-text {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.ss-toggle-label {
	font-size: 14px;
	font-weight: 600;
	color: $ss-settings-text;
}

.ss-toggle-desc {
	font-size: 14px;
	color: $ss-settings-text-muted;
}

.ss-toggle-control {
	position: relative;
	display: inline-block;
	flex-shrink: 0;
}

.ss-toggle-input {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
	margin: 0;
}

.ss-toggle-track {
	display: inline-block;
	width: 40px;
	height: 20px;
	border-radius: 999px;
	background-color: $ss-toggle-off;
	position: relative;
	transition: background-color 0.18s ease;
}

.ss-toggle-thumb {
	position: absolute;
	top: 2px;
	left: 2px;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background-color: #fff;
	transition: transform 0.18s ease;
}

.ss-toggle-input:checked + .ss-toggle-track {
	background-color: $primary-button-bg;

	.ss-toggle-thumb {
		transform: translateX(20px);
	}
}

.ss-toggle-input:focus-visible + .ss-toggle-track {
	box-shadow: 0 0 0 3px rgba(33, 34, 38, 0.25);
}
