/* EM Preventivi — Frontend (theme-proof, mobile-first, BEM scoping under .em-preventivi-root)
 * Tutte le variabili sono iniettate inline da Shortcode->enqueue() in base alle option em_preventivi_options.aspetto.
 * I valori qui sotto sono fallback in caso le option manchino (es. plugin appena attivato senza migration).
 */

.em-preventivi-root {
	/* === Tipografia === */
	--em-font-sans: inherit;
	--em-font-serif: inherit;

	/* === Brand === */
	--em-primary: #E53935;
	--em-dark: #C62828;
	--em-bg: #FFFFFF;
	--em-text: #1A1A1A;
	--em-text-muted: #4A4A4A;

	/* === Card e form === */
	--em-card-bg: #FFFFFF;
	--em-card-border: #E5E5E5;
	--em-step-active-bg: #FCE8E7;
	--em-step-active-text: #C62828;
	--em-card-radius: 16px;
	--em-card-shadow: none;

	/* === Hero totale === */
	--em-hero-bg-from: #FFFFFF;
	--em-hero-bg-to: #FCE8E7;
	--em-hero-accent: #E53935;

	/* === CTA === */
	--em-cta-bg: #0F2545;
	--em-cta-text: #FFFFFF;
	--em-cta-accent: #FFB4B2;

	/* === Stato successo === */
	--em-success-bg: #E8F5E9;
	--em-success-accent: #2E7D32;

	/* === Bottoni === */
	--em-btn-radius: 999px;
	--em-btn-letter-spacing: 0.06em;
	--em-btn-shadow: 0 4px 12px rgba(229, 57, 53, 0.25);

	/* === Internal === */
	--em-bg-soft: #F7F7F7;
	--em-tabular: "tnum" 1, "lnum" 1;
	--em-input-radius: 8px;

	font-family: var(--em-font-sans);
	color: var(--em-text);
	line-height: 1.5;
	max-width: 960px;
	margin: 0 auto;
	box-sizing: border-box;
	background: var(--em-bg);
}

.em-preventivi-root *,
.em-preventivi-root *::before,
.em-preventivi-root *::after { box-sizing: border-box; }

/* ===== Stepper ===== */
.em-preventivi__stepper {
	display: flex; gap: 8px; list-style: none;
	margin: 0 0 24px 0; padding: 0;
}
.em-preventivi__step {
	flex: 1; display: flex; align-items: center; gap: 12px;
	padding: 12px 14px;
	background: var(--em-bg-soft);
	border-radius: var(--em-input-radius);
	color: var(--em-text-muted);
	transition: background 0.2s, color 0.2s;
	font-size: 14px;
}
.em-preventivi__step.is-active {
	background: var(--em-step-active-bg);
	color: var(--em-step-active-text);
}
.em-preventivi__step.is-done {
	background: var(--em-success-bg);
	color: var(--em-success-accent);
}
.em-preventivi__step-num {
	display: inline-flex; width: 28px; height: 28px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.55);
	align-items: center; justify-content: center;
	font-weight: 700; flex-shrink: 0;
}
.em-preventivi__step:not(.is-active):not(.is-done) .em-preventivi__step-num {
	background: #fff; color: var(--em-text-muted);
	border: 1px solid var(--em-card-border);
}
.em-preventivi__step-label { font-weight: 600; letter-spacing: 0.02em; }

/* ===== Pannelli ===== */
.em-preventivi__panel {
	background: var(--em-card-bg);
	border: 1px solid var(--em-card-border);
	border-radius: var(--em-card-radius);
	box-shadow: var(--em-card-shadow);
	padding: 28px;
	display: none;
	animation: em-preventivi-fadein 0.3s ease;
}
.em-preventivi__panel.is-active { display: block; }
@keyframes em-preventivi-fadein {
	from { opacity: 0; transform: translateY(8px); }
	to   { opacity: 1; transform: translateY(0); }
}
.em-preventivi__title {
	font-family: var(--em-font-serif);
	font-size: 26px; margin: 0 0 6px 0;
	color: var(--em-text); font-weight: 700; line-height: 1.2;
}
.em-preventivi__subtitle {
	color: var(--em-text-muted); margin: 0 0 20px 0; font-size: 15px;
}

