/* TP Chatbot AI — Frontend Styles
   Variables injectées via JS sur :root */

:root {
	--tp-chat-primary:    #0073aa;
	--tp-chat-secondary:  #23282d;
	--tp-chat-text:       #333333;
	--tp-chat-accent:     #00a0d2;
	--tp-chat-background: #ffffff;

	--tp-chat-radius:     12px;
	--tp-chat-shadow:     0 4px 24px rgba(0,0,0,.18);
	--tp-chat-font:       -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	--tp-chat-width:      450px;
	--tp-chat-height:     auto;
}

/* =========================================================================
   Bulle flottante
   ========================================================================= */

#tp-chatbot-bubble {
	position: fixed;
	z-index: 99999;
	bottom: 24px;
}

#tp-chatbot-bubble.tp-chatbot--position-bottom-right { right: 24px; }
#tp-chatbot-bubble.tp-chatbot--position-bottom-left  { left: 24px; }

.tp-chatbot-bubble__btn {
	display: flex;
	align-items: center;
	gap: 8px;
	background: var(--tp-chat-primary);
	color: #fff;
	border: none;
	border-radius: 50px;
	padding: 12px 20px;
	cursor: pointer;
	font-family: var(--tp-chat-font);
	font-size: 15px;
	font-weight: 600;
	box-shadow: var(--tp-chat-shadow);
	transition: background .2s, transform .15s;
}

.tp-chatbot-bubble__btn:hover {
	background: var(--tp-chat-accent);
	transform: scale(1.04);
}

.tp-chatbot-bubble__icon {
	width: 22px;
	height: 22px;
	flex-shrink: 0;
}

/* Fenêtre de chat de la bulle */
#tp-chatbot-bubble .tp-chatbot-window {
	position: absolute;
	bottom: calc(100% + 12px);
	width: var(--tp-chat-width);
	max-height: var(--tp-chat-height);
	opacity: 0;
	pointer-events: none;
	transform: translateY(10px) scale(.97);
	transition: opacity .2s, transform .2s;
	transform-origin: bottom center;
}

/* Position bulle gauche : ouvrir vers la droite */
#tp-chatbot-bubble.tp-chatbot--position-bottom-left .tp-chatbot-window { left: 0; }
#tp-chatbot-bubble.tp-chatbot--position-bottom-right .tp-chatbot-window { right: 0; }

#tp-chatbot-bubble.tp-chatbot--open .tp-chatbot-window {
	opacity: 1;
	pointer-events: all;
	transform: translateY(0) scale(1);
}

/* =========================================================================
   Widget inline (shortcode)
   ========================================================================= */

#tp-chatbot-inline {
	width: 100%;
	max-width: 640px;
	margin: 0 auto;
}

/* =========================================================================
   Fenêtre de chat (commune)
   ========================================================================= */

.tp-chatbot-window {
	display: flex;
	flex-direction: column;
	background: var(--tp-chat-background);
	border-radius: var(--tp-chat-radius);
	box-shadow: var(--tp-chat-shadow);
	overflow: hidden;
	font-family: var(--tp-chat-font);
	color: var(--tp-chat-text);
}

/* En-tête */
.tp-chatbot-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	background: var(--tp-chat-primary);
	color: #fff;
	padding: 14px 16px;
	flex-shrink: 0;
}

.tp-chatbot-header__title {
	font-size: 15px;
	font-weight: 600;
	margin: 0;
}

.tp-chatbot-header__actions {
	display: flex;
	gap: 8px;
}

.tp-chatbot-close,
.tp-chatbot-clear {
	background: transparent;
	border: none;
	color: rgba(255,255,255,.8);
	cursor: pointer;
	font-size: 18px;
	line-height: 1;
	transition: color .15s, background .15s;
        display: flex;
        align-items: center;
        justify-content: center;
}

#tp-chatbot-bubble .tp-chatbot-close,
#tp-chatbot-bubble .tp-chatbot-clear {
	padding: 10px 20px 10px 20px;
	border-radius: 50px;
}

#tp-chatbot-bubble .tp-chatbot-close:hover,
#tp-chatbot-bubble .tp-chatbot-clear:hover {
        color: #fff;
        background: rgba(255,255,255,.15);
}

#tp-chatbot-bubble .tp-chatbot-clear svg,
#tp-chatbot-bubble .tp-chatbot-close svg {
        width: 16px;
        height: 16px;
        display: block;
}

