/* ZeroPulp Employee Portal redesign - the AI Report Writer chat window (Reports -> AI Report Writer).
   See zpPortal.css for the shared tokens. The dialog (js/pulpstreamTemplate.js chatGPTDialog) is
   appended to <body> and shared with other chats; neo/js/home/chat.js marks the report writer's with
   .ai-report-writer, so only that one is restyled here. !important only where the template or
   chat.js write inline styles. */

/* ---- the window: a portal card floating over the page ---- */
.zp-portal-theme .chatgpt-dialog.ai-report-writer
{
	/* chat.js setHeightForConversation sizes the window from .home-page-container (100dvh) and pins it
	   absolute to the bottom of the document. On a page that is taller than the viewport (the sandbox
	   banner sits above the 100dvh container, a start-form deep link grows it) the window scrolled with
	   the page and its header went off the top. Pin it to the viewport and never let it be taller than
	   the viewport; setHeightForConversation reads the clamped height back when it sizes .dialog-body. */
	position: fixed !important;
	max-height: calc(100vh - 20px) !important;
	max-height: calc(100dvh - 20px) !important;
	font-family: var(--zp-font);
	color: var(--zp-ink);
	background: var(--zp-surface) !important;
	border: 1px solid var(--zp-line) !important;
	border-radius: var(--zp-radius-card) !important;
	box-shadow: 0 16px 40px rgba(28,27,34,0.14), 0 2px 6px rgba(28,27,34,0.06);
}

.zp-portal-theme .chatgpt-dialog.ai-report-writer button,
.zp-portal-theme .chatgpt-dialog.ai-report-writer textarea
{
	font-family: var(--zp-font);
}

/* ---- header: title left, actions right, hairline under it ---- */
.zp-portal-theme .chatgpt-dialog.ai-report-writer .header
{
	padding: 0 12px 0 18px !important;
	border-bottom: 1px solid var(--zp-line-soft) !important;
	background: var(--zp-surface);
}

.zp-portal-theme .chatgpt-dialog.ai-report-writer .chat-header-text
{
	font-size: 15px;
	font-weight: 700;
	color: var(--zp-ink);
	letter-spacing: -0.01em;
}

/* New chat: the portal's solid accent button instead of the old purple gradient pill */
.zp-portal-theme .chatgpt-dialog.ai-report-writer #newChat
{
	height: 34px;
	padding: 0 14px !important;
	gap: 6px !important;
	background: var(--zp-accent) !important;
	background-image: none !important;
	border: 0;
	border-radius: var(--zp-radius-control) !important;
	color: #FFFFFF;
	font-size: 13px !important;
	font-weight: 600 !important;
	letter-spacing: 0 !important;
	opacity: 1 !important;
	transition: background-color .15s ease;
}

.zp-portal-theme .chatgpt-dialog.ai-report-writer #newChat:hover
{
	background: var(--zp-accent-strong) !important;
}

.zp-portal-theme .chatgpt-dialog.ai-report-writer #newChat svg
{
	width: 16px;
	height: 16px;
}

/* history / maximize / close: quiet grey icon buttons that tint on hover */
.zp-portal-theme .chatgpt-dialog.ai-report-writer #lisPreviousChat,
.zp-portal-theme .chatgpt-dialog.ai-report-writer #minimizeChatWindow,
.zp-portal-theme .chatgpt-dialog.ai-report-writer #maximizeChatWindow,
.zp-portal-theme .chatgpt-dialog.ai-report-writer #closeChatWindow
{
	display: flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	padding: 0 !important;
	border-radius: var(--zp-radius-control);
	opacity: 1 !important;
	transition: background-color .15s ease;
}

.zp-portal-theme .chatgpt-dialog.ai-report-writer #minimizeChatWindow.hidden
{
	display: none;
}

.zp-portal-theme .chatgpt-dialog.ai-report-writer #lisPreviousChat:hover,
.zp-portal-theme .chatgpt-dialog.ai-report-writer #minimizeChatWindow:hover,
.zp-portal-theme .chatgpt-dialog.ai-report-writer #maximizeChatWindow:hover,
.zp-portal-theme .chatgpt-dialog.ai-report-writer #closeChatWindow:hover
{
	background: var(--zp-accent-tint);
}

.zp-portal-theme .chatgpt-dialog.ai-report-writer #lisPreviousChat svg,
.zp-portal-theme .chatgpt-dialog.ai-report-writer #maximizeChatWindow svg,
.zp-portal-theme .chatgpt-dialog.ai-report-writer #minimizeChatWindow svg
{
	width: 20px;
	height: 20px;
}

