/* ============================================================
   Smart Product Sort — Enterprise Admin UI
   Color System: Deep Indigo + Clean Neutrals
   ============================================================ */

/* ── Variables ─────────────────────────────────── */
:root {
	--spsort-primary:       #6C5CE7;
	--spsort-primary-dark:  #5A4BD1;
	--spsort-primary-light: #A29BFE;
	--spsort-primary-50:    #F3F1FF;
	--spsort-primary-glow:  rgba(108, 92, 231, .2);
	--spsort-green:         #10B981;
	--spsort-green-50:      #ECFDF5;
	--spsort-green-100:     #D1FAE5;
	--spsort-red:           #EF4444;
	--spsort-red-50:        #FEF2F2;
	--spsort-amber:         #F59E0B;
	--spsort-gray-50:       #F9FAFB;
	--spsort-gray-100:      #F3F4F6;
	--spsort-gray-200:      #E5E7EB;
	--spsort-gray-300:      #D1D5DB;
	--spsort-gray-400:      #9CA3AF;
	--spsort-gray-500:      #6B7280;
	--spsort-gray-600:      #4B5563;
	--spsort-gray-700:      #374151;
	--spsort-gray-800:      #1F2937;
	--spsort-gray-900:      #111827;
	--spsort-white:         #FFFFFF;
	--spsort-radius:        10px;
	--spsort-radius-sm:     6px;
	--spsort-radius-full:   9999px;
	--spsort-shadow:        0 1px 3px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .04);
	--spsort-shadow-md:     0 4px 6px rgba(0, 0, 0, .04), 0 2px 4px rgba(0, 0, 0, .03);
	--spsort-shadow-lg:     0 10px 25px rgba(0, 0, 0, .06), 0 4px 10px rgba(0, 0, 0, .04);
	--spsort-transition:    .2s cubic-bezier(.4, 0, .2, 1);
}

/* ── Reset WP defaults ─────────────────────────── */
.spsort-wrap {
	max-width: 1140px;
	padding: 24px 0 40px;
}

.spsort-wrap h1,
.spsort-wrap h2 {
	padding: 0;
	margin: 0;
}

/* ── Card container ────────────────────────────── */
.spsort-card {
	background: var(--spsort-white);
	border: 1px solid var(--spsort-gray-200);
	border-radius: var(--spsort-radius);
	box-shadow: var(--spsort-shadow);
	overflow: hidden;
}

/* ── Card header ───────────────────────────────── */
.spsort-card-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 20px 28px;
	border-bottom: 1px solid var(--spsort-gray-100);
	background: var(--spsort-white);
}

.spsort-card-header-left {
	display: flex;
	align-items: center;
	gap: 12px;
}

