/* TERRA – Devis interactif · v1.8.0 */

.terra-devis {
	--td-accent: #b3282d;      /* rouge TERRA – ajustable */
	--td-accent-dark: #8f1f23;
	--td-ink: #23292e;
	--td-muted: #6b7681;
	--td-line: #dfe4e8;
	--td-bg: #f6f7f8;
	--td-radius: 10px;
	box-sizing: border-box;
	max-width: 1280px;
	margin: 0 auto;
	color: var(--td-ink);
	font-size: 16px;
	line-height: 1.5;
}

.terra-devis *,
.terra-devis *::before,
.terra-devis *::after { box-sizing: inherit; }

/* ---- Mise en page : desktop = sommaire + page défilante ---- */

.td-mode-desktop { display: flex; gap: 26px; align-items: flex-start; }

.td-sidebar {
	flex: 0 0 250px;
	position: sticky;
	top: 20px;
	background: #fff;
	border: 1px solid var(--td-line);
	border-radius: var(--td-radius);
	padding: 20px 16px;
}

.td-sidebar-title { font-size: 21px; font-weight: 700; }
.td-sidebar-sub { font-size: 13px; color: var(--td-muted); margin-bottom: 16px; }

.td-side-step {
	display: flex;
	gap: 11px;
	width: 100%;
	padding: 9px 8px;
	border: 0;
	background: none;
	border-radius: 8px;
	cursor: pointer;
	text-align: left;
	font: inherit;
	color: inherit;
	align-items: flex-start;
}

.td-side-step:hover { background: var(--td-bg); }

.td-side-n {
	flex: none;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	background: #cfd6dc;
	color: #fff;
	font-weight: 700;
	font-size: 14px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin-top: 2px;
}

.td-side-step.is-active .td-side-n,
.td-side-step.is-done .td-side-n { background: var(--td-accent); }

.td-side-l { display: block; font-weight: 700; font-size: 14.5px; }
.td-side-s { display: block; font-size: 12.5px; color: var(--td-muted); }

.td-sidebar-help {
	margin-top: 18px;
	padding: 13px;
	background: var(--td-bg);
	border-radius: 8px;
	font-size: 13.5px;
	line-height: 1.7;
}

.td-sidebar-help a { color: var(--td-accent); }

.td-mainwrap { flex: 1; min-width: 0; }
.td-main { display: flex; flex-direction: column; gap: 22px; }

.td-section {
	background: #fff;
	border: 1px solid var(--td-line);
	border-radius: var(--td-radius);
	padding: 22px;
}

.td-title { margin: 0 0 16px; font-size: 20px; font-weight: 700; }
.td-title-n { color: var(--td-accent); }

/* Fil d'étapes mobile (points) */
.td-dots { display: none; }

/* Mode mobile : wizard */
.td-mode-mobile { display: block; }
.td-mode-mobile .td-sidebar { display: none; }

.td-mode-mobile .td-dots {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 4px;
	margin-bottom: 16px;
}

.td-dot {
	width: 27px;
	height: 27px;
	border-radius: 50%;
	background: #cfd6dc;
	color: #fff;
	font-size: 13px;
	font-weight: 700;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: none;
}

.td-dot.is-active, .td-dot.is-done { background: var(--td-accent); }
.td-dot-line { flex: 0 1 34px; height: 2px; background: var(--td-line); }

.td-nav { display: none; }

.td-mode-mobile .td-nav {
	display: flex;
	justify-content: space-between;
	gap: 12px;
	margin-top: 16px;
}

/* ---- Messages ---- */

/* Message flash : superposition fixe (hors flux — ne casse jamais la mise en page) */
.td-flash {
	position: fixed;
	top: 22px;
	left: 50%;
	z-index: 100000;
	max-width: min(560px, 92vw);
	padding: 12px 18px;
	border-radius: 10px;
	background: #b3282d;
	color: #fff;
	font-weight: 600;
	font-size: 15px;
	box-shadow: 0 8px 30px rgba(0,0,0,.25);
	opacity: 0;
	transform: translateX(-50%) translateY(-8px);
	transition: opacity .25s, transform .25s;
	pointer-events: none;
}