.zp-portal-theme .chatgpt-dialog.ai-report-writer #lisPreviousChat svg path
{
	stroke: var(--zp-ink-4);
}

.zp-portal-theme .chatgpt-dialog.ai-report-writer #maximizeChatWindow svg,
.zp-portal-theme .chatgpt-dialog.ai-report-writer #minimizeChatWindow svg
{
	fill: var(--zp-ink-4);
}

.zp-portal-theme .chatgpt-dialog.ai-report-writer #closeChatWindow svg path
{
	stroke: var(--zp-ink-4);
	fill: var(--zp-ink-4);
}

.zp-portal-theme .chatgpt-dialog.ai-report-writer #lisPreviousChat:hover svg path,
.zp-portal-theme .chatgpt-dialog.ai-report-writer #closeChatWindow:hover svg path
{
	stroke: var(--zp-accent);
}

.zp-portal-theme .chatgpt-dialog.ai-report-writer #closeChatWindow:hover svg path
{
	fill: var(--zp-accent);
}

.zp-portal-theme .chatgpt-dialog.ai-report-writer #maximizeChatWindow:hover svg,
.zp-portal-theme .chatgpt-dialog.ai-report-writer #minimizeChatWindow:hover svg
{
	fill: var(--zp-accent);
}

/* ---- conversation: the portal canvas behind white message cards ---- */
.zp-portal-theme .chatgpt-dialog.ai-report-writer .dialog-body,
.zp-portal-theme .chatgpt-dialog.ai-report-writer .message-container
{
	background: var(--zp-canvas) !important;
}

/* The composer card (.inner-footer, absolute, bottom:35px in the template) rides ~14px up over the
   body's bottom edge, so the last line of the conversation - the live activity line while the agent
   works - needs that much extra room below it to clear the card when scrolled to the bottom. */
.zp-portal-theme .chatgpt-dialog.ai-report-writer .message-container
{
	/* the template gives it h-full (height:100%) and it is a flex item of the scrolling .dialog-body
	   (flex-col), so it shrank to the body's height and its content overflowed past its own padding -
	   the padding never counted toward the scroll height. Let it grow with the conversation instead. */
	flex: 0 0 auto;
	height: auto !important;
	min-height: 100%;
	padding: 8px 10px 30px;
}

/* Empty-chat greeting. The shared template (chat.js promptDetailHTML) pins "How can I help you today?"
   to the bottom of the canvas, just above the composer; the Report Writer shows it in the upper middle
   instead, with the starter questions (chat.js promptHTML, .prompt-questions) underneath. */
.zp-portal-theme .chatgpt-dialog.ai-report-writer .prompt-message
{
	align-items: center;
	justify-content: flex-start;
	padding-top: 22%;
}

.zp-portal-theme .chatgpt-dialog.ai-report-writer .prompt-message .title
{
	font-size: 15px;
	font-weight: 600;
	color: var(--zp-ink-3);
}

/* Starter questions: one click posts the chip's text as the first message (chat.js attachQuestionClickEvent). */
.zp-portal-theme .chatgpt-dialog.ai-report-writer .prompt-questions
{
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	width: 100%;
	margin-top: 18px;
}

.zp-portal-theme .chatgpt-dialog.ai-report-writer .prompt-questions .question
{
	max-width: 85%;
	margin: 0;
	padding: 8px 14px;
	background: var(--zp-surface);
	border: 1px solid var(--zp-line);
	border-radius: 999px;
	box-shadow: var(--zp-shadow-card);
	color: var(--zp-ink-2);
	font-size: 13px;
	line-height: 1.4;
	text-align: center;
	cursor: pointer;
	transition: border-color .15s ease, background-color .15s ease, color .15s ease;
}

.zp-portal-theme .chatgpt-dialog.ai-report-writer .prompt-questions .question:hover
{
	background: var(--zp-accent-tint);
	border-color: var(--zp-accent-border);
	color: var(--zp-accent-ink);
}

.zp-portal-theme .chatgpt-dialog.ai-report-writer .human-message
{
	padding: 10px 16px;
	background: var(--zp-accent-tint);
	border: 1px solid var(--zp-accent-border);
	border-radius: 14px 4px 14px 14px;
	color: var(--zp-ink);
	font-size: 14px;
	align-items: flex-start;
}