.spsort-logo-icon {
	width: 36px;
	height: 36px;
	background: var(--spsort-primary);
	color: var(--spsort-white);
	border-radius: 8px;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.spsort-card-title {
	font-size: 18px !important;
	font-weight: 700 !important;
	color: var(--spsort-gray-900) !important;
	letter-spacing: -0.01em;
}

/* ── Buttons ───────────────────────────────────── */
.spsort-btn {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-size: 13px;
	font-weight: 600;
	padding: 9px 20px;
	border-radius: var(--spsort-radius-sm);
	border: none;
	cursor: pointer;
	transition: all var(--spsort-transition);
	line-height: 1.4;
	text-decoration: none;
	white-space: nowrap;
}

.spsort-btn-primary {
	background: var(--spsort-primary);
	color: var(--spsort-white);
	box-shadow: 0 1px 2px rgba(108, 92, 231, .3);
}

.spsort-btn-primary:hover,
.spsort-btn-primary:focus {
	background: var(--spsort-primary-dark);
	color: var(--spsort-white);
	box-shadow: 0 4px 12px rgba(108, 92, 231, .35);
	transform: translateY(-1px);
}

.spsort-btn-primary:active {
	transform: translateY(0);
}

.spsort-btn-ghost {
	background: transparent;
	color: var(--spsort-gray-500);
	border: 1px solid var(--spsort-gray-300);
	padding: 8px 20px;
}

.spsort-btn-ghost:hover {
	background: var(--spsort-gray-50);
	color: var(--spsort-gray-700);
	border-color: var(--spsort-gray-400);
}

/* ── Icon buttons ──────────────────────────────── */
.spsort-btn-icon {
	width: 34px;
	height: 34px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: var(--spsort-radius-sm);
	border: 1px solid var(--spsort-gray-200);
	background: var(--spsort-white);
	color: var(--spsort-gray-500);
	cursor: pointer;
	transition: all var(--spsort-transition);
}

.spsort-btn-icon:hover {
	background: var(--spsort-primary-50);
	color: var(--spsort-primary);
	border-color: var(--spsort-primary-light);
}

.spsort-btn-icon-danger:hover {
	background: var(--spsort-red-50);
	color: var(--spsort-red);
	border-color: var(--spsort-red);
}

.spsort-action-btns {
	display: flex;
	gap: 6px;
}

/* ── Table ─────────────────────────────────────── */
.spsort-table-wrap {
	overflow-x: auto;
}

.spsort-table {
	width: 100%;
	border-collapse: collapse;
	border-spacing: 0;
}

.spsort-table thead th {
	background: var(--spsort-gray-50);
	color: var(--spsort-gray-400);
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	padding: 12px 20px;
	text-align: left;
	border-bottom: 1px solid var(--spsort-gray-100);
	white-space: nowrap;
	-webkit-user-select: none;
	user-select: none;
}

.spsort-table tbody td {
	padding: 16px 20px;
	font-size: 14px;
	color: var(--spsort-gray-600);
	border-bottom: 1px solid var(--spsort-gray-100);
	vertical-align: middle;
}

.spsort-table tbody tr:last-child td {
	border-bottom: none;
}

.spsort-table tbody tr {
	transition: background var(--spsort-transition);
}

.spsort-table tbody tr:hover {
	background: var(--spsort-gray-50);
}

.spsort-table tbody td strong {
	color: var(--spsort-gray-800);
	font-weight: 600;
}

/* ── Column widths ─────────────────────────────── */
.spsort-col-name     { min-width: 160px; }
.spsort-col-sort     { min-width: 110px; }
.spsort-col-order    { min-width: 80px; }
.spsort-col-cat      { min-width: 110px; }
.spsort-col-prio     { min-width: 70px; text-align: center; }
.spsort-col-status   { min-width: 90px; }
.spsort-col-actions  { min-width: 100px; }

thead .spsort-col-prio { text-align: center; }

/* ── Inline badges ─────────────────────────────── */
.spsort-sort-badge {
	display: inline-block;
	background: var(--spsort-primary-50);
	color: var(--spsort-primary);
	font-size: 11px;
	font-weight: 600;
	padding: 3px 10px;
	border-radius: var(--spsort-radius-full);
	white-space: nowrap;
	max-width: 140px;
	overflow: hidden;
	text-overflow: ellipsis;
}

.spsort-order-badge {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-size: 12px;
	font-weight: 500;
	color: var(--spsort-gray-500);
}

.spsort-global-tag {
	display: inline-block;
	background: var(--spsort-gray-100);
	color: var(--spsort-gray-600);
	font-size: 12px;
	font-weight: 600;
	padding: 3px 10px;
	border-radius: var(--spsort-radius-full);
}

.spsort-priority-num {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	background: var(--spsort-gray-100);
	color: var(--spsort-gray-700);
	font-size: 13px;
	font-weight: 700;
	border-radius: 50%;
}

/* ── Status toggle ─────────────────────────────── */
.spsort-toggle-rule {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 12px;
	font-weight: 600;
	padding: 5px 14px;
	border-radius: var(--spsort-radius-full);
	border: none;
	cursor: pointer;
	transition: all var(--spsort-transition);
	line-height: 1.4;
}

.spsort-status-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	flex-shrink: 0;
}

.spsort-toggle-rule.spsort-active {
	background: var(--spsort-green-100);
	color: #065F46;
}

