/**
 * Automotive Inventory Importer — admin styles
 *
 * Extracted from inline <style> blocks and expanded with a small, consistent
 * design system (cards, status panel, setup steps, log summary, token preview).
 * Loaded only on the plugin's settings screen and the dashboard widget.
 */

/* --- Design tokens --------------------------------------------------------- */
:root {
	--afi-brand: #2271b1;
	--afi-brand-dark: #135e96;
	--afi-ok: #00a32a;
	--afi-warn: #dba617;
	--afi-bad: #d63638;
	--afi-ink: #1d2327;
	--afi-muted: #646970;
	--afi-line: #ccd0d4;
	--afi-soft: #f6f7f7;
	--afi-radius: 6px;
	--afi-gap: 16px;
}

/* --- Layout shell ---------------------------------------------------------- */
.afi-tab-content {
	background: #fff;
	padding: 20px;
	border: 1px solid var(--afi-line);
	border-top: none;
	margin-top: 0;
}

.nav-tab-wrapper {
	margin-bottom: 0 !important;
}

.afi-settings-layout {
	display: flex;
	gap: 20px;
	align-items: flex-start;
	flex-wrap: wrap;
}

.afi-settings-main {
	flex: 1 1 0;
	min-width: 0;
}

.afi-settings-sidebar {
	flex: 0 0 280px;
	max-width: 100%;
}

@media (max-width: 900px) {
	.afi-settings-layout {
		flex-direction: column;
	}

	.afi-settings-sidebar {
		flex: 1 1 auto;
	}
}

/* --- Status panel (top of every tab) -------------------------------------- */
.afi-status-panel {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	margin: 0 0 18px;
}

.afi-status-card {
	flex: 1 1 160px;
	background: #fff;
	border: 1px solid var(--afi-line);
	border-left: 4px solid var(--afi-brand);
	border-radius: var(--afi-radius);
	padding: 12px 16px;
	min-width: 150px;
}

.afi-status-card.is-ok {
	border-left-color: var(--afi-ok);
}

.afi-status-card.is-warn {
	border-left-color: var(--afi-warn);
}

.afi-status-card.is-bad {
	border-left-color: var(--afi-bad);
}

.afi-status-label {
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: .03em;
	color: var(--afi-muted);
	margin: 0 0 4px;
}

.afi-status-value {
	font-size: 16px;
	font-weight: 700;
	color: var(--afi-ink);
	line-height: 1.25;
}

.afi-status-value .afi-dot {
	display: inline-block;
	width: 9px;
	height: 9px;
	border-radius: 50%;
	margin-right: 6px;
	vertical-align: baseline;
	background: var(--afi-muted);
}

.afi-status-card.is-ok .afi-dot {
	background: var(--afi-ok);
}

.afi-status-card.is-warn .afi-dot {
	background: var(--afi-warn);
}

.afi-status-card.is-bad .afi-dot {
	background: var(--afi-bad);
}

.afi-status-sub {
	font-size: 12px;
	color: var(--afi-muted);
	margin: 2px 0 0;
}

/* --- Setup steps (first-run guidance) ------------------------------------- */
.afi-steps {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin: 0 0 18px;
	padding: 0;
	list-style: none;
	counter-reset: afi-step;
}

.afi-steps li {
	flex: 1 1 180px;
	position: relative;
	background: var(--afi-soft);
	border: 1px solid #dcdcde;
	border-radius: var(--afi-radius);
	padding: 10px 12px 10px 42px;
	min-width: 170px;
}

