/* -------------------------------------------------------------------------- */
/*                              Action Table CSS                              */
/* -------------------------------------------------------------------------- */

action-table {
	display: block;
	--highlight: paleturquoise;
	--focus: dodgerblue;
	--star-checked: orange;
	--star-unchecked: gray;
	--switch-checked: green;
	--switch-unchecked: lightgray;
	--border: 1px solid lightgray;
	--border-radius: 0.2em;
	--th-bg: whitesmoke;
	--th-sorted: rgb(244, 220, 188);
	--col-sorted: rgb(255, 253, 240);
	--td-options-bg: whitesmoke;
	--page-btn: whitesmoke;
	--page-btn-active: rgb(244, 220, 188);
	--responsive-scroll-gradient: linear-gradient(to right, #fff 30%, rgba(255, 255, 255, 0)), linear-gradient(to right, rgba(255, 255, 255, 0), #fff 70%) 0 100%,
		radial-gradient(farthest-side at 0% 50%, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0)), radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0)) 0 100%;
}

action-table :where(table) {
	border-collapse: collapse;
	margin: 1em 0;
	max-width: 100%;
	overflow: auto;
	display: block;
	/* Responsive scroll shadow gradient. Code from https://adrianroselli.com/2020/11/under-engineered-responsive-tables.html */
	background: var(--responsive-scroll-gradient);
	background-repeat: no-repeat;
	background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
	background-position: 0 0, 100%, 0 0, 100%;
	background-attachment: local, local, scroll, scroll;
}

action-table :where(th) {
	border: var(--border);
	padding: 0;
	text-align: left;
	background: var(--th-bg);
}

action-table :where(th[no-sort]) {
	padding: 0.2em 0.5em 0.2em 0.5em;
}

action-table :where(th button) {
	cursor: pointer;
	font-weight: bold;
	border: 0;
	width: 100%;
	height: 100%;
	display: block;
	padding: 0.2em 1.5em 0.2em 0.5em;
	background-color: transparent;
	position: relative;
	text-align: left;
	font-size: inherit;
	line-height: inherit;
}

action-table :where(th button:hover, th:has(button):hover, th button:focus, th:has(button):focus) {
	background-color: var(--highlight);
}

action-table :where(th button)::after {
	content: "";
	background-image: url("data:image/svg+xml,%3Csvg version='1.1' xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Cpath d='M9 16.172l-6.071-6.071-1.414 1.414 8.485 8.485 8.485-8.485-1.414-1.414-6.071 6.071v-16.172h-2z'%3E%3C/path%3E%3C/svg%3E%0A");
	background-repeat: no-repeat;
	background-position: center right;
	background-size: 0.7em;
	height: 0.7em;
	width: 0.7em;
	display: block;
	opacity: 0.2;
	position: absolute;
	right: 0.4em;
	top: 50%;
	transform: translateY(-50%);
	float: right;
	transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out;
}

action-table :where(th[aria-sort$="ing"] button, th[aria-sort$="ing"]:has(button)) {
	background-color: var(--th-sorted);
}

action-table :where(th[aria-sort$="ing"] button)::after {
	opacity: 1;
}

action-table :where(th[aria-sort="descending"] button)::after {
	opacity: 1;
	transform: translateY(-50%) rotate(180deg);
}

action-table :where(td) {
	border: var(--border);
	padding: 0.2em 0.4em;
}

action-table .sorted {
	background-color: var(--col-sorted);
}

/* Use spans for multiple values in cell */
action-table :where(td span) {
	background-color: var(--td-options-bg);
	padding: 0 0.4em 0.1em 0.4em;
	margin: 0 0.2em;
}

/* Hide custom elements by default as they only work with js loaded */
action-table:not(:defined),
action-table-filters:not(:defined) {
	visibility: hidden;
}

action-table :where(select, input, button) {
	font-size: inherit;
}
action-table :where(input[type="search"], select) {
	border: var(--border);
	border-radius: var(--border-radius);
}
action-table .selected {
	background-color: var(--highlight);
	transition: color 0.2s ease;
}

