/* =========================================================================
   WC Recesso Digitale - stili front-end e admin
   I colori derivano dalle variabili del tema (Woodmart / preset WordPress)
   con fallback neutri, così l'aspetto segue il brand del negozio.
   ========================================================================= */

:where(.wcrd-flow, .wcrd-button-box, .wcrd-picker, .wcrd-done, .wcrd-shortcode-wrap) {
	/* Colore accento: Woodmart -> preset WP -> Kava/Elementor -> fallback. */
	--wcrd-accent: var(--wd-primary-color, var(--wp--preset--color--primary, var(--e-global-color-primary, #2c6ecb)));
	--wcrd-accent-contrast: #ffffff;

	--wcrd-ink: var(--wd-text-color, var(--wp--preset--color--foreground, inherit));
	--wcrd-title: var(--wd-title-color, var(--wcrd-ink));

	/* Tinte derivate dal testo corrente: si adattano a temi chiari/scuri. */
	--wcrd-muted: rgba(125, 125, 125, 0.95);
	--wcrd-border: rgba(0, 0, 0, 0.10);
	--wcrd-surface: rgba(0, 0, 0, 0.025);
	--wcrd-surface-2: rgba(0, 0, 0, 0.04);

	--wcrd-radius: 14px;
	--wcrd-radius-sm: 9px;
	--wcrd-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 10px 30px rgba(0, 0, 0, 0.07);
	--wcrd-gap: 18px;
}

@supports (color: color-mix(in srgb, red 50%, white)) {
	:where(.wcrd-flow, .wcrd-button-box, .wcrd-picker, .wcrd-done, .wcrd-shortcode-wrap) {
		--wcrd-muted: color-mix(in srgb, currentColor 58%, transparent);
		--wcrd-border: color-mix(in srgb, currentColor 16%, transparent);
		--wcrd-surface: color-mix(in srgb, var(--wcrd-accent) 4%, transparent);
		--wcrd-surface-2: color-mix(in srgb, var(--wcrd-accent) 8%, transparent);
	}
}

/* --- Layout generale dei blocchi --- */
.wcrd-flow,
.wcrd-picker,
.wcrd-done { max-width: 680px; }

.wcrd-flow__title,
.wcrd-picker .wcrd-flow__title {
	font-size: 1.5em;
	line-height: 1.25;
	margin: 0 0 6px;
	color: var(--wcrd-title);
}
.wcrd-flow__lead { color: var(--wcrd-muted); margin: 0 0 24px; font-size: 1.02em; }

/* --- Pulsanti: usano la classe nativa del tema (.button) + solo layout --- */
.wcrd-cta {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	font-weight: 600 !important;
	line-height: 1.2;
	border-radius: var(--wcrd-radius-sm);
	cursor: pointer;
	text-decoration: none;
	transition: transform .12s ease, box-shadow .12s ease, opacity .12s ease;
}
.wcrd-cta:hover { transform: translateY(-1px); }
.wcrd-cta:active { transform: translateY(0); }
.wcrd-cta--small { font-size: .92em; }
.wcrd-cta svg { width: 1.05em; height: 1.05em; }

/* Quando il tema non colora la .button, garantiamo un fallback con l'accento. */
.wcrd-cta:not(.button) {
	padding: 12px 22px;
	background: var(--wcrd-accent);
	color: var(--wcrd-accent-contrast);
	border: 0;
}

.wcrd-link {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: var(--wcrd-accent);
	text-decoration: none;
	font-weight: 600;
}
.wcrd-link:hover { text-decoration: underline; }

/* --- Card pulsante nel dettaglio ordine --- */
.wcrd-button-box {
	margin: 28px 0;
	padding: 22px 24px;
	border: 1px solid var(--wcrd-border);
	border-left: 4px solid var(--wcrd-accent);
	border-radius: var(--wcrd-radius);
	background: var(--wcrd-surface);
	box-shadow: var(--wcrd-shadow);
}
.wcrd-button-box__title { margin: 0 0 6px; font-size: 1.2em; color: var(--wcrd-title); }
.wcrd-button-box__text { margin: 0 0 16px; color: var(--wcrd-muted); }
.wcrd-button-box__text strong { color: var(--wcrd-ink); }

/* --- Stepper (1 Dati > 2 Conferma > 3 Fatto) --- */
.wcrd-steps {
	display: flex;
	list-style: none;
	margin: 0 0 26px;
	padding: 0;
	gap: 0;
	counter-reset: step;
}
.wcrd-steps li {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	position: relative;
	font-size: .86em;
	color: var(--wcrd-muted);
	text-align: center;
}
.wcrd-steps li::before { /* linea di collegamento */
	content: "";
	position: absolute;
	top: 16px;
	left: -50%;
	width: 100%;
	height: 2px;
	background: var(--wcrd-border);
	z-index: 0;
}
.wcrd-steps li:first-child::before { display: none; }
.wcrd-steps__dot {
	position: relative;
	z-index: 1;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	display: grid;
	place-items: center;
	font-weight: 700;
	background: var(--wcrd-surface-2);
	color: var(--wcrd-muted);
	border: 2px solid var(--wcrd-border);
}
.wcrd-steps li.is-active .wcrd-steps__dot {
	background: var(--wcrd-accent);
	color: var(--wcrd-accent-contrast);
	border-color: var(--wcrd-accent);
	box-shadow: 0 0 0 4px var(--wcrd-surface-2);
}
.wcrd-steps li.is-active { color: var(--wcrd-ink); font-weight: 600; }
.wcrd-steps li.is-done .wcrd-steps__dot {
	background: transparent;
	color: var(--wcrd-accent);
	border-color: var(--wcrd-accent);
}
.wcrd-steps li.is-done::before { background: var(--wcrd-accent); }

/* --- Form --- */
.wcrd-field { margin-bottom: var(--wcrd-gap); }
.wcrd-field > label { display: block; font-weight: 600; margin-bottom: 6px; color: var(--wcrd-ink); }
.wcrd-field input[type="text"],
.wcrd-field input[type="email"],
.wcrd-field select,
.wcrd-field textarea {
	width: 100%;
	max-width: 460px;
	padding: 11px 13px;
	border: 1px solid var(--wcrd-border);
	border-radius: var(--wcrd-radius-sm);
	background: #fff;
	color: #1f2430;
	font-size: 1em;
	transition: border-color .12s ease, box-shadow .12s ease;
}
.wcrd-field input[type="file"] { max-width: 460px; font-size: .95em; }
.wcrd-file-list { display: block; margin-top: 6px; font-size: .85em; color: var(--wcrd-muted); }
.wcrd-field input:focus,
.wcrd-field select:focus,
.wcrd-field textarea:focus {
	outline: none;
	border-color: var(--wcrd-accent);
	box-shadow: 0 0 0 3px var(--wcrd-surface-2);
}
.wcrd-field .description { display: block; color: var(--wcrd-muted); font-size: .86em; margin-top: 5px; }
.wcrd-field .required { color: var(--wcrd-accent); }
.wcrd-static {
	display: inline-block;
	padding: 9px 13px;
	background: var(--wcrd-surface);
	border-radius: var(--wcrd-radius-sm);
	color: var(--wcrd-ink);
}

.wcrd-items {
	border: 1px solid var(--wcrd-border);
	border-radius: var(--wcrd-radius);
	padding: 16px 18px;
	background: var(--wcrd-surface);
}
.wcrd-items legend { font-weight: 600; padding: 0 6px; color: var(--wcrd-title); }
.wcrd-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin: 4px 0;
	padding: 8px 10px;
	border-radius: var(--wcrd-radius-sm);
	transition: background .12s ease;
}
.wcrd-item:hover { background: var(--wcrd-surface-2); }
.wcrd-item__label { display: flex; align-items: center; gap: 10px; flex: 1; cursor: pointer; }
.wcrd-item__label input[type="checkbox"] { accent-color: var(--wcrd-accent); width: 18px; height: 18px; }
.wcrd-item__qty { display: inline-flex; align-items: center; gap: 6px; font-size: .9em; color: var(--wcrd-muted); white-space: nowrap; }
.wcrd-item__qty input[type="number"] { width: 64px; padding: 6px 8px; border: 1px solid var(--wcrd-border); border-radius: 8px; }

.wcrd-actions { margin-top: 26px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

/* --- Banner informativo (residuo giorni) --- */
.wcrd-callout {
	display: flex;
	gap: 12px;
	align-items: flex-start;
	padding: 14px 16px;
	margin: 0 0 24px;
	background: var(--wcrd-surface);
	border: 1px solid var(--wcrd-border);
	border-left: 4px solid var(--wcrd-accent);
	border-radius: var(--wcrd-radius-sm);
	color: var(--wcrd-ink);
}
.wcrd-callout svg { flex: 0 0 auto; width: 20px; height: 20px; color: var(--wcrd-accent); margin-top: 1px; }
.wcrd-callout strong { color: var(--wcrd-accent); }

/* --- Tabella riepilogo --- */
.wcrd-summary {
	width: 100%;
	border-collapse: separate;
	border-spacing: 0;
	margin: 6px 0 22px;
	border: 1px solid var(--wcrd-border);
	border-radius: var(--wcrd-radius);
	overflow: hidden;
}
.wcrd-summary th,
.wcrd-summary td { text-align: left; padding: 13px 16px; vertical-align: top; }
.wcrd-summary tr + tr th,
.wcrd-summary tr + tr td { border-top: 1px solid var(--wcrd-border); }
.wcrd-summary th { width: 40%; color: var(--wcrd-muted); font-weight: 600; background: var(--wcrd-surface); }
.wcrd-summary td { color: var(--wcrd-ink); }

/* --- Lista ordini (picker) --- */
.wcrd-order-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.wcrd-order-list__item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 16px 18px;
	border: 1px solid var(--wcrd-border);
	border-radius: var(--wcrd-radius);
	background: var(--wcrd-surface);
	transition: border-color .12s ease, box-shadow .12s ease;
}
.wcrd-order-list__item:hover { border-color: var(--wcrd-accent); box-shadow: var(--wcrd-shadow); }
.wcrd-order-list__info { display: flex; flex-direction: column; gap: 3px; color: var(--wcrd-ink); }
.wcrd-order-list__info span { color: var(--wcrd-muted); font-size: .92em; }
.wcrd-days { color: var(--wcrd-accent) !important; font-weight: 700 !important; }

/* --- Esito --- */
.wcrd-done { text-align: center; }
.wcrd-done__icon {
	width: 76px;
	height: 76px;
	margin: 4px auto 16px;
	border-radius: 50%;
	display: grid;
	place-items: center;
	background: var(--wcrd-accent);
	color: var(--wcrd-accent-contrast);
	box-shadow: 0 0 0 8px var(--wcrd-surface-2);
}
.wcrd-done__icon svg { width: 38px; height: 38px; }
.wcrd-done .wcrd-summary { text-align: left; }
.wcrd-done .wcrd-actions { justify-content: center; }

/* --- Info "già esercitato" --- */
.wcrd-info {
	display: flex; gap: 10px; align-items: center;
	padding: 12px 14px; border-radius: var(--wcrd-radius-sm);
	background: var(--wcrd-surface); color: var(--wcrd-muted);
}

/* --- Footer link --- */
.wcrd-footer-link { text-align: center; padding: 10px; font-size: .85em; }
.wcrd-footer-link a { color: inherit; opacity: .8; text-decoration: none; }
.wcrd-footer-link a:hover { opacity: 1; text-decoration: underline; }

/* --- Responsive --- */
@media (max-width: 600px) {
	.wcrd-order-list__item { flex-direction: column; align-items: stretch; }
	.wcrd-order-list__item .wcrd-cta { width: 100%; }
	.wcrd-field input[type="text"],
	.wcrd-field input[type="email"],
	.wcrd-field textarea { max-width: 100%; }
	.wcrd-steps li { font-size: .78em; }
	.wcrd-summary th { width: 45%; }
}

/* =========================================================================
   Admin
   ========================================================================= */
.wcrd-badge {
	display: inline-block; padding: 3px 11px; border-radius: 999px;
	font-size: 12px; font-weight: 600; color: #fff; white-space: nowrap;
}
.wcrd-badge-pending { background: #d4a017; }
.wcrd-badge-confirmed { background: #2271b1; }
.wcrd-badge-processing { background: #6c5ce7; }
.wcrd-badge-accepted { background: #1f8f3a; }
.wcrd-badge-refunded { background: #0a7d6b; }
.wcrd-badge-rejected { background: #b32d2e; }

.wcrd-declaration {
	background: #f6f7f7; border: 1px solid #dcdcde; border-radius: 6px;
	padding: 14px; white-space: pre-wrap; max-width: 100%; overflow:auto;
}
.wcrd-help li { list-style: disc; margin-left: 20px; }

/* Card statistiche elenco */
.wcrd-stats { display: flex; flex-wrap: wrap; gap: 12px; margin: 16px 0 8px; }
.wcrd-stat {
	flex: 1 1 120px; min-width: 120px; text-decoration: none;
	background: #fff; border: 1px solid #dcdcde; border-radius: 10px;
	padding: 14px 16px; display: flex; flex-direction: column; gap: 2px;
	box-shadow: 0 1px 2px rgba(0,0,0,.04); transition: box-shadow .12s, border-color .12s;
}
.wcrd-stat:hover { box-shadow: 0 4px 14px rgba(0,0,0,.08); border-color: #2271b1; }
.wcrd-stat__num { font-size: 26px; font-weight: 700; color: #1d2327; line-height: 1.1; }
.wcrd-stat__label { font-size: 12px; color: #646970; text-transform: uppercase; letter-spacing: .03em; }
.wcrd-stat--confirmed .wcrd-stat__num { color: #2271b1; }
.wcrd-stat--accepted .wcrd-stat__num { color: #1f8f3a; }
.wcrd-stat--refunded .wcrd-stat__num { color: #0a7d6b; }
.wcrd-stat--rejected .wcrd-stat__num { color: #b32d2e; }

/* Dettaglio richiesta: layout a due colonne */
.wcrd-admin-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; margin-top: 12px; }
@media (max-width: 1100px) { .wcrd-admin-grid { grid-template-columns: 1fr; } }
.wcrd-col { display: flex; flex-direction: column; gap: 20px; }
.wcrd-card {
	background: #fff; border: 1px solid #dcdcde; border-radius: 12px;
	padding: 18px 20px; box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.wcrd-card__title {
	margin: 0 0 14px; font-size: 15px; display: flex; align-items: center;
	justify-content: space-between; gap: 10px;
}
.wcrd-kv { width: 100%; border-collapse: collapse; }
.wcrd-kv th, .wcrd-kv td { text-align: left; padding: 8px 0; vertical-align: top; border-bottom: 1px solid #f0f0f1; font-weight: normal; }
.wcrd-kv th { width: 40%; color: #646970; }
.wcrd-kv tr:last-child th, .wcrd-kv tr:last-child td { border-bottom: 0; }

.wcrd-note { margin-top: 14px; padding: 10px 12px; border-radius: 8px; font-size: 13px; }
.wcrd-note--reject { background: #fcf0f1; border: 1px solid #f3c2c5; color: #8c1f20; }
.wcrd-note--refund { background: #eafaf4; border: 1px solid #b6e6d4; color: #0a5e51; }

/* Form rimborso: lista articoli */
.wcrd-refund-items { border: 1px solid #e0e0e0; border-radius: 8px; padding: 6px 10px; margin-bottom: 12px; }
.wcrd-refund-item { display: flex; align-items: center; gap: 8px; padding: 7px 2px; border-bottom: 1px solid #f0f0f1; }
.wcrd-refund-item:last-child { border-bottom: 0; }
.wcrd-refund-item__name { flex: 1; }
.wcrd-refund-item__max { color: #888; font-size: 12px; }
.wcrd-refund-item input[type="number"] { width: 64px; }
.wcrd-media-field { margin: 12px 0; }

/* Miniature foto cliente nel dettaglio */
.wcrd-thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.wcrd-thumbs img { width: 80px; height: 80px; object-fit: cover; border: 1px solid #dcdcde; border-radius: 8px; background: #fff; }