/* Zone de messages */
.tp-chatbot-messages {
	flex: 1;
	overflow-y: auto;
	padding: 14px 12px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	min-height: 280px;
	max-height: 520px;
}

/* Messages */
.tp-chatbot-msg {
	max-width: 82%;
	padding: 9px 13px;
	border-radius: 16px;
	font-size: 14px;
	line-height: 1.5;
	word-break: break-word;
}

.tp-chatbot-msg--user {
	align-self: flex-end;
	background: var(--tp-chat-primary);
	color: #fff;
	border-bottom-right-radius: 4px;
}

.tp-chatbot-msg--assistant {
	align-self: flex-start;
	background: #f0f0f0;
	color: var(--tp-chat-text);
	border-bottom-left-radius: 4px;
}

/* Messages — mise en forme Markdown dans les réponses de l'assistant */

.tp-chatbot-msg--assistant p {
	margin: 0 0 6px 0;
}

.tp-chatbot-msg--assistant p:last-child {
	margin-bottom: 0;
}

.tp-chatbot-msg--assistant strong {
	font-weight: 700;
}

.tp-chatbot-msg--assistant em {
	font-style: italic;
}

.tp-chatbot-msg--assistant ol,
.tp-chatbot-msg--assistant ul {
	margin: 6px 0 6px 18px;
	padding: 0;
}

.tp-chatbot-msg--assistant li {
	margin-bottom: 5px;
	line-height: 1.5;
}

/* Sous-items injectés dans un <li> de liste numérotée */
.tp-chatbot-msg--assistant .tp-chat-subitem {
	display: block;
	padding-left: 6px;
	color: #555;
	font-size: 0.93em;
}

.tp-chatbot-msg--assistant a {
	color: var(--tp-chat-primary);
	text-decoration: underline;
	word-break: break-all;
}

.tp-chatbot-msg--assistant a:hover {
	color: var(--tp-chat-accent);
}

.tp-chatbot-msg--assistant br {
	display: block;
	margin-top: 4px;
	content: '';
}

/* Questions cliquables (pattern ?>) */
.tp-chat-clickable-question {
	display: block;
	width: 100%;
	margin: 6px 0;
	padding: 10px 14px;
	background: var(--tp-chat-primary);
	color: #fff;
	border: none;
	border-radius: 8px;
	font-family: var(--tp-chat-font);
	font-size: 14px;
	font-weight: 500;
	text-align: left;
	cursor: pointer;
	transition: background 0.2s, transform 0.1s;
	box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.tp-chat-clickable-question:hover {
	background: var(--tp-chat-accent);
	transform: translateY(-1px);
	box-shadow: 0 3px 6px rgba(0,0,0,0.15);
}

.tp-chat-clickable-question:active {
	transform: translateY(0);
	box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.tp-chat-clickable-question:focus {
	outline: 2px solid var(--tp-chat-accent);
	outline-offset: 2px;
}

/* Indicateur de frappe */
.tp-chatbot-typing {
	display: flex;
	align-items: center;
	gap: 5px;
	padding: 10px 14px;
}

.tp-chatbot-typing span {
	display: inline-block;
	width: 8px;
	height: 8px;
	background: #aaa;
	border-radius: 50%;
	animation: tp-bounce .8s infinite ease-in-out;
}

.tp-chatbot-typing span:nth-child(2) { animation-delay: .15s; }
.tp-chatbot-typing span:nth-child(3) { animation-delay: .3s; }

@keyframes tp-bounce {
	0%, 80%, 100% { transform: scale(.7); opacity: .5; }
	40%           { transform: scale(1);  opacity: 1; }
}

/* Zone de saisie */
.tp-chatbot-input-area {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px;
	border-top: 1px solid #e0e0e0;
	flex-shrink: 0;
}

.tp-chatbot-input {
	flex: 1;
	border: 1px solid #ddd;
	border-radius: 20px;
	padding: 8px 14px;
	font-family: var(--tp-chat-font);
	font-size: 14px;
	resize: none;
	outline: none;
	transition: border-color .2s;
	max-height: 80px;
	line-height: 1.4;
}

.tp-chatbot-input:focus {
	border-color: var(--tp-chat-primary);
}

.tp-chatbot-send {
	background: var(--tp-chat-primary);
	color: #fff;
	border: none;
	border-radius: 50%;
	width: 36px;
	height: 36px;
	cursor: pointer;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 16px;
	line-height: 1;
	transition: background .2s, transform .15s;
	padding: 0;
}

.tp-chatbot-send:hover {
	background: var(--tp-chat-accent);
	transform: scale(1.08);
}

.tp-chatbot-send svg {
	width: 16px;
	height: 16px;
	fill: currentColor;
	color: inherit;
}

/* Pied de fenêtre */
.tp-chatbot-footer {
	padding: 8px 12px;
	border-top: 1px solid #e0e0e0;
	display: flex;
	justify-content: flex-end;
	flex-shrink: 0;
}

.tp-chatbot-contact-btn {
	background: transparent;
	/* border: 1px solid var(--tp-chat-primary); */
	color: var(--tp-chat-primary);
	cursor: pointer;
	font-family: var(--tp-chat-font);
	transition: background .2s, color .2s;
}

#tp-chatbot-bubble .tp-chatbot-contact-btn {
	border-radius: 20px;
	padding: 5px 14px;
	font-size: 13px;
}

.tp-chatbot-contact-btn:hover {
	background: var(--tp-chat-primary);
	color: #fff;
}

/* =========================================================================
   Vues chat / formulaire
   ========================================================================= */

.tp-chatbot-view--chat {
	display: flex;
	flex-direction: column;
	flex: 1;
}

.tp-chatbot-view--form {
	display: none;
	flex-direction: column;
	flex: 1;
}

#tp-chatbot-bubble .tp-chatbot-back {
    padding: 10px 20px;
}

