@import "../shared.css";

body {
	display: flex;
	flex-direction: column;
	align-items: center;
	background-color: var(--colour-0);
	color: var(--text-colour-normal);
	margin: 0;
	padding: 0;
}

#settings-wrapper {
	display: flex;
	flex-direction: column;
	gap: 1rem;
	padding-block: 1rem;
	flex: 1 1 auto;
	max-width: 800px;
	width: 100%;
}

#footer {
	display: contents;
}

/* Layout */

#settings-wrapper:not(.tab-switch-1) #tab-1,
#settings-wrapper:not(.tab-switch-2) #tab-2,
#settings-wrapper:not(.tab-switch-3) #tab-3 {
	display: none;
}

.tab {
	width: 100%;
}

.grid-one-column {
	display: grid;
	gap: 1rem;
	grid-template-columns: 1fr;
}

.grid-two-columns {
	display: grid;
	gap: 1rem;
	grid-template-columns: 1fr 1fr;

	@media screen and (max-width: 450px) {
		& {
			grid-template-columns: 1fr;
		}
	}
}

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

.section {
	align-items: center;
	background-color: var(--colour-1);
	border-radius: 8px;
	display: flex;
	flex: 0 0 auto;
	flex-direction: column;
	gap: 0.5rem;
	padding: 1.25rem;
}

.section-title {
	font-weight: 600;
}

.section-text {
	color: var(--text-colour-secondary);
}

.section-subtitle {
	align-items: center;
	display: flex;
	font-size: inherit;
	font-weight: inherit;
	line-height: normal;
	margin-block: 0.25rem;
	padding: 0;
}

/* Elements */

a {
	&:link,
	&:visited {
		color: var(--link-colour-normal);
		text-decoration: none;
	}
	&:hover {
		color: var(--link-colour-hover);
		text-decoration: underline;
	}
	&:active {
		color: var(--link-colour-active);
		text-decoration: underline;
	}
}

hr {
	background-color: var(--colour-3);
	border-width: 0;
	height: 1px;
	margin: 0;
	width: 100%;
}

button {
	align-items: center;
	background-color: var(--colour-2);
	border: none;
	border-radius: 4px;
	color: var(--text-colour-normal);
	display: flex;
	height: 2rem;
	justify-content: center;
	padding: 0;
	text-align: center;
	width: 2rem;

	&:hover {
		background-color: var(--colour-3);
	}
	&:active {
		background-color: var(--colour-5);
	}
}

.text-button {
	align-items: center;
	background-color: var(--colour-2);
	border: none;
	border-radius: 4px;
	box-sizing: border-box;
	color: var(--text-colour-normal);
	display: flex;
	font-size: inherit;
	gap: 0.5rem;
	height: 2rem;
	justify-content: start;
	padding: 0 0.5rem;
	text-align: start;
	width: 100%;

	&:hover {
		background-color: var(--colour-3);
	}
	&:active {
		background-color: var(--colour-5);
	}
}

select {
	background-color: var(--colour-2);
	border: none;
	border-radius: 4px;
	color: var(--text-colour-normal);
	display: flex;
	height: 2rem;
	padding-inline: 0.5rem 0;
	vertical-align: middle;
	width: max-content;

	&:hover {
		background-color: var(--colour-3);
	}
	&:active {
		background-color: var(--colour-5);
	}
}

input[type="color"] {
	display: none;
}

input[type="text"] {
	background-color: var(--colour-2);
	border: none;
	border-radius: 4px;
	box-sizing: border-box;
	color: inherit;
	display: inline-block;
	font-family: monospace;
	height: 2rem;
	line-height: 100%;
	outline: none;
	outline-offset: -1px;
	padding-inline: 0.5rem;
	vertical-align: middle;
	width: 100%;

	&:hover {
		background-color: var(--colour-3);
	}

	&:focus-visible {
		background-color: transparent;
		outline: solid 1px var(--colour-3);
	}
}

input[type="checkbox"] {
	accent-color: var(--accent-colour);
}

input[type="radio"] {
	accent-color: var(--accent-colour);
	margin: 0;
}

/* Slider */

.slider {
	display: flex;
	flex-direction: row;
	gap: 0.5rem;
	margin-block-start: 0.5rem;
}

.slider-title {
	color: var(--text-colour-secondary);
	font-size: 80%;
	text-align: center;
}

