@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&display=swap');

/* ── CSS variables ── */
.prm-chatbot-widget {
	--cb-font:          'DM Sans', sans-serif;
	--cb-bg:            #0d1117;
	--cb-surface:       #161c26;
	--cb-surface-2:     #1e2735;
	--cb-border:        rgba(255, 255, 255, 0.07);
	--cb-border-hover:  rgba(255, 255, 255, 0.14);
	--cb-accent:        #0f7b6c;
	--cb-accent-light:  #13a899;
	--cb-accent-glow:   rgba(15, 123, 108, 0.3);
	--cb-text:          #dde5ee;
	--cb-text-muted:    #6e7d8f;
	--cb-user-bg:       #0b3d34;
	--cb-user-text:     #aee8dd;
	--cb-radius:        16px;
	--cb-radius-sm:     10px;
	--cb-shadow:        0 32px 72px rgba(0, 0, 0, 0.6), 0 8px 24px rgba(0, 0, 0, 0.35);
}

/* ── Widget root ── */
.prm-chatbot-widget {
	position: fixed;
	left: 1.5rem;
	bottom: 8rem;
	z-index: 10010;
	font-family: var(--cb-font);
	display: flex;
	flex-direction: column-reverse;
	align-items: flex-start;
	gap: 0.8rem;
}

.prm-chatbot-widget--hidden {
	display: none;
}