.spsort-toggle-rule.spsort-active .spsort-status-dot {
	background: var(--spsort-green);
	box-shadow: 0 0 0 2px rgba(16, 185, 129, .3);
}

.spsort-toggle-rule.spsort-active:hover {
	background: #A7F3D0;
}

.spsort-toggle-rule.spsort-inactive {
	background: var(--spsort-gray-100);
	color: var(--spsort-gray-500);
}

.spsort-toggle-rule.spsort-inactive .spsort-status-dot {
	background: var(--spsort-gray-400);
}

.spsort-toggle-rule.spsort-inactive:hover {
	background: var(--spsort-gray-200);
}

/* ── Empty state ───────────────────────────────── */
.spsort-empty-state {
	text-align: center;
	padding: 48px 20px;
	color: var(--spsort-gray-400);
}

.spsort-empty-state svg {
	margin-bottom: 12px;
	opacity: .5;
}

.spsort-empty-state p {
	font-size: 16px;
	font-weight: 600;
	color: var(--spsort-gray-500);
	margin: 0 0 4px;
}

.spsort-empty-state span {
	font-size: 13px;
	color: var(--spsort-gray-400);
}

/* ── Notice bar ────────────────────────────────── */
.spsort-notice {
	padding: 12px 20px;
	border-radius: var(--spsort-radius-sm);
	font-size: 13px;
	font-weight: 500;
	margin-bottom: 16px;
	display: flex;
	align-items: center;
	gap: 8px;
}

.spsort-notice.notice-success {
	background: var(--spsort-green-50);
	color: #065F46;
	border: 1px solid var(--spsort-green-100);
}

.spsort-notice.notice-error {
	background: var(--spsort-red-50);
	color: #991B1B;
	border: 1px solid #FECACA;
}

.spsort-notice p {
	margin: 0;
}

/* ── Modal overlay ─────────────────────────────── */
#spsort-modal-overlay {
	position: fixed;
	inset: 0;
	background: rgba(17, 24, 39, .5);
	backdrop-filter: blur(4px);
	-webkit-backdrop-filter: blur(4px);
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
}

#spsort-modal {
	background: var(--spsort-white);
	border-radius: 12px;
	box-shadow: var(--spsort-shadow-lg);
	width: 580px;
	max-width: 100%;
	max-height: 90vh;
	overflow-y: auto;
	animation: spsortModalIn .25s cubic-bezier(.4, 0, .2, 1);
}

@keyframes spsortModalIn {
	from {
		opacity: 0;
		transform: translateY(16px) scale(.98);
	}
	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

/* ── Modal header ──────────────────────────────── */
.spsort-modal-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 20px 24px;
	border-bottom: 1px solid var(--spsort-gray-100);
}

.spsort-modal-header h2 {
	font-size: 16px !important;
	font-weight: 700 !important;
	color: var(--spsort-gray-900) !important;
}

.spsort-modal-close {
	width: 32px;
	height: 32px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: var(--spsort-radius-sm);
	border: none;
	background: transparent;
	color: var(--spsort-gray-400);
	cursor: pointer;
	transition: all var(--spsort-transition);
}

.spsort-modal-close:hover {
	background: var(--spsort-gray-100);
	color: var(--spsort-gray-700);
}

/* ── Form body ─────────────────────────────────── */
.spsort-form-body {
	padding: 24px;
	display: flex;
	flex-direction: column;
	gap: 20px;
}

.spsort-field-row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 16px;
}

.spsort-label {
	display: block;
	font-size: 13px;
	font-weight: 600;
	color: var(--spsort-gray-700);
	margin-bottom: 6px;
}

.spsort-required {
	color: var(--spsort-red);
}

.spsort-input,
.spsort-select {
	width: 100%;
	padding: 9px 12px;
	font-size: 14px;
	color: var(--spsort-gray-800);
	background: var(--spsort-white);
	border: 1px solid var(--spsort-gray-300);
	border-radius: var(--spsort-radius-sm);
	transition: border-color var(--spsort-transition), box-shadow var(--spsort-transition);
	outline: none;
	-webkit-appearance: none;
	appearance: none;
}

