/**
 * Gang sheet builder and upload workflow.
 *
 * Uses the DECOVINK design tokens defined by the child theme so the two
 * workflows sit inside the existing visual system rather than beside it. No
 * token is redefined here and no existing selector is restyled.
 */

.dvg {
	--dvg-line: var(--dv-line, #E4E0DF);
	--dvg-ink: var(--dv-ink, #161616);
	--dvg-muted: var(--dv-ink-muted, #57514F);
	--dvg-accent: var(--dv-accent, #E30613);
	--dvg-surface: var(--dv-surface, #FAFAFA);
	--dvg-radius: var(--dv-r-md, 12px);
	font-family: var(--dv-font, system-ui, sans-serif);
	color: var(--dvg-ink);
}

.dvg *, .dvg *::before, .dvg *::after { box-sizing: border-box; }

.dvg-closed {
	padding: 32px;
	border: 1px dashed var(--dv-line, #E4E0DF);
	border-radius: 12px;
	background: var(--dv-surface, #FAFAFA);
	text-align: center;
	color: var(--dv-ink-muted, #57514F);
}

.dvg-devnotice {
	margin: 0 0 16px;
	padding: 10px 14px;
	border: 1px dashed var(--dvg-accent);
	border-radius: 8px;
	background: var(--dvg-surface);
	font-size: 0.875rem;
	color: var(--dvg-muted);
}

.dvg-sr {
	position: absolute; width: 1px; height: 1px; overflow: hidden;
	clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------------------------------------------------------------- controls */

.dvg-label {
	display: block;
	font-size: 0.8125rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	color: var(--dvg-muted);
	margin-bottom: 6px;
}

.dvg-select,
.dvg-input {
	width: 100%;
	padding: 10px 12px;
	border: 1px solid var(--dvg-line);
	border-radius: 8px;
	background: #fff;
	color: var(--dvg-ink);
	font: inherit;
	font-size: 0.9375rem;
}

.dvg-input--qty { max-width: 120px; }

.dvg-select:focus-visible,
.dvg-input:focus-visible,
.dvg-btn:focus-visible,
.dvg-item:focus-visible,
.dvg-drop:focus-visible,
.dvg-size:focus-visible {
	outline: 2px solid var(--dvg-accent);
	outline-offset: 2px;
}

.dvg-hint, .dvg-note, .dvg-fineprint, .dvg-muted {
	color: var(--dvg-muted);
	font-size: 0.8125rem;
	line-height: 1.55;
	margin: 6px 0 0;
}

.dvg-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 10px 16px;
	border: 1px solid var(--dvg-ink);
	border-radius: 999px;
	background: #fff;
	color: var(--dvg-ink);
	font: inherit;
	font-weight: 700;
	font-size: 0.875rem;
	cursor: pointer;
	transition: background .15s, color .15s, border-color .15s;
}

.dvg-btn:hover:not(:disabled) { background: var(--dvg-ink); color: #fff; }
.dvg-btn:disabled { opacity: .45; cursor: not-allowed; }

.dvg-btn--primary { background: var(--dvg-accent); border-color: var(--dvg-accent); color: #fff; }
.dvg-btn--primary:hover:not(:disabled) { background: var(--dv-accent-hover, #C1050F); border-color: var(--dv-accent-hover, #C1050F); }
.dvg-btn--ghost { border-color: var(--dvg-line); font-weight: 500; }
.dvg-btn--danger:hover:not(:disabled) { background: var(--dvg-accent); border-color: var(--dvg-accent); }
.dvg-btn--block { display: flex; width: 100%; }
.dvg-btn--sm { padding: 6px 12px; font-size: 0.8125rem; }
.dvg-btn--icon { width: 34px; height: 34px; padding: 0; font-size: 1.125rem; line-height: 1; }

.dvg-error {
	margin: 12px 0 0;
	padding: 10px 12px;
	border-left: 3px solid var(--dvg-accent);
	background: #FDF2F3;
	color: #8A0510;
	font-size: 0.875rem;
	line-height: 1.5;
}

/* -------------------------------------------------------------- top bar */

.dvg-bar {
	display: grid;
	gap: 16px;
	padding: 16px;
	margin-bottom: 16px;
	border: 1px solid var(--dvg-line);
	border-radius: var(--dvg-radius);
	background: var(--dvg-surface);
}

@media (min-width: 800px) {
	.dvg-bar { grid-template-columns: 2fr 1fr auto; align-items: start; }
	.dvg-bar__group--actions { display: flex; gap: 8px; align-self: end; }
}

/* ------------------------------------------------------------ workspace */

.dvg-work { display: grid; gap: 16px; }

@media (min-width: 1100px) {
	.dvg-work { grid-template-columns: 260px minmax(0, 1fr) 320px; align-items: start; }
}

.dvg-side, .dvg-panel {
	padding: 16px;
	border: 1px solid var(--dvg-line);
	border-radius: var(--dvg-radius);
	background: #fff;
}

.dvg-side__title, .dvg-panel__title {
	margin: 0 0 12px;
	font-size: 1rem;
	font-weight: 800;
}

/* ------------------------------------------------------------------ drop */

.dvg-drop {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	padding: 24px 16px;
	border: 2px dashed var(--dvg-line);
	border-radius: var(--dvg-radius);
	background: var(--dvg-surface);
	text-align: center;
	cursor: pointer;
	transition: border-color .15s, background .15s;
}

.dvg-drop:hover, .dvg-drop.is-over { border-color: var(--dvg-accent); background: #fff; }
.dvg-drop__icon { font-size: 1.5rem; color: var(--dvg-accent); line-height: 1; }
.dvg-drop__text { font-weight: 700; font-size: 0.9375rem; }
.dvg-drop__note { font-size: 0.75rem; color: var(--dvg-muted); }

/* --------------------------------------------------------------- library */

.dvg-library { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 8px; }

.dvg-lib {
	display: grid;
	grid-template-columns: 44px minmax(0, 1fr);
	gap: 10px;
	align-items: center;
	padding: 8px;
	border: 1px solid var(--dvg-line);
	border-radius: 8px;
}

.dvg-lib > .dvg-btn { grid-column: 1 / -1; }
.dvg-lib.is-error { border-color: var(--dvg-accent); }
.dvg-lib__thumb {
	width: 44px; height: 44px;
	display: grid; place-items: center;
	border-radius: 6px;
	background:
		linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%) 0 0/12px 12px,
		linear-gradient(45deg, #eee 25%, #fff 25%, #fff 75%, #eee 75%) 6px 6px/12px 12px;
	overflow: hidden;
}
.dvg-lib__thumb img { max-width: 100%; max-height: 100%; display: block; }
.dvg-lib__body { min-width: 0; }
.dvg-lib__name {
	display: block; font-size: 0.8125rem; font-weight: 700;
	overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dvg-lib__note { display: block; font-size: 0.75rem; color: var(--dvg-muted); }

/* ---------------------------------------------------------------- canvas */

.dvg-canvas-wrap {
	border: 1px solid var(--dvg-line);
	border-radius: var(--dvg-radius);
	background: var(--dvg-surface);
	padding: 12px;
}

.dvg-canvas-scroll { overflow: auto; max-height: 70vh; }

.dvg-sheet {
	position: relative;
	margin: 0 auto;
	background: #fff;
	border: 1px solid var(--dvg-line);
	box-shadow: 0 1px 4px rgba(0,0,0,.08);
	touch-action: none;
}

/* The printable area. Anything outside this is trim. */
.dvg-sheet__safe {
	position: absolute;
	border: 1px dashed rgba(227,6,19,.45);
	pointer-events: none;
}

.dvg-item {
	position: absolute;
	border: 1px solid transparent;
	cursor: grab;
	display: grid;
	place-items: center;
	overflow: visible;
}

.dvg-item img {
	position: absolute;
	top: 50%; left: 50%;
	transform-origin: center center;
	pointer-events: none;
	user-select: none;
}

.dvg-item.is-selected { border-color: var(--dvg-accent); box-shadow: 0 0 0 1px var(--dvg-accent); }
.dvg-item.is-dragging { cursor: grabbing; opacity: .85; }
.dvg-item.is-over { border-color: #C1050F; background: rgba(227,6,19,.12); }

.dvg-item__handle {
	position: absolute;
	right: -6px; bottom: -6px;
	width: 14px; height: 14px;
	border: 1px solid var(--dvg-accent);
	border-radius: 3px;
	background: #fff;
	cursor: nwse-resize;
	display: none;
}
.dvg-item.is-selected .dvg-item__handle { display: block; }

.dvg-zoom {
	display: flex; align-items: center; justify-content: center; gap: 10px;
	margin-top: 10px;
}
.dvg-zoom__val { font-size: 0.8125rem; color: var(--dvg-muted); min-width: 48px; text-align: center; }

/* ------------------------------------------------------- selected panel */

.dvg-selected__name {
	margin: 0 0 10px; font-weight: 700; font-size: 0.875rem;
	overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.dvg-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.dvg-field { display: block; font-size: 0.75rem; color: var(--dvg-muted); }
.dvg-field span { display: block; margin-bottom: 4px; }
.dvg-field input {
	width: 100%; padding: 8px 10px;
	border: 1px solid var(--dvg-line); border-radius: 8px;
	font: inherit; font-size: 0.875rem; color: var(--dvg-ink);
}

.dvg-rowbtns { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }

.dvg-dpi {
	margin: 10px 0 0; padding: 8px 10px;
	border-radius: 6px; background: var(--dvg-surface);
	font-size: 0.8125rem; color: var(--dvg-muted);
}
.dvg-dpi--ok   { background: #FFF8E6; color: #6B4E00; }
.dvg-dpi--low  { background: #FDF2F3; color: #8A0510; }

.dvg-check { display: flex; gap: 8px; align-items: flex-start; font-size: 0.8125rem; line-height: 1.5; }
.dvg-check--inline { margin: 10px 0; }
.dvg-check input { margin-top: 2px; flex: none; }

.dvg-ack {
	margin: 12px 0;
	padding: 10px 12px;
	border: 1px solid var(--dvg-line);
	border-radius: 8px;
	background: var(--dvg-surface);
}

/* --------------------------------------------------------------- summary */

.dvg-sum { margin: 16px 0 0; }
.dvg-sum__row {
	display: flex; justify-content: space-between; gap: 12px;
	padding: 7px 0; border-bottom: 1px solid var(--dvg-line);
	font-size: 0.875rem;
}
.dvg-sum__row dt { color: var(--dvg-muted); margin: 0; }
.dvg-sum__row dd { margin: 0; font-weight: 700; text-align: right; }
.dvg-sum__row--total { border-bottom: 0; padding-top: 12px; font-size: 1.125rem; }
.dvg-sum__row--total dt { color: var(--dvg-ink); font-weight: 800; }
.dvg-sum__row--total dd { color: var(--dvg-accent); font-weight: 800; }

.dvg-tip {
	margin: 10px 0 0; padding: 10px 12px;
	border-radius: 8px; background: #FFF8E6;
	color: #6B4E00; font-size: 0.8125rem; line-height: 1.55;
}

/* ---------------------------------------------------------------- upload */

.dvg-up { display: grid; gap: 16px; }

@media (min-width: 1000px) {
	.dvg-up { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
}

.dvg-up__main {
	padding: 16px;
	border: 1px solid var(--dvg-line);
	border-radius: var(--dvg-radius);
	background: #fff;
}

.dvg-step {
	display: flex; align-items: center; gap: 10px;
	margin: 20px 0 12px; font-size: 1rem; font-weight: 800;
}
.dvg-step:first-child { margin-top: 0; }
.dvg-step span {
	display: grid; place-items: center;
	width: 26px; height: 26px; border-radius: 999px;
	background: var(--dvg-accent); color: #fff;
	font-size: 0.8125rem; font-weight: 700;
}

.dvg-sizes { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }

.dvg-size {
	display: grid; gap: 2px;
	padding: 10px 12px; text-align: left;
	border: 1px solid var(--dvg-line); border-radius: 10px;
	background: #fff; cursor: pointer; font: inherit;
}
.dvg-size:hover { border-color: var(--dvg-ink); }
.dvg-size.is-on { border-color: var(--dvg-accent); box-shadow: 0 0 0 1px var(--dvg-accent); }
.dvg-size__label { font-weight: 700; font-size: 0.875rem; }
.dvg-size__dim { font-size: 0.75rem; color: var(--dvg-muted); }
.dvg-size__price { font-size: 0.875rem; font-weight: 700; color: var(--dvg-accent); }

.dvg-preview { margin-top: 16px; }
.dvg-prev { display: grid; grid-template-columns: 120px minmax(0,1fr); gap: 14px; align-items: center; }
.dvg-prev__img {
	width: 120px; height: auto; max-height: 260px; object-fit: contain;
	border: 1px solid var(--dvg-line); border-radius: 8px; background: #fff;
}
.dvg-prev__none {
	padding: 16px; border: 1px dashed var(--dvg-line); border-radius: 8px;
	font-size: 0.8125rem; color: var(--dvg-muted);
}
.dvg-prev__name { margin: 0 0 4px; font-weight: 700; font-size: 0.875rem; word-break: break-word; }

.dvg-checks { margin-top: 16px; }
.dvg-checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.dvg-checklist li {
	display: flex; gap: 10px; align-items: flex-start;
	padding: 10px 12px; border-radius: 8px;
	background: var(--dvg-surface); font-size: 0.8125rem; line-height: 1.5;
}
.dvg-checklist__mark {
	flex: none; width: 20px; height: 20px; border-radius: 999px;
	display: grid; place-items: center; font-size: 0.75rem; font-weight: 700; color: #fff;
}
.dvg-checklist .is-ok .dvg-checklist__mark,
.dvg-checklist li.is-ok .dvg-checklist__mark { background: #1B7F3B; }
.dvg-checklist li.is-warn { background: #FDF2F3; }
.dvg-checklist li.is-warn .dvg-checklist__mark { background: var(--dvg-accent); }
.dvg-checklist li.is-unknown .dvg-checklist__mark { background: var(--dvg-muted); }

/* ---------------------------------------------------------------- mobile */

@media (max-width: 1099px) {
	/* A phone cannot show a library, a 22 inch sheet and a control panel at
	   once, so they stack and the canvas keeps a workable height instead of
	   being squeezed into a strip. */
	.dvg-canvas-scroll { max-height: 55vh; }
	/* The sticky summary that used to live here covered the canvas. Replaced
	   by .dvg-mbar further down this file. */
}

@media (max-width: 640px) {
	.dvg-bar { padding: 12px; }
	.dvg-fields { grid-template-columns: 1fr; }
	.dvg-rowbtns .dvg-btn { flex: 1 1 auto; }
	.dvg-prev { grid-template-columns: 1fr; }
	.dvg-prev__img { width: 100%; max-height: 200px; }
	/* Touch targets stay comfortable. */
	.dvg-item__handle { width: 20px; height: 20px; right: -10px; bottom: -10px; }
}

@media (prefers-reduced-motion: reduce) {
	.dvg-btn, .dvg-drop { transition: none; }
}

/* =========================================================================
 * Phase F.1 additions
 * ====================================================================== */

/* ---------------------------------------------------------- rate card */

.dvg-card { margin: 0; }
.dvg-card__scroll {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	border: 1px solid var(--dvg-line, #E4E0DF);
	border-radius: 12px;
	background: #fff;
}
.dvg-card__table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.dvg-card__table th,
.dvg-card__table td {
	padding: 12px 16px; text-align: left;
	border-bottom: 1px solid var(--dvg-line, #E4E0DF);
	white-space: nowrap;
}
.dvg-card__table thead th {
	background: var(--dvg-surface, #FAFAFA);
	font-size: 0.75rem; letter-spacing: 0.04em; text-transform: uppercase;
	color: var(--dvg-muted, #57514F);
}
.dvg-card__table tbody th { font-weight: 700; }
.dvg-card__table tbody tr:last-child th,
.dvg-card__table tbody tr:last-child td { border-bottom: 0; }
.dvg-card__table tbody tr:hover { background: var(--dvg-surface, #FAFAFA); }
/* The best cost per foot is marked as a fact, not as a promotional badge. */
.dvg-card__table tbody tr.is-best td:last-child { color: var(--dvg-accent, #E30613); font-weight: 700; }
.dvg-card__unit { font-size: 0.75rem; color: var(--dvg-muted, #57514F); margin-left: 2px; }
.dvg-card__note {
	margin: 12px 0 0; font-size: 0.8125rem; line-height: 1.6;
	color: var(--dvg-muted, #57514F);
}
.dvg-ctas { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 0; }

@media (max-width: 599px) {
	/* Stack each sheet into its own block so nothing needs sideways scrolling. */
	.dvg-card__table, .dvg-card__table thead, .dvg-card__table tbody,
	.dvg-card__table tr, .dvg-card__table th, .dvg-card__table td { display: block; white-space: normal; }
	.dvg-card__table thead { display: none; }
	.dvg-card__table tbody tr { border-bottom: 1px solid var(--dvg-line, #E4E0DF); padding: 6px 0; }
	.dvg-card__table tbody tr:last-child { border-bottom: 0; }
	.dvg-card__table tbody th { border-bottom: 0; font-size: 1rem; padding-bottom: 2px; }
	.dvg-card__table tbody td {
		border-bottom: 0; display: flex; justify-content: space-between; gap: 12px; padding: 4px 16px;
	}
	.dvg-card__table tbody td::before {
		content: attr(data-label); color: var(--dvg-muted, #57514F); font-size: 0.8125rem;
	}
}

/* ---------------------------------------------------------- templates */

.dvg-templates {
	list-style: none; margin: 0; padding: 0;
	display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}
.dvg-templates > li { margin: 0; }
.dvg-template {
	display: flex; align-items: center; justify-content: space-between; gap: 12px;
	height: 100%; padding: 12px 14px;
	border: 1px solid var(--dvg-line, #E4E0DF); border-radius: 10px;
	background: #fff; text-decoration: none; color: inherit;
	transition: border-color .15s, transform .15s;
}
.dvg-template:hover, .dvg-template:focus-visible {
	border-color: var(--dvg-ink, #161616); transform: translateY(-1px);
}
.dvg-template__label { display: block; font-weight: 700; font-size: 0.9375rem; }
.dvg-template__dim { display: block; font-size: 0.8125rem; color: var(--dvg-muted, #57514F); }
.dvg-template__meta { text-align: right; flex: none; }
.dvg-template__fmt {
	display: block; font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.06em;
	color: var(--dvg-accent, #E30613);
}
.dvg-template__size { display: block; font-size: 0.75rem; color: var(--dvg-muted, #57514F); }

/* -------------------------------------------------------- spec list */

.dvg-specs {
	margin: 0; border: 1px solid var(--dvg-line, #E4E0DF);
	border-radius: 12px; overflow: hidden; background: #fff;
}
.dvg-specs__row {
	display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 12px 16px;
	border-bottom: 1px solid var(--dvg-line, #E4E0DF);
}
.dvg-specs__row:last-child { border-bottom: 0; }
.dvg-specs dt {
	flex: 0 0 auto; min-width: 190px; margin: 0;
	font-size: 0.8125rem; font-weight: 500; color: var(--dvg-muted, #57514F);
}
.dvg-specs dd { flex: 1 1 220px; margin: 0; font-weight: 500; }

/* =========================================================================
 * Mobile: the summary must never cover the canvas
 *
 * Phase F made .dvg-panel sticky at the bottom below 1100px, which parked the
 * order summary on top of the sheet the customer was trying to arrange. The
 * panel now sits in normal flow and a slim action bar carries the total and
 * the add button instead, so the canvas stays fully visible and Add to Cart
 * stays one tap away.
 * ====================================================================== */

.dvg-mbar { display: none; }

@media (max-width: 1099px) {
	/* A single-column grid sizes its column to `auto`, which is max-content, so
	   one wide child pushed the whole column past the viewport and gave the page
	   a horizontal scrollbar at 320px. minmax(0, 1fr) caps it at the container. */
	.dvg-work { grid-template-columns: minmax(0, 1fr); }
	.dvg-canvas-scroll { max-width: 100%; }
	.dvg-up { grid-template-columns: minmax(0, 1fr); }

	.dvg-panel { position: static; }

	.dvg-mbar {
		position: sticky;
		bottom: 0;
		z-index: 3;
		display: flex;
		align-items: center;
		gap: 12px;
		margin: 12px 0 0;
		padding: 10px 12px;
		border: 1px solid var(--dvg-line, #E4E0DF);
		border-radius: 12px;
		background: rgba(255,255,255,0.97);
		backdrop-filter: saturate(140%) blur(6px);
		box-shadow: 0 -2px 10px rgba(0,0,0,.06);
	}

	.dvg-mbar__total { flex: 1 1 auto; min-width: 0; line-height: 1.25; }
	.dvg-mbar__label {
		display: block; font-size: 0.6875rem; letter-spacing: 0.04em;
		text-transform: uppercase; color: var(--dvg-muted, #57514F);
	}
	.dvg-mbar__value { display: block; font-size: 1.125rem; font-weight: 800; }
	.dvg-mbar__value .woocommerce-Price-amount { color: var(--dvg-ink, #161616); }
	.dvg-mbar .dvg-btn { flex: 0 0 auto; min-height: 44px; }

	/* The canvas gets the room the summary used to sit on. */
	.dvg-canvas-scroll { max-height: 62vh; }
}

@media (max-width: 430px) {
	.dvg-mbar { gap: 8px; padding: 8px 10px; }
	.dvg-mbar__value { font-size: 1rem; }
	.dvg-mbar .dvg-btn { padding: 10px 12px; font-size: 0.8125rem; }
}

@media (max-width: 360px) {
	/* At 320px the sheet selector and quantity need the full width each. */
	.dvg-bar { gap: 12px; }
	.dvg-mbar__label { display: none; }
	.dvg-work { gap: 12px; }
	.dvg-side, .dvg-panel, .dvg-canvas-wrap { padding: 12px; }
}

/* Touch devices get larger grab targets regardless of width. */
@media (hover: none) and (pointer: coarse) {
	.dvg-item__handle { width: 22px; height: 22px; right: -11px; bottom: -11px; }
	.dvg-btn { min-height: 44px; }
}

/* ------------------------------------------------- compact disclosure */

/* Used below the builder so the supporting copy does not become a wall of
   text above the fold's competition. Purchasing conditions stay visible. */
.dv-acc { border: 1px solid var(--dv-line, #E4E0DF); border-radius: 12px; overflow: hidden; background: #fff; }
.dv-acc > details { border-bottom: 1px solid var(--dv-line, #E4E0DF); }
.dv-acc > details:last-child { border-bottom: 0; }
.dv-acc summary {
	display: flex; align-items: center; justify-content: space-between; gap: 16px;
	padding: 16px; cursor: pointer; font-weight: 700; list-style: none;
}
.dv-acc summary::-webkit-details-marker { display: none; }
.dv-acc summary::marker { content: ""; }
.dv-acc summary::after {
	content: "+"; flex: none; font-size: 1.25rem; font-weight: 400;
	color: var(--dv-ink-muted, #57514F); line-height: 1;
}
.dv-acc > details[open] summary::after { content: "\2212"; color: var(--dv-accent, #E30613); }
.dv-acc summary:hover { background: var(--dv-surface, #FAFAFA); }
.dv-acc__body { padding: 0 16px 16px; }
.dv-acc__body > :first-child { margin-top: 0; }