.afi-steps li::before {
	counter-increment: afi-step;
	content: counter(afi-step);
	position: absolute;
	left: 10px;
	top: 50%;
	transform: translateY(-50%);
	width: 24px;
	height: 24px;
	border-radius: 50%;
	background: #c3c4c7;
	color: #fff;
	font-weight: 700;
	font-size: 13px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.afi-steps li.is-done::before {
	content: "\2713";
	background: var(--afi-ok);
}

.afi-steps li.is-current {
	border-color: var(--afi-brand);
	box-shadow: 0 0 0 1px var(--afi-brand) inset;
}

.afi-steps li.is-current::before {
	background: var(--afi-brand);
}

.afi-step-title {
	font-weight: 600;
	display: block;
}

.afi-step-sub {
	font-size: 12px;
	color: var(--afi-muted);
}

.afi-step-action {
	margin-top: 4px !important;
}

/* --- Unique-ID callout (mapping tab) -------------------------------------- */
.afi-uid-callout {
	background: #fff8e5;
	border: 1px solid #f0e2b6;
	border-left: 4px solid var(--afi-warn);
	border-radius: var(--afi-radius);
	padding: 14px 16px;
	margin: 16px 0;
}

.afi-uid-callout.is-set {
	background: #edfaef;
	border-color: #b8e6c0;
	border-left-color: var(--afi-ok);
}

.afi-uid-callout h3 {
	margin: 0 0 6px;
	font-size: 14px;
}

.afi-uid-callout p {
	margin: 0 0 8px;
}

.afi-uid-callout select {
	min-width: 240px;
}

/* --- Feed link test feedback ---------------------------------------------- */
.afi-input-row {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 8px;
}

.afi-feed-test-result {
	margin: 8px 0 0;
	font-weight: 600;
	display: none;
}

.afi-feed-test-result.is-ok {
	color: var(--afi-ok);
	display: block;
}

.afi-feed-test-result.is-bad {
	color: var(--afi-bad);
	display: block;
}

.afi-feed-test-result.is-busy {
	color: var(--afi-muted);
	display: block;
}

/* --- Sync blocking overlay ------------------------------------------------ */
.afi-sync-overlay {
	position: fixed;
	inset: 0;
	z-index: 100050; /* above WP admin bar + thickbox */
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(29, 35, 39, 0.72);
	padding: 20px;
}

.afi-sync-overlay__box {
	background: #fff;
	border-radius: 10px;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
	padding: 32px 36px;
	max-width: 420px;
	text-align: center;
}

.afi-sync-overlay__box h2 {
	margin: 18px 0 8px;
	font-size: 20px;
}

.afi-sync-overlay__box p {
	margin: 0;
	color: var(--afi-muted);
	font-size: 14px;
	line-height: 1.5;
}

.afi-spinner {
	width: 46px;
	height: 46px;
	margin: 0 auto;
	border: 4px solid #e2e4e7;
	border-top-color: var(--afi-brand);
	border-radius: 50%;
	animation: afi-spin 0.9s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
	.afi-spinner { animation-duration: 2.4s; }
}

/* --- Log summary ----------------------------------------------------------- */
.afi-log-summary {
	margin: 0 0 16px;
}

.afi-log-summary h3 {
	margin: 0 0 8px;
}

.afi-log-stats {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	margin-bottom: 12px;
}

.afi-log-issues {
	background: #fcf0f1;
	border: 1px solid #f1c0c2;
	border-left: 4px solid var(--afi-bad);
	border-radius: var(--afi-radius);
	padding: 12px 16px;
	margin: 12px 0;
}

.afi-log-issues h4 {
	margin: 0 0 8px;
	color: var(--afi-bad);
}

.afi-log-issues ul {
	margin: 0 0 0 18px;
	list-style: disc;
}

.afi-log-issues li {
	margin-bottom: 4px;
}

.afi-log-clean {
	background: #edfaef;
	border: 1px solid #b8e6c0;
	border-left: 4px solid var(--afi-ok);
	border-radius: var(--afi-radius);
	padding: 12px 16px;
	margin: 12px 0;
}

.afi-log-details {
	margin-top: 12px;
}

.afi-log-details > summary {
	cursor: pointer;
	color: var(--afi-brand);
	font-weight: 600;
}

.afi-log-pre {
	margin: 10px 0 0;
	white-space: pre-wrap;
	font-size: 12px;
	line-height: 1.6;
	background: var(--afi-soft);
	border: 1px solid #dcdcde;
	border-radius: var(--afi-radius);
	padding: 12px;
	max-height: 420px;
	overflow: auto;
}

.afi-log-pre .afi-log-error {
	color: var(--afi-bad);
	font-weight: 600;
}

/* --- Token preview (page templates) --------------------------------------- */
.afi-token-preview {
	margin: 6px 0 0;
	padding: 8px 12px;
	background: var(--afi-soft);
	border: 1px solid #dcdcde;
	border-radius: var(--afi-radius);
	font-size: 13px;
}

.afi-token-preview .afi-preview-label {
	color: var(--afi-muted);
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: .03em;
	display: block;
	margin-bottom: 2px;
}

/* --- Pro hint (subtle, contextual) ---------------------------------------- */
.afi-pro-hint {
	display: inline-block;
	font-size: 11px;
	font-weight: 600;
	color: var(--afi-brand-dark);
	background: #eaf2fb;
	border: 1px solid #c5dcf2;
	border-radius: 10px;
	padding: 1px 8px;
	margin-left: 6px;
	vertical-align: middle;
}

/* --- Quick Start Guide ----------------------------------------------------- */
.afi-qsg-card {
	background: #fff;
	border: 1px solid var(--afi-line);
	border-left: 4px solid var(--afi-brand);
	border-radius: var(--afi-radius);
	padding: 12px 15px 15px;
}

.afi-qsg-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
}