/* ---- the reply: answer text in white bubbles, the AI's activity between them on the canvas ----
   chat.js renders one timeline per reply (.inner-message-container): .tl-text answer segments, one per
   text block the model wrote between tool calls, plus an inline clarifying-question card when the agent
   asks one. The card around all of it (.ai-message-container, Tailwind bg-white/padding in chat.js) is
   made transparent here and each .tl-text segment is the white bubble; the agent's activity shows on
   the single live line below (.processing-hint), never inside the answer. */
.zp-portal-theme .chatgpt-dialog.ai-report-writer .ai-message-container
{
	padding: 0 !important;
	margin: 0 !important;
	background: transparent !important;
	border: 0;
	border-radius: 0 !important;
	box-shadow: none;
	font-size: 14px;
	color: var(--zp-ink);
}

/* Tailwind's space-y-3 on the card spaces the timeline from the rating/copy row; keep it small. */
.zp-portal-theme .chatgpt-dialog.ai-report-writer .ai-message-container > :not([hidden]) ~ :not([hidden])
{
	margin-top: 6px;
}

.zp-portal-theme .chatgpt-dialog.ai-report-writer .inner-message-container
{
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 4px;
}

/* An answer segment: the white reply bubble (what the whole card used to be). Full width so report
   tables and charts have room; blank segments (whitespace between two tool calls) draw nothing. */
.zp-portal-theme .chatgpt-dialog.ai-report-writer .inner-message-container > .tl-text
{
	align-self: stretch;
	margin: 2px 0;
	padding: 12px 16px;
	background: var(--zp-surface);
	border: 1px solid var(--zp-line);
	border-radius: 4px 14px 14px 14px;
	box-shadow: var(--zp-shadow-card);
	font-size: 14px;
	color: var(--zp-ink);
}

.zp-portal-theme .chatgpt-dialog.ai-report-writer .inner-message-container > .tl-text:empty,
.zp-portal-theme .chatgpt-dialog.ai-report-writer .inner-message-container > .tl-text.tl-blank
{
	display: none;
}

.zp-portal-theme .chatgpt-dialog.ai-report-writer .inner-message-container > .tl-text > :first-child
{
	margin-top: 0;
}

.zp-portal-theme .chatgpt-dialog.ai-report-writer .inner-message-container > .tl-text > :last-child
{
	margin-bottom: 0;
}

/* A clarifying-question card is a card of its own on the canvas. */
.zp-portal-theme .chatgpt-dialog.ai-report-writer .inner-message-container > .cq-card
{
	align-self: stretch;
	background: var(--zp-surface);
	border-color: var(--zp-line);
	box-shadow: var(--zp-shadow-card);
}

/* The rating / copy row under the last bubble. */
.zp-portal-theme .chatgpt-dialog.ai-report-writer .button-container
{
	padding: 0 6px;
}

/* ---- live "working" line (.processing-hint): the current activity label + typing dots ----
   A sibling after the reply (chat.js aImsgHtmlString). ONE line that stays in place while the agent
   works: chat.js setActivity cross-fades the label on every tool call / thinking signal (the .aa-label
   transition lives in chat.js ensureToolStepStyles), nothing is listed. Alone (nothing answered yet)
   it is just the dots. */
.zp-portal-theme .chatgpt-dialog.ai-report-writer .processing-hint
{
	align-self: flex-start;
	/* baseline, not center: the dots have no text, so their baseline is synthesised from their bottom
	   edge and they sit on the label's text baseline like an ellipsis, instead of floating mid-row. */
	align-items: baseline;
	gap: 8px;
	padding: 3px 6px;
	margin-top: 2px;
	background: transparent;
	border: 0;
	box-shadow: none;
	color: var(--zp-ink-3);
}

.zp-portal-theme .chatgpt-dialog.ai-report-writer .processing-hint.hidden
{
	display: none;
}

.zp-portal-theme .chatgpt-dialog.ai-report-writer .processing-hint .agent-action-text
{
	font-size: 13px !important;
	color: var(--zp-ink-3) !important;
	line-height: 1.4;
	margin: 0;
}

.zp-portal-theme .chatgpt-dialog.ai-report-writer .processing-hint .agent-action-text:empty
{
	display: none;
}

/* The dots: three 5px discs in the row's text colour, bouncing in turn. No fixed height: the box is
   exactly the dots, so its bottom edge (= its baseline in the baseline-aligned row) is the dots' bottom. */
