/* Standalone product/category manager — self-contained styling, does not
 * rely on the shop theme's CSS since this page skips get_header()/get_footer(). */

.freshio-pm-body {
	--pm-bg: #f5f6f8;
	--pm-surface: #ffffff;
	--pm-border: #e2e5ea;
	--pm-text: #1c1f26;
	--pm-text-muted: #6b7280;
	--pm-primary: #2563eb;
	--pm-primary-hover: #1d4ed8;
	--pm-danger: #dc2626;
	--pm-danger-hover: #b91c1c;
	--pm-success: #16a34a;
	--pm-radius: 10px;
	--pm-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);

	margin: 0;
	background: var(--pm-bg);
	color: var(--pm-text);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.5;
}

.freshio-pm-body * {
	box-sizing: border-box;
}

/* Login */

.freshio-pm-login-wrap {
	min-height: 100vh;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
}

.freshio-pm-login-card {
	width: 100%;
	max-width: 360px;
	background: var(--pm-surface);
	border: 1px solid var(--pm-border);
	border-radius: var(--pm-radius);
	box-shadow: var(--pm-shadow);
	padding: 32px;
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.freshio-pm-login-card h1 {
	margin: 0 0 4px;
	font-size: 20px;
}

.freshio-pm-login-card label {
	display: flex;
	flex-direction: column;
	gap: 6px;
	font-size: 13px;
	font-weight: 600;
	color: var(--pm-text-muted);
}

.freshio-pm-login-card input {
	font-size: 15px;
	font-weight: 400;
	color: var(--pm-text);
	padding: 10px 12px;
	border: 1px solid var(--pm-border);
	border-radius: 8px;
}

.freshio-pm-login-card input:focus {
	outline: 2px solid var(--pm-primary);
	outline-offset: 1px;
}

.freshio-pm-error {
	margin: 0;
	padding: 10px 12px;
	background: #fef2f2;
	color: var(--pm-danger);
	border-radius: 8px;
	font-size: 13px;
}

/* Buttons */

.freshio-pm-btn {
	appearance: none;
	border: 1px solid var(--pm-border);
	background: var(--pm-surface);
	color: var(--pm-text);
	border-radius: 8px;
	padding: 10px 16px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: background-color 0.15s ease, border-color 0.15s ease;
}

.freshio-pm-btn:hover {
	background: #f9fafb;
}

.freshio-pm-btn-primary {
	background: var(--pm-primary);
	border-color: var(--pm-primary);
	color: #fff;
}

.freshio-pm-btn-primary:hover {
	background: var(--pm-primary-hover);
	border-color: var(--pm-primary-hover);
}

.freshio-pm-btn-danger {
	color: var(--pm-danger);
	border-color: #fecaca;
}

.freshio-pm-btn-danger:hover {
	background: #fef2f2;
	border-color: var(--pm-danger-hover);
}

/* App shell */

.freshio-pm-topbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 24px;
	background: var(--pm-surface);
	border-bottom: 1px solid var(--pm-border);
	position: sticky;
	top: 0;
	z-index: 10;
}

.freshio-pm-topbar h1 {
	margin: 0;
	font-size: 18px;
}

.freshio-pm-topbar-right {
	display: flex;
	align-items: center;
	gap: 16px;
	font-size: 14px;
}

.freshio-pm-home {
	color: var(--pm-text-muted);
	text-decoration: none;
	border: 1px solid var(--pm-border);
	border-radius: 6px;
	padding: 4px 10px;
}

.freshio-pm-home:hover {
	color: var(--pm-primary);
	border-color: var(--pm-primary);
}

.freshio-pm-user {
	color: var(--pm-text-muted);
}

.freshio-pm-logout {
	color: var(--pm-primary);
	text-decoration: none;
}

.freshio-pm-logout:hover {
	text-decoration: underline;
}

.freshio-pm-tabs {
	display: flex;
	gap: 4px;
	padding: 16px 24px 0;
	max-width: 1200px;
	margin: 0 auto;
}