action-table .no-results :where(td) {
	padding: 1em;
	text-align: center;
}
action-table :where(button) {
	cursor: pointer;
}

/* -------------------------------------------------------------------------- */
/*                            Action Table Filters                            */
/* -------------------------------------------------------------------------- */

/* -------------------------------------------------------------------------- */
/*                        Action Table Filter Elements                        */
/* -------------------------------------------------------------------------- */

action-table-filter-menu,
action-table-filter-switch label,
action-table-filter-menu .filter-label {
	display: inline-flex;
	flex-wrap: wrap;
	align-items: center;
}
action-table-filter-menu label,
action-table-filter-menu .filter-label {
	margin-inline-end: 0.3em;
}

/* -------------------------------------------------------------------------- */
/*                                Switch Toggle                               */
/* -------------------------------------------------------------------------- */

action-table .switch label {
	display: inline-flex;
	align-items: center;
	margin: 0;
}
action-table .switch input {
	appearance: none;
	position: relative;
	display: inline-block;
	background: var(--switch-unchecked);
	cursor: pointer;
	height: 1.4em;
	width: 2.75em;
	vertical-align: middle;
	border-radius: 2em;
	box-shadow: 0px 1px 3px #0003 inset;
	transition: 0.25s linear background;
}
action-table .switch input::before {
	content: "";
	display: block;
	width: 1em;
	height: 1em;
	background: #fff;
	border-radius: 1em;
	position: absolute;
	top: 0.2em;
	left: 0.2em;
	box-shadow: 0px 1px 3px #0003;
	transition: 0.25s linear transform;
	transform: translateX(0em);
}
action-table .switch :checked {
	background: var(--switch-checked);
}
action-table .switch :checked::before {
	transform: translateX(1.3em);
}
action-table .switch input:focus,
action-table .star input:focus {
	outline: transparent;
}
action-table .switch input:focus-visible,
action-table .star input:focus-visible {
	outline: 2px solid var(--focus);
	outline-offset: 2px;
}

/* -------------------------------------------------------------------------- */
/*                             Star Switch Toggle                             */
/* -------------------------------------------------------------------------- */

action-table .star input {
	appearance: none;
	position: relative;
	cursor: pointer;
	height: 1.6em;
	width: 1.6em;
	vertical-align: middle;
	border-radius: 0.3em;
}
action-table .star input::before {
	content: "";
	background: var(--star-unchecked);
	cursor: pointer;
	position: absolute;
	height: 1.6em;
	width: 1.6em;
	vertical-align: middle;
	transition: 0.25s linear background;
	clip-path: polygon(50% 0%, 62% 29%, 98% 35%, 74% 58%, 79% 91%, 50% 76%, 21% 91%, 26% 58%, 2% 35%, 34% 29%);
}

action-table .star input:checked::before {
	background: var(--star-checked);
}

/* -------------------------------------------------------------------------- */
/*                           Action Table Pagination                          */
/* -------------------------------------------------------------------------- */

action-table-pagination {
	display: flex;
	justify-content: start;
	align-items: center;
	flex-wrap: wrap;
	gap: 0.6em;
	max-width: 100%;
	overflow: auto;
}

action-table-pagination .pagination-buttons {
	display: flex;
	justify-content: start;
	align-items: center;
	gap: 0.3em;
}
action-table-pagination button {
	cursor: pointer;
	font-size: inherit;
	background-color: var(--page-btn);
	border: 0;
	border-radius: 0.3em;
	padding: 0.2em 0.5em;
}

action-table-pagination button:hover {
	background-color: var(--highlight);
}

action-table-pagination .active {
	font-weight: bold;
	background-color: var(--page-btn-active);
}

@keyframes fade-in {
	from {
		opacity: 0;
	}
}

@keyframes fade-out {
	to {
		opacity: 0;
	}
}

