@use "../tokens" as *;

// WordPress-screen skin (components/wp.js). Values are the prototype's `.pbtn … .mdz` rules
// (appendix D §14.7). Inputs are scoped under .ssw-admin to outrank forms.css `input[type=text]`.

/* Buttons ---------------------------------------------------------------------------------------- */

.ssw-pbtn,
.ssw-gbtn,
.ssw-tbtn,
.ssw-tbtn2,
.ssw-addbtn,
.ssw-rmbtn,
.ssw-dbtn,
.ssw-cbtn {
	cursor: pointer;
	white-space: nowrap;

	@include focus-visible;

	&.is-block {
		width: 100%;
		justify-content: center;
	}
}

.ssw-pbtn {
	height: 38px;
	padding: 0 16px;
	border: 1px solid $blue;
	background: $blue;
	color: #fff;
	border-radius: 4px;
	font-size: 14px;
	font-weight: 600;
	transition: background 150ms ease;

	&:hover {
		background: $blue-2;
	}

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

.ssw-gbtn {
	height: 38px;
	padding: 0 14px;
	border: 1px solid $faint;
	background: #fff;
	color: $ink;
	border-radius: 4px;
	font-size: 14px;
	font-weight: 500;
	transition: border-color 150ms ease;

	&:hover {
		border-color: #787c82;
	}
}

.ssw-tbtn {
	height: 36px;
	padding: 0 12px;
	border: 1px solid $blue;
	background: #fff;
	color: $blue;
	border-radius: 4px;
	font-size: 13px;
	font-weight: 500;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	transition: background 150ms ease, color 150ms ease, border-color 150ms ease;

	&:hover {
		background: $tint;
	}

	&.is-solid {
		background: $blue;
		color: #fff;

		&:hover {
			background: $blue-2;
			border-color: $blue-2;
		}
	}
}

.ssw-tbtn2 {
	height: 34px;
	padding: 0 12px;
	border: 1px solid #dcdce0;
	background: #fff;
	color: $muted;
	border-radius: 4px;
	font-size: 13px;
	font-weight: 500;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	transition: border-color 150ms ease, color 150ms ease;

	&:hover {
		border-color: $faint-2;
		color: $ink;
	}
}

.ssw-addbtn {
	height: 36px;
	padding: 0 13px;
	border: 1px dashed #b8bcc2;
	background: #fff;
	color: $blue;
	border-radius: 6px;
	font-size: 13px;
	font-weight: 500;
	display: inline-flex;
	align-items: center;
	gap: 7px;
	transition: border-color 150ms ease, background 150ms ease;

	&:hover {
		border-color: $blue;
		background: $tint;
	}
}

.ssw-rmbtn {
	width: 34px;
	height: 34px;
	flex: 0 0 34px;
	border: 1px solid transparent;
	border-radius: 4px;
	background: transparent;
	color: $faint-2;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: color 150ms ease, background 150ms ease;

	&:hover {
		color: $danger;
		background: #fcf0f0;
	}
}

// Inline-confirm buttons (h30).
.ssw-cbtn,
.ssw-dbtn {
	height: 30px;
	padding: 0 12px;
	border-radius: 4px;
	font-size: 13px;
}

.ssw-cbtn {
	border: 1px solid $faint;
	background: #fff;
	color: $ink;
}

.ssw-dbtn {
	border: 1px solid $danger;
	background: $danger;
	color: #fff;
	font-weight: 500;
	transition: background 150ms ease;

	&:hover {
		background: $danger-2;
	}
}

/* Pills ------------------------------------------------------------------------------------------ */

.ssw-pill {
	flex: 0 0 auto;
	font-size: 11px;
	font-weight: 500;
	line-height: 18px;
	padding: 0 7px;
	border-radius: 999px;
	white-space: nowrap;

	&.is-recommended {
		background: $success-tint;
		color: $success-ink;
	}

	&.is-active {
		background: #edfaef;
		color: $success;
	}

	&.is-neutral {
		background: $line-list;
		color: $text-2;
	}

	&.is-warning {
		background: #fcf9e8;
		color: $warning;
	}
}

/* Fields ----------------------------------------------------------------------------------------- */

.ssw-field {
	margin-bottom: 16px;
}

.ssw-lbl {
	display: block;
	font-size: 14px;
	font-weight: 500;
	color: $text;
	margin: 0 0 8px;
}

.ssw-desc {
	font-size: 13px;
	color: $muted;
	margin: 4px 0 0;
}

.ssw-admin .ssw-wpi,
.ssw-admin .ssw-wpta {
	width: 100%;
	border: 1px solid $line-ring;
	border-radius: 4px;
	background: #fff;
	font-size: 14px;
	color: $ink;
	outline: none;
	box-shadow: none;
	transition: border-color 150ms ease;

	&:hover {
		border-color: $faint-2;
	}

	&:focus {
		border-color: $blue;
		box-shadow: none;
	}
}

.ssw-admin .ssw-wpi {
	height: 40px;
	min-height: 0;
	padding: 0 10px 0 12px;
	line-height: normal;
}

.ssw-admin .ssw-wpta {
	display: block;
	min-height: 80px;
	padding: 8px 10px;
	line-height: 1.5;
	resize: vertical;
}

.ssw-frow {
	display: flex;
	gap: 16px;
	align-items: flex-start;
}

.ssw-flbl {
	flex: 0 0 140px;
	font-size: 14px;
	font-weight: 500;
	color: $text;
	padding-top: 11px;
	white-space: nowrap;
}

.ssw-fctrl {
	flex: 1;
	min-width: 0;
	display: flex;
	justify-content: flex-end;
	flex-wrap: wrap;
}

/* WP-form dropdown ------------------------------------------------------------------------------- */

.ssw-ssdd-wrap {
	position: relative;
}

.ssw-ssdd {
	width: 100%;
	// max-width: 400px;
	height: 40px;
	border: 1px solid $line-ring;
	border-radius: 4px;
	background: #fff;
	display: flex;
	align-items: center;
	padding: 0 10px;
	font-size: 14px;
	color: $ink;
	text-align: left;
	gap: 8px;
	transition: border-color 150ms ease, box-shadow 150ms ease;

	@include focus-visible;

	&:hover {
		border-color: $faint-2;
	}

	svg {
		flex: 0 0 18px;
		color: #c1c2c6;
		transition: color 160ms ease;
	}

	&:hover svg,
	&.is-open svg {
		color: $ink-2;
	}

	&.is-open {
		border-color: $blue;
		box-shadow: 0 0 0 1px $blue;
	}
}

.ssw-ssdd__label {
	flex: 1;
}

.ssw-ssmenu {
	position: absolute;
	top: calc(100% + 4px);
	left: 0;
	width: 100%;
	max-width: 400px;
	z-index: 30;
	background: #fff;
	border: 1px solid #e2e3e6;
	border-radius: 6px;
	box-shadow: 0 8px 24px rgba(16, 17, 20, 0.12);
	padding: 4px;
	display: flex;
	flex-direction: column;
	gap: 3px;
	transform-origin: top center;
	animation: ssw-menu-in 140ms $ease;
}

.ssw-ssopt {
	display: flex;
	align-items: center;
	gap: 10px;
	font-size: 14px;
	padding: 8px 10px;
	border-radius: 4px;
	cursor: pointer;
	color: $ink-2;
	transition: background 160ms ease, color 160ms ease;

	&:hover,
	&.is-active {
		background: $tint;
		color: $blue-2;
	}

	&.is-selected {
		background: $tint;
		color: $blue;
	}

	.ssw-pill {
		margin-left: auto;
	}
}

@keyframes ssw-menu-in {

	from {
		opacity: 0;
		transform: translateY(-6px) scale(0.97);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

/* Menu (.tmenu) ---------------------------------------------------------------------------------- */

.ssw-menu-anchor {
	position: relative;
}

.ssw-tmenu {
	position: absolute;
	top: calc(100% + 4px);
	left: 0;
	z-index: 30;
	width: 180px;
	background: #fff;
	border: 1px solid #e2e3e6;
	border-radius: 6px;
	box-shadow: 0 8px 24px rgba(16, 17, 20, 0.12);
	padding: 4px;
	animation: ssw-menu-in 140ms $ease;

	&.is-right {
		left: auto;
		right: 0;
	}
}

.ssw-topt {
	display: flex;
	width: 100%;
	align-items: center;
	gap: 9px;
	font-size: 13px;
	color: $ink;
	padding: 8px 10px;
	border-radius: 4px;
	text-align: left;
	transition: background 130ms ease;

	&:hover,
	&:focus-visible {
		background: $tint;
		outline: none;
	}
}

/* Inline confirm --------------------------------------------------------------------------------- */

.ssw-confpop {
	position: absolute;
	top: calc(100% - 4px);
	left: 14px;
	z-index: 50;
	width: 230px;
	background: #fff;
	border: 1px solid #e2e3e6;
	border-radius: 8px;
	box-shadow: 0 12px 30px rgba(16, 17, 20, 0.2);
	padding: 12px 13px;
	animation: ssw-pop-in 140ms $ease;

	&.is-out {
		animation: ssw-pop-out 120ms ease forwards;
	}
}

.ssw-confpop__text {
	font-size: 13px;
	color: $ink;
	margin-bottom: 11px;

	strong {
		font-weight: 600;
	}
}

.ssw-confpop__actions {
	display: flex;
	gap: 7px;
	justify-content: flex-end;
}

@keyframes ssw-pop-in {

	from {
		opacity: 0;
		transform: translateY(-6px) scale(0.98);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

@keyframes ssw-pop-out {

	from {
		opacity: 1;
		transform: none;
	}

	to {
		opacity: 0;
		transform: translateY(10px) scale(0.975);
	}
}

/* Modal and drawer ------------------------------------------------------------------------------- */

.ssw-modal-layer {
	position: fixed;
	inset: 0;
	z-index: 100000; // over the WP admin bar (99999)
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;

	&.is-drawer {
		display: block;
		padding: 0;
	}
}

.ssw-scrim {
	position: absolute;
	inset: 0;
	background: rgba(16, 17, 20, 0.34);
	animation: ssw-fade-in 160ms ease;
}

.ssw-modal {
	position: relative;
	z-index: 1;
	max-width: calc(100vw - 40px);
	max-height: 88vh;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	background: #fff;
	border-radius: 10px;
	box-shadow: $shadow-modal;
	outline: none;
	animation: ssw-modal-in 190ms $ease;
}

.ssw-modal__head {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 16px 20px;
	border-bottom: 1px solid #ececed;
	flex: 0 0 auto;
}

.ssw-modal .ssw-modal__title {
	font-size: 16px;
	font-weight: 600;
	line-height: 1.5;
	color: $ink;
	margin: 0;
}

.ssw-modal__close {
	margin-left: auto;
	width: 30px;
	height: 30px;
	border: 1px solid #dcdce0;
	background: #fff;
	border-radius: 6px;
	color: $muted-2;
	display: inline-flex;
	align-items: center;
	justify-content: center;

	@include focus-visible;

	&:hover {
		border-color: $faint-2;
		color: $ink-2;
	}
}

.ssw-modal__body {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	padding: 20px;

	.ssw-modal.has-height & {
		padding: 16px 20px;
	}
}

.ssw-modal__strip {
	flex: 0 0 auto;
	padding: 12px 20px;
	border-top: 1px solid $line-list;
}

.ssw-modal__foot {
	display: flex;
	align-items: center;
	gap: 9px;
	padding: 14px 20px;
	border-top: 1px solid #ececed;
	background: $surface-3;
	flex: 0 0 auto;
}

.ssw-modal__actions {
	margin-left: auto;
	display: flex;
	gap: 9px;
}

.ssw-drawer {
	position: absolute;
	top: 0;
	right: 0;
	height: 100%;
	max-width: calc(100vw - 40px);
	overflow: auto;
	background: $line-list;
	box-shadow: -16px 0 48px rgba(16, 17, 20, 0.18);
	outline: none;
	animation: ssw-drawer-in 240ms $ease;
}

@keyframes ssw-modal-in {

	from {
		opacity: 0;
		transform: translateY(10px) scale(0.975);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

@keyframes ssw-drawer-in {

	from {
		transform: translateX(100%);
	}

	to {
		transform: none;
	}
}

/* Upload targets --------------------------------------------------------------------------------- */

.ssw-filedrop {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 12px;
	border: 2px dashed #c4c7cd;
	border-radius: 10px;
	padding: 40px 24px;
	cursor: pointer;
	text-align: center;
	background: #fafbfc;
	transition: border-color 150ms, background 150ms;

	&:hover,
	&.is-over {
		border-color: $blue;
		background: $tint;
	}

	&:focus-within {
		outline: 2px solid $blue;
		outline-offset: 2px;
	}
}

.ssw-filedrop__icon {
	width: 52px;
	height: 52px;
	border-radius: 12px;
	background: $tint;
	color: $blue;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.ssw-filedrop__title {
	font-size: 15px;
	font-weight: 600;
	color: $ink;
}

.ssw-filedrop__hint {
	font-size: 13px;
	color: $muted;
	max-width: 46ch;
	line-height: 1.5;
}

.ssw-dztip {
	position: relative;
	display: inline-flex;
}

.ssw-dz {
	display: inline-flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 3px;
	border: 1px dashed #b8bcc2;
	border-radius: 8px;
	background: $surface-3;
	color: $faint;
	transition: border-color 150ms ease, color 150ms ease, background 150ms ease;

	@include focus-visible;

	svg {
		transition: transform 160ms ease;
	}

	&:hover {
		border-color: $blue;
		color: $blue;
		background: $tint;

		svg {
			transform: scale(1.14);
		}
	}
}

// Dark tooltip above (".dztip .tip") or to the left (".cwtip").
.ssw-dztip__tip,
.ssw-cwtip {
	position: absolute;
	white-space: nowrap;
	background: $ink;
	color: $line-list;
	font-size: 12px;
	border-radius: 6px;
	box-shadow: 0 6px 20px rgba(16, 17, 20, 0.22);
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity 150ms ease, transform 150ms ease;

	&::after {
		content: "";
		position: absolute;
		border: 5px solid transparent;
	}
}

.ssw-dztip__tip {
	bottom: calc(100% + 8px);
	left: 50%;
	transform: translateX(-50%) translateY(4px);
	width: max-content;
	max-width: 160px;
	padding: 6px 10px;
	z-index: 40;

	&::after {
		top: 100%;
		left: 50%;
		transform: translateX(-50%);
		border-top-color: $ink;
	}

	.ssw-dztip:hover &,
	.ssw-dztip:focus-within & {
		opacity: 1;
		visibility: visible;
		transform: translateX(-50%) translateY(0);
	}
}

.ssw-imgwrap {
	position: relative;
	display: inline-block;
}

.ssw-cwtip {
	top: 50%;
	right: calc(100% + 8px);
	transform: translateY(-50%) translateX(4px);
	padding: 5px 9px;
	z-index: 45;

	&::after {
		left: 100%;
		top: 50%;
		transform: translateY(-50%);
		border-left-color: $ink;
	}

	.ssw-imgwrap:hover &,
	.ssw-imgwrap:focus-within & {
		opacity: 1;
		visibility: visible;
		transform: translateY(-50%) translateX(0);
	}
}

.ssw-mdz {
	width: 38px;
	height: 38px;
	flex: 0 0 38px;
	border: 1px dashed #b8bcc2;
	border-radius: 4px;
	background: $surface-3;
	color: $faint-2;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	vertical-align: top;
	transition: border-color 150ms ease, color 150ms ease, background 150ms ease;

	@include focus-visible;

	&:hover {
		border-color: $blue;
		color: $blue;
		background: $tint;
	}

	// A chosen image (MiniThumb): the same box, solid edge, the image filling it.
	&.is-filled {
		overflow: hidden;
		padding: 0;
		border-style: solid;
		border-color: #dcdce0;
		background: #fff;

		&:hover {
			border-color: $blue;
		}

		img {
			display: block;
			width: 100%;
			height: 100%;
			object-fit: cover;
		}
	}
}

.ssw-thumb {
	position: relative;
	display: inline-block;
	border-radius: 8px;
	overflow: hidden;
	border: 1px solid #dcdce0;

	img {
		display: block;
		width: 100%;
		height: 100%;
		object-fit: cover;
	}
}

.ssw-thumb__rm {
	position: absolute;
	top: 3px;
	right: 3px;
	z-index: 2;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: rgba(29, 35, 39, 0.72);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 9px;

	@include focus-visible;
}

.ssw-thumb__rep {
	position: absolute;
	inset: 0;
	background: rgba(29, 35, 39, 0.48);
	color: #fff;
	font-size: 11px;
	font-weight: 500;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	transition: opacity 140ms ease;

	.ssw-thumb:hover &,
	&:focus-visible {
		opacity: 1;
		outline: none;
	}
}

/* Table ------------------------------------------------------------------------------------------ */

.ssw-table-wrap {
	background: #fff;
	border: 1px solid $line-card;
	border-radius: 6px;
	overflow-x: auto;
}

.ssw-table {
	border-collapse: collapse;
	width: 100%;
	min-width: 520px;
	font-size: 14px;

	th {
		padding: 12px 14px;
		text-align: left;
		font-weight: 400;
		color: $ink;
		border-bottom: 1px solid $line-card;
	}

	th,
	td {
		line-height: 1.5; // common.css sets td to 1.4em
	}

	td {
		padding: 12px 14px;
		vertical-align: top;
		border-bottom: 1px solid $line-list;
		color: $text;
	}

	.is-muted {
		color: $muted;
		font-variant-numeric: tabular-nums;
	}

	.is-title {
		position: relative;

		> a {
			font-weight: 600;
		}
	}
}

.ssw-table__row {
	background: #fff;

	&.is-zebra {
		background: $surface-2;
	}
}

// Row actions: hidden until the row is hovered or holds focus (opacity keeps them focusable).
.ssw-ract {
	margin-top: 4px;
	font-size: 13px;
	opacity: 0;

	.ssw-table__row:hover &,
	.ssw-table__row:focus-within & {
		opacity: 1;
	}
}

.ssw-ract__sep {
	color: #c6c7cb;
}

.ssw-ract__link {
	color: $blue;
	font-size: 13px;

	@include focus-visible;

	&:hover {
		color: $blue-2;
	}

	&.is-danger {
		color: $danger-2;
	}
}

/* Notices ---------------------------------------------------------------------------------------- */

.ssw-inline-notice {
	font-size: 13px;
	color: $success-2; // prototype #00a32a is 3.1:1 on white; WP's darker success green passes AA
}