.freshio-pm-tab {
	appearance: none;
	border: none;
	background: transparent;
	padding: 10px 4px;
	margin-right: 20px;
	font-size: 14px;
	font-weight: 600;
	color: var(--pm-text-muted);
	cursor: pointer;
	border-bottom: 2px solid transparent;
}

.freshio-pm-tab.is-active {
	color: var(--pm-text);
	border-bottom-color: var(--pm-primary);
}

.freshio-pm-toolbar {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	padding: 16px 24px;
	max-width: 1200px;
	margin: 0 auto;
}

.freshio-pm-toolbar input[type="search"],
.freshio-pm-toolbar select {
	padding: 9px 12px;
	border: 1px solid var(--pm-border);
	border-radius: 8px;
	font-size: 14px;
	background: var(--pm-surface);
}

.freshio-pm-toolbar input[type="search"] {
	flex: 1 1 220px;
	min-width: 160px;
}

.freshio-pm-toolbar #freshio-pm-add-btn {
	margin-left: auto;
}

/* List */

.freshio-pm-list {
	max-width: 1200px;
	margin: 0 auto;
	padding: 0 24px 40px;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
	gap: 14px;
}

.freshio-pm-card {
	background: var(--pm-surface);
	border: 1px solid var(--pm-border);
	border-radius: var(--pm-radius);
	box-shadow: var(--pm-shadow);
	overflow: hidden;
	display: flex;
	flex-direction: column;
}

/* This store's "woocommerce_thumbnail" size is NOT hard-cropped to a
   square -- object-fit: cover was zooming into the center and cutting
   off the edges of every product photo. Use contain within a square
   box so the full image shows, same as the shop page. */
.freshio-pm-card-image {
	width: 100%;
	aspect-ratio: 1 / 1;
	object-fit: contain;
	background: var(--pm-surface);
	display: block;
}

.freshio-pm-card-body {
	padding: 12px 14px 14px;
	display: flex;
	flex-direction: column;
	gap: 6px;
	flex: 1;
}