@keyframes slide-from-bottom {
	from {
		transform: translateY(50px);
	}
}

@keyframes slide-to-top {
	to {
		transform: translateY(-50px);
	}
}

/* table {
    view-transition-name: row;
  } */
::view-transition-old(row) {
	animation: 90ms cubic-bezier(0.4, 0, 1, 1) both fade-out, 300ms cubic-bezier(0.4, 0, 0.2, 1) both slide-to-top;
}

::view-transition-new(row) {
	animation: 1210ms cubic-bezier(0, 0, 0.2, 1) 90ms both fade-in, 300ms cubic-bezier(0.4, 0, 0.2, 1) both slide-from-bottom;
}

/* -------------------------------------------------------------------------- */
/*                          Action Table Filter Range                         */
/* -------------------------------------------------------------------------- */
action-table-filter-range {
	--thumb-size: 1.3em;
	--thumb-bg: #fff;
	--thumb-border: solid 2px #9e9e9e;
	--thumb-shadow: 0 1px 4px 0.5px rgba(0, 0, 0, 0.25);
	--thumb-highlight: var(--highlight);
	--track-bg: lightgray;
	--track-shadow: inset 0 0 2px #00000099;
	--track-highlight: var(--highlight);
	--ticks-color: #b2b2b2;
	--ticks-width: 1;
}
action-table-filter-range,
action-table-filter-range > div,
action-table-filter-range label {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 0.6em;
}

/* ----------------- Action Table Filter Range Fancy Overlap ---------------- */
action-table-filter-range .range-slider-group {
	display: grid;
}

action-table-filter-range .range-slider-group > * {
	grid-column: 1;
	grid-row: 1;
	position: relative;
}

action-table-filter-range .range-slider-group::after {
	content: "";
	width: 100%;
	height: 0.5em;
	background-color: var(--track-bg);
	border-radius: 50px;
	background-size: 100% 2px;
	box-shadow: var(--track-shadow);
	grid-column: 1;
	grid-row: 1;
	justify-self: center;
}

action-table-filter-range .range-slider-highlight {
	background-color: var(--track-highlight);
	width: 100%;
	height: 0.35em;
}

action-table-filter-range input {
	-webkit-appearance: none;
	appearance: none;
	margin: 0;
	width: 100%;
	background: transparent;
	padding: 0.2em 0;
	pointer-events: none;
	cursor: -webkit-grab;
	cursor: grab;
}

action-table-filter-range input::-webkit-slider-runnable-track {
	-webkit-appearance: none;
	appearance: none;
	background: transparent;
}

action-table-filter-range input::-webkit-slider-thumb {
	-webkit-appearance: none;
	height: var(--thumb-size);
	width: var(--thumb-size);
	border-radius: 50%;
	background: var(--thumb-bg);
	border: var(--thumb-border);
	box-shadow: var(--thumb-shadow);
	pointer-events: auto;
}

action-table-filter-range input::-moz-range-thumb {
	-webkit-appearance: none;
	height: var(--thumb-size);
	width: var(--thumb-size);
	background: var(--thumb-bg);
	border-radius: 50%;
	border: var(--thumb-border);
	box-shadow: var(--thumb-shadow);
	pointer-events: auto;
}

action-table-filter-range input::-ms-thumb {
	-webkit-appearance: none;
	height: var(--thumb-size);
	width: var(--thumb-size);
	background: var(--thumb-bg);
	border-radius: 50%;
	border: var(--thumb-border);
	box-shadow: var(--thumb-shadow);
	pointer-events: auto;
}

action-table-filter-range input::-webkit-slider-thumb:hover {
	background: var(--thumb-highlight);
}

action-table-filter-range svg {
	color: var(--ticks-color);
	position: relative;
	top: -0.6em;
	width: calc(100% - var(--thumb-size));
	justify-self: center;
	border-left: 1px solid var(--ticks-color);
	border-right: 1px solid var(--ticks-color);
	box-sizing: border-box;
}
