/* ==========================================================================
   Naya — Assistant IA
   Widget flottant + page dédiée
   ========================================================================== */

:root {
	--naya-c1: #6d28d9;
	--naya-c2: #db2777;
	--naya-grad: linear-gradient(135deg, var(--naya-c1), var(--naya-c2));
	--naya-bg: #ffffff;
	--naya-surface: #f6f5fa;
	--naya-text: #1c1a27;
	--naya-muted: #7a7690;
	--naya-radius: 20px;
	--naya-shadow: 0 24px 60px -12px rgba(30, 10, 60, 0.35);
	--naya-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

#naya-widget, #naya-page { font-family: var(--naya-font); }
#naya-widget *, #naya-page * { box-sizing: border-box; }

/* --------------------------------------------------------------------------
   Bulle de lancement
   -------------------------------------------------------------------------- */
#naya-launcher {
	position: fixed;
	right: 24px;
	bottom: 24px;
	z-index: 99998;
	width: 62px;
	height: 62px;
	border: none;
	border-radius: 50%;
	background: var(--naya-grad);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 10px 30px -6px rgba(109, 40, 217, 0.55);
	transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s;
}
#naya-launcher:hover { transform: scale(1.08) rotate(-4deg); box-shadow: 0 16px 40px -6px rgba(109, 40, 217, 0.65); }
#naya-launcher:active { transform: scale(0.96); }

.naya-launcher-pulse {
	position: absolute;
	inset: 0;
	border-radius: 50%;
	background: var(--naya-grad);
	opacity: 0.45;
	animation: naya-pulse 2.4s ease-out infinite;
	pointer-events: none;
}
@keyframes naya-pulse {
	0% { transform: scale(1); opacity: 0.45; }
	70% { transform: scale(1.55); opacity: 0; }
	100% { transform: scale(1.55); opacity: 0; }
}

#naya-widget.naya-open #naya-launcher { transform: scale(0); pointer-events: none; }

/* --------------------------------------------------------------------------
   Fenêtre flottante
   -------------------------------------------------------------------------- */
#naya-window {
	position: fixed;
	right: 24px;
	bottom: 24px;
	z-index: 99999;
	width: 390px;
	max-width: calc(100vw - 32px);
	height: 600px;
	max-height: calc(100vh - 48px);
	background: var(--naya-bg);
	border-radius: var(--naya-radius);
	box-shadow: var(--naya-shadow);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	transform-origin: bottom right;
	animation: naya-pop 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#naya-window.naya-hidden { display: none; }
@keyframes naya-pop {
	from { transform: scale(0.6) translateY(30px); opacity: 0; }
	to { transform: scale(1) translateY(0); opacity: 1; }
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */
.naya-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 18px;
	background: var(--naya-grad);
	color: #fff;
	flex-shrink: 0;
}
.naya-avatar {
	width: 42px;
	height: 42px;
	border-radius: 14px;
	background: rgba(255, 255, 255, 0.18);
	backdrop-filter: blur(6px);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 20px;
	flex-shrink: 0;
}
.naya-header-meta { display: flex; flex-direction: column; line-height: 1.25; flex: 1; min-width: 0; }
.naya-header-meta strong { font-size: 16px; }
.naya-status { font-size: 12px; opacity: 0.85; display: flex; align-items: center; gap: 6px; }
.naya-dot {
	width: 8px; height: 8px; border-radius: 50%;
	background: #4ade80;
	box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.3);
}
.naya-close, .naya-expand, .naya-toggle-sidebar {
	background: rgba(255, 255, 255, 0.15);
	border: none;
	color: #fff;
	width: 32px;
	height: 32px;
	border-radius: 10px;
	cursor: pointer;
	font-size: 14px;
	display: flex;
	align-items: center;
	justify-content: center;
	text-decoration: none;
	transition: background 0.2s;
	flex-shrink: 0;
}
.naya-close:hover, .naya-expand:hover, .naya-toggle-sidebar:hover { background: rgba(255, 255, 255, 0.3); }