.freshio-pm-card-title {
	font-size: 14px;
	font-weight: 600;
	margin: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.freshio-pm-card-meta {
	font-size: 12.5px;
	color: var(--pm-text-muted);
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	align-items: center;
}

.freshio-pm-badge {
	display: inline-block;
	padding: 2px 8px;
	border-radius: 999px;
	font-size: 11px;
	font-weight: 600;
}

.freshio-pm-badge-instock {
	background: #f0fdf4;
	color: var(--pm-success);
}

.freshio-pm-badge-outofstock {
	background: #fef2f2;
	color: var(--pm-danger);
}

.freshio-pm-badge-draft {
	background: #f3f4f6;
	color: var(--pm-text-muted);
}

.freshio-pm-card-actions {
	margin-top: auto;
	display: flex;
	gap: 8px;
	padding-top: 8px;
}

.freshio-pm-card-actions .freshio-pm-btn {
	flex: 1;
	padding: 7px 10px;
	font-size: 13px;
}

.freshio-pm-pagination {
	max-width: 1200px;
	margin: 0 auto;
	padding: 4px 24px 40px;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 16px;
	font-size: 13px;
	color: var(--pm-text-muted);
}

.freshio-pm-pagination[hidden] {
	display: none;
}

.freshio-pm-pagination .freshio-pm-btn {
	padding: 6px 14px;
	font-size: 13px;
}

.freshio-pm-empty {
	grid-column: 1 / -1;
	text-align: center;
	color: var(--pm-text-muted);
	padding: 60px 20px;
}

.freshio-pm-loading {
	grid-column: 1 / -1;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	color: var(--pm-text-muted);
	padding: 60px 20px;
	font-size: 14px;
}

.freshio-pm-spinner {
	width: 18px;
	height: 18px;
	border: 2px solid var(--pm-border);
	border-top-color: var(--pm-primary);
	border-radius: 50%;
	animation: freshio-pm-spin 0.7s linear infinite;
}

.freshio-pm-btn-spinner {
	display: inline-block;
	width: 12px;
	height: 12px;
	margin-right: 6px;
	vertical-align: -2px;
	border: 2px solid currentColor;
	border-top-color: transparent;
	border-radius: 50%;
	opacity: 0.7;
	animation: freshio-pm-spin 0.7s linear infinite;
}

.freshio-pm-btn:disabled {
	opacity: 0.7;
	cursor: default;
}

@keyframes freshio-pm-spin {
	to {
		transform: rotate(360deg);
	}
}

.freshio-pm-toolbar {
	position: relative;
}

.freshio-pm-toolbar.is-loading::after {
	content: "";
	position: absolute;
	left: 24px;
	right: 24px;
	bottom: -1px;
	height: 2px;
	background: linear-gradient(90deg, transparent, var(--pm-primary), transparent);
	background-size: 200% 100%;
	animation: freshio-pm-shimmer 1.1s linear infinite;
}

@keyframes freshio-pm-shimmer {
	from {
		background-position: 200% 0;
	}
	to {
		background-position: -200% 0;
	}
}

/* Modal */

.freshio-pm-modal {
	position: fixed;
	inset: 0;
	background: rgba(17, 24, 39, 0.5);
	display: flex;
	align-items: flex-start;
	justify-content: center;
	padding: 40px 16px;
	overflow-y: auto;
	z-index: 100;
}

.freshio-pm-modal[hidden] {
	display: none;
}

.freshio-pm-modal-card {
	background: var(--pm-surface);
	border-radius: var(--pm-radius);
	width: 100%;
	max-width: 520px;
	padding: 28px;
	position: relative;
	box-shadow: 0 10px 40px rgba(16, 24, 40, 0.2);
}

.freshio-pm-modal-close {
	position: absolute;
	top: 16px;
	right: 16px;
	border: none;
	background: transparent;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	color: var(--pm-text-muted);
}

.freshio-pm-modal-close:hover {
	color: var(--pm-text);
}

.freshio-pm-form h2 {
	margin: 0 0 18px;
	font-size: 18px;
}

.freshio-pm-form-row {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin-bottom: 14px;
}

.freshio-pm-form-row-inline {
	flex-direction: row;
	gap: 14px;
}

.freshio-pm-form-row-inline > * {
	flex: 1;
}

.freshio-pm-form-row label,
.freshio-pm-form-row .freshio-pm-form-label {
	font-size: 13px;
	font-weight: 600;
	color: var(--pm-text-muted);
}

.freshio-pm-form-help {
	margin-top: -8px;
	margin-bottom: 14px;
	font-size: 12px;
	line-height: 1.5;
	color: var(--pm-text-muted);
}

.freshio-pm-form-row input[type="text"],
.freshio-pm-form-row input[type="number"],
.freshio-pm-form-row select,
.freshio-pm-form-row textarea {
	font-size: 14px;
	padding: 9px 12px;
	border: 1px solid var(--pm-border);
	border-radius: 8px;
	width: 100%;
	font-family: inherit;
}

.freshio-pm-form-row textarea {
	resize: vertical;
	min-height: 70px;
}

.freshio-pm-checkbox-row {
	flex-direction: row;
	align-items: center;
	gap: 8px;
}

/* Barcode field: text input + camera scan button */
.freshio-pm-barcode-group {
	display: flex;
	gap: 8px;
}

.freshio-pm-barcode-group input {
	flex: 1;
	min-width: 0;
}

.freshio-pm-btn-scan {
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 42px;
	height: 42px;
	padding: 0;
	background: var(--pm-primary);
	border: 0;
	border-radius: 8px;
	color: #fff;
	cursor: pointer;
}

.freshio-pm-btn-scan:hover {
	background: var(--pm-primary-hover);
}

.freshio-pm-btn-scan svg {
	width: 20px;
	height: 20px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
}

/* Full-screen barcode scanner overlay (self-contained -- this panel skips
 * get_header()/get_footer(), so it doesn't share barcode-scanner.css from
 * the storefront scan-to-cart feature even though the same decoder library
 * is used). */
.freshio-pm-scanner-overlay {
	position: fixed;
	inset: 0;
	z-index: 100000;
	background: #000;
	display: none;
	flex-direction: column;
}

.freshio-pm-scanner-overlay.is-open {
	display: flex;
}

.freshio-pm-scanner-overlay__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 16px;
	padding-top: calc(14px + env(safe-area-inset-top));
	color: #fff;
}