/* ===== Form grid ===== */
.em-preventivi__grid {
	display: grid; grid-template-columns: repeat(2, 1fr);
	gap: 16px; margin-bottom: 20px;
}
.em-preventivi__field { display: flex; flex-direction: column; gap: 6px; }
.em-preventivi__field--full { grid-column: 1 / -1; }
.em-preventivi__label {
	font-size: 13px; font-weight: 600;
	color: var(--em-text); letter-spacing: 0.02em;
}

.em-preventivi-root input[type="text"],
.em-preventivi-root input[type="email"],
.em-preventivi-root input[type="tel"],
.em-preventivi-root input[type="date"],
.em-preventivi-root input[type="number"],
.em-preventivi-root select,
.em-preventivi-root textarea {
	font-family: inherit; font-size: 15px;
	padding: 10px 12px;
	background: #fff !important;
	color: var(--em-text) !important;
	border: 1px solid var(--em-card-border) !important;
	border-radius: var(--em-input-radius) !important;
	width: 100%;
	transition: border-color 0.15s, box-shadow 0.15s;
	line-height: 1.4; min-height: 42px;
}
.em-preventivi-root input:focus,
.em-preventivi-root select:focus,
.em-preventivi-root textarea:focus {
	outline: none;
	border-color: var(--em-primary) !important;
	box-shadow: 0 0 0 3px rgba(229, 57, 53, 0.12) !important;
}
.em-preventivi-root input.is-invalid,
.em-preventivi-root select.is-invalid,
.em-preventivi-root textarea.is-invalid {
	border-color: var(--em-primary) !important;
	box-shadow: 0 0 0 3px rgba(229, 57, 53, 0.18) !important;
}

.em-preventivi__check {
	display: flex; align-items: flex-start; gap: 10px;
	font-size: 14px; color: var(--em-text);
	margin: 12px 0; cursor: pointer;
}
.em-preventivi-root .em-preventivi__check input[type="checkbox"] {
	width: 18px; height: 18px; margin: 2px 0 0 0;
	flex-shrink: 0; accent-color: var(--em-primary);
}

/* ===== Bottoni ===== */
.em-preventivi__actions {
	display: flex; gap: 12px; justify-content: flex-end;
	flex-wrap: wrap; margin-top: 20px;
}
.em-preventivi__actions--center { justify-content: center; }

/* ===== Download PDF (STEP 3) ===== */
.em-preventivi__download {
	margin-top: 22px;
	padding: 18px 20px;
	border: 1px solid var(--em-card-border);
	border-radius: var(--em-card-radius);
	background: var(--em-card-bg);
	text-align: center;
}
.em-preventivi__download-text {
	font-size: 14px; font-weight: 600;
	color: var(--em-text); margin: 0 0 10px;
}
.em-preventivi__download .em-preventivi__check {
	justify-content: center; margin: 0 0 12px;
}

.em-preventivi__btn {
	font-family: inherit; font-size: 14px; font-weight: 700;
	letter-spacing: var(--em-btn-letter-spacing);
	text-transform: uppercase;
	padding: 12px 24px !important;
	border-radius: var(--em-btn-radius) !important;
	border: 2px solid transparent !important;
	cursor: pointer;
	transition: transform 0.1s, box-shadow 0.15s, background 0.15s, border-color 0.15s, color 0.15s;
	min-height: 46px; line-height: 1.2;
	text-decoration: none !important;
	display: inline-flex; align-items: center; justify-content: center;
}
.em-preventivi__btn:active { transform: translateY(1px); }
.em-preventivi__btn:disabled { opacity: 0.55; cursor: not-allowed; }

