/* ============================================================
   CHATBOT TICQ — Widget flottant
   Flux : Cookies → Email → Chat
   ============================================================ */

/* --- Bouton flottant --- */
#ticq-chat-toggle {
	position: fixed;
	bottom: 28px;
	right: 28px;
	width: 60px;
	height: 60px;
	border-radius: var(--ticq-radius-round, 50%);
	background-color: var(--ticq-color-primary, #6B3A2A);
	color: #fff;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 4px 20px rgba(0,0,0,0.25);
	z-index: 10000005 !important;
	/* 'bottom' inclus pour la transition quand le bandeau cookies est ouvert */
	transition: transform 0.25s ease, background-color 0.25s ease,
	            box-shadow 0.25s ease, bottom 0.32s ease;
}

#ticq-chat-toggle:hover {
	transform: scale(1.08);
	box-shadow: 0 6px 28px rgba(0,0,0,0.32);
}

#ticq-chat-toggle svg {
	width: var(--ticq-icon-lg);
	height: var(--ticq-icon-lg);
	fill: #fff;
}

#ticq-chat-toggle.is-open svg.icon-chat  { display: none; }
#ticq-chat-toggle svg.icon-close         { display: none; }
#ticq-chat-toggle.is-open svg.icon-close { display: block; }

/* Badge non-lus */
#ticq-chat-badge {
	position: absolute;
	top: -4px;
	right: -4px;
	width: 20px;
	height: 20px;
	border-radius: var(--ticq-radius-round);
	background-color: #e53935;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	transform: scale(0);
	transition: opacity 0.2s, transform 0.2s;
}

#ticq-chat-badge.visible {
	opacity: 1;
	transform: scale(1);
}

/* --- Fenêtre de chat --- */
#ticq-chat-window {
	position: fixed;
	bottom: 100px;
	right: 28px;
	width: 360px;
	max-width: calc(100vw - 40px);
	height: 540px;
	max-height: calc(100vh - 140px);
	background-color: #fff;
	border-radius: var(--ticq-radius-md);
	box-shadow: 0 8px 40px rgba(0,0,0,0.18);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	z-index: 10000004 !important;
	opacity: 0;
	visibility: hidden;
	transform: translateY(16px) scale(0.97);
	transform-origin: bottom right;
	transition: opacity 0.25s ease, visibility 0.25s ease, transform 0.25s ease;
}

#ticq-chat-window.is-open {
	opacity: 1;
	visibility: visible;
	transform: translateY(0) scale(1);
}

/* --- En-tête --- */
#ticq-chat-header {
	background-color: var(--ticq-color-primary);
	color: #fff;
	padding: 14px 18px;
	display: flex;
	align-items: center;
	gap: 12px;
	flex-shrink: 0;
}

#ticq-chat-header .ticq-avatar {
	width: 36px;
	height: 36px;
	border-radius: var(--ticq-radius-round);
	background-color: rgba(255,255,255,0.2);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 12px;
	font-weight: 800;
	letter-spacing: 0.03em;
	color: #fff;
	flex-shrink: 0;
}

#ticq-chat-header .ticq-chat-name {
	font-size: 13px;
	font-weight: 700;
	line-height: 1.3;
	font-family: var(--ticq-font-heading);
}

#ticq-chat-header .ticq-chat-status {
	font-size: 11px;
	opacity: 0.8;
	display: flex;
	align-items: center;
	gap: 5px;
	margin-top: 2px;
}

#ticq-chat-header .ticq-chat-status::before {
	content: '';
	width: 7px;
	height: 7px;
	border-radius: var(--ticq-radius-round);
	background-color: #4caf50;
	display: inline-block;
}

#ticq-chat-header-close {
	margin-left: auto;
	background: transparent;
	border: none;
	color: #ffffff;
	cursor: pointer;
	padding: 6px;
	border-radius: var(--ticq-radius-round, 50%);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background-color 0.2s ease, transform 0.15s ease;
}

#ticq-chat-header-close:hover {
	background-color: rgba(255, 255, 255, 0.2);
	transform: scale(1.08);
}

#ticq-chat-header-close svg {
	width: 20px;
	height: 20px;
	fill: #ffffff;
}

/* ============================================================
   ÉCRANS DE PRÉ-CHAT (Cookies + Email)
   ============================================================ */

.ticq-screen {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 28px 24px;
	background-color: #faf7f4;
	text-align: center;
	gap: 12px;
}

.ticq-screen h3 {
	font-size: 17px;
	font-weight: 700;
	color: #2d1a10;
	margin: 0;
	font-family: var(--ticq-font-heading);
}