.spsort-input:focus,
.spsort-select:focus {
	border-color: var(--spsort-primary);
	box-shadow: 0 0 0 3px var(--spsort-primary-glow);
}

.spsort-input::placeholder {
	color: var(--spsort-gray-400);
}

.spsort-select {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 12px center;
	padding-right: 32px;
}

.spsort-hint {
	display: block;
	font-size: 12px;
	color: var(--spsort-gray-400);
	margin-top: 4px;
}

/* ── Toggle switch ─────────────────────────────── */
.spsort-field-toggle {
	padding-top: 4px;
}

.spsort-toggle-label {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	cursor: pointer;
}

.spsort-toggle-label input[type="checkbox"] {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
}

.spsort-toggle-switch {
	position: relative;
	width: 40px;
	height: 22px;
	background: var(--spsort-gray-300);
	border-radius: var(--spsort-radius-full);
	transition: background var(--spsort-transition);
	flex-shrink: 0;
}

.spsort-toggle-switch::after {
	content: '';
	position: absolute;
	top: 3px;
	left: 3px;
	width: 16px;
	height: 16px;
	background: var(--spsort-white);
	border-radius: 50%;
	transition: transform var(--spsort-transition);
	box-shadow: 0 1px 3px rgba(0, 0, 0, .15);
}

.spsort-toggle-label input:checked + .spsort-toggle-switch {
	background: var(--spsort-primary);
}

.spsort-toggle-label input:checked + .spsort-toggle-switch::after {
	transform: translateX(18px);
}

.spsort-toggle-label input:focus + .spsort-toggle-switch {
	box-shadow: 0 0 0 3px var(--spsort-primary-glow);
}

.spsort-toggle-text {
	font-size: 13px;
	font-weight: 500;
	color: var(--spsort-gray-700);
}

/* ── Modal footer ──────────────────────────────── */
.spsort-modal-footer {
	display: flex;
	justify-content: flex-end;
	gap: 10px;
	padding: 16px 24px;
	border-top: 1px solid var(--spsort-gray-100);
	background: var(--spsort-gray-50);
	border-radius: 0 0 12px 12px;
}

/* ── Pro upsell teaser (free users) ────────────── */
.spsort-pro-teaser {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 20px;
	padding: 18px 28px;
	background: linear-gradient(135deg, #F3F1FF 0%, #EEF2FF 100%);
	border-top: 1px solid rgba(108, 92, 231, .12);
	border-radius: 0 0 var(--spsort-radius) var(--spsort-radius);
}

.spsort-pro-teaser p {
	margin: 0;
	font-size: 13px;
	color: var(--spsort-gray-600);
	line-height: 1.5;
}

.spsort-pro-teaser .spsort-btn {
	flex-shrink: 0;
}

/* ── Pro toolbar (pro users) ──────────────────── */
.spsort-pro-toolbar {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 12px 28px;
	border-top: 1px solid var(--spsort-gray-100);
	background: var(--spsort-gray-50);
	border-radius: 0 0 var(--spsort-radius) var(--spsort-radius);
}

/* ── Responsive ────────────────────────────────── */
@media (max-width: 782px) {
	.spsort-card-header {
		flex-direction: column;
		align-items: flex-start;
		gap: 12px;
	}

	.spsort-field-row {
		grid-template-columns: 1fr;
	}

	#spsort-modal {
		width: 100%;
		margin: 10px;
	}

	.spsort-table thead th,
	.spsort-table tbody td {
		padding: 10px 12px;
		font-size: 13px;
	}
}

@media (max-width: 480px) {
	.spsort-card-header {
		padding: 16px;
	}

	.spsort-table thead th,
	.spsort-table tbody td {
		padding: 8px 10px;
		font-size: 12px;
	}

	.spsort-modal-footer {
		flex-direction: column-reverse;
	}

	.spsort-modal-footer .spsort-btn {
		width: 100%;
		justify-content: center;
	}
}