.em-preventivi__btn--primary {
	background: var(--em-primary) !important;
	color: #fff !important;
	border-color: var(--em-primary) !important;
	box-shadow: var(--em-btn-shadow);
}
.em-preventivi__btn--primary:hover:not(:disabled) {
	background: var(--em-dark) !important;
	border-color: var(--em-dark) !important;
}
.em-preventivi__btn--secondary {
	background: #fff !important;
	color: var(--em-cta-bg) !important;
	border-color: #fff !important;
}
.em-preventivi__btn--secondary:hover:not(:disabled) {
	background: var(--em-step-active-bg) !important;
	color: var(--em-cta-bg) !important;
}
.em-preventivi__btn--ghost {
	background: transparent !important;
	color: var(--em-text) !important;
	border-color: var(--em-card-border) !important;
	box-shadow: none;
}
.em-preventivi__btn--ghost:hover:not(:disabled) {
	background: var(--em-bg-soft) !important;
	border-color: var(--em-text) !important;
}

.em-preventivi__btn.is-loading {
	color: transparent !important;
	position: relative; pointer-events: none;
}
.em-preventivi__btn.is-loading::after {
	content: ""; position: absolute; inset: 0; margin: auto;
	width: 18px; height: 18px;
	border: 2.5px solid currentColor;
	border-top-color: transparent;
	border-radius: 50%;
	animation: em-preventivi-spin 0.7s linear infinite;
	color: #fff;
}
.em-preventivi__btn--ghost.is-loading::after { color: var(--em-text); }
@keyframes em-preventivi-spin { to { transform: rotate(360deg); } }

/* ===== Card familiare ===== */
.em-preventivi__familiare {
	background: var(--em-bg-soft);
	border-radius: var(--em-input-radius);
	padding: 16px 18px; margin-bottom: 12px;
	border: 1px solid var(--em-card-border);
}
.em-preventivi__familiare-title {
	font-size: 13px; font-weight: 700;
	letter-spacing: 0.05em; text-transform: uppercase;
	color: var(--em-text); margin: 0 0 10px 0;
}
.em-preventivi__familiare-title--titolare { color: var(--em-primary); }
.em-preventivi__familiare .em-preventivi__grid { margin-bottom: 0; }
.em-preventivi-root .em-preventivi__familiare input:disabled {
	background: #f3f3f3 !important;
	color: var(--em-text-muted) !important;
	cursor: not-allowed;
}

/* ===== Riepilogo ===== */
.em-preventivi__breakdown-wrap { overflow-x: auto; margin-bottom: 24px; }
.em-preventivi__breakdown { width: 100%; border-collapse: collapse; font-size: 14px; }
.em-preventivi__breakdown thead th {
	background: var(--em-bg-soft);
	color: var(--em-text);
	font-weight: 700; text-align: left;
	padding: 12px 14px;
	font-size: 12px; letter-spacing: 0.06em;
	text-transform: uppercase;
	border-bottom: 1px solid var(--em-card-border);
}
.em-preventivi__breakdown tbody td {
	padding: 14px;
	border-bottom: 1px solid var(--em-card-border);
}
.em-preventivi__num {
	text-align: right;
	font-feature-settings: var(--em-tabular);
	font-variant-numeric: tabular-nums lining-nums;
	white-space: nowrap;
}

/* ===== Hero totale ===== */
.em-preventivi__hero {
	background: linear-gradient(180deg, var(--em-hero-bg-from) 0%, var(--em-hero-bg-to) 100%);
	border: 2px solid var(--em-hero-accent);
	border-radius: var(--em-card-radius);
	padding: 22px 28px;
	margin-bottom: 24px;
}
.em-preventivi__hero-row {
	display: flex; justify-content: space-between;
	align-items: baseline; gap: 16px; padding: 8px 0;
}
.em-preventivi__hero-row + .em-preventivi__hero-row {
	border-top: 1px solid rgba(0, 0, 0, 0.08);
}
.em-preventivi__hero-label {
	color: var(--em-text); font-weight: 600; font-size: 15px;
}
.em-preventivi__hero-val {
	color: var(--em-hero-accent); font-weight: 700;
	font-feature-settings: var(--em-tabular);
	font-variant-numeric: tabular-nums lining-nums;
	font-size: 18px;
}
.em-preventivi__hero-val--big {
	font-family: var(--em-font-serif);
	font-style: italic;
	font-size: 38px;
	letter-spacing: -0.01em;
}
.em-preventivi__hero-row--main { padding: 12px 0; }