.afi-qsg-header h3 {
	margin: 0;
	font-size: 14px;
}

.afi-qsg-actions {
	display: flex;
	gap: 2px;
	flex: 0 0 auto;
}

.afi-qsg-actions button {
	background: none;
	border: none;
	cursor: pointer;
	color: var(--afi-muted);
	font-size: 16px;
	line-height: 1;
	padding: 4px 6px;
	border-radius: 3px;
}

.afi-qsg-actions button:hover {
	background: #f0f0f1;
	color: var(--afi-brand-dark);
}

.afi-qsg-body ol {
	margin: 12px 0;
	padding-left: 18px;
}

.afi-qsg-body li {
	margin-bottom: 8px;
}

.afi-qsg-pro {
	background: var(--afi-soft);
	border: 1px solid #dcdcde;
	border-radius: 4px;
	padding: 10px 12px;
	margin: 12px 0;
}

.afi-qsg-pro-title {
	margin: 0 0 6px;
	font-weight: 600;
}

.afi-qsg-pro ul {
	margin: 0 0 4px;
	padding-left: 18px;
	list-style: disc;
}

.afi-qsg-pro li {
	margin-bottom: 5px;
}

.afi-qsg-tip {
	color: var(--afi-muted);
	margin-bottom: 0;
}

/* --- File browser modal ---------------------------------------------------- */
#afi-file-browser-modal {
	padding: 20px;
}

.afi-file-list {
	list-style: none;
	padding: 0;
	margin: 10px 0;
	max-height: 400px;
	overflow-y: auto;
	border: 1px solid #ddd;
	background: #fff;
}

.afi-file-list li {
	padding: 8px 12px;
	border-bottom: 1px solid #f0f0f0;
	cursor: pointer;
}

.afi-file-list li:hover {
	background: #f0f0f0;
}

.afi-folder-item {
	color: var(--afi-brand);
	font-weight: 600;
}

.afi-file-item {
	color: #333;
}

.afi-current-path {
	padding: 10px;
	background: #f5f5f5;
	margin-bottom: 10px;
	font-family: monospace;
	word-break: break-all;
}

/* --- Dashboard widget ------------------------------------------------------ */
.afi-dash-widget .afi-status-panel {
	margin-bottom: 12px;
}

.afi-dash-widget .afi-status-card {
	flex: 1 1 120px;
	min-width: 110px;
}
