/* Chat IA — modale fiche profil (mobile-first). Reprend les couleurs du thème
   via --couleur_1 / --couleur_2, avec repli si non définies. */

.htr-chat-modal {
	--htr-c1: var(--couleur_1, #772fb9);
	--htr-c2: var(--couleur_2, #fe6595);
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: none;
	background: rgba(0, 0, 0, .45);
	backdrop-filter: blur(3px);
}
.htr-chat-modal.open { display: block; }
body.htr-chat-noscroll { overflow: hidden; }

.htr-chat-box {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	background: #f4f5f7;
	max-width: 480px;
	margin: 0 auto;
	box-shadow: 0 0 40px rgba(0, 0, 0, .3);
}

/* Header */
.htr-chat-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 12px 14px;
	background: linear-gradient(135deg, var(--htr-c1) 0%, var(--htr-c2) 100%);
	color: #fff;
	flex-shrink: 0;
}
.htr-chat-close {
	background: none;
	border: 0;
	color: #fff;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	padding: 4px 8px;
	opacity: .9;
}
.htr-chat-close:hover { opacity: 1; }
.htr-chat-avatar {
	width: 42px;
	height: 42px;
	border-radius: 50%;
	overflow: hidden;
	background: rgba(255, 255, 255, .25);
	flex-shrink: 0;
}
.htr-chat-avatar img { width: 100%; height: 100%; object-fit: cover; object-position: center top; }
.htr-chat-name { font-weight: 700; font-size: 1rem; line-height: 1.1; }
.htr-chat-status { font-size: .78rem; opacity: .95; display: flex; align-items: center; gap: 5px; }
.htr-chat-dot {
	width: 8px; height: 8px; border-radius: 50%;
	background: #4ade80; display: inline-block;
	box-shadow: 0 0 0 0 rgba(74, 222, 128, .7);
	animation: htrPulse 1.8s infinite;
}
@keyframes htrPulse {
	0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, .6); }
	70% { box-shadow: 0 0 0 7px rgba(74, 222, 128, 0); }
	100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

/* Ligne système (ex. « Mia a quitté le chat ») */
.htr-chat-sys {
	align-self: center;
	color: #9aa0ad;
	font-size: .78rem;
	font-style: italic;
	margin: 6px 0;
	text-align: center;
}
.htr-chat-dot.off { background: #c2c6cf; box-shadow: none; animation: none; }

/* Messages */
.htr-chat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px 14px;
	display: flex;
	flex-direction: column;
	gap: 8px;
}
/* Une ligne = (avatar) + bulle */
.htr-chat-row {
	display: flex;
	align-items: flex-end;
	gap: 8px;
}
.htr-row-user { justify-content: flex-end; }
.htr-row-assistant { justify-content: flex-start; }
.htr-chat-bub-av {
	width: 30px;
	height: 30px;
	border-radius: 50%;
	object-fit: cover;
	object-position: center top;
	flex-shrink: 0;
	box-shadow: 0 1px 3px rgba(0, 0, 0, .15);
}

.htr-chat-bubble {
	max-width: 80%;
	padding: 9px 13px;
	border-radius: 18px;
	font-size: .95rem;
	line-height: 1.35;
	text-align: left;
	word-wrap: break-word;
	white-space: pre-wrap;
}
.htr-chat-bubble.htr-user {
	align-self: flex-end;
	background: linear-gradient(135deg, var(--htr-c1) 0%, var(--htr-c2) 100%);
	color: #fff;
	border-bottom-right-radius: 5px;
}
.htr-chat-bubble.htr-assistant {
	align-self: flex-start;
	background: #fff;
	color: #1f2330;
	border-bottom-left-radius: 5px;
	box-shadow: 0 1px 2px rgba(0, 0, 0, .08);
}

/* Numéro 06 intégré dans la bulle (chiffres cliquables, naturel — pas un bouton CTA) */
.htr-chat-num {
	font-weight: 800;
	color: var(--htr-c1) !important;
	text-decoration: underline;
	white-space: nowrap;
}
.htr-chat-num:hover { filter: brightness(1.1); }

/* Indicateur de frappe */
/* Indicateur de frappe : « {prénom} écrit… » dans la couleur du thème */
.htr-chat-typing-text {
	align-self: flex-end;
	color: var(--htr-c1);
	font-style: italic;
	font-size: .85rem;
	padding: 4px 2px;
}
.htr-chat-typing-text::after {
	content: '';
	animation: htrTypingDots 1.4s steps(1, end) infinite;
}
@keyframes htrTypingDots {
	0%   { content: ''; }
	25%  { content: '.'; }
	50%  { content: '..'; }
	75%  { content: '...'; }
	100% { content: ''; }
}

/* Saisie */
.htr-chat-input {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px;
	background: #fff;
	border-top: 1px solid #e6e8ee;
	flex-shrink: 0;
}
.htr-chat-input textarea {
	flex: 1 1 auto;
	min-width: 0;          /* clé : permet au textarea de s'étirer/rétrécir en flex */
	width: 100%;
	display: block;
	box-sizing: border-box;
	height: 44px;          /* hauteur de base (1 ligne), agrandie par JS au besoin */
	border: 1px solid #d7dae3;
	border-radius: 22px;
	padding: 10px 16px;
	margin: 0;
	font-size: 16px;        /* 16px = pas de zoom auto iOS */
	font-family: inherit;
	line-height: 1.4;
	outline: none;
	resize: none;
	overflow-y: auto;
	max-height: 110px;
	background: #f4f5f7;
}
.htr-chat-input textarea:focus { border-color: var(--htr-c1); background: #fff; }
.htr-chat-send {
	width: 44px; height: 44px;
	flex-shrink: 0;
	border: 0;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--htr-c1) 0%, var(--htr-c2) 100%);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
}
.htr-chat-send svg { width: 20px; height: 20px; }

/* Bouton d'ouverture posé sur la fiche */
.htr-chat-open-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: 100%;
	box-sizing: border-box;
	margin: 8px 0;
	padding: 13px 18px;
	border: 0;
	border-radius: 30px;
	background: linear-gradient(135deg, var(--couleur_1, #772fb9) 0%, var(--couleur_2, #fe6595) 100%);
	color: #fff;
	font-size: 1rem;
	font-weight: 700;
	cursor: pointer;
	text-decoration: none;
}
.htr-chat-open-btn:hover { filter: brightness(1.07); }

/* Version compacte dans les cellules profil (listes home/catégorie/related) */
.trk_profile_block .htr-chat-open-btn {
	font-size: .9rem;
	padding: 10px 12px;
	margin: 6px 0;
}
