/* =========================
   MESSAGERIE - Inbox (/account/messages/) et conversation (/account/messages/{thread}/)
   Coquilles : hivepress/message/tfd-inbox.php et tfd-thread.php ; contenu rendu par
   tfd-core/assets/js/tfd-messaging.js. Chargé sur les deux routes (functions.php).
   Même vocabulaire que My listings : carte 12px, bordure #e6e6e6, badges, orange #F15A29.
   Badge rouge = compteur de non-lus, comme le badge natif du menu compte.
========================= */

/* L'attribut hidden (posé par le JS) doit gagner sur les display: définis ci-dessous. */
.tfd-inbox [hidden],
.tfd-thread [hidden] {
	display: none !important;
}

/* Espace avant le footer du site. */
.tfd-inbox,
.tfd-thread {
	margin-bottom: 48px;
}

/* ---------- Inbox ---------- */

.tfd-inbox__list {
	border: 1px solid #e6e6e6;
	border-radius: 12px;
	background: #fff;
	overflow: hidden;
}

.tfd-inbox__state {
	margin: 0;
	padding: 28px 16px;
	text-align: center;
	font-size: 14px;
	color: #6b6b6b;
}

.tfd-inbox__state--error {
	color: #c62828;
}

.tfd-inbox__row {
	display: grid;
	grid-template-columns: 56px minmax(0, 1fr) auto;
	gap: 16px;
	align-items: center;
	padding: 14px 16px;
	border-bottom: 1px solid #eee;
	color: inherit;
	text-decoration: none;
	transition: background .15s;
}

.tfd-inbox__row:last-child {
	border-bottom: 0;
}

.tfd-inbox__row:hover,
.tfd-inbox__row:focus-visible {
	background: #fff7f2;
	outline: none;
}

.tfd-inbox__thumb {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 56px;
	height: 56px;
	border-radius: 8px;
	background: #f3f3f3;
	color: #b5b5b5;
	overflow: hidden;
	flex: 0 0 auto;
}

.tfd-inbox__thumb img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.tfd-inbox__thumb svg {
	width: 22px;
	height: 22px;
}

.tfd-inbox__thumb.is-off {
	opacity: .55;
}

.tfd-inbox__body {
	display: flex;
	flex-direction: column;
	gap: 3px;
	min-width: 0;
}

.tfd-inbox__who {
	display: flex;
	align-items: baseline;
	flex-wrap: wrap;
	gap: 4px 10px;
	min-width: 0;
}

.tfd-inbox__name {
	font-size: 15px;
	font-weight: 600;
	color: #202A35;
}

.tfd-inbox__listing {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	max-width: 100%;
	font-size: 13px;
	color: #6b6b6b;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.tfd-inbox__listing svg {
	width: 12px;
	height: 12px;
	flex: 0 0 auto;
}

.tfd-inbox__listing.is-off {
	text-decoration: line-through;
	opacity: .7;
}

.tfd-inbox__preview {
	font-size: 14px;
	color: #6b6b6b;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.tfd-inbox__row.is-unread .tfd-inbox__preview {
	color: #202A35;
	font-weight: 600;
}

.tfd-inbox__meta {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 6px;
	font-size: 13px;
	color: #8a8a8a;
	white-space: nowrap;
}

.tfd-inbox__row.is-unread .tfd-inbox__meta {
	color: #F15A29;
	font-weight: 500;
}

.tfd-inbox__count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 18px;
	height: 18px;
	padding: 0 5px;
	border-radius: 999px;
	background: #e5383b;
	color: #fff;
	font-size: 11px;
	font-weight: 600;
	line-height: 1;
}

/* Bouton neutre à contour (pas la couleur secondaire verte du thème). */
.tfd-inbox__more {
	display: block;
	margin: 16px auto 0;
	padding: 10px 18px;
	border: 1px solid #e0e0e0;
	border-radius: 8px;
	background: #fff;
	color: #2d2d2d;
	font: inherit;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
}

.tfd-inbox__more:hover,
.tfd-inbox__more:focus-visible {
	border-color: #F15A29;
	color: #F15A29;
	outline: none;
}

.tfd-inbox__more:disabled {
	opacity: .6;
	cursor: default;
}

/* Badge d'état (annonce supprimée) : même dessin que My listings. */
.tfd-badge {
	display: inline-block;
	padding: 3px 10px;
	border-radius: 6px;
	font-size: 12px;
	font-weight: 500;
	line-height: 1.5;
	white-space: nowrap;
	background: #eee;
	color: #555;
}

/* ---------- Conversation ---------- */