/* ── FAB button ── */
.prm-chatbot-widget__fab {
	position: relative;
	display: flex;
	align-items: center;
	gap: 0.6rem;
	background: var(--cb-surface);
	color: var(--cb-text);
	border: 1px solid var(--cb-border-hover);
	border-radius: 999px;
	padding: 0.75rem 1.3rem 0.75rem 1.1rem;
	box-shadow:
		0 8px 32px rgba(0, 0, 0, 0.45),
		0 0 0 1px var(--cb-accent-glow),
		inset 0 1px 0 rgba(255, 255, 255, 0.05);
	cursor: pointer;
	transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

/* Live pulse ring */
.prm-chatbot-widget__fab::before {
	content: '';
	position: absolute;
	inset: -5px;
	border-radius: 999px;
	border: 2px solid var(--cb-accent);
	opacity: 0;
	pointer-events: none;
	animation: cb-ring-pulse 3s ease-out infinite;
}

@keyframes cb-ring-pulse {
	0%   { opacity: 0.65; transform: scale(1); }
	100% { opacity: 0;    transform: scale(1.22); }
}

.prm-chatbot-widget__fab:hover {
	transform: translateY(-2px);
	border-color: var(--cb-accent);
	box-shadow:
		0 16px 48px rgba(0, 0, 0, 0.55),
		0 0 0 2px var(--cb-accent-glow),
		inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

.prm-chatbot-widget__fab:active {
	transform: translateY(0);
}

/* Online indicator dot */
.prm-chatbot-widget__fab-dot {
	width: 7px;
	height: 7px;
	background: var(--cb-accent-light);
	border-radius: 50%;
	box-shadow: 0 0 8px var(--cb-accent-light);
	flex-shrink: 0;
	animation: cb-dot-breathe 2s ease-in-out infinite;
}

@keyframes cb-dot-breathe {
	0%, 100% { opacity: 1; }
	50%       { opacity: 0.5; }
}

.prm-chatbot-widget__fab-label {
	font-size: 1.3rem;
	font-weight: 600;
	letter-spacing: 0.02em;
}

/* ── Chat panel ── */
.prm-chatbot-widget__panel {
	display: none;
	width: 480px;
	max-width: calc(100vw - 2rem);
	height: 680px;
	max-height: calc(100vh - 12rem);
	border-radius: var(--cb-radius);
	background: var(--cb-bg);
	border: 1px solid var(--cb-border);
	box-shadow: var(--cb-shadow);
	overflow: hidden;
	transform-origin: bottom left;
	font-size: 1.3rem; /* default, overridable via widget_styles.font_size */
}

.prm-chatbot-widget__panel.is-open {
	display: flex;
	flex-direction: column;
	animation: cb-panel-in 0.28s cubic-bezier(0.34, 1.35, 0.64, 1) both;
}

@keyframes cb-panel-in {
	from { opacity: 0; transform: scale(0.9) translateY(10px); }
	to   { opacity: 1; transform: scale(1)   translateY(0); }
}

/* ── Header ── */
.prm-chatbot-widget__header {
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0.9rem 1.2rem;
	background: var(--cb-surface);
	border-bottom: 1px solid var(--cb-border);
	position: relative;
}

/* Teal gradient top bar */
.prm-chatbot-widget__header::before {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 2px;
	background: linear-gradient(90deg, var(--cb-accent), var(--cb-accent-light), transparent);
}

.prm-chatbot-widget__title {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	font-size: 1.3rem;
	font-weight: 700;
	color: var(--cb-text);
	letter-spacing: 0.01em;
}

.prm-chatbot-widget__title::before {
	content: '';
	width: 6px;
	height: 6px;
	background: var(--cb-accent-light);
	border-radius: 50%;
	box-shadow: 0 0 8px var(--cb-accent-light);
	flex-shrink: 0;
}

.prm-chatbot-widget__new-session {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 2.6rem;
	height: 2.6rem;
	margin-left: auto;
	background: rgba(0, 0, 0, 0.2);
	border: 1px solid rgba(255, 255, 255, 0.25);
	border-radius: 50%;
	color: rgba(255, 255, 255, 0.85);
	font-size: 1.2rem;
	line-height: 1;
	cursor: pointer;
	transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.prm-chatbot-widget__new-session:hover {
	color: #fff;
	border-color: rgba(255, 255, 255, 0.5);
	background: rgba(0, 0, 0, 0.35);
}

.prm-chatbot-widget__close {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 2.6rem;
	height: 2.6rem;
	margin-left: 0.4rem;
	background: rgba(0, 0, 0, 0.2);
	border: 1px solid rgba(255, 255, 255, 0.25);
	border-radius: 50%;
	color: rgba(255, 255, 255, 0.85);
	font-size: 1.5rem;
	line-height: 1;
	cursor: pointer;
	transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.prm-chatbot-widget__close:hover {
	color: #fff;
	border-color: rgba(255, 255, 255, 0.5);
	background: rgba(0, 0, 0, 0.35);
}

/* ── Messages area ── */
.prm-chatbot-widget__messages {
	flex: 1;
	padding: 1rem;
	overflow-y: auto;
	background: var(--cb-bg);
	display: flex;
	flex-direction: column;
	gap: 0.6rem;
	scrollbar-width: thin;
	scrollbar-color: var(--cb-surface-2) transparent;
}

.prm-chatbot-widget__messages::-webkit-scrollbar { width: 4px; }
.prm-chatbot-widget__messages::-webkit-scrollbar-track { background: transparent; }
.prm-chatbot-widget__messages::-webkit-scrollbar-thumb {
	background: var(--cb-surface-2);
	border-radius: 2px;
}

.prm-chatbot-widget__message {
	padding: 0.7rem 0.9rem;
	border-radius: var(--cb-radius-sm);
	font-size: inherit;
	line-height: 1.6;
	word-break: break-word;
	max-width: 88%;
	animation: cb-msg-in 0.2s ease both;
}

@keyframes cb-msg-in {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: translateY(0); }
}

.prm-chatbot-widget__message--assistant {
	background: var(--cb-surface);
	color: var(--cb-text);
	border: 1px solid var(--cb-border);
	align-self: flex-start;
	border-bottom-left-radius: 3px;
}

.prm-chatbot-widget__message--assistant a {
	color: var(--cb-primary, #0f7b6c);
	text-decoration: underline;
	word-break: break-all;
}

.prm-chatbot-widget__message--assistant a:hover {
	color: #0a5e52;
}

.prm-chatbot-widget__prm-link {
	display: inline-block;
	margin-top: 2px;
	padding: 2px 8px;
	font-size: 0.85em;
	color: var(--cb-primary, #0f7b6c);
	border: 1px solid var(--cb-primary, #0f7b6c);
	border-radius: 4px;
	text-decoration: none;
}

.prm-chatbot-widget__prm-link:hover {
	background: var(--cb-primary, #0f7b6c);
	color: #fff;
	text-decoration: none;
}

.prm-chatbot-widget__message--user {
	background: var(--cb-user-bg);
	color: var(--cb-user-text);
	border: 1px solid rgba(15, 123, 108, 0.25);
	align-self: flex-end;
	border-bottom-right-radius: 3px;
	white-space: pre-wrap;
}

/* ── Citations ── */
.prm-chatbot-widget__citations {
	margin-top: 0.5rem;
	padding-left: 1.2rem;
	font-size: 1.1rem;
	color: var(--cb-text-muted);
}

/* ── Company link in citations ── */
.prm-chatbot-widget__citation--company {
	list-style: none;
	margin-left: -1.2rem;
	margin-top: 0.35rem;
}

.prm-chatbot-widget__company-link {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	padding: 0.25rem 0.7rem;
	border-radius: 999px;
	background: var(--cb-user-bg);
	border: 1px solid rgba(15, 123, 108, 0.3);
	color: var(--cb-accent-light);
	font-size: 1.1rem;
	font-weight: 500;
	text-decoration: none;
	transition: background 0.15s, border-color 0.15s;
}

.prm-chatbot-widget__company-link::before {
	content: '\1F3ED';
	font-size: 0.9rem;
}

.prm-chatbot-widget__company-link:hover {
	background: rgba(15, 123, 108, 0.2);
	border-color: var(--cb-accent);
	color: #fff;
	text-decoration: none;
}

/* ── Feedback ── */
.prm-chatbot-widget__feedback {
	display: flex;
	align-items: center;
	gap: 0.4rem;
	margin-top: 0.6rem;
	flex-wrap: wrap;
}

.prm-chatbot-widget__feedback-label {
	font-size: 1.05rem;
	color: var(--cb-text-muted);
	width: 100%;
}

.prm-chatbot-widget__feedback-button {
	border: 1px solid var(--cb-border);
	background: transparent;
	color: var(--cb-text-muted);
	border-radius: 999px;
	padding: 0.2rem 0.7rem;
	font-size: 1.05rem;
	font-family: var(--cb-font);
	cursor: pointer;
	transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.prm-chatbot-widget__feedback-button:hover {
	border-color: var(--cb-accent);
	color: var(--cb-accent-light);
}

.prm-chatbot-widget__feedback-button.is-selected,
.prm-chatbot-widget__feedback-button:disabled {
	background: var(--cb-user-bg);
	border-color: var(--cb-accent);
	color: var(--cb-accent-light);
	cursor: default;
}

/* ── Handoff CTA ── */
.prm-chatbot-widget__handoff {
	margin-top: 0.6rem;
}

.prm-chatbot-widget__handoff-link {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	padding: 0.4rem 0.85rem;
	border-radius: 999px;
	background: var(--cb-accent);
	color: #fff;
	font-size: 1.1rem;
	font-family: var(--cb-font);
	font-weight: 600;
	text-decoration: none;
	transition: background 0.15s;
}

.prm-chatbot-widget__handoff-link:hover {
	background: var(--cb-accent-light);
	color: #fff;
	text-decoration: none;
}

/* ── Composer ── */
.prm-chatbot-widget__composer {
	flex-shrink: 0;
	padding: 0.8rem 1rem;
	border-top: 1px solid var(--cb-border);
	background: var(--cb-surface);
	display: flex;
	gap: 0.5rem;
	align-items: flex-end;
}

.prm-chatbot-widget__input {
	flex: 1;
	resize: none;
	background: var(--cb-bg);
	border: 1px solid var(--cb-border);
	border-radius: var(--cb-radius-sm);
	padding: 0.6rem 0.85rem;
	font-size: 1.3rem;
	font-family: var(--cb-font);
	color: var(--cb-text);
	outline: none;
	transition: border-color 0.15s, box-shadow 0.15s;
}

.prm-chatbot-widget__input::placeholder {
	color: var(--cb-text-muted);
}

.prm-chatbot-widget__input:focus {
	border-color: var(--cb-accent);
	box-shadow: 0 0 0 3px var(--cb-accent-glow);
}

.prm-chatbot-widget__send {
	padding: 0.6rem 1.2rem;
	border: 0;
	border-radius: var(--cb-radius-sm);
	background: var(--cb-accent);
	color: #fff;
	font-size: 1.3rem;
	font-weight: 600;
	font-family: var(--cb-font);
	letter-spacing: 0.03em;
	cursor: pointer;
	white-space: nowrap;
	transition: background 0.15s, transform 0.1s, opacity 0.15s;
}

.prm-chatbot-widget__send:hover:not(:disabled) {
	background: var(--cb-accent-light);
}

.prm-chatbot-widget__send:active:not(:disabled) {
	transform: scale(0.98);
}

.prm-chatbot-widget__send:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

/* ── Mobile: fullscreen chat experience ── */
@media (max-width: 767px) {
	.prm-chatbot-widget {
		left: 0.8rem;
		right: 0.8rem;
		bottom: 6rem;
	}

	.prm-chatbot-widget__fab-label {
		font-size: 1.1rem;
	}

	.prm-chatbot-widget__panel {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		width: 100%;
		height: 100%;
		max-width: 100vw;
		max-height: 100vh;
		border-radius: 0;
		border: none;
		z-index: 10020;
	}

	.prm-chatbot-widget__panel.is-open {
		animation: cb-panel-in-mobile 0.25s ease both;
	}

	@keyframes cb-panel-in-mobile {
		from { opacity: 0; transform: translateY(100%); }
		to   { opacity: 1; transform: translateY(0); }
	}

	.prm-chatbot-widget__header {
		padding: 0.9rem 1rem;
		padding-top: calc(env(safe-area-inset-top, 0px) + 0.9rem);
	}

	.prm-chatbot-widget__messages {
		padding: 0.8rem;
	}

	.prm-chatbot-widget__message {
		max-width: 92%;
		font-size: 1.35rem;
	}

	.prm-chatbot-widget__composer {
		padding: 0.7rem 0.8rem;
		padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 0.7rem);
	}

	.prm-chatbot-widget__input {
		font-size: 1.4rem;
		padding: 0.7rem 0.85rem;
	}

	.prm-chatbot-widget__send {
		font-size: 1.35rem;
		padding: 0.7rem 1.1rem;
	}
}

/* ── Thinking indicator ── */
.prm-chatbot-widget__thinking {
	display: inline-block;
}

.prm-chatbot-widget__thinking-dots {
	display: inline-flex;
	align-items: center;
	gap: 3px;
	font-size: 24px;
	font-weight: bold;
	color: var(--cb-text-muted);
	line-height: 1;
}

.prm-chatbot-widget__thinking-dots span {
	animation: cb-dot-bounce 1.4s infinite ease-in-out both;
}

.prm-chatbot-widget__thinking-dots span:nth-child(1) {
	animation-delay: 0s;
}

.prm-chatbot-widget__thinking-dots span:nth-child(2) {
	animation-delay: 0.2s;
}

.prm-chatbot-widget__thinking-dots span:nth-child(3) {
	animation-delay: 0.4s;
}

@keyframes cb-dot-bounce {
	0%, 80%, 100% {
		opacity: 0.3;
		transform: translateY(0);
	}
	40% {
		opacity: 1;
		transform: translateY(-4px);
	}
}

/* ── Collapsible content (View More) ── */
.prm-chatbot-widget__content-wrap {
	position: relative;
}

.prm-chatbot-widget__content-wrap.is-collapsed .prm-chatbot-widget__content-inner {
	max-height: 280px;
	overflow: hidden;
	-webkit-mask-image: linear-gradient(to bottom, black 70%, transparent 100%);
	mask-image: linear-gradient(to bottom, black 70%, transparent 100%);
}

.prm-chatbot-widget__view-more {
	display: block;
	width: 100%;
	margin-top: 0.4em;
	padding: 0.3em 0;
	background: transparent;
	border: 1px solid var(--cb-border-hover);
	border-radius: 6px;
	color: var(--cb-accent-light);
	font-size: 1.1rem;
	cursor: pointer;
	text-align: center;
	transition: background 0.15s, color 0.15s;
}

.prm-chatbot-widget__view-more:hover {
	background: var(--cb-surface-2);
	color: #fff;
}

/* ── Quick action buttons ── */
.prm-chatbot-widget__quick-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4em;
	margin-top: 0.6em;
	padding-top: 0.5em;
	border-top: 1px solid var(--cb-border);
}

.prm-chatbot-widget__quick-action {
	padding: 0.35em 0.7em;
	background: var(--cb-surface-2);
	border: 1px solid var(--cb-border-hover);
	border-radius: 16px;
	color: var(--cb-accent-light);
	font-size: 1.1rem;
	cursor: pointer;
	transition: background 0.15s, border-color 0.15s, color 0.15s;
	white-space: nowrap;
	max-width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
}

.prm-chatbot-widget__quick-action:hover {
	background: var(--cb-accent);
	border-color: var(--cb-accent);
	color: #fff;
}