.ticq-screen p {
	font-size: 13px;
	line-height: 1.6;
	color: #5a4030;
	margin: 0;
}

.ticq-privacy-link {
	font-size: 12px !important;
	color: #634d40 !important;
}

.ticq-privacy-link a {
	color: var(--ticq-color-primary, #6B3A2A);
	text-decoration: underline;
	font-weight: 600;
}

/* Boutons des écrans */
.ticq-screen-actions {
	display: flex;
	flex-direction: column;
	gap: 8px;
	width: 100%;
	margin-top: 4px;
}

.ticq-btn {
	display: block;
	width: 100%;
	padding: 12px 20px;
	border-radius: var(--ticq-radius-pill, 50px);
	font-size: 14px;
	font-weight: 700;
	border: 2px solid transparent;
	cursor: pointer;
	transition: opacity 0.2s, box-shadow 0.2s, transform 0.15s;
	text-align: center;
	font-family: var(--ticq-font-body, system-ui, sans-serif);
}

.ticq-btn--primary {
	background-color: var(--ticq-color-primary, #6B3A2A);
	color: #fff;
	border-color: var(--ticq-color-primary, #6B3A2A);
}

.ticq-btn--primary:hover {
	opacity: 0.92;
	transform: translateY(-1px);
	box-shadow: 0 4px 14px rgba(107,58,42,0.3);
}

.ticq-btn--ghost {
	background-color: transparent;
	color: #4d3527;
	border-color: #c4b4a4;
	font-size: 13px;
	font-weight: 600;
}

.ticq-btn--ghost:hover {
	background-color: #ede2d8;
}

/* Champ email */
#ticq-screen-email form {
	width: 100%;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

#ticq-email-input {
	width: 100%;
	padding: 12px 16px;
	border: 1px solid #d0c0b0;
	border-radius: var(--ticq-radius-sm);
	font-size: 14px;
	color: #2d1a10;
	background-color: #fff;
	outline: none;
	transition: border-color 0.2s;
	box-sizing: border-box;
	font-family: var(--ticq-font-body);
}

#ticq-email-input:focus {
	border-color: var(--ticq-color-primary);
	box-shadow: 0 0 0 3px rgba(107,58,42,0.1);
}

.ticq-field-error {
	font-size: 12px;
	color: #dc3545;
	text-align: left;
	padding: 0 4px;
}

/* ============================================================
   ÉCRAN CHAT
   ============================================================ */

#ticq-screen-chat {
	flex: 1;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

/* Zone messages */
#ticq-chat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 20px 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background-color: #faf7f4;
	scroll-behavior: smooth;
}

#ticq-chat-messages::-webkit-scrollbar       { width: 4px; }
#ticq-chat-messages::-webkit-scrollbar-track  { background: transparent; }
#ticq-chat-messages::-webkit-scrollbar-thumb  { background-color: #d0c0b0; border-radius: 4px; }

/* Bulles */
.ticq-msg {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	max-width: 90%;
}

.ticq-msg--bot  { align-self: flex-start; }
.ticq-msg--user { align-self: flex-end; flex-direction: row-reverse; }

.ticq-msg__bubble {
	padding: 10px 14px;
	border-radius: var(--ticq-radius-md);
	font-size: 14px;
	line-height: 1.55;
	word-break: break-word;
	font-family: var(--ticq-font-body);
}