.freshio-pm-scanner-overlay__header h2 {
	margin: 0;
	font-size: 16px;
	color: #fff;
}

.freshio-pm-scanner-overlay__close {
	background: none;
	border: 0;
	color: #fff;
	font-size: 28px;
	line-height: 1;
	padding: 4px 8px;
	cursor: pointer;
}

.freshio-pm-scanner-overlay__reader {
	flex: 1;
	width: 100%;
}

.freshio-pm-scanner-overlay__reader video {
	object-fit: cover;
}

.freshio-pm-scanner-overlay__status {
	color: #fff;
	text-align: center;
	padding: 12px 16px 24px;
	min-height: 1.5em;
	font-size: 14px;
}

.freshio-pm-checkbox-row input {
	width: auto;
}

.freshio-pm-category-picker {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 16px;
	max-height: 130px;
	overflow-y: auto;
	border: 1px solid var(--pm-border);
	border-radius: 8px;
	padding: 10px 12px;
}

.freshio-pm-category-picker label {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 13px;
	font-weight: 400;
	color: var(--pm-text);
}

.freshio-pm-category-picker input {
	width: auto;
}

.freshio-pm-image-picker {
	display: flex;
	align-items: center;
	gap: 12px;
}

.freshio-pm-upload-status {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin-top: 8px;
	color: var(--pm-text-muted);
	font-size: 12px;
}

.freshio-pm-upload-status .freshio-pm-spinner {
	width: 14px;
	height: 14px;
	flex: 0 0 auto;
}

.freshio-pm-image-preview {
	width: 64px;
	height: 64px;
	border-radius: 8px;
	object-fit: cover;
	border: 1px solid var(--pm-border);
	background: var(--pm-bg);
}

.freshio-pm-gallery-preview {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 8px;
}

.freshio-pm-gallery-item {
	position: relative;
	width: 56px;
	height: 56px;
}

.freshio-pm-gallery-item img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: 6px;
	border: 1px solid var(--pm-border);
}

.freshio-pm-gallery-item a {
	display: block;
	width: 100%;
	height: 100%;
}

.freshio-pm-gallery-item button {
	position: absolute;
	top: -6px;
	right: -6px;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	border: none;
	background: var(--pm-danger);
	color: #fff;
	font-size: 11px;
	line-height: 1;
	cursor: pointer;
}

.freshio-pm-form-error {
	background: #fef2f2;
	color: var(--pm-danger);
	border-radius: 8px;
	padding: 8px 12px;
	font-size: 13px;
	margin-bottom: 14px;
}

.freshio-pm-form-actions {
	display: flex;
	justify-content: flex-end;
	gap: 10px;
	margin-top: 20px;
}

/* Toast */

.freshio-pm-toast {
	position: fixed;
	bottom: 24px;
	left: 50%;
	transform: translateX(-50%);
	display: flex;
	align-items: center;
	gap: 12px;
	background: #111827;
	color: #fff;
	padding: 10px 18px;
	border-radius: 8px;
	font-size: 13px;
	z-index: 200;
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.freshio-pm-toast[hidden] {
	display: none;
}

.freshio-pm-toast.is-error {
	background: var(--pm-danger);
}

.freshio-pm-toast.is-success {
	background: #15803d;
}

.freshio-pm-toast.is-info {
	background: #ca8a04;
}

.freshio-pm-toast button {
	width: 22px;
	height: 22px;
	padding: 0;
	border: 0;
	background: transparent;
	color: inherit;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
}

@media (max-width: 600px) {
	.freshio-pm-topbar,
	.freshio-pm-tabs,
	.freshio-pm-toolbar,
	.freshio-pm-list {
		padding-left: 16px;
		padding-right: 16px;
	}

	.freshio-pm-toolbar #freshio-pm-add-btn {
		margin-left: 0;
		width: 100%;
	}
}
