/* AskDoc AI — frontend widget. Self-contained, themeable via --askdoc-accent / --askdoc-accent-dark.
   Minimal search-first panel: heading + pill search bar + disclaimer, answers below on demand. */
:root {
	--askdoc-accent: #FF7D44;
	--askdoc-accent-dark: #ff5e1a;
	--askdoc-text: #212126;
	--askdoc-muted: #8e8e98;
	--askdoc-border: #e4e4e9;
	--askdoc-panel-radius: 28px;
	--askdoc-font-body: "Nunito Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	--askdoc-font-head: "DM Sans", "Nunito Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	--askdoc-shadow: 0 24px 60px rgba(15, 26, 46, 0.22);
}

.askdoc-app {
	box-sizing: border-box;
	font-family: var(--askdoc-font-body);
	color: var(--askdoc-text);
	font-size: 15px;
	line-height: 1.55;
}
.askdoc-app *, .askdoc-app *::before, .askdoc-app *::after { box-sizing: border-box; }

/* Self-contained accessible hiding (don't rely on the theme defining .screen-reader-text). */
.askdoc-app .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	border: 0;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	overflow: hidden;
	word-wrap: normal !important;
}

.askdoc-panel {
	position: relative;
	background: #fff;
	border: 1px solid var(--askdoc-border);
	border-radius: var(--askdoc-panel-radius);
	overflow: hidden;
}

/* ---- Body: heading, search, disclaimer ---- */
.askdoc-body { padding: 44px 52px 40px; }

.askdoc-title {
	margin: 0 0 22px;
	font-family: var(--askdoc-font-head);
	font-weight: 700;
	font-size: 25px;
	line-height: 1.25;
	color: var(--askdoc-text);
}

.askdoc-form {
	display: flex;
	align-items: center;
	gap: 14px;
	border: 1px solid var(--askdoc-border);
	border-radius: 999px;
	padding: 0 24px;
	height: 66px;
	background: #fff;
	transition: border-color .15s ease, box-shadow .15s ease;
}
.askdoc-form:focus-within {
	border-color: var(--askdoc-accent);
	box-shadow: 0 0 0 4px color-mix(in srgb, var(--askdoc-accent) 14%, transparent);
}
.askdoc-search-icon {
	flex: 0 0 auto;
	display: inline-flex;
	color: var(--askdoc-accent);
}
.askdoc-search-icon svg { width: 24px; height: 24px; }
.askdoc-input {
	flex: 1;
	min-width: 0;
	border: none;
	background: transparent;
	font-family: var(--askdoc-font-body);
	font-size: 17px;
	color: var(--askdoc-text);
	height: 100%;
}
.askdoc-input::placeholder { color: #4c4c54; opacity: 1; }
.askdoc-input:focus { outline: none; }

/* Enter key icon at the right end of the pill — same accent colour and size as the search icon. */
.askdoc-enter {
	flex: 0 0 auto;
	display: inline-flex;
	color: var(--askdoc-accent);
}
.askdoc-enter svg { width: 24px; height: 24px; }

.askdoc-disclaimer {
	margin: 22px auto 0 !important;
    max-width: 100%;
    text-align: center;
    font-size: 13px;
    line-height: 1.6;
	color: var(--askdoc-muted);
}

/* ---- Result ---- */
.askdoc-result { margin-top: 26px; }
.askdoc-result:empty { margin-top: 0; }

.askdoc-loading {
	color: var(--askdoc-muted);
	display: flex;
	align-items: center;
	gap: 9px;
	padding: 6px 0;
	font-size: 14px;
}
/* Cycling stage text ("Thinking → Searching the document → Writing the answer")
   with a light sweep, echoing an AI pipeline at work. */
.askdoc-stage {
	font-weight: 600;
	background: linear-gradient( 90deg, var(--askdoc-muted) 15%, var(--askdoc-accent) 50%, var(--askdoc-muted) 85% );
	background-size: 200% 100%;
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
	animation: askdoc-shimmer 1.9s linear infinite;
}
@keyframes askdoc-shimmer {
	from { background-position: 200% 0; }
	to { background-position: -200% 0; }
}
.askdoc-dots { display: inline-flex; gap: 4px; }
.askdoc-dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--askdoc-accent);
	animation: askdoc-bounce 1s infinite ease-in-out;
}
.askdoc-dot:nth-child(2) { animation-delay: 0.15s; }
.askdoc-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes askdoc-bounce {
	0%, 80%, 100% { transform: translateY(0); opacity: .45; }
	40% { transform: translateY(-5px); opacity: 1; }
}

.askdoc-answer {
	background: #f7f7f9;
	border-radius: 16px;
	padding: 16px 18px;
	margin: 0 0 14px;
	font-size: 15px;
	white-space: pre-wrap;
	word-wrap: break-word;
	overflow-wrap: break-word;
}

