/* Ciseaux Conseiller IA — widget frontend
   Identité : acier forgé (encre profonde) + accent laiton configurable.
   Tout est préfixé .ccia- pour ne jamais entrer en conflit avec le thème. */

:root {
	--ccia-accent: #8a6d3b;
	--ccia-ink: #201e1b;
	--ccia-ink-soft: #57534d;
	--ccia-paper: #faf9f6;
	--ccia-line: #e7e3db;
	--ccia-bot-bubble: #f1efe9;
	--ccia-shadow: 0 18px 48px -12px rgba(32, 30, 27, .34);
	--ccia-radius: 16px;
}

.ccia-hidden { display: none !important; }

/* ---------- Lanceur ---------- */
.ccia-launcher {
	position: fixed;
	right: 24px;
	bottom: 24px;
	z-index: 2147483000;
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 12px 18px 12px 14px;
	border: none;
	border-radius: 999px;
	background: var(--ccia-ink);
	color: #fdfcf9;
	font: 600 15px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	letter-spacing: .01em;
	cursor: pointer;
	box-shadow: var(--ccia-shadow);
	transition: transform .18s ease, box-shadow .18s ease;
}
.ccia-launcher:hover { transform: translateY(-2px); }
.ccia-launcher:focus-visible { outline: 3px solid var(--ccia-accent); outline-offset: 3px; }
.ccia-launcher__ring {
	display: grid;
	place-items: center;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	background: var(--ccia-accent);
	color: #fff;
}
.ccia-launcher__ring svg { width: 19px; height: 19px; }

/* Logo personnalisé : image contenue sur un disque blanc, jamais rognée. */
.ccia-mark-img {
	width: 100%;
	height: 100%;
	box-sizing: border-box;
	padding: 3px;
	object-fit: contain;
	border-radius: 50%;
	background: #fff;
	display: block;
}