.ticq-msg--bot .ticq-msg__bubble {
	background-color: #fff;
	color: #2d1a10;
	border-bottom-left-radius: 4px;
	box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.ticq-msg--user .ticq-msg__bubble {
	background-color: var(--ticq-color-primary);
	color: #fff;
	border-bottom-right-radius: 4px;
}

/* --- Contenu formaté dans les bulles bot --- */
.ticq-msg__bubble--formatted p {
	margin: 0 0 6px 0;
	line-height: 1.6;
}

.ticq-msg__bubble--formatted p:last-child {
	margin-bottom: 0;
}

.ticq-msg__bubble--formatted strong {
	font-weight: 700;
	color: var(--ticq-color-primary);
}

.ticq-msg__bubble--formatted em {
	font-style: italic;
	color: #5a4030;
}

/* Liens rendus comme boutons dans les réponses du bot */
.ticq-link-btn {
	display: inline-block;
	padding: 5px 14px;
	margin: 5px 3px 2px 0;
	background-color: var(--ticq-color-primary);
	color: #fff !important;
	border-radius: var(--ticq-radius-pill);
	text-decoration: none !important;
	font-size: 12px;
	font-weight: 600;
	line-height: 1.5;
	transition: opacity 0.15s;
	cursor: pointer;
	white-space: nowrap;
	vertical-align: middle;
	font-family: var(--ticq-font-body);
}

.ticq-link-btn:hover {
	opacity: 0.82;
	color: #fff !important;
}

/* Boutons de choix d'actions interactives directes */
.ticq-choice-btn {
	display: inline-flex;
	align-items: center;
	padding: 7px 15px;
	margin: 5px 4px 5px 0;
	background-color: #fdf6ec;
	color: var(--ticq-color-primary, #6B3A2A) !important;
	border: 1.5px solid var(--ticq-color-primary, #6B3A2A);
	border-radius: var(--ticq-radius-pill, 50px);
	font-size: 13px;
	font-weight: 700;
	line-height: 1.4;
	cursor: pointer;
	text-align: left;
	font-family: var(--ticq-font-body, system-ui, sans-serif);
	transition: background-color 0.2s ease, color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.ticq-choice-btn:hover {
	background-color: var(--ticq-color-primary, #6B3A2A);
	color: #ffffff !important;
	transform: translateY(-1px);
	box-shadow: 0 4px 10px rgba(107, 58, 42, 0.2);
}

.ticq-choice-btn:focus-visible {
	outline: 2px solid var(--ticq-color-accent, #C4813A);
	outline-offset: 2px;
}

.ticq-msg__bubble--formatted ol,
.ticq-msg__bubble--formatted ul {
	margin: 6px 0;
	padding-left: 20px;
}

.ticq-msg__bubble--formatted ol {
	list-style-type: decimal;
}

.ticq-msg__bubble--formatted ul {
	list-style-type: disc;
}

.ticq-msg__bubble--formatted li {
	margin-bottom: 5px;
	line-height: 1.55;
}

.ticq-msg__bubble--formatted li:last-child {
	margin-bottom: 0;
}

.ticq-msg__bubble--formatted br {
	display: block;
	content: '';
	margin-top: 4px;
}

/* --- Cartes produit dans les bulles du bot --- */
.ticq-pc {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 9px 12px;
	background: #fdf6ec;
	border: 1.5px solid #e0d0c0;
	border-radius: var(--ticq-radius-sm);
	text-decoration: none;
	margin: 5px 0;
	transition: background-color 0.15s, border-color 0.15s, transform 0.15s;
}

.ticq-pc:hover {
	background-color: #f5e8d5;
	border-color: var(--ticq-color-primary);
	transform: translateX(3px);
	text-decoration: none;
}

.ticq-pc__body {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.ticq-pc__name {
	font-size: 12px;
	font-weight: 700;
	color: var(--ticq-color-primary);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	font-family: var(--ticq-font-heading);
}

.ticq-pc__desc {
	font-size: 11px;
	color: #8a7060;
	line-height: 1.35;
	overflow: hidden;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}

.ticq-pc__price {
	font-size: 13px;
	font-weight: 800;
	color: var(--ticq-color-accent);
	white-space: nowrap;
	flex-shrink: 0;
}

.ticq-pc__arrow {
	width: 14px;
	height: 14px;
	fill: #c0a080;
	flex-shrink: 0;
}


/* --- Suggestions de questions --- */
.ticq-suggestions {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	padding: 2px 0 6px;
	align-self: flex-start;
	max-width: 100%;
}

.ticq-suggestion {
	background: #fff;
	border: 1.5px solid var(--ticq-color-primary);
	color: var(--ticq-color-primary);
	border-radius: var(--ticq-radius-pill);
	padding: 6px 13px;
	font-size: 12px;
	font-family: var(--ticq-font-body);
	cursor: pointer;
	transition: background-color 0.15s, color 0.15s;
	white-space: nowrap;
	line-height: 1.4;
}

.ticq-suggestion:hover {
	background-color: var(--ticq-color-primary);
	color: #fff;
}

/* --- Typing indicator --- */
.ticq-typing {
	display: flex;
	align-items: center;
	gap: 5px;
	padding: 10px 14px;
	background-color: #fff;
	border-radius: var(--ticq-radius-md);
	border-bottom-left-radius: 4px;
	box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.ticq-typing span {
	width: 7px;
	height: 7px;
	border-radius: var(--ticq-radius-round);
	background-color: var(--ticq-color-primary);
	opacity: 0.4;
	animation: ticq-bounce 1.2s infinite ease-in-out;
}

.ticq-typing span:nth-child(2) { animation-delay: 0.2s; }
.ticq-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ticq-bounce {
	0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
	40%           { transform: translateY(-6px); opacity: 1; }
}

/* --- Zone de saisie --- */
#ticq-chat-input-area {
	padding: 12px 14px;
	background-color: #fff;
	border-top: 1px solid #ede0d0;
	display: flex;
	align-items: flex-end;
	gap: 8px;
	flex-shrink: 0;
}

#ticq-chat-input {
	flex: 1;
	resize: none;
	border: 1px solid #ddd0c0;
	border-radius: var(--ticq-radius-pill);
	padding: 10px 16px;
	font-size: 14px;
	font-family: var(--ticq-font-body);
	color: #2d1a10;
	background-color: #faf7f4;
	outline: none;
	max-height: 100px;
	overflow-y: auto;
	line-height: 1.4;
	transition: border-color 0.2s;
}

#ticq-chat-input:focus         { border-color: var(--ticq-color-primary); }
#ticq-chat-input::placeholder  { color: #b0a090; }

#ticq-chat-send {
	width: 40px;
	height: 40px;
	border-radius: var(--ticq-radius-round);
	background-color: var(--ticq-color-primary);
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: background-color 0.2s, transform 0.15s;
}

#ticq-chat-send svg {
	width: var(--ticq-icon-sm);
	height: var(--ticq-icon-sm);
	fill: #fff;
}


#ticq-chat-send:hover    { opacity: 0.88; transform: scale(1.08); }
#ticq-chat-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
#ticq-chat-send svg      { width: 18px; height: 18px; fill: #fff; }

/* ============================================================
   RESPONSIVE — Chatbot
   ============================================================ */

/* ── Tablette (≤ 991 px) ── */
@media (max-width: 991px) {
	#ticq-chat-window {
		width: 340px;
		max-width: calc(100vw - 32px);
		height: 500px;
		max-height: calc(100vh - 120px);
	}
}

/* ── Mobile (≤ 599 px) : fenêtre plein écran qui monte du bas ── */
@media (max-width: 599px) {
	#ticq-chat-toggle {
		right: 16px;
		bottom: 16px;
		width: 52px;
		height: 52px;
	}

	#ticq-chat-toggle svg {
		width: 24px;
		height: 24px;
	}

	#ticq-chat-window {
		/* Couvre tout l'écran en slide-up depuis le bas */
		left: 0;
		right: 0;
		bottom: 0;
		width: 100%;
		max-width: 100%;
		height: 88vh;
		height: 88dvh; /* exclut la barre d'adresse mobile */
		max-height: 88vh;
		max-height: 88dvh;
		border-radius: 20px 20px 0 0;
		transform-origin: bottom center;
	}

	#ticq-chat-header {
		padding: 12px 14px;
	}

	#ticq-chat-header .ticq-avatar {
		width: 32px;
		height: 32px;
		font-size: 11px;
	}

	#ticq-chat-header .ticq-chat-name {
		font-size: 12px;
	}

	#ticq-chat-header .ticq-chat-status {
		font-size: 10px;
	}

	#ticq-chat-messages {
		padding: 14px 12px;
	}

	.ticq-msg {
		max-width: 94%;
	}

	.ticq-msg__bubble {
		font-size: 13.5px;
		padding: 9px 13px;
	}

	.ticq-suggestion {
		font-size: 11px;
		padding: 5px 11px;
	}

	#ticq-chat-input-area {
		padding: 10px 12px;
		/* Zone sûre pour les iPhones avec Dynamic Island / home indicator */
		padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
	}

	#ticq-chat-input {
		font-size: 16px; /* évite le zoom auto sur iOS lors du focus */
	}

	/* Décalage quand le bandeau cookies est ouvert */
	body.ticq-cookie-open #ticq-chat-toggle {
		bottom: calc(170px + env(safe-area-inset-bottom, 0px));
	}
}

/* ── Très petits écrans (≤ 360 px) ── */
@media (max-width: 360px) {
	#ticq-chat-header .ticq-chat-name {
		font-size: 11px;
	}

	.ticq-screen {
		padding: 20px 16px;
	}

	.ticq-screen h3 {
		font-size: 15px;
	}
}

/* ── Paysage mobile (hauteur réduite) ── */
@media (max-width: 991px) and (orientation: landscape) {
	#ticq-chat-window {
		height: 92vh;
		height: 92dvh;
		max-height: 92vh;
		max-height: 92dvh;
	}

	#ticq-chat-toggle {
		bottom: 12px;
		right: 12px;
	}
}
