/* CSV Manager - wp-admin styling.
 *
 * Visual language follows wp-admin conventions (form-table, button-primary,
 * widefat tables) so the page looks native, but laid out as a single
 * scrollable wizard rather than three separate page loads.
 *
 * Colour palette mirrors the rest of the plugin:
 *   primary   var(--w2dc-primary, #2271b1)
 *   ok-green  #16a34a / bg #dcfce7
 *   err-red   #dc2626 / bg #fee2e2
 *   warn-amb  #d97706 / bg #fef3c7
 *   muted     #6b7280
 */

.w2dc-csv {
	max-width: 1100px;
	font-size: 14px;
	color: #1f2937;
}

/* ---- Two-column page layout (React app + side-rail instructions) ---- */
.w2dc-csv-page--split {
	display: flex;
	gap: 24px;
	align-items: flex-start;
	max-width: 1800px;
}
.w2dc-csv-page__main {
	flex: 6 1 0;
	min-width: 0; /* let the React app collapse / scroll its tables without overflowing the column */
}
.w2dc-csv-page__aside {
	flex: 4 1 0;
	min-width: 0;
}
.w2dc-csv-page__main .w2dc-csv {
	max-width: none; /* the column already caps width */
}
.w2dc-csv-page__aside {
	background: #fff;
	border: 1px solid #c3c4c7;
	border-radius: 4px;
	padding: 14px 18px;
	font-size: 13px;
	line-height: 1.55;
	color: #374151;
}
.w2dc-csv-page__aside h3 {
	margin-top: 0;
}
.w2dc-csv-page__aside p {
	margin: 6px 0;
}

/* Stacked layout below 1024 px - instructions slide BELOW the app
   (it's already after the app in markup order, so flex-direction:
   column does the rest). */
@media (max-width: 1024px) {
	.w2dc-csv-page--split {
		flex-direction: column;
	}
	.w2dc-csv-page__main,
	.w2dc-csv-page__aside {
		flex: 1 1 auto;
		width: 100%;
	}
}