.tfd-thread {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.tfd-thread__back {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	align-self: flex-start;
	font-size: 14px;
	font-weight: 500;
	color: #6b6b6b;
	text-decoration: none;
}

.tfd-thread__back svg {
	width: 14px;
	height: 14px;
}

.tfd-thread__back:hover {
	color: #F15A29;
}

.tfd-thread__card {
	border: 1px solid #e6e6e6;
	border-radius: 12px;
	background: #fff;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.tfd-thread__head {
	display: grid;
	grid-template-columns: 56px minmax(0, 1fr) auto;
	gap: 16px;
	align-items: center;
	padding: 14px 16px;
	border-bottom: 1px solid #eee;
}

.tfd-thread__head-text {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.tfd-thread__listing {
	font-size: 16px;
	font-weight: 600;
	color: #202A35;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.tfd-thread__with {
	font-size: 13px;
	color: #6b6b6b;
}

.tfd-thread__ghost {
	padding: 9px 14px;
	border: 1px solid #e0e0e0;
	border-radius: 8px;
	font-size: 13px;
	font-weight: 600;
	color: #2d2d2d;
	text-decoration: none;
	white-space: nowrap;
}

.tfd-thread__ghost:hover {
	border-color: #F15A29;
	color: #F15A29;
}

.tfd-thread__older {
	align-self: center;
	margin: 12px auto 0;
	background: none;
	border: 0;
	padding: 6px 10px;
	font-size: 13px;
	font-weight: 500;
	color: #6b6b6b;
	cursor: pointer;
}

.tfd-thread__older:hover {
	color: #F15A29;
}

.tfd-thread__messages {
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding: 20px 16px;
	max-height: 60vh;
	overflow-y: auto;
	overscroll-behavior: contain;
}

.tfd-thread__state {
	margin: 0;
	text-align: center;
	font-size: 14px;
	color: #6b6b6b;
}

.tfd-thread__state--error {
	color: #c62828;
}

.tfd-msg-day {
	align-self: center;
	font-size: 12px;
	font-weight: 500;
	letter-spacing: .04em;
	text-transform: uppercase;
	color: #8a8a8a;
}

.tfd-msg {
	max-width: 68%;
	padding: 12px 14px;
	border-radius: 14px;
	font-size: 15px;
	line-height: 1.4;
	display: flex;
	flex-direction: column;
	gap: 6px;
	color: #202A35;
}

.tfd-msg--them {
	align-self: flex-start;
	background: #f3f2ef;
	border-bottom-left-radius: 4px;
}

.tfd-msg--me {
	align-self: flex-end;
	background: #fff1e8;
	border-bottom-right-radius: 4px;
}

.tfd-msg__text {
	overflow-wrap: anywhere;
}

.tfd-msg__time {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 11px;
	color: #8a8a8a;
}

.tfd-msg--me .tfd-msg__time {
	align-self: flex-end;
}

.tfd-msg__time svg {
	width: 13px;
	height: 13px;
}

.tfd-thread__compose {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	gap: 12px;
	align-items: end;
	padding: 14px 16px;
	border-top: 1px solid #eee;
	background: #fff;
}

.tfd-thread__compose textarea {
	width: 100%;
	min-height: 48px;
	resize: vertical;
	border: 1px solid #e0e0e0;
	border-radius: 10px;
	padding: 12px 14px;
	font: inherit;
	font-size: 14px;
	line-height: 1.4;
}

.tfd-thread__compose textarea:focus {
	border-color: #F15A29;
	outline: none;
}

.tfd-thread__compose button {
	white-space: nowrap;
}

.tfd-thread__error {
	grid-column: 1 / -1;
	margin: 0;
	font-size: 13px;
	color: #c62828;
}

.tfd-thread__closed {
	margin: 0;
	padding: 14px 16px;
	border-top: 1px solid #eee;
	font-size: 14px;
	color: #6b6b6b;
	text-align: center;
}

/* ---------- Mobile ---------- */

@media (max-width: 767px) {
	.tfd-inbox__row {
		grid-template-columns: 48px minmax(0, 1fr) auto;
		gap: 12px;
	}

	.tfd-inbox__thumb {
		width: 48px;
		height: 48px;
	}

	.tfd-inbox__who {
		flex-direction: column;
		align-items: flex-start;
		gap: 1px;
	}

	.tfd-thread__head {
		grid-template-columns: 44px minmax(0, 1fr);
	}

	.tfd-thread__head .tfd-inbox__thumb {
		width: 44px;
		height: 44px;
	}

	.tfd-thread__ghost,
	.tfd-thread__head .tfd-badge {
		grid-column: 2;
		justify-self: start;
	}

	.tfd-thread__messages {
		max-height: none;
		min-height: 40vh;
		overflow: visible;
	}

	.tfd-msg {
		max-width: 84%;
	}

	.tfd-thread__compose {
		position: sticky;
		bottom: 0;
		grid-template-columns: minmax(0, 1fr) auto;
	}
}