.slider-body {
	align-items: center;
	background-color: var(--colour-2);
	background-image: linear-gradient(to right, var(--transparent-0), var(--transparent-0) 50%, var(--colour-2) 50%);
	background-position-x: var(--slider-position, 100%);
	background-size: 200% 100%;
	border-radius: 4px;
	display: flex;
	height: 2rem;
	justify-content: center;
	line-height: 2rem;
	text-align: center;
	transition: background-position-x 0.1s ease-in;
	width: 10rem;

	&.percentage::after {
		content: "%";
		margin-inline-start: 0.5rem;
	}
}

/* Toggle */
/* To-do: use a light switch instead of a simple checkbox */

.checkbox-wrapper {
	display: flex;
	gap: 1rem;
	width: 100%;
}

/* Colour input */

.colour-input-wrapper {
	position: relative;
}

.colour-picker-display {
	border-radius: 50%;
	cursor: pointer;
	height: 1rem;
	left: 0.5rem;
	outline: solid 1px var(--colour-5);
	position: absolute;
	top: 0.5rem;
	width: 1rem;
}

input[type="text"].colour-input {
	padding-left: 2rem;
}

/* Toggle switch */

.toggle-switch-wrapper {
	background-color: var(--colour-2);
	border-radius: 4px;
	display: grid;
	grid-auto-columns: minmax(0, 1fr);
	grid-auto-flow: column;
	height: 2rem;
	overflow: hidden;
	width: 100%;

	label.toggle-switch {
		align-items: center;
		display: flex;
		justify-content: center;

		&:hover {
			background-color: var(--colour-3);
		}
		&:active {
			background-color: var(--colour-5);
		}
	}

	input.toggle-switch {
		display: none;

		&:checked + label.toggle-switch {
			background-color: var(--colour-4);
			color: var(--link-colour-normal);

			&:hover {
				background-color: var(--colour-5);
			}
		}
	}
}

/* Tab switch */

.tab-switch-wrapper {
	&.toggle-switch-wrapper {
		background-color: var(--colour-1);
		height: auto;
	}

	label.toggle-switch {
		font-weight: 600;
		padding: 0.5rem 2rem;

		&:hover {
			background-color: var(--colour-2);
		}
		&:active {
			background-color: var(--colour-4);
		}
	}

	input.toggle-switch {
		&:checked + label.toggle-switch {
			background-color: var(--colour-3);
			color: var(--link-colour-normal);

			&:hover {
				background-color: var(--colour-4);
			}
		}
	}
}

/* Fixed elements */

p#reinstall-tip {
	width: 50%;
}

#add-new-rule {
	background-color: var(--colour-1);
	border-radius: 6px;
	height: 3rem;
	width: 100%;

	&:hover {
		background-color: var(--colour-2);
	}
	&:active {
		background-color: var(--colour-4);
	}
}

#sponsor {
	display: flex;
	gap: 0.5rem;
	filter: saturate(0) brightness(1.1);

	@media (prefers-color-scheme: dark) {
		& {
			filter: sepia(1) hue-rotate(218deg) saturate(0.5) brightness(0.7);
		}
	}
}

/* List */

.list {
	display: flex;
	flex-direction: column;

	.section {
		border-radius: 0;
		display: grid;
		gap: 0.5rem;
		grid-template-columns: auto max-content 10rem max-content;
		padding: 0.5rem;

		&:nth-of-type(even) {
			background-color: var(--colour-1-5);
		}
	}

	:is(.section:first-of-type) {
		border-top-left-radius: 6px;
		border-top-right-radius: 6px;
	}

	:is(.section:last-of-type) {
		border-bottom-left-radius: 6px;
		border-bottom-right-radius: 6px;
	}
}

#tab-2:not(:has(.policy)) {
	gap: 0;
}

#tab-3 .list .section {
	grid-template-columns: auto max-content 7.5rem;
}

.policy-header {
	margin-inline: 0.5rem auto;
	max-width: 100%;
}

.policy .policy-header {
	max-width: 60%;
}

.policy-header-input-wrapper {
	align-items: center;
	display: flex;
	position: relative;
}

.policy-header-warning {
	display: none;
	height: 1rem;
	position: absolute;
	right: 0.5rem;
	top: 0.25rem;
	width: 1rem;
}

.policy.warning {
	.policy-header-input {
		padding-inline-end: 2rem;
	}
	.policy-header-warning {
		cursor: help;
		display: block;
	}
}

select {
	~ .colour-input-wrapper,
	~ .toggle-switch-wrapper,
	~ .qs-input-wrapper {
		display: none;
	}

	&.COLOUR ~ .colour-input-wrapper,
	&.THEME_COLOUR ~ .toggle-switch-wrapper,
	&.QUERY_SELECTOR ~ .qs-input-wrapper {
		display: grid;
	}
}