/* Structured answers: paragraphs, bullet lists, bold labels. */
.askdoc-answer p {
	margin: 0 0 10px;
}
.askdoc-answer p:last-child,
.askdoc-answer ul:last-child {
	margin-bottom: 0;
}
.askdoc-answer ul {
	margin: 0 0 10px;
	padding-left: 22px;
	list-style: disc outside;
}
.askdoc-answer li {
	margin: 0 0 7px;
	padding-left: 2px;
}
.askdoc-answer li:last-child {
	margin-bottom: 0;
}
.askdoc-answer strong {
	font-weight: 700;
}

/* "AI answer" tag with sparkle */
.askdoc-ai-label {
	display: flex;
	align-items: center;
	gap: 6px;
	margin: 0 0 8px;
	font-family: var(--askdoc-font-head);
	font-size: 11.5px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.07em;
	color: var(--askdoc-text);
}
.askdoc-ai-spark {
	display: inline-flex;
	color: var(--askdoc-accent);
}
.askdoc-ai-spark svg { width: 14px; height: 14px; }

/* Inline page citations inside the answer text — link straight to the PDF page. */
.askdoc-answer a.askdoc-cite,
.askdoc-notfound a.askdoc-cite {
	color: var(--askdoc-accent-dark) !important;
	font-weight: 700;
	text-decoration: underline;
	text-decoration-thickness: 1.5px;
	text-decoration-color: color-mix(in srgb, var(--askdoc-accent) 45%, transparent);
	text-underline-offset: 2px;
	white-space: nowrap;
	transition: color .12s ease, text-decoration-color .12s ease;
}
.askdoc-answer a.askdoc-cite:hover,
.askdoc-notfound a.askdoc-cite:hover {
	color: var(--askdoc-accent);
	text-decoration-color: var(--askdoc-accent);
}
.askdoc-answer a.askdoc-cite:focus-visible,
.askdoc-notfound a.askdoc-cite:focus-visible {
	outline: 2px solid var(--askdoc-accent);
	outline-offset: 2px;
	border-radius: 2px;
}

.askdoc-pages { padding: 2px 0 4px; }
.askdoc-pages-label {
	display: block;
	font-size: 11.5px;
	color: var(--askdoc-text);
	margin-bottom: 8px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.4px;
	font-family: var(--askdoc-text);
}
.askdoc-page-btn {
	display: inline-flex;
	align-items: center;
	margin: 0 6px 6px 0;
	background: #fff;
	color: var(--askdoc-accent-dark) !important;
	border: 1.5px solid var(--askdoc-accent);
	text-decoration: none;
	border-radius: 999px;
	padding: 7px 15px;
	font-family: var(--askdoc-font-head);
	font-size: 13px;
	font-weight: 700;
	transition: background .12s ease, color .12s ease, transform .12s ease, box-shadow .12s ease;
}
.askdoc-page-btn:hover {
	background: var(--askdoc-accent);
	color: #fff !important;
	transform: translateY(-1px);
	box-shadow: 0 4px 12px color-mix(in srgb, var(--askdoc-accent) 30%, transparent);
}

.askdoc-error {
	background: #fdf2f2;
	border: 1px solid #f3c8c8;
	border-radius: 12px;
	padding: 10px 14px;
	margin: 4px 0 8px;
	font-size: 14px;
}
.askdoc-notfound {
	background: #fdf7ec;
	border: 1px solid #f2ddb0;
	border-radius: 12px;
	padding: 10px 14px;
	margin: 4px 0 8px;
	font-size: 14px;
}

/* ---- Floating variant (built-in launcher; a custom host modal can embed the shortcode instead) ---- */
.askdoc-launcher {
	position: fixed;
	bottom: 22px;
	z-index: 99998;
	width: 58px;
	height: 58px;
	border-radius: 50%;
	border: none;
	cursor: pointer;
	background: linear-gradient(135deg, var(--askdoc-accent), var(--askdoc-accent-dark));
	color: #fff;
	box-shadow: 0 6px 22px color-mix(in srgb, var(--askdoc-accent) 45%, transparent);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform .18s ease, box-shadow .18s ease;
}
.askdoc-launcher:hover { transform: translateY(-2px); box-shadow: 0 10px 28px color-mix(in srgb, var(--askdoc-accent) 55%, transparent); }
.askdoc-launcher.askdoc-pos-right { right: 22px; }
.askdoc-launcher.askdoc-pos-left { left: 22px; }
.askdoc-launcher svg { width: 26px; height: 26px; }
.askdoc-launcher .askdoc-launcher-close { display: none; font-size: 30px; line-height: 1; font-family: var(--askdoc-font-body); }
.askdoc-launcher.is-open .askdoc-launcher-icon { display: none; }
.askdoc-launcher.is-open .askdoc-launcher-close { display: block; }

