/**
 * Redirect Manager admin styles.
 * Aligned with CPT Builder / PowerSuite module screens.
 *
 * @package RedirectManager
 */

.wpps-redirect-manager {
	--wpps-rm-accent: var(--wp-admin-theme-color, #2271b1);
	--wpps-rm-accent-hover: var(--wp-admin-theme-color-darker-10, #135e96);
	--wpps-rm-accent-bg: color-mix(in srgb, var(--wp-admin-theme-color, #2271b1) 12%, #fff);
}

.wpps-redirect-manager .rm-muted {
	color: #646970;
}

.wpps-redirect-manager .wpps-rm-required {
	color: #d63638;
}

/* Page hero meta buttons */
.wrap.wpps-redirect-manager .wpps-page-hero__meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: flex-end;
	gap: 8px;
}

.wrap.wpps-redirect-manager .wpps-page-hero__meta .button {
	margin: 0;
}

/* Empty state */
.wpps-redirect-manager .rm-empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	background: #fff;
	border: 1px solid #c3c4c7;
	box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
	padding: 64px 32px;
	margin-top: 16px;
}

.wpps-redirect-manager .rm-empty .dashicons {
	display: block;
	font-size: 48px;
	width: 48px;
	height: 48px;
	color: var(--wpps-rm-accent);
	margin-bottom: 4px;
}

.wpps-redirect-manager .rm-empty h3 {
	margin: 16px 0 0;
	font-size: 18px;
}

.wpps-redirect-manager .rm-empty .description {
	margin: 8px 0 0;
	max-width: 420px;
}

.wpps-redirect-manager .rm-empty .button {
	margin-top: 24px;
}

/* List table header */
.wpps-redirect-manager .rm-list-header,
.wpps-redirect-manager .wpps-rm-list-header {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin: 8px 0 0;
}

.wpps-redirect-manager .rm-list-header .subsubsub,
.wpps-redirect-manager .wpps-rm-list-header .subsubsub {
	float: none;
	margin: 0;
}

.wpps-redirect-manager .rm-list-header .search-box,
.wpps-redirect-manager .wpps-rm-list-header .search-box {
	float: none;
	margin: 0;
}

.wpps-redirect-manager #wpps-rm-list-form {
	margin-top: 0;
	clear: both;
}

.wpps-redirect-manager .wp-list-table .row-actions {
	color: #646970;
}

/* Status pills (match CPT Builder) */
.wpps-redirect-manager .rm-status {
	display: inline-block;
	padding: 2px 10px;
	border-radius: 999px;
	font-size: 12px;
	font-weight: 600;
}

.wpps-redirect-manager .rm-status--on {
	background: #edfaef;
	color: #1a7f37;
}

.wpps-redirect-manager .rm-status--off {
	background: #f0f0f1;
	color: #646970;
}

/* Panels (import, test, form sections) */
.wpps-redirect-manager .rm-import-panel,
.wpps-redirect-manager .rm-panel {
	background: #fff;
	border: 1px solid #c3c4c7;
	box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
	padding: 20px 24px;
	margin: 16px 0;
}

.wpps-redirect-manager .rm-panel-title {
	margin: 0 0 4px;
	font-size: 16px;
	font-weight: 600;
	color: #1d2327;
}

.wpps-redirect-manager .rm-panel-desc {
	margin: 0 0 20px;
}

/* Edit actions bar */
.wpps-redirect-manager .rm-actions-bar {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 12px;
	background: #fff;
	border: 1px solid #c3c4c7;
	box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
	padding: 12px 16px;
	margin: 16px 0;
}

.wpps-redirect-manager .rm-actions-bar--bottom {
	justify-content: space-between;
}

/* Save button loading state */
.wpps-redirect-manager .wpps-rm-save-btn.is-loading {
	pointer-events: none;
	opacity: 0.85;
}

.wpps-redirect-manager .wpps-rm-spinner {
	display: inline-block;
	width: 16px;
	height: 16px;
	border: 2px solid rgba(255, 255, 255, 0.4);
	border-top-color: #fff;
	border-radius: 50%;
	animation: wpps-rm-spin 0.7s linear infinite;
	vertical-align: middle;
	margin-right: 6px;
}

@keyframes wpps-rm-spin {
	to { transform: rotate(360deg); }
}

/* Form layout */
.wpps-redirect-manager .wpps-rm-form-wrap {
	margin-bottom: 32px;
}

.wpps-redirect-manager .wpps-rm-form-grid {
	display: grid;
	gap: 20px;
	margin-bottom: 20px;
}

.wpps-redirect-manager .wpps-rm-form-grid:last-child {
	margin-bottom: 0;
}

.wpps-redirect-manager .wpps-rm-form-grid-2col {
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

.wpps-redirect-manager .wpps-rm-form-grid-3col {
	grid-template-columns: repeat(3, minmax(0, 1fr));
}

.wpps-redirect-manager .wpps-rm-form-grid-4col {
	grid-template-columns: repeat(4, minmax(0, 1fr));
}

.wpps-redirect-manager .wpps-rm-form-full {
	grid-column: 1 / -1;
}

.wpps-redirect-manager .wpps-rm-target-row {
	display: grid;
	grid-template-columns: minmax(0, 7fr) minmax(0, 3fr);
	gap: 20px;
	grid-column: 1 / -1;
	align-items: start;
}

.wpps-redirect-manager .wpps-rm-target-row .wpps-rm-target-input-wrap,
.wpps-redirect-manager .wpps-rm-target-row .wpps-rm-page-picker-wrap {
	min-width: 0;
}

.wpps-redirect-manager .wpps-rm-target-row .wpps-rm-page-picker-wrap {
	margin-top: 0;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 6px;
}

@media (max-width: 782px) {
	.wpps-redirect-manager .wpps-rm-form-grid-2col,
	.wpps-redirect-manager .wpps-rm-form-grid-3col,
	.wpps-redirect-manager .wpps-rm-form-grid-4col {
		grid-template-columns: 1fr;
	}

	.wpps-redirect-manager .wpps-rm-target-row {
		grid-template-columns: 1fr;
	}
}

.wpps-redirect-manager .wpps-rm-form-group {
	display: flex;
	flex-direction: column;
	gap: 6px;
	min-width: 0;
}

.wpps-redirect-manager .wpps-rm-form-group label {
	font-size: 13px;
	font-weight: 600;
	color: #1d2327;
}

.wpps-redirect-manager .wpps-rm-input,
.wpps-redirect-manager .wpps-rm-select {
	box-sizing: border-box;
	width: 100%;
	min-width: 0;
	padding: 8px 12px;
	min-height: 36px;
	border: 1px solid #8c8f94;
	border-radius: 4px;
	font-size: 14px;
	background: #fff;
}

.wpps-redirect-manager .wpps-rm-select {
	-webkit-appearance: none;
	-moz-appearance: none;
	appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2350575e' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 12px center;
	padding-right: 36px;
}

.wpps-redirect-manager .wpps-rm-input:focus,
.wpps-redirect-manager .wpps-rm-select:focus {
	border-color: var(--wpps-rm-accent);
	box-shadow: 0 0 0 1px var(--wpps-rm-accent);
	outline: 2px solid transparent;
}

.wpps-redirect-manager .wpps-rm-textarea {
	min-height: 60px;
	resize: vertical;
}

.wpps-redirect-manager .wpps-rm-help {
	font-size: 12px;
	color: #646970;
}

.wpps-redirect-manager .wpps-rm-checkbox-label {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 13px;
	font-weight: 500;
	color: #1d2327;
	cursor: pointer;
}

.wpps-redirect-manager .wpps-rm-checkbox {
	width: 18px;
	height: 18px;
	margin: 0;
}

.wpps-redirect-manager .wpps-rm-inline-fields {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
}

.wpps-redirect-manager .wpps-rm-inline-fields .wpps-rm-input {
	flex: 1;
	min-width: 120px;
}

.wpps-redirect-manager .wpps-rm-condition-row {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

/* Page picker */
.wpps-redirect-manager .wpps-rm-page-picker-combobox {
	position: relative;
	width: 100%;
	min-width: 0;
}

.wpps-redirect-manager .wpps-rm-page-picker-input {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2350575e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 12px center;
	background-size: 14px;
	padding-right: 36px;
}

.wpps-redirect-manager .wpps-rm-page-picker-dropdown {
	display: none;
	position: absolute;
	top: 100%;
	left: 0;
	right: 0;
	max-height: 220px;
	overflow-y: auto;
	margin-top: 2px;
	background: #fff;
	border: 1px solid #c3c4c7;
	border-radius: 4px;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
	z-index: 100;
}

.wpps-redirect-manager .wpps-rm-page-picker-option {
	padding: 10px 12px;
	font-size: 14px;
	cursor: pointer;
}

.wpps-redirect-manager .wpps-rm-page-picker-option:hover {
	background: #f6f7f7;
}

.wpps-redirect-manager .wpps-rm-page-picker-empty {
	padding: 12px;
	font-size: 13px;
	color: #646970;
	text-align: center;
}

/* Accordion */
.wpps-redirect-manager .wpps-rm-accordion {
	padding: 0;
	overflow: visible;
}

.wpps-redirect-manager .wpps-rm-accordion-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	padding: 16px 24px;
	background: transparent;
	border: none;
	cursor: pointer;
	font-size: 14px;
	font-weight: 600;
	color: #1d2327;
	text-align: left;
}

.wpps-redirect-manager .wpps-rm-accordion-header:hover {
	background: #f6f7f7;
}

.wpps-redirect-manager .wpps-rm-accordion-chevron {
	font-size: 18px;
	width: 18px;
	height: 18px;
	transition: transform 0.2s;
}

.wpps-redirect-manager .wpps-rm-accordion.is-open .wpps-rm-accordion-chevron {
	transform: rotate(180deg);
}

.wpps-redirect-manager .wpps-rm-accordion-title {
	display: flex;
	align-items: center;
	gap: 8px;
}

.wpps-redirect-manager .wpps-rm-accordion-tooltip {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: help;
	z-index: 1;
}

.wpps-redirect-manager .wpps-rm-accordion-tooltip-trigger {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 18px;
	height: 18px;
	font-size: 12px;
	font-weight: 600;
	color: #646970;
	background: #f0f0f1;
	border-radius: 50%;
	line-height: 1;
}

.wpps-redirect-manager .wpps-rm-accordion-tooltip:hover .wpps-rm-accordion-tooltip-trigger {
	color: var(--wpps-rm-accent);
	background: var(--wpps-rm-accent-bg);
}

.wpps-redirect-manager .wpps-rm-accordion-tooltip-panel {
	position: absolute;
	left: 0;
	bottom: calc(100% + 10px);
	transform: translateY(4px);
	min-width: 220px;
	max-width: min(320px, calc(100vw - 32px));
	padding: 12px 14px;
	font-size: 12px;
	font-weight: 400;
	line-height: 1.5;
	color: #1d2327;
	background: #fff;
	border: 1px solid #c3c4c7;
	border-radius: 6px;
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
	z-index: 100000;
}

.wpps-redirect-manager .wpps-rm-accordion-tooltip-panel.is-positioned {
	position: fixed !important;
	bottom: auto !important;
	transform: none !important;
}

.wpps-redirect-manager .wpps-rm-accordion-tooltip.is-active .wpps-rm-accordion-tooltip-panel {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

@media (hover: hover) {
	html:not(.wpps-accordion-tooltips-ready) .wpps-redirect-manager .wpps-rm-accordion-tooltip:hover .wpps-rm-accordion-tooltip-panel:not(.is-positioned) {
		opacity: 1;
		visibility: visible;
		transform: translateY(0);
	}
}

.wpps-redirect-manager .wpps-rm-accordion-body {
	padding: 0 24px 24px;
	border-top: 1px solid #dcdcde;
}

.wpps-redirect-manager .wpps-rm-accordion-body .wpps-rm-panel-desc {
	margin-bottom: 16px;
	padding-top: 16px;
}

.wpps-redirect-manager .wpps-rm-accordion-nested {
	margin-top: 12px;
	border: 1px solid #dcdcde;
	border-radius: 4px;
	overflow: hidden;
}

.wpps-redirect-manager .wpps-rm-accordion-header-nested {
	padding: 12px 16px;
	font-size: 13px;
}

.wpps-redirect-manager .wpps-rm-accordion-body-nested {
	padding: 16px;
	border-top: 1px solid #dcdcde;
}

.wpps-redirect-manager .wpps-rm-howto-desc {
	margin: 0 0 16px;
	font-size: 13px;
	line-height: 1.5;
	color: #646970;
}

.wpps-redirect-manager .wpps-rm-howto-notice {
	margin: 0 0 16px;
	padding: 10px 12px;
	background: #fcf9e8;
	border: 1px solid #dba617;
	border-radius: 4px;
	font-size: 12px;
	color: #1d2327;
}

.wpps-redirect-manager .wpps-rm-howto-example {
	margin-bottom: 20px;
	padding: 14px 16px;
	background: #f6f7f7;
	border: 1px solid #dcdcde;
	border-radius: 4px;
}

.wpps-redirect-manager .wpps-rm-howto-example-row label {
	display: inline-block;
	min-width: 90px;
	font-weight: 600;
}

.wpps-redirect-manager .wpps-rm-howto-example-row code {
	background: #fff;
	padding: 2px 8px;
	border: 1px solid #dcdcde;
	border-radius: 2px;
	font-size: 12px;
}

.wpps-redirect-manager .wpps-rm-howto-example-desc {
	margin: 0;
	font-size: 12px;
	color: #646970;
}

.wpps-redirect-manager .wpps-rm-howto-tools a {
	color: var(--wpps-rm-accent);
}

/* Test URL panel */
.wpps-redirect-manager .rm-test-row {
	display: flex;
	gap: 8px;
	align-items: center;
	flex-wrap: wrap;
	margin-top: 8px;
	max-width: 640px;
}

.wpps-redirect-manager .rm-test-row input {
	flex: 1;
	min-width: 200px;
}

.wpps-redirect-manager .rm-test-result {
	margin-top: 12px;
	padding: 12px 16px;
	border-radius: 4px;
	font-size: 13px;
}

.wpps-redirect-manager .rm-test-result.rm-test-success {
	background: #edfaef;
	color: #1a7f37;
	border: 1px solid #68de7c;
}

.wpps-redirect-manager .rm-test-result.rm-test-error {
	background: #fcf0f1;
	color: #d63638;
	border: 1px solid #d63638;
}

.wpps-redirect-manager .rm-test-result.rm-test-info {
	background: var(--wpps-rm-accent-bg);
	color: #1d2327;
	border: 1px solid #c3c4c7;
}

.wpps-redirect-manager .rm-test-result.rm-test-loading {
	background: #f6f7f7;
	color: #646970;
	border: 1px solid #dcdcde;
}

/* Toggle switch */
.wpps-redirect-manager .wpps-rm-inactive {
	opacity: 0.65;
}

.wpps-redirect-manager .wpps-rm-toggle {
	position: relative;
	display: inline-block;
	width: 38px;
	height: 20px;
	cursor: pointer;
}

.wpps-redirect-manager .wpps-rm-toggle-input {
	opacity: 0;
	width: 0;
	height: 0;
}

.wpps-redirect-manager .wpps-rm-toggle-slider {
	position: absolute;
	inset: 0;
	background: #c3c4c7;
	border-radius: 20px;
	transition: 0.2s;
}

.wpps-redirect-manager .wpps-rm-toggle-slider::before {
	content: "";
	position: absolute;
	height: 14px;
	width: 14px;
	left: 3px;
	bottom: 3px;
	background: #fff;
	border-radius: 50%;
	transition: 0.2s;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.wpps-redirect-manager .wpps-rm-toggle-input:checked + .wpps-rm-toggle-slider {
	background: #00a32a;
}

.wpps-redirect-manager .wpps-rm-toggle-input:checked + .wpps-rm-toggle-slider::before {
	transform: translateX(18px);
}

.wpps-redirect-manager .wpps-rm-warning {
	color: #d63638 !important;
	font-weight: 500;
}