/* ---- Tabs ---- */
.w2dc-csv__tabs {
	display: flex;
	gap: 4px;
	border-bottom: 1px solid #c3c4c7;
	margin-bottom: 16px;
}
.w2dc-csv__tab {
	border: 1px solid transparent;
	border-bottom: 0;
	background: transparent;
	padding: 8px 18px;
	cursor: pointer;
	font-size: 14px;
	color: #2c3338;
	border-radius: 4px 4px 0 0;
}
.w2dc-csv__tab:hover { background: #f0f0f1; }
.w2dc-csv__tab.is-active {
	background: #fff;
	border-color: #c3c4c7;
	border-bottom-color: #fff;
	margin-bottom: -1px;
	font-weight: 600;
}

/* ---- Wizard step block ---- */
.w2dc-csv__step {
	margin-bottom: 18px;
	background: #fff;
	border: 1px solid #c3c4c7;
	border-radius: 4px;
	box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
}
.w2dc-csv__step.is-disabled .w2dc-csv__step-head { cursor: not-allowed; opacity: 0.55; }
.w2dc-csv__step.is-active   { border-color: var(--w2dc-primary, #2271b1); }
.w2dc-csv__step.is-active   .w2dc-csv__step-head { background: #f0f6fc; }
.w2dc-csv__step.is-done     .w2dc-csv__step-mark { color: #16a34a; }

.w2dc-csv__step-head {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px 16px;
	cursor: pointer;
	-webkit-user-select: none;
	   -moz-user-select: none;
	        user-select: none;
	border-bottom: 1px solid transparent;
}
.w2dc-csv__step.is-active .w2dc-csv__step-head { border-bottom-color: #c3c4c7; }
.w2dc-csv__step-num {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	background: #6b7280;
	color: #fff;
	font-size: 13px;
	font-weight: 600;
}
.w2dc-csv__step.is-active .w2dc-csv__step-num { background: var(--w2dc-primary, #2271b1); }
.w2dc-csv__step.is-done   .w2dc-csv__step-num { background: #16a34a; }
.w2dc-csv__step-title { font-size: 15px; font-weight: 600; flex: 1; }
.w2dc-csv__step-mark  { font-size: 18px; }
.w2dc-csv__step-body  { padding: 16px; }
.w2dc-csv__step:not(.is-active) .w2dc-csv__step-body { padding: 8px 16px; color: #6b7280; }

/* ---- Form layout ---- */
.w2dc-csv__form { display: flex; flex-direction: column; gap: 14px; }
.w2dc-csv__row {
	display: grid;
	grid-template-columns: 220px 1fr;
	gap: 16px;
	align-items: start;
}
.w2dc-csv__label {
	font-weight: 600;
	padding-top: 6px;
}
.w2dc-csv__field { display: flex; flex-direction: column; gap: 6px; }
.w2dc-csv__radio,
.w2dc-csv__check {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin-right: 14px;
	cursor: pointer;
}
/* Radio + checkbox tints, focus ring, and `.button-primary`
 * recolour live in `classes/settings/css_vars.php` ->
 * `w2dc_emit_form_control_styles()`. That helper emits one
 * `<style id="w2dc-form-controls">` block in `wp_head` AND
 * `admin_head`, scoped to every plugin-managed container
 * (.w2dc-csv included) so the customization-colour palette
 * applies uniformly across admin + frontend. Per-page overrides
 * removed from here to avoid two sources of truth. */
.w2dc-csv__hint  { color: #6b7280; }
.w2dc-csv__muted { color: #9ca3af; }
.w2dc-csv__sep-input {
	width: 50px;
	font-family: monospace;
	text-align: center;
}
.w2dc-csv__filelist {
	margin: 4px 0 0;
	padding-left: 18px;
	color: #374151;
}
.w2dc-csv__error {
	background: #fee2e2;
	border: 1px solid #fecaca;
	color: #991b1b;
	padding: 10px 12px;
	border-radius: 4px;
}

/* Server PHP-ini panel - small info row above the upload button so
 * the operator can see the relevant ceilings BEFORE attempting an
 * upload that would otherwise drop on `post_max_size`. */
.w2dc-csv__limits {
	background: #f0f6fc;
	border: 1px solid #bfdbfe;
	color: #1e3a8a;
	padding: 8px 12px;
	border-radius: 4px;
	font-size: 12px;
	line-height: 1.5;
}
.w2dc-csv__limits code {
	background: rgba(37, 99, 235, 0.08);
	padding: 1px 5px;
	border-radius: 3px;
	font-size: 11px;
}
.w2dc-csv__limit-bad {
	color: #b91c1c;
	font-weight: 600;
	margin-left: 4px;
}
.w2dc-csv__actions {
	display: flex;
	gap: 8px;
	padding-top: 6px;
}

/* ---- Mapping table ---- */
.w2dc-csv__map-table { margin-bottom: 16px; }
.w2dc-csv__map-table td,
.w2dc-csv__map-table th { padding: 6px 10px; vertical-align: middle; }
.w2dc-csv__map-table select { width: 100%; max-width: 360px; }
.w2dc-csv__map-sample {
	color: #6b7280;
	font-style: italic;
	max-width: 220px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* ---- Diagnostic row ---- */
.w2dc-csv__diag {
	margin-top: 8px;
	padding: 8px 12px;
	border-radius: 4px;
	font-size: 13px;
}
.w2dc-csv__diag-ok   { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.w2dc-csv__diag-warn { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.w2dc-csv__diag-err  { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* ---- Run / progress ---- */
.w2dc-csv__run { display: flex; flex-direction: column; gap: 14px; }
.w2dc-csv__progress {
	position: relative;
	height: 28px;
	background: #f3f4f6;
	border: 1px solid #c3c4c7;
	border-radius: 4px;
	overflow: hidden;
}
.w2dc-csv__progress-bar {
	height: 100%;
	background: var(--w2dc-primary, #2271b1);
	transition: width 0.18s ease;
}
.w2dc-csv__progress-text {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 600;
	color: #1f2937;
	mix-blend-mode: difference;
	font-size: 13px;
}
.w2dc-csv__stats {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
}
.w2dc-csv__stat {
	flex: 1 1 140px;
	background: #f9fafb;
	border: 1px solid #e5e7eb;
	border-radius: 4px;
	padding: 8px 12px;
}
.w2dc-csv__stat-value { font-size: 18px; font-weight: 600; color: #111827; }
.w2dc-csv__stat-label { font-size: 11px; text-transform: uppercase; color: #6b7280; letter-spacing: 0.4px; }
.w2dc-csv__stat.is-err .w2dc-csv__stat-value { color: #b91c1c; }
/* Text-mode stat (e.g. "Last batch: 379 rows · 25.4s · next 373") -
 * needs more room and must NOT wrap mid-sentence. We claim a wider
 * flex-basis so the stat-row gives it priority, shrink the value's
 * font, and clip with an ellipsis only if even the wider basis isn't
 * enough (extreme edge case at very narrow viewports). */
.w2dc-csv__stat.is-text { flex-basis: 320px; }
.w2dc-csv__stat.is-text .w2dc-csv__stat-value {
	font-size: 14px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.w2dc-csv__errlist {
	background: #fef2f2;
	border: 1px solid #fecaca;
	border-radius: 4px;
	padding: 8px 12px;
}
.w2dc-csv__errlist summary { cursor: pointer; color: #991b1b; font-weight: 600; }
.w2dc-csv__errlist ul {
	margin: 8px 0 0 18px;
	font-size: 13px;
	color: #991b1b;
}

.w2dc-csv__placeholder {
	background: #f9fafb;
	border: 1px dashed #d1d5db;
	border-radius: 6px;
	padding: 24px;
	color: #4b5563;
}

.w2dc-csv__summary {
	background: #f9fafb;
	border: 1px solid #e5e7eb;
	padding: 8px 12px;
	border-radius: 4px;
	display: flex;
	justify-content: space-between;
	align-items: center;
}

/* Resume panel - surfaced at the top of Step 1 when the server
 * reports on-disk sessions this user owns but the wizard isn't
 * actively pointed at one. Light blue accent distinguishes it from
 * the main upload form below without being alarming (this isn't an
 * error - it's an offer). */
.w2dc-csv__resume-panel {
	background: #eff6ff;
	border: 1px solid #bfdbfe;
	border-radius: 6px;
	padding: 12px 16px 14px;
	margin: 0 0 16px;
}
.w2dc-csv__resume-title {
	margin: 0 0 4px;
	font-size: 14px;
	font-weight: 600;
	color: #1e3a8a;
}
.w2dc-csv__resume-hint {
	margin: 0 0 10px;
	font-size: 12px;
	color: #475569;
}
.w2dc-csv__resume-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 6px;
}
.w2dc-csv__resume-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	background: #fff;
	border: 1px solid #dbeafe;
	border-radius: 4px;
	padding: 8px 10px;
}
.w2dc-csv__resume-meta {
	display: flex;
	flex-wrap: wrap;
	gap: 4px 10px;
	font-size: 12px;
	color: #334155;
	min-width: 0;
	flex: 1 1 auto;
}
.w2dc-csv__resume-id {
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	color: #2563eb;
	font-weight: 600;
}
.w2dc-csv__resume-type {
	background: #e0e7ff;
	color: #3730a3;
	padding: 0 6px;
	border-radius: 2px;
}
.w2dc-csv__resume-progress {
	color: #0d9488;
	font-weight: 500;
}
.w2dc-csv__resume-actions {
	display: flex;
	align-items: center;
	gap: 8px;
	flex: 0 0 auto;
}

/* ===== Export panel ===== */
.w2dc-csv-export {
	max-width: 920px;
}
.w2dc-csv-export .muted {
	color: #6b7280;
	font-size: 12px;
}
.w2dc-csv-export__section {
	margin: 18px 0;
	background: #f9fafb;
	border: 1px solid #e5e7eb;
	border-radius: 6px;
	padding: 12px 14px;
}
.w2dc-csv-export__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 8px;
	font-size: 13px;
}
.w2dc-csv-export__actions {
	display: flex;
	gap: 4px;
}
.w2dc-csv-export__actions button {
	font-size: 11px;
	padding: 2px 8px;
	background: #fff;
	border: 1px solid #d1d5db;
	border-radius: 3px;
	cursor: pointer;
}
.w2dc-csv-export__actions button:hover {
	border-color: #2563eb;
	color: #2563eb;
}
.w2dc-csv-export__cols {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
	gap: 4px 12px;
	max-height: 320px;
	overflow-y: auto;
	padding: 4px;
	background: #fff;
	border: 1px solid #e5e7eb;
	border-radius: 4px;
}
.w2dc-csv-export__col {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 4px 8px;
	font-size: 13px;
	cursor: pointer;
	border-radius: 3px;
}
.w2dc-csv-export__col:hover {
	background: #f3f4f6;
}
.w2dc-csv-export__col input[type="checkbox"] {
	flex: 0 0 auto;
	margin: 0;
}
.w2dc-csv-export__col-label {
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.w2dc-csv-export__col-slug {
	font-size: 10px;
	color: #9ca3af;
	background: #f3f4f6;
	padding: 1px 5px;
	border-radius: 2px;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.w2dc-csv-export__filters {
	display: flex;
	flex-wrap: wrap;
	gap: 14px;
}
.w2dc-csv-export__filters label {
	display: flex;
	flex-direction: column;
	gap: 4px;
	font-size: 12px;
	color: #374151;
}
.w2dc-csv-export__filters label > span {
	font-weight: 500;
}
.w2dc-csv-export__filters textarea {
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 12px;
	min-width: 280px;
	min-height: 40px;
	padding: 6px 8px;
	border: 1px solid #d1d5db;
	border-radius: 3px;
}
.w2dc-csv-export__run {
	display: flex;
	align-items: center;
	gap: 14px;
	margin-top: 20px;
	flex-wrap: wrap;
}
.w2dc-csv-export__progressbar {
	flex: 1 1 240px;
	max-width: 480px;
}
.w2dc-csv-export__error {
	color: #b91c1c;
	font-size: 13px;
}
.w2dc-csv-export__result {
	color: #047857;
	font-size: 13px;
}
.w2dc-csv-export__result a {
	color: #2563eb;
	text-decoration: underline;
}