.askdoc-floating {
	position: fixed;
	bottom: 94px;
	z-index: 99999;
	width: 420px;
	max-width: calc(100vw - 32px);
}
html[data-askdoc-pos="right"] .askdoc-floating,
.askdoc-floating.askdoc-pos-right { right: 22px; left: auto; }
html[data-askdoc-pos="left"] .askdoc-floating,
.askdoc-floating.askdoc-pos-left { left: 22px; right: auto; }
.askdoc-floating .askdoc-panel {
	box-shadow: var(--askdoc-shadow);
	animation: askdoc-pop .22s cubic-bezier(0.165, 0.84, 0.44, 1);
	transform-origin: bottom right;
}
html[data-askdoc-pos="left"] .askdoc-floating .askdoc-panel { transform-origin: bottom left; }
@keyframes askdoc-pop {
	from { opacity: 0; transform: translateY(10px) scale(0.97); }
	to { opacity: 1; transform: none; }
}

.askdoc-floating .askdoc-body { padding: 30px 26px 26px; }
.askdoc-floating .askdoc-title { font-size: 19px; margin-bottom: 16px; }
.askdoc-floating .askdoc-form { height: 54px; padding: 0 18px; gap: 10px; }
.askdoc-floating .askdoc-search-icon svg { width: 20px; height: 20px; }
.askdoc-floating .askdoc-enter svg { width: 20px; height: 20px; }
.askdoc-floating .askdoc-input { font-size: 15px; }
.askdoc-floating .askdoc-disclaimer { font-size: 12px; margin-top: 16px; }
.askdoc-floating .askdoc-result { margin-top: 18px; }

.askdoc-close {
	position: absolute;
	top: 16px;
	right: 18px;
	z-index: 1;
	background: transparent;
	border: none;
	color: var(--askdoc-muted);
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	padding: 2px 6px;
	transition: color .12s ease;
}
.askdoc-close:hover { color: var(--askdoc-text); }

/* Keyboard focus (a11y) */
.askdoc-launcher:focus-visible,
.askdoc-close:focus-visible,
.askdoc-page-btn:focus-visible {
	outline: 2px solid var(--askdoc-accent);
	outline-offset: 2px;
}

/* Compact screens: tighter paddings, sheet-style floating panel */
@media (max-width: 640px) {
	.askdoc-embed .askdoc-body { padding: 26px 20px 24px; }
	.askdoc-title { font-size: 20px; margin-bottom: 16px; }
	.askdoc-form { height: 56px; padding: 0 18px; gap: 10px; }
	.askdoc-search-icon svg { width: 20px; height: 20px; }
	.askdoc-enter svg { width: 20px; height: 20px; }
	.askdoc-input { font-size: 16px; }
	.askdoc-disclaimer { font-size: 12px; margin-top: 16px; }
}
@media (max-width: 480px) {
	.askdoc-floating {
		left: 0 !important;
		right: 0 !important;
		bottom: 0;
		width: 100%;
		max-width: none;
	}
	.askdoc-floating .askdoc-panel {
		border-radius: 20px 20px 0 0;
		border-bottom: none;
		max-height: 80vh;
		overflow-y: auto;
		animation: askdoc-sheet .24s cubic-bezier(0.165, 0.84, 0.44, 1);
	}
	@keyframes askdoc-sheet {
		from { transform: translateY(100%); }
		to { transform: none; }
	}
	.askdoc-launcher { bottom: 16px; }
	.askdoc-launcher.askdoc-pos-right { right: 14px; }
	.askdoc-launcher.askdoc-pos-left { left: 14px; }
}

@media (prefers-reduced-motion: reduce) {
	.askdoc-floating .askdoc-panel,
	.askdoc-launcher,
	.askdoc-page-btn,
	.askdoc-stage { animation: none !important; transition: none !important; }
	.askdoc-stage { color: var(--askdoc-muted); background: none; -webkit-background-clip: initial; background-clip: initial; }
}

/* ------------------------------------------------------------------ */
/* Chat mode (2026): the result box is a scrolling conversation.       */
/* ------------------------------------------------------------------ */

.askdoc-app.askdoc-chat .askdoc-title {
	display: none;
}

.askdoc-app.askdoc-chat .askdoc-result {
    max-height: 50vh;
    overflow-y: auto;
    padding-right: 6px;
    margin-top: 20px;
    margin-bottom: 20px;
}

/* The "AI answer" tag repeats per turn in a log — hide it, the layout
   already reads as chat. */
.askdoc-app.askdoc-chat .askdoc-ai-label {
	display: none;
}

.askdoc-app.askdoc-chat .askdoc-answer,
.askdoc-app.askdoc-chat .askdoc-notfound,
.askdoc-app.askdoc-chat .askdoc-error {
	margin-top: 14px;
}

.askdoc-app.askdoc-chat .askdoc-pages {
	margin-top: 12px;
	display: none;
}

/* The user's question — right-aligned grey pill. */
.askdoc-q {
	margin: 20px 0 12px auto;
	width: fit-content;
	max-width: 85%;
	background: #f1f3f4;
	border-radius: 22px;
	padding: 12px 22px;
	font-size: 15px;
	font-weight: 600;
	color: #17172b;
}

.askdoc-app.askdoc-chat .askdoc-loading {
	margin: 6px 0 0;
}

@media (max-width: 767px) {
	.askdoc-app.askdoc-chat .askdoc-result {
		max-height: 46vh;
	}
}