/* --------------------------------------------------------------------------
   Messages
   -------------------------------------------------------------------------- */
.naya-messages {
	flex: 1;
	overflow-y: auto;
	padding: 18px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background:
		radial-gradient(1200px 300px at 50% -100px, color-mix(in srgb, var(--naya-c1) 8%, transparent), transparent),
		var(--naya-surface);
	scroll-behavior: smooth;
}
.naya-msg {
	max-width: 82%;
	padding: 11px 15px;
	border-radius: 18px;
	font-size: 14.5px;
	line-height: 1.55;
	white-space: pre-wrap;
	word-wrap: break-word;
	animation: naya-msg-in 0.25s ease-out;
}
@keyframes naya-msg-in {
	from { opacity: 0; transform: translateY(8px); }
	to { opacity: 1; transform: translateY(0); }
}
.naya-msg-user {
	align-self: flex-end;
	background: var(--naya-grad);
	color: #fff;
	border-bottom-right-radius: 6px;
}
.naya-msg-assistant {
	align-self: flex-start;
	background: var(--naya-bg);
	color: var(--naya-text);
	border: 1px solid rgba(0, 0, 0, 0.05);
	box-shadow: 0 2px 8px rgba(20, 10, 50, 0.05);
	border-bottom-left-radius: 6px;
}
.naya-msg-assistant a {
	color: var(--naya-c1);
	font-weight: 600;
	text-decoration: underline;
	text-decoration-color: color-mix(in srgb, var(--naya-c1) 40%, transparent);
	text-underline-offset: 2px;
	transition: text-decoration-color 0.15s;
}
.naya-msg-assistant a:hover { text-decoration-color: var(--naya-c1); }
.naya-msg-error {
	align-self: center;
	background: #fef2f2;
	color: #b91c1c;
	font-size: 13px;
	border: 1px solid #fecaca;
}

/* Indicateur de frappe */
.naya-typing {
	align-self: flex-start;
	display: flex;
	gap: 5px;
	padding: 14px 18px;
	background: var(--naya-bg);
	border-radius: 18px;
	border-bottom-left-radius: 6px;
	border: 1px solid rgba(0, 0, 0, 0.05);
}
.naya-typing span {
	width: 7px; height: 7px; border-radius: 50%;
	background: var(--naya-c1);
	opacity: 0.4;
	animation: naya-bounce 1.2s infinite;
}
.naya-typing span:nth-child(2) { animation-delay: 0.15s; }
.naya-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes naya-bounce {
	0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
	30% { transform: translateY(-6px); opacity: 1; }
}

/* --------------------------------------------------------------------------
   Suggestions
   -------------------------------------------------------------------------- */
.naya-suggestions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 0 18px 8px;
	background: var(--naya-surface);
}
.naya-suggestions:empty { display: none; }
.naya-sugg {
	border: 1px solid color-mix(in srgb, var(--naya-c1) 35%, transparent);
	background: color-mix(in srgb, var(--naya-c1) 6%, #fff);
	color: var(--naya-c1);
	font-size: 12.5px;
	padding: 7px 13px;
	border-radius: 999px;
	cursor: pointer;
	transition: all 0.2s;
}
.naya-sugg:hover { background: var(--naya-c1); color: #fff; transform: translateY(-1px); }

/* --------------------------------------------------------------------------
   Zone de saisie
   -------------------------------------------------------------------------- */
.naya-input-bar {
	display: flex;
	align-items: flex-end;
	gap: 10px;
	padding: 12px 14px;
	background: var(--naya-bg);
	border-top: 1px solid rgba(0, 0, 0, 0.06);
	flex-shrink: 0;
	margin: 0;
}
/* Honeypot anti-bots : invisible pour les humains, rempli par les robots. */
.naya-hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px; height: 1px;
	opacity: 0;
	pointer-events: none;
}

.naya-input-bar textarea {
	flex: 1;
	border: 1.5px solid rgba(0, 0, 0, 0.1);
	border-radius: 14px;
	padding: 10px 14px;
	font-size: 14.5px;
	font-family: inherit;
	resize: none;
	max-height: 120px;
	outline: none;
	background: var(--naya-surface);
	color: var(--naya-text);
	transition: border-color 0.2s, box-shadow 0.2s;
}
.naya-input-bar textarea:focus {
	border-color: var(--naya-c1);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--naya-c1) 15%, transparent);
}
.naya-input-bar button {
	width: 42px;
	height: 42px;
	border: none;
	border-radius: 13px;
	background: var(--naya-grad);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: transform 0.2s, opacity 0.2s;
}
.naya-input-bar button:hover { transform: scale(1.06); }
.naya-input-bar button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.naya-footer-brand {
	text-align: center;
	font-size: 11px;
	color: var(--naya-muted);
	padding: 6px 0 10px;
	background: var(--naya-bg);
}