/* ---------- Panneau ---------- */
.ccia-panel {
	position: fixed;
	right: 24px;
	bottom: 24px;
	z-index: 2147483000;
	display: flex;
	flex-direction: column;
	width: 384px;
	max-width: calc(100vw - 32px);
	height: 620px;
	max-height: calc(100vh - 48px);
	background: var(--ccia-paper);
	border: 1px solid var(--ccia-line);
	border-radius: var(--ccia-radius);
	box-shadow: var(--ccia-shadow);
	overflow: hidden;
	transform-origin: bottom right;
	animation: ccia-pop .22s cubic-bezier(.2, .8, .2, 1);
}
@keyframes ccia-pop {
	from { opacity: 0; transform: translateY(12px) scale(.98); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- En-tête ---------- */
.ccia-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 16px 15px;
	background: var(--ccia-ink);
	color: #fdfcf9;
}
.ccia-header__mark {
	display: grid;
	place-items: center;
	width: 38px;
	height: 38px;
	flex: none;
	border-radius: 50%;
	background: rgba(255, 255, 255, .08);
	border: 1px solid rgba(255, 255, 255, .16);
	color: var(--ccia-accent);
}
.ccia-header__mark svg { width: 20px; height: 20px; }
.ccia-header__title {
	margin: 0;
	font: 600 16.5px/1.2 Georgia, "Times New Roman", serif;
	letter-spacing: .01em;
}
.ccia-header__sub {
	margin: 2px 0 0;
	font: 400 12px/1.3 system-ui, sans-serif;
	color: rgba(253, 252, 249, .62);
}
.ccia-header__close {
	margin-left: auto;
	width: 30px;
	height: 30px;
	display: grid;
	place-items: center;
	border: none;
	border-radius: 8px;
	background: transparent;
	color: rgba(253, 252, 249, .7);
	cursor: pointer;
	font-size: 20px;
	line-height: 1;
	transition: background .15s ease;
}
.ccia-header__close:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.ccia-header__close:focus-visible { outline: 2px solid var(--ccia-accent); outline-offset: 2px; }

/* ---------- Fil de messages ---------- */
.ccia-messages {
	flex: 1;
	overflow-y: auto;
	padding: 18px 16px 8px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	scroll-behavior: smooth;
}
.ccia-msg {
	max-width: 84%;
	padding: 11px 14px;
	border-radius: 14px;
	font: 400 14.5px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	color: var(--ccia-ink);
	word-wrap: break-word;
}
.ccia-msg a { color: var(--ccia-accent); font-weight: 600; }
.ccia-msg--bot {
	align-self: flex-start;
	background: var(--ccia-bot-bubble);
	border-bottom-left-radius: 5px;
}
.ccia-msg--user {
	align-self: flex-end;
	background: var(--ccia-ink);
	color: #fdfcf9;
	border-bottom-right-radius: 5px;
}
.ccia-msg--user a { color: #e9d9b8; }

/* Boutons de réponse rapide (quick replies) */
.ccia-qr {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-self: flex-start;
	max-width: 92%;
	margin: -2px 0 2px;
	animation: ccia-pop .2s ease;
}
.ccia-qr__btn {
	padding: 8px 14px;
	border: 1.5px solid var(--ccia-accent);
	border-radius: 999px;
	background: transparent;
	color: var(--ccia-accent);
	font: 600 13.5px/1.2 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	cursor: pointer;
	transition: background .15s ease, color .15s ease, transform .1s ease;
}
.ccia-qr__btn:hover { background: var(--ccia-accent); color: #fff; }
.ccia-qr__btn:active { transform: scale(.96); }
.ccia-qr__btn:focus-visible { outline: 3px solid var(--ccia-ink); outline-offset: 2px; }

/* Indicateur de saisie */
.ccia-typing {
	align-self: flex-start;
	display: inline-flex;
	gap: 5px;
	padding: 14px 15px;
	background: var(--ccia-bot-bubble);
	border-radius: 14px;
	border-bottom-left-radius: 5px;
}
.ccia-typing span {
	width: 7px; height: 7px;
	border-radius: 50%;
	background: var(--ccia-ink-soft);
	animation: ccia-bounce 1.2s infinite ease-in-out;
}
.ccia-typing span:nth-child(2) { animation-delay: .15s; }
.ccia-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes ccia-bounce {
	0%, 60%, 100% { transform: translateY(0); opacity: .5; }
	30% { transform: translateY(-5px); opacity: 1; }
}

.ccia-error {
	align-self: center;
	font: 400 12.5px/1.4 system-ui, sans-serif;
	color: #a3341f;
	background: #f9e8e3;
	padding: 8px 12px;
	border-radius: 10px;
}

/* ---------- Saisie ---------- */
.ccia-input {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 12px;
	border-top: 1px solid var(--ccia-line);
	background: var(--ccia-paper);
}
.ccia-input textarea {
	flex: 1;
	resize: none;
	max-height: 120px;
	padding: 11px 13px;
	border: 1px solid var(--ccia-line);
	border-radius: 12px;
	background: #fff;
	color: var(--ccia-ink);
	font: 400 14.5px/1.4 system-ui, -apple-system, sans-serif;
	outline: none;
	transition: border-color .15s ease;
}
.ccia-input textarea:focus { border-color: var(--ccia-accent); }
.ccia-send {
	flex: none;
	width: 44px; height: 44px;
	display: grid;
	place-items: center;
	border: none;
	border-radius: 12px;
	background: var(--ccia-accent);
	color: #fff;
	cursor: pointer;
	transition: filter .15s ease, transform .1s ease;
}
.ccia-send:hover { filter: brightness(1.08); }
.ccia-send:active { transform: scale(.95); }
.ccia-send:disabled { opacity: .45; cursor: default; }
.ccia-send:focus-visible { outline: 3px solid var(--ccia-ink); outline-offset: 2px; }
.ccia-send svg { width: 20px; height: 20px; }

.ccia-foot {
	padding: 0 12px 10px;
	text-align: center;
	font: 400 10.5px/1.3 system-ui, sans-serif;
	color: var(--ccia-ink-soft);
	background: var(--ccia-paper);
}

/* Barre de défilement discrète */
.ccia-messages::-webkit-scrollbar { width: 8px; }
.ccia-messages::-webkit-scrollbar-thumb { background: #d8d3c9; border-radius: 8px; }

/* ---------- Mobile ---------- */
@media (max-width: 480px) {
	.ccia-panel {
		right: 0; bottom: 0;
		width: 100vw;
		height: 100dvh;
		max-height: 100dvh;
		border-radius: 0;
		border: none;
	}
	.ccia-launcher { right: 16px; bottom: 16px; }
	.ccia-launcher__label { display: none; }
	.ccia-launcher { padding: 12px; }
}

@media (prefers-reduced-motion: reduce) {
	.ccia-panel, .ccia-launcher, .ccia-typing span, .ccia-send { animation: none !important; transition: none !important; }
}