.td-flash.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- Boutons ---- */

.td-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 12px 26px;
	border-radius: 999px;
	border: 2px solid transparent;
	font-size: 16px;
	font-weight: 700;
	cursor: pointer;
	transition: background .15s, color .15s, border-color .15s;
	line-height: 1.2;
	font-family: inherit;
}

.td-btn-primary { background: var(--td-accent); color: #fff; }
.td-btn-primary:hover { background: var(--td-accent-dark); }
.td-btn-primary:disabled { opacity: .55; cursor: wait; }

.td-btn-ghost { background: #fff; border-color: var(--td-line); color: var(--td-ink); }
.td-btn-ghost:hover { border-color: var(--td-accent); color: var(--td-accent); }

.td-btn-sm { padding: 8px 16px; font-size: 14px; }

/* ---- Étape 1 : cartes ---- */

.td-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
	gap: 12px;
}

.td-card {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 7px;
	padding: 15px;
	background: #fff;
	border: 2px solid var(--td-line);
	border-radius: var(--td-radius);
	cursor: pointer;
	text-align: left;
	transition: border-color .15s, box-shadow .15s;
	font: inherit;
	color: inherit;
}

.td-card:hover { border-color: #b9c2ca; box-shadow: 0 3px 14px rgba(0,0,0,.07); }
.td-card.is-selected { border-color: var(--td-accent); box-shadow: 0 3px 16px rgba(179,40,45,.16); }

.td-card-icon { width: 38px; height: 38px; color: var(--td-accent); }
.td-card-icon svg { width: 100%; height: 100%; }
.td-card-label { font-weight: 700; font-size: 15px; }
.td-card-desc { font-size: 12.5px; color: var(--td-muted); }

/* ---- Champs / formulaires ---- */

.td-label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 5px; }

.td-input {
	width: 100%;
	padding: 11px 14px;
	border: 1px solid var(--td-line);
	border-radius: 8px;
	font: inherit;
	font-size: 15px;
	color: var(--td-ink);
	background: #fff;
}

.td-input:focus {
	outline: none;
	border-color: var(--td-accent);
	box-shadow: 0 0 0 3px rgba(179,40,45,.12);
}

textarea.td-input { resize: vertical; }

.td-form { display: flex; flex-wrap: wrap; gap: 14px; }
.td-field { flex: 1 1 100%; margin-bottom: 4px; }
.td-field.td-w50 { flex: 1 1 calc(50% - 7px); min-width: 230px; }

.td-qgroup {
	margin-top: 16px;
	padding: 16px;
	background: var(--td-bg);
	border: 1px solid var(--td-line);
	border-radius: var(--td-radius);
}

.td-qgroup-title { font-weight: 700; margin-bottom: 12px; }
.td-qgroup-title small { font-weight: 400; color: var(--td-muted); }
.td-qgroup .td-field { margin-bottom: 12px; }

.td-radios { display: flex; gap: 8px; flex-wrap: wrap; }

.td-radio-pill { cursor: pointer; }
.td-radio-pill input { position: absolute; opacity: 0; }

.td-radio-pill span {
	display: inline-block;
	padding: 8px 18px;
	border: 1px solid var(--td-line);
	border-radius: 999px;
	background: #fff;
	font-size: 14px;
	font-weight: 600;
	color: var(--td-muted);
}

.td-radio-pill input:checked + span {
	background: var(--td-accent);
	border-color: var(--td-accent);
	color: #fff;
}

/* Pot de miel */
.td-hp { position: absolute !important; left: -6000px !important; width: 1px; height: 1px; overflow: hidden; }

/* ---- Onglets / recherche ---- */

.td-tabs { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }

.td-tab {
	padding: 8px 18px;
	border: 1px solid var(--td-line);
	border-radius: 999px;
	background: #fff;
	cursor: pointer;
	font: inherit;
	font-size: 14px;
	font-weight: 600;
	color: var(--td-muted);
}

.td-tab.is-active { background: var(--td-accent); border-color: var(--td-accent); color: #fff; }

.td-autowrap { position: relative; flex: 1; }

.td-suggest:empty { display: none; }

.td-suggest {
	position: absolute;
	top: calc(100% + 4px);
	left: 0;
	right: 0;
	z-index: 1400;
	background: #fff;
	border-radius: 8px;
	box-shadow: 0 8px 26px rgba(0,0,0,.16);
	overflow: hidden;
}

.td-suggest-item {
	display: block;
	width: 100%;
	padding: 10px 14px;
	border: 0;
	background: none;
	text-align: left;
	cursor: pointer;
	font: inherit;
	font-size: 14px;
}

.td-suggest-item small { color: var(--td-muted); }
.td-suggest-item:hover { background: var(--td-bg); }

.td-parcelle-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.td-f-commune { min-width: 210px; }
.td-f-section { width: 110px; flex: none; }
.td-f-numero { width: 110px; flex: none; }

.td-found {
	margin-top: 12px;
	padding: 11px 14px;
	background: #eef7ef;
	border: 1px solid #bcdec1;
	border-radius: 8px;
	font-size: 14.5px;
}

.td-found-ok {
	display: inline-flex;
	width: 20px; height: 20px;
	border-radius: 50%;
	background: #2e9e5b;
	color: #fff;
	align-items: center;
	justify-content: center;
	font-size: 12px;
	margin-right: 4px;
}

.td-found-surf { float: right; font-weight: 700; }

.td-selection { margin-top: 14px; }
.td-sel-title { font-weight: 700; margin-bottom: 8px; }

.td-chips { display: flex; flex-wrap: wrap; gap: 8px; font-size: 14px; }
.td-chips em { color: var(--td-muted); }

.td-chip {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	padding: 6px 8px 6px 12px;
	background: #fff;
	border: 1px solid var(--td-accent);
	color: var(--td-accent-dark);
	border-radius: 999px;
	font-weight: 600;
}

.td-chip small { color: var(--td-muted); font-weight: 400; }

.td-chip button {
	border: 0;
	background: var(--td-accent);
	color: #fff;
	width: 20px;
	height: 20px;
	border-radius: 50%;
	cursor: pointer;
	font-size: 13px;
	line-height: 1;
	padding: 0;
}

/* ---- Étape 3 : carte + outils ---- */

.td-mapbar {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 12px;
	flex-wrap: wrap;
	margin-bottom: 10px;
}

.td-fonds { display: flex; gap: 6px; flex-wrap: wrap; }

.td-fond {
	padding: 7px 15px;
	border: 1px solid var(--td-line);
	border-radius: 8px;
	background: #fff;
	cursor: pointer;
	font: inherit;
	font-size: 13.5px;
	font-weight: 600;
	color: var(--td-muted);
}

.td-fond.is-active { background: var(--td-ink); border-color: var(--td-ink); color: #fff; }

.td-check { display: inline-flex; gap: 7px; align-items: center; font-size: 14px; cursor: pointer; }
.td-check input { accent-color: var(--td-accent); width: 16px; height: 16px; }

.td-maprow { display: flex; gap: 12px; }

#td-map {
	flex: 1;
	height: 60vh;
	min-height: 420px;
	border-radius: var(--td-radius);
	border: 1px solid var(--td-line);
	z-index: 1;
	background: #dfe8dc;
}

#td-map.td-fond-blanc { background: #f7f6f2; }

.td-toolside { flex: 0 0 185px; display: flex; flex-direction: column; gap: 8px; }

.td-tool-title { font-weight: 700; font-size: 13.5px; margin-top: 4px; }

.td-types { display: flex; flex-direction: column; gap: 6px; }

.td-type {
	display: flex;
	align-items: center;
	gap: 9px;
	padding: 8px 11px;
	border: 2px solid var(--td-line);
	border-radius: 8px;
	background: #fff;
	cursor: pointer;
	font: inherit;
	font-size: 13.5px;
	font-weight: 600;
	text-align: left;
}

.td-type.is-active { border-color: var(--td-ink); background: var(--td-bg); }

.td-swatch { width: 15px; height: 15px; border-radius: 4px; flex: none; }
.td-swatch-parcelle { background: #ffd100; }

.td-legende {
	display: flex;
	flex-direction: column;
	gap: 5px;
	padding: 10px;
	background: var(--td-bg);
	border: 1px solid var(--td-line);
	border-radius: 8px;
	font-size: 12.5px;
}

.td-leg-item { display: flex; align-items: center; gap: 8px; }

.td-parcelle-tip {
	background: rgba(35,41,46,.85);
	border: 0;
	color: #ffd100;
	font-weight: 700;
	box-shadow: none;
	padding: 1px 6px;
}

.td-parcelle-tip::before { display: none; }

.td-hint {
	margin-top: 10px;
	padding: 11px 14px;
	background: #fdf6e7;
	border: 1px solid #f0dfb4;
	border-radius: 8px;
	font-size: 14px;
}

.td-astuce { margin-top: 8px; font-size: 13.5px; color: var(--td-muted); }

/* ---- Étape 5 : upload, récap, envoi ---- */

.td-drop {
	display: block;
	padding: 26px 16px;
	border: 2px dashed var(--td-line);
	border-radius: var(--td-radius);
	background: #fff;
	text-align: center;
	color: var(--td-muted);
	cursor: pointer;
	font-size: 14.5px;
}

.td-drop.is-over, .td-drop:hover { border-color: var(--td-accent); color: var(--td-accent-dark); }

.td-filelist { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; }

.td-recap-box { margin-top: 16px; }

.td-recap-row {
	display: flex;
	gap: 16px;
	padding: 10px 14px;
	background: #fff;
	border: 1px solid var(--td-line);
	border-radius: 8px;
	margin-bottom: 6px;
}

.td-recap-row > span { flex: 0 0 120px; color: var(--td-muted); font-size: 13.5px; font-weight: 600; }
.td-recap-row > strong { font-weight: 600; font-size: 14.5px; }

.td-consent {
	display: flex;
	gap: 10px;
	align-items: flex-start;
	font-size: 14px;
	color: var(--td-muted);
	cursor: pointer;
	margin: 16px 0;
}

.td-consent input { margin-top: 3px; accent-color: var(--td-accent); width: 17px; height: 17px; flex: none; }
.td-consent a { color: var(--td-accent); }

.td-btn-send { width: 100%; padding: 16px; font-size: 18px; }

.td-progress {
	margin-top: 14px;
	font-weight: 600;
	display: flex;
	align-items: center;
	gap: 10px;
	flex-wrap: wrap;
}

.td-spinner {
	width: 20px;
	height: 20px;
	border: 3px solid var(--td-line);
	border-top-color: var(--td-accent);
	border-radius: 50%;
	animation: td-spin .8s linear infinite;
	flex: none;
}

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

.td-error {
	width: 100%;
	padding: 14px 16px;
	border: 1px solid var(--td-accent);
	border-radius: var(--td-radius);
	background: #fdf1f1;
	font-weight: 400;
}

.td-secure { font-size: 13px; color: var(--td-muted); margin-top: 12px; }

.td-success { text-align: center; padding: 46px 16px; background: #fff; border: 1px solid var(--td-line); border-radius: var(--td-radius); }

.td-success-icon {
	width: 74px;
	height: 74px;
	margin: 0 auto 16px;
	border-radius: 50%;
	background: #2e9e5b;
	color: #fff;
	font-size: 40px;
	line-height: 74px;
	font-weight: 700;
}

.td-success h3 { font-size: 26px; margin: 0 0 12px; }
.td-success-contact { color: var(--td-muted); }
.td-success-contact a { color: var(--td-accent); }

/* ---- Responsive ---- */

@media (max-width: 1020px) {
	.td-maprow { flex-direction: column; }
	.td-toolside { flex-direction: row; flex-wrap: wrap; flex: 1 1 auto; align-items: center; }
	.td-types { flex-direction: row; flex-wrap: wrap; }
	.td-legende { flex: 1 1 100%; flex-direction: row; flex-wrap: wrap; gap: 12px; }
}

@media (max-width: 820px) {
	#td-map { height: 55vh; min-height: 340px; }

	/* Récapitulatif compact */
	.td-recap-row {
		flex-direction: column;
		gap: 1px;
		padding: 7px 11px;
		margin-bottom: 4px;
	}

	.td-recap-row > span { flex: none; font-size: 12px; }
	.td-recap-row > strong { font-size: 14px; line-height: 1.35; }
	.td-found-surf { float: none; display: block; }
	.td-parcelle-form .td-btn { width: 100%; }
	.td-section { padding: 16px; }
}


/* ---- Cadre d'introduction (bien visible) ---- */

.td-intro {
	display: flex;
	gap: 14px;
	align-items: flex-start;
	background: #fdf3f3;
	border: 2px solid var(--td-accent);
	border-radius: var(--td-radius);
	padding: 18px 20px;
	margin-bottom: 18px;
	font-size: 15.5px;
	line-height: 1.65;
	color: #33272a;
	box-shadow: 0 3px 14px rgba(179,40,45,.10);
}

.td-intro-icon {
	flex: none;
	width: 34px;
	height: 34px;
	color: var(--td-accent);
	margin-top: 2px;
}

.td-intro-icon svg { width: 100%; height: 100%; }

.td-intro-title {
	display: block;
	font-size: 19px;
	font-weight: 800;
	color: var(--td-accent-dark);
	margin-bottom: 6px;
}

/* ---- v1.2 : conseil/astuce au-dessus de la carte ---- */

.td-hint { margin-top: 0; margin-bottom: 8px; }
.td-astuce { margin: 0 0 12px; }

/* ---- Icône poubelle pour la suppression de forme ---- */
.terra-devis .leaflet-pm-toolbar .leaflet-pm-icon-delete {
	background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%23333333" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 7h16M9 7V4h6v3M6 7l1 13a1.5 1.5 0 0 0 1.5 1.3h7A1.5 1.5 0 0 0 17 20l1-13M10 11v6M14 11v6"/></svg>') !important;
	background-size: 65% !important;
	background-repeat: no-repeat !important;
	background-position: center !important;
}

/* ---- v1.2 : carte en plein écran ---- */

.td-fs a { font-size: 17px; }

.terra-devis .td-maprow.td-full {
	position: fixed;
	inset: 0;
	z-index: 99990;
	background: #fff;
	margin: 0;
	padding: 12px;
}

.terra-devis .td-maprow.td-full #td-map {
	height: calc(100vh - 24px);
	min-height: 0;
	flex: 1;
}

body.td-noscroll { overflow: hidden !important; }

@media (max-width: 1020px) {
	.terra-devis .td-maprow.td-full { overflow: auto; }
	.terra-devis .td-maprow.td-full #td-map { height: 62vh; flex: none; }
}


/* ---- v1.3 : logo, aide, légende des outils, info conditionnelle ---- */

.td-logo {
	display: block;
	width: 100%;
	max-width: 205px;
	height: auto;
	margin: 2px auto 14px;
}

.td-logo-mobile { display: none; }
.td-mode-mobile .td-logo-mobile { display: block; max-width: 215px; margin: 0 auto 14px; }

.td-sidebar-help {
	font-size: 15px;
	text-align: center;
}

.td-sidebar-help strong { display: block; font-size: 16px; margin-bottom: 6px; }

.td-help-tel {
	display: block;
	font-size: 21px;
	font-weight: 800;
	color: var(--td-accent) !important;
	text-decoration: none;
	margin: 2px 0 4px;
	letter-spacing: .3px;
}

.td-help-tel:hover { color: var(--td-accent-dark) !important; }

.td-help-mail {
	display: block;
	font-size: 14.5px;
	color: var(--td-ink) !important;
	text-decoration: underline;
	word-break: break-all;
}

.td-leg-tools { color: #3d454c; }

/* Icônes de la légende = icônes réelles de la barre d'outils Geoman */
.td-leg-ico {
	display: inline-flex;
	width: 19px;
	height: 19px;
	flex: none;
	background: none;
	border: 0;
	box-shadow: none;
}

.td-leg-ico .control-icon {
	display: block;
	position: static !important;
	width: 100% !important;
	height: 100% !important;
	margin: 0 !important;
	padding: 0 !important;
	background-size: contain !important;
	background-repeat: no-repeat !important;
	background-position: center !important;
}

.td-qinfo {
	padding: 10px 13px;
	background: #eef6fd;
	border: 1px solid #b9dcf5;
	border-radius: 8px;
	font-size: 13.5px;
	color: #1f4e6e;
}



/* ---- v1.7 : accès direct à la carte (étape 2) ---- */

.td-skip {
	margin-top: 4px;
	padding: 12px 14px;
	background: var(--td-bg);
	border: 1px dashed var(--td-line);
	border-radius: var(--td-radius);
	display: flex;
	align-items: center;
	gap: 12px;
	flex-wrap: wrap;
}

.td-skip-txt { font-size: 14px; color: var(--td-muted); flex: 1 1 240px; }
.td-skip .td-btn { flex: none; }

@media (max-width: 820px) {
	.td-skip .td-btn { width: 100%; }
}

/* ---- v1.7 : sur mobile, masquer « Retirer le dernier sommet » pendant le
   dessin pour que « Terminer » reste toujours visible (règle imparable,
   indépendante de l'API Geoman) ---- */

@media (max-width: 820px) {
	.terra-devis .leaflet-pm-action.action-removeLastVertex { display: none !important; }
}


/* ---- v1.7.1 : finitions mobiles ---- */

/* Consigne simple en étape 1 (remplace le cartouche rouge sur mobile) */
.td-choose { display: none; }

.td-mode-mobile .td-choose {
	display: block;
	margin: 0 0 12px;
	font-size: 15.5px;
	font-weight: 600;
	color: var(--td-ink);
}

/* Séparateur « ou » entre la recherche et l'accès direct à la carte */
.td-or {
	display: flex;
	align-items: center;
	gap: 12px;
	margin: 22px 0 10px;
	color: var(--td-muted);
	font-size: 13.5px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: .5px;
}

.td-or::before,
.td-or::after {
	content: '';
	flex: 1;
	height: 1px;
	background: var(--td-line);
}

/* Onglets de localisation côte à côte sur mobile */
@media (max-width: 820px) {
	.td-tabs { flex-wrap: nowrap; gap: 6px; }

	.td-tab {
		flex: 1 1 0;
		padding: 9px 6px;
		font-size: 12.5px;
		text-align: center;
		white-space: nowrap;
	}
}


/* ---- v1.8 : logo cliquable ---- */

.td-logo-link { display: block; line-height: 0; }
.td-logo-mobile-link { display: none; }
.td-mode-mobile .td-logo-mobile-link { display: block; }
.td-mode-mobile .td-logo-mobile-link .td-logo-mobile { display: block; }