/* --------------------------------------------------------------------------
   Page dédiée
   -------------------------------------------------------------------------- */
#naya-page {
	display: flex;
	height: 78vh;
	min-height: 540px;
	border-radius: var(--naya-radius);
	overflow: hidden;
	box-shadow: 0 10px 40px rgba(20, 10, 50, 0.12);
	border: 1px solid rgba(0, 0, 0, 0.06);
	background: var(--naya-bg);
	margin: 8px 0 32px;
}

.naya-sidebar {
	width: 280px;
	flex-shrink: 0;
	background: #16121f;
	color: #e8e5f2;
	display: flex;
	flex-direction: column;
	padding: 16px 12px;
	gap: 12px;
}
.naya-new-chat {
	border: 1px dashed rgba(255, 255, 255, 0.3);
	background: rgba(255, 255, 255, 0.05);
	color: #fff;
	border-radius: 12px;
	padding: 12px;
	font-size: 14px;
	cursor: pointer;
	transition: background 0.2s, border-color 0.2s;
}
.naya-new-chat:hover { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.6); }

.naya-conv-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.naya-conv-item {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 12px;
	border-radius: 10px;
	font-size: 13.5px;
	cursor: pointer;
	color: #bdb7cf;
	transition: background 0.15s, color 0.15s;
}
.naya-conv-item:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.naya-conv-item.naya-active {
	background: color-mix(in srgb, var(--naya-c1) 45%, transparent);
	color: #fff;
}
.naya-conv-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.naya-conv-del {
	background: none; border: none; color: inherit; opacity: 0;
	cursor: pointer; font-size: 12px; padding: 2px 4px; border-radius: 6px;
	transition: opacity 0.15s, background 0.15s;
}
.naya-conv-item:hover .naya-conv-del { opacity: 0.7; }
.naya-conv-del:hover { opacity: 1 !important; background: rgba(255, 255, 255, 0.15); }
.naya-conv-empty { font-size: 13px; color: #7a7690; text-align: center; padding: 24px 8px; }

.naya-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.naya-header-page .naya-toggle-sidebar { display: none; }

#naya-page .naya-msg { max-width: 70%; font-size: 15px; }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
	#naya-window {
		right: 0; bottom: 0;
		width: 100vw; height: 100vh;
		max-width: 100vw; max-height: 100vh;
		border-radius: 0;
	}
	#naya-launcher { right: 16px; bottom: 16px; }
}

@media (max-width: 768px) {
	#naya-page { height: 82vh; }
	.naya-sidebar {
		position: absolute;
		z-index: 5;
		height: 100%;
		transform: translateX(-100%);
		transition: transform 0.28s ease;
	}
	#naya-page { position: relative; }
	#naya-page.naya-sidebar-open .naya-sidebar { transform: translateX(0); }
	.naya-header-page .naya-toggle-sidebar { display: flex; }
	#naya-page .naya-msg { max-width: 85%; }
}