.zp-portal-theme .chatgpt-dialog .zp-typing-dots
{
	display: inline-flex;
	align-items: flex-end;
	gap: 4px;
	flex: 0 0 auto;
}

.zp-portal-theme .chatgpt-dialog .zp-typing-dots span
{
	width: 5px;
	height: 5px;
	border-radius: 50%;
	background: currentColor;
	opacity: .35;
	animation: zpTypingDot 1.2s ease-in-out infinite;
}

.zp-portal-theme .chatgpt-dialog .zp-typing-dots span:nth-child(2) { animation-delay: .15s; }
.zp-portal-theme .chatgpt-dialog .zp-typing-dots span:nth-child(3) { animation-delay: .3s; }

@keyframes zpTypingDot
{
	0%, 60%, 100% { opacity: .35; transform: translateY(0); }
	30% { opacity: 1; transform: translateY(-3px); }
}

@media (prefers-reduced-motion: reduce)
{
	.zp-portal-theme .chatgpt-dialog .zp-typing-dots span { animation: none; opacity: .7; }
}

.zp-portal-theme .chatgpt-dialog.ai-report-writer .chat-action-btn svg
{
	width: 18px;
	height: 18px;
}

.zp-portal-theme .chatgpt-dialog.ai-report-writer .chat-action-btn svg path,
.zp-portal-theme .chatgpt-dialog.ai-report-writer .chat-action-btn svg rect
{
	stroke: var(--zp-ink-5);
}

.zp-portal-theme .chatgpt-dialog.ai-report-writer .chat-action-btn:hover svg path,
.zp-portal-theme .chatgpt-dialog.ai-report-writer .chat-action-btn:hover svg rect
{
	stroke: var(--zp-accent);
}

/* Show Report: same solid accent as New chat */
.zp-portal-theme .chatgpt-dialog.ai-report-writer #showReport
{
	height: 32px;
	padding: 0 14px !important;
	background: var(--zp-accent) !important;
	background-image: none !important;
	border-radius: var(--zp-radius-control) !important;
	font-size: 13px !important;
	font-weight: 600 !important;
	letter-spacing: 0 !important;
}

.zp-portal-theme .chatgpt-dialog.ai-report-writer #showReport:hover
{
	background: var(--zp-accent-strong) !important;
	opacity: 1;
}

/* ---- composer: a portal input card with an accent send button ---- */
.zp-portal-theme .chatgpt-dialog.ai-report-writer .footer
{
	background: var(--zp-canvas) !important;
}

.zp-portal-theme .chatgpt-dialog.ai-report-writer .inner-footer
{
	background: var(--zp-surface) !important;
	border: 1px solid var(--zp-line) !important;
	border-radius: var(--zp-radius-card) !important;
	box-shadow: var(--zp-shadow-card);
	transition: border-color .15s ease, box-shadow .15s ease;
}

.zp-portal-theme .chatgpt-dialog.ai-report-writer .inner-footer:focus-within
{
	border-color: var(--zp-accent-border) !important;
	box-shadow: 0 0 0 3px var(--zp-accent-tint);
}

.zp-portal-theme .chatgpt-dialog.ai-report-writer .inner-footer textarea
{
	font-size: 14px !important;
	color: var(--zp-ink) !important;
	background: transparent;
}

.zp-portal-theme .chatgpt-dialog.ai-report-writer .inner-footer textarea::placeholder
{
	color: var(--zp-ink-5);
}

.zp-portal-theme .chatgpt-dialog.ai-report-writer #message-post-button
{
	justify-content: center;
	width: 34px;
	height: 34px;
	background: var(--zp-accent);
	border-radius: var(--zp-radius-control);
	opacity: 1 !important;
	transition: background-color .15s ease;
}

.zp-portal-theme .chatgpt-dialog.ai-report-writer #message-post-button:hover
{
	background: var(--zp-accent-strong);
}

.zp-portal-theme .chatgpt-dialog.ai-report-writer #message-post-button svg
{
	width: 18px;
	height: 18px;
}

/* the send glyph is stroked, the stop glyph (chat.js stopIconSVG) is a filled square */
.zp-portal-theme .chatgpt-dialog.ai-report-writer #message-post-button svg path
{
	stroke: #FFFFFF;
}

.zp-portal-theme .chatgpt-dialog.ai-report-writer #message-post-button svg rect
{
	fill: #FFFFFF;
}

.zp-portal-theme .chatgpt-dialog.ai-report-writer .footer > p
{
	color: var(--zp-ink-5) !important;
	font-size: 12px !important;
}
