/* NovaLab AI — chat panel styles */

:root {
	--mmai-primary: var(--wp--preset--color--primary, #ffb300);
	--mmai-charcoal: var(--wp--preset--color--charcoal, #1e2128);
	--mmai-fg: var(--wp--preset--color--foreground, #1e2128);
	--mmai-muted: var(--wp--preset--color--muted, #f3f4f6);
	--mmai-muted-fg: var(--wp--preset--color--muted-foreground, #6b7280);
	--mmai-border: var(--wp--preset--color--border, #e5e7eb);
	--mmai-success: var(--wp--preset--color--success, #10b981);
}

/* Panel container — held below sticky header */
.mm-ai-panel {
	position: fixed;
	top: 110px;
	left: 50%;
	transform: translateX(-50%);
	z-index: 90;
	width: min(92vw, 720px);
	background: #fff;
	border: 1px solid var(--mmai-border);
	border-radius: 1rem;
	box-shadow: 0 20px 60px rgba(30, 33, 40, 0.18);
	max-height: calc(100vh - 140px);
	overflow: hidden;
	display: flex;
	flex-direction: column;
}
.mm-ai-panel[hidden] { display: none; }

/* Chat layout */
.mm-chat {
	display: flex;
	flex-direction: column;
	max-height: inherit;
	min-height: 200px;
}
.mm-chat__thread {
	flex: 1;
	overflow-y: auto;
	padding: 1.25rem;
	display: flex;
	flex-direction: column;
	gap: 1rem;
	scroll-behavior: smooth;
	min-height: 0;
}
.mm-chat__thread:empty::before {
	content: 'Ask anything about our products. The AI remembers what you ask within this session.';
	color: var(--mmai-muted-fg);
	font-style: italic;
	text-align: center;
	padding: 1rem 2rem;
	font-size: 0.9rem;
}

/* Message bubbles */
.mm-msg {
	display: flex;
	gap: 0.6rem;
	max-width: 85%;
	align-items: flex-start;
}
/* AI messages: default width, or wider when they contain product cards */
.mm-msg--ai { max-width: 92%; }
.mm-msg--ai .mm-msg__bubble { width: 100%; box-sizing: border-box; }
.mm-msg--user {
	max-width: 85%;
	margin-left: auto;
	flex-direction: row-reverse;
}
.mm-msg__avatar {
	width: 28px;
	height: 28px;
	border-radius: 999px;
	background: var(--mmai-primary);
	color: var(--mmai-charcoal);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}
.mm-msg--keyword .mm-msg__avatar {
	background: var(--mmai-muted);
	color: var(--mmai-muted-fg);
}
.mm-msg__bubble {
	background: var(--mmai-muted);
	color: var(--mmai-fg);
	padding: 0.7rem 0.95rem;
	border-radius: 1rem;
	font-size: 0.92rem;
	line-height: 1.5;
	position: relative;
	min-width: 0;
}
.mm-msg--ai .mm-msg__bubble {
	background: #f7f5f0;
	border: 1px solid var(--mmai-border);
}
.mm-msg--user .mm-msg__bubble {
	background: var(--mmai-charcoal);
	color: #fff;
}
.mm-msg__text {
	margin: 0;
	white-space: pre-wrap;
	word-wrap: break-word;
}
.mm-msg__tag {
	display: inline-block;
	margin-top: 0.4rem;
	padding: 0.1rem 0.45rem;
	border-radius: 999px;
	background: rgba(255, 179, 0, 0.15);
	color: var(--mmai-charcoal);
	font-size: 0.65rem;
	font-weight: 700;
	letter-spacing: 0.05em;
	text-transform: uppercase;
}
.mm-msg--keyword .mm-msg__tag {
	background: var(--mmai-muted);
	color: var(--mmai-muted-fg);
}

/* Thinking indicator */
.mm-msg--thinking .mm-msg__bubble {
	padding: 0.85rem 1.1rem;
}
.mm-thinking-dots {
	display: inline-flex;
	gap: 0.25rem;
	align-items: center;
}
.mm-thinking-dots span {
	width: 6px;
	height: 6px;
	border-radius: 999px;
	background: var(--mmai-muted-fg);
	opacity: 0.5;
	animation: mm-thinking-bounce 1.2s infinite ease-in-out;
}
.mm-thinking-dots span:nth-child(2) { animation-delay: 0.15s; }
.mm-thinking-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes mm-thinking-bounce {
	0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
	40%           { opacity: 1;   transform: translateY(-4px); }
}

/* Product cards inside an AI message — always single column so they
   never overflow the chat bubble regardless of viewport size. */
.mm-msg__products {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	margin-top: 0.65rem;
	width: 100%;
}
.mm-ai-card {
	display: flex;
	gap: 0.6rem;
	padding: 0.55rem;
	border: 1px solid var(--mmai-border);
	border-radius: 0.55rem;
	text-decoration: none;
	color: inherit;
	background: #fff;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
	width: 100%;
	box-sizing: border-box;
}
.mm-ai-card:hover {
	border-color: var(--mmai-primary);
	box-shadow: 0 2px 8px rgba(255, 179, 0, 0.15);
}
.mm-ai-card__img {
	width: 52px;
	height: 52px;
	flex-shrink: 0;
	background: var(--mmai-muted);
	border-radius: 0.35rem;
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
}
.mm-ai-card__img img { width: 100%; height: 100%; object-fit: contain; padding: 4px; mix-blend-mode: multiply; }
.mm-ai-card__img-placeholder { color: var(--mmai-muted-fg); }
.mm-ai-card__body { flex: 1; min-width: 0; }
.mm-ai-card__name {
	font-weight: 600;
	font-size: 0.85rem;
	margin: 0 0 0.2rem;
	color: var(--mmai-fg);
	line-height: 1.3;
	/* Wrap long names instead of truncating with ellipsis — cards are
	   full-width now so there's room. */
	overflow: hidden;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}
.mm-ai-card__meta {
	display: flex;
	align-items: center;
	gap: 0.4rem;
	font-size: 0.75rem;
}
.mm-ai-card__price { font-weight: 700; color: var(--mmai-fg); }
.mm-ai-card__stock {
	display: inline-block;
	padding: 0.05rem 0.4rem;
	border-radius: 999px;
	font-size: 0.6rem;
	font-weight: 600;
}
.mm-ai-card__stock--in {
	background: rgba(16, 185, 129, 0.12);
	color: var(--mmai-success);
}
.mm-ai-card__stock--out {
	background: var(--mmai-muted);
	color: var(--mmai-muted-fg);
}

/* Composer */
.mm-chat__composer {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.8rem 1rem;
	border-top: 1px solid var(--mmai-border);
	background: #fff;
	flex-shrink: 0;
}
.mm-chat__input {
	flex: 1;
	border: 1px solid var(--mmai-border);
	border-radius: 999px;
	padding: 0.55rem 1rem;
	font-family: inherit;
	font-size: 0.9rem;
	color: var(--mmai-fg);
	background: var(--mmai-muted);
	outline: 0;
	transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.mm-chat__input:focus {
	background: #fff;
	border-color: var(--mmai-primary);
	box-shadow: 0 0 0 3px rgba(255, 179, 0, 0.15);
}
.mm-chat__send {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.25rem;
	height: 2.25rem;
	background: var(--mmai-primary);
	color: var(--mmai-charcoal);
	border: 0;
	border-radius: 999px;
	cursor: pointer;
	flex-shrink: 0;
	transition: transform 0.15s ease, background 0.15s ease;
}
.mm-chat__send:hover { transform: scale(1.05); background: #ffa000; }
.mm-chat__send:active { transform: scale(0.95); }

/* Footer */
.mm-chat__footer {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.5rem 1rem;
	border-top: 1px solid var(--mmai-border);
	background: var(--mmai-muted);
	font-size: 0.72rem;
	color: var(--mmai-muted-fg);
	flex-shrink: 0;
}
.mm-chat__hint { flex: 1; }
.mm-chat__reset {
	background: transparent;
	border: 1px solid var(--mmai-border);
	color: var(--mmai-muted-fg);
	padding: 0.2rem 0.6rem;
	border-radius: 999px;
	font-size: 0.7rem;
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease;
}
.mm-chat__reset:hover {
	background: #fff;
	color: var(--mmai-fg);
}
.mm-ai-badge {
	display: inline-flex;
	align-items: center;
	background: var(--mmai-primary);
	color: var(--mmai-charcoal);
	padding: 0.1rem 0.5rem;
	border-radius: 999px;
	font-weight: 800;
	font-size: 0.6rem;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

/* AI sparkle indicator inside header search button when AI is enabled */
.is-ai-enabled .mm-ai-trigger::after,
.mm-nav__search.is-ai-enabled .mm-nav__search-toggle::after {
	content: '';
	position: absolute;
	top: 6px;
	right: 6px;
	width: 6px;
	height: 6px;
	background: var(--mmai-success);
	border-radius: 999px;
	border: 1.5px solid #fff;
}

@media (max-width: 600px) {
	.mm-ai-panel { width: 96vw; top: 90px; }
	.mm-msg { max-width: 92%; }
}