/* ===== CTA ===== */
.em-preventivi__cta {
	background: var(--em-cta-bg);
	color: var(--em-cta-text);
	border-radius: var(--em-card-radius);
	padding: 26px 28px; margin-bottom: 24px;
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.08);
}
.em-preventivi__cta-title {
	color: var(--em-cta-text);
	font-family: var(--em-font-serif);
	font-size: 22px; font-weight: 700;
	margin: 0 0 6px 0;
}
.em-preventivi__cta-title em {
	color: var(--em-cta-accent);
	font-style: italic;
}
.em-preventivi__cta-text {
	color: var(--em-cta-text); opacity: 0.85;
	margin: 0 0 16px 0; font-size: 15px;
}
.em-preventivi__cta-form {
	margin-top: 18px;
	background: #fff;
	color: var(--em-text);
	padding: 22px;
	border-radius: var(--em-input-radius);
	animation: em-preventivi-fadein 0.25s ease;
}
.em-preventivi__cta-form .em-preventivi__label { color: var(--em-text); }

/* ===== Alert ===== */
.em-preventivi__alert {
	background: #fff5f5;
	color: #b71c1c;
	border: 1px solid #ffcdd2;
	border-radius: var(--em-input-radius);
	padding: 12px 16px; margin-bottom: 16px;
	font-size: 14px;
}
.em-preventivi__alert--success {
	background: var(--em-success-bg);
	color: var(--em-success-accent);
	border-color: var(--em-success-accent);
}

/* ===== Success state ===== */
.em-preventivi__panel--success {
	text-align: center;
	padding: 56px 28px;
	background: var(--em-success-bg);
	border-color: var(--em-success-accent);
}
.em-preventivi__success { max-width: 520px; margin: 0 auto; }
.em-preventivi__success-check {
	color: var(--em-success-accent);
	display: inline-flex; margin-bottom: 18px;
}
.em-preventivi__success-circle {
	stroke-dasharray: 151; stroke-dashoffset: 151;
	animation: em-preventivi-circle 0.5s ease forwards;
}
.em-preventivi__success-tick {
	stroke-dasharray: 50; stroke-dashoffset: 50;
	animation: em-preventivi-tick 0.4s 0.4s ease forwards;
}
@keyframes em-preventivi-circle { to { stroke-dashoffset: 0; } }
@keyframes em-preventivi-tick { to { stroke-dashoffset: 0; } }

.em-preventivi-root select optgroup {
	font-style: normal; font-weight: 700; color: var(--em-text);
}

/* ===== Mobile ===== */
@media (max-width: 600px) {
	.em-preventivi__panel { padding: 20px 16px; }
	.em-preventivi__title { font-size: 22px; }
	.em-preventivi__grid { grid-template-columns: 1fr; gap: 14px; }
	.em-preventivi__hero { padding: 18px 20px; }
	.em-preventivi__hero-val--big { font-size: 28px; }
	.em-preventivi__hero-row { flex-wrap: wrap; }
	.em-preventivi__cta { padding: 22px 20px; }
	.em-preventivi__step-label { display: none; }
	.em-preventivi__step { padding: 10px; justify-content: center; }
	.em-preventivi__actions { justify-content: stretch; }
	.em-preventivi__actions .em-preventivi__btn { flex: 1; }
}

/* ===== Print ===== */
@media print {
	.em-preventivi__no-print,
	.em-preventivi__stepper,
	.em-preventivi__cta,
	.em-preventivi__alert { display: none !important; }
	.em-preventivi__panel { box-shadow: none; padding: 0; }
	.em-preventivi__hero { background: #fff; border: 2px solid #000; }
	.em-preventivi__hero-val { color: #000; }
}