.tp-chatbot-back {
	background: transparent;
	border: none;
	color: rgba(255,255,255,.85);
	cursor: pointer;
	font-size: 13px;
	font-family: var(--tp-chat-font);
	padding: 0;
}

.tp-chatbot-back:hover { color: #fff; }

.tp-chatbot-contact-form {
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 14px 12px;
	overflow-y: auto;
}

.tp-chatbot-contact-form input,
.tp-chatbot-contact-form textarea {
	width: 100%;
	border: 1px solid #ddd;
	border-radius: 8px;
	padding: 8px 11px;
	font-family: var(--tp-chat-font);
	font-size: 14px;
	outline: none;
	box-sizing: border-box;
	transition: border-color .2s;
}

.tp-chatbot-contact-form input:focus,
.tp-chatbot-contact-form textarea:focus {
	border-color: var(--tp-chat-primary);
}

.tp-chatbot-contact-form textarea {
	resize: vertical;
	min-height: 70px;
}

.tp-chatbot-contact-form button[type="submit"] {
	background: var(--tp-chat-primary);
	color: #fff;
	border: none;
	border-radius: 8px;
	padding: 10px;
	font-family: var(--tp-chat-font);
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: background .2s;
}

.tp-chatbot-contact-form button[type="submit"]:hover {
	background: var(--tp-chat-accent);
}

.tp-chatbot-contact-form button[type="submit"]:disabled {
	opacity: .6;
	cursor: not-allowed;
}

.tp-chatbot-form-feedback {
	display: none;
	padding: 8px 11px;
	border-radius: 8px;
	font-size: 13px;
}

.tp-chatbot-form-feedback.success {
	background: #d4edda;
	color: #155724;
}

.tp-chatbot-form-feedback.error {
	background: #f8d7da;
	color: #721c24;
}

.tp-chatbot-contact-phone {
	font-size: 14px;
	padding: 8px 0;
	color: var(--tp-chat-text);
}

.tp-chatbot-contact-phone a {
	color: var(--tp-chat-primary);
	font-weight: 600;
	text-decoration: none;
}

.tp-chatbot-contact-phone a:hover {
	text-decoration: underline;
}

/* =========================================================================
   Responsive
   ========================================================================= */

@media ( max-width: 600px ) {
	:root {
		--tp-chat-width: calc(100vw - 24px);
	}

	#tp-chatbot-bubble {
		bottom: 12px;
	}

	#tp-chatbot-bubble.tp-chatbot--position-bottom-right { right: 12px; }
	#tp-chatbot-bubble.tp-chatbot--position-bottom-left  { left: 12px; }

	#tp-chatbot-bubble .tp-chatbot-window {
		right: 0;
		left: 0;
	}
}
