/*!
 * Prop Nexia Chat — Widget CSS
 *
 * Scoped under .pnc-widget so it can't conflict with the Kadence theme
 * or any other plugin on propnexia.com.
 *
 * Brand colours match the rest of the site:
 *   navy  #11387d
 *   blue  #2274c3
 *   font  Inter (falls back to system if Kadence isn't loading Inter)
 *
 * Layout:
 *   .pnc-widget    fixed bottom-right container, z-index 9999
 *   .pnc-bubble    the round chat icon (visible when closed)
 *   .pnc-panel     the chat window (visible when open)
 *
 * State management is done via data-state="closed|open" on .pnc-widget.
 * --------------------------------------------------------------------- */

.pnc-widget {
	--pnc-navy: #11387d;
	--pnc-blue: #2274c3;
	--pnc-blue-50: #f4f8fd;
	--pnc-blue-100: #dbe8f7;
	--pnc-text: #36456a;
	--pnc-muted: #6b7a99;
	--pnc-line: #e5edf7;
	--pnc-white: #ffffff;
	--pnc-shadow: 0 12px 32px rgba(17, 56, 125, 0.18);

	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 999999; /* Above almost everything; Kadence sticky header is ~9999 */
	font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	font-size: 14px;
	line-height: 1.5;
	color: var(--pnc-text);
}

/* RTL flip — when the page is Arabic, dock the widget on the left.
   Both [dir="rtl"] (set explicitly on Arabic) and the parent page
   being RTL trigger this. The widget sets its own dir on render so
   we don't depend on the host theme. */
[dir="rtl"] .pnc-widget,
.pnc-widget[dir="rtl"] {
	right: auto;
	left: 20px;
}
@media (max-width: 480px) {
	[dir="rtl"] .pnc-widget,
	.pnc-widget[dir="rtl"] {
		left: 12px;
	}
}

/* Arabic text rendering — use a better Arabic-supporting fallback
   stack since Inter doesn't ship Arabic glyphs. The Apple/Samsung/
   Windows system Arabic fonts are all high quality. */
.pnc-widget[dir="rtl"],
.pnc-widget[data-language="ar"] {
	font-family: 'Inter', 'Segoe UI', Tahoma, 'Geeza Pro', 'Arabic UI Text',
	             -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ---------------------------------------------------------------------
 * Chat bubble (closed state)
 * ------------------------------------------------------------------ */

.pnc-bubble {
	width: 60px;
	height: 60px;
	border-radius: 50%;
	background: linear-gradient(180deg, var(--pnc-blue) 0%, var(--pnc-navy) 100%);
	color: var(--pnc-white);
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: var(--pnc-shadow);
	transition: transform 0.18s ease, box-shadow 0.18s ease;
	padding: 0;
}
.pnc-bubble:hover {
	transform: translateY(-2px);
	box-shadow: 0 16px 40px rgba(17, 56, 125, 0.25);
}
.pnc-bubble:focus-visible {
	outline: 3px solid var(--pnc-blue-100);
	outline-offset: 3px;
}
.pnc-bubble-icon {
	width: 26px;
	height: 26px;
}

/* When the panel is open, hide the bubble (a close button lives in the panel header). */
.pnc-widget[data-state="open"] .pnc-bubble {
	display: none;
}

/* ---------------------------------------------------------------------
 * Chat panel (open state)
 * ------------------------------------------------------------------ */

.pnc-panel {
	width: 360px;
	max-width: calc(100vw - 40px);
	height: 520px;
	max-height: calc(100vh - 120px);
	background: var(--pnc-white);
	border-radius: 16px;
	box-shadow: var(--pnc-shadow);
	display: none; /* JS sets to flex when opening; hidden attr removed */
	flex-direction: column;
	overflow: hidden;
	border: 1px solid var(--pnc-line);
}
.pnc-widget[data-state="open"] .pnc-panel {
	display: flex;
}

/* On phones the panel fills nearly the whole screen. */
@media (max-width: 480px) {
	.pnc-panel {
		width: calc(100vw - 24px);
		height: calc(100vh - 100px);
		max-height: none;
		right: 12px;
	}
	.pnc-widget {
		right: 12px;
		bottom: 12px;
	}
	[dir="rtl"] .pnc-widget {
		left: 12px;
	}
}

/* ---------------------------------------------------------------------
 * Panel header
 * ------------------------------------------------------------------ */

.pnc-panel-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 16px 10px;
	background: linear-gradient(180deg, var(--pnc-navy) 0%, #0a2354 100%);
	color: var(--pnc-white);
	flex-shrink: 0;
}
.pnc-panel-titles {
	display: flex;
	flex-direction: column;
	gap: 2px;
}
.pnc-panel-title {
	font-size: 15px;
	font-weight: 600;
	color: var(--pnc-white);
}
.pnc-panel-status {
	font-size: 11px;
	color: rgba(255, 255, 255, 0.72);
	display: inline-flex;
	align-items: center;
	gap: 6px;
}
.pnc-panel-status::before {
	content: '';
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #22c55e; /* green dot — online */
	display: inline-block;
}

/* Close button (X) */
.pnc-close {
	background: transparent;
	border: none;
	color: rgba(255, 255, 255, 0.85);
	cursor: pointer;
	padding: 4px;
	border-radius: 6px;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s ease, color 0.15s ease;
}
.pnc-close:hover {
	background: rgba(255, 255, 255, 0.1);
	color: var(--pnc-white);
}
.pnc-close:focus-visible {
	outline: 2px solid rgba(255, 255, 255, 0.6);
	outline-offset: 1px;
}

/* ---------------------------------------------------------------------
 * Disclaimer (always visible, fine print)
 * ------------------------------------------------------------------ */

.pnc-disclaimer {
	padding: 6px 16px;
	background: var(--pnc-blue-50);
	color: var(--pnc-muted);
	font-size: 11px;
	text-align: center;
	border-bottom: 1px solid var(--pnc-line);
	flex-shrink: 0;
}

/* ---------------------------------------------------------------------
 * Operator banner *
 * Appears just under the disclaimer when an operator takes over from
 * AI. Disappears when they release.
 * ------------------------------------------------------------------ */

.pnc-operator-banner {
	padding: 8px 16px;
	background: linear-gradient(180deg, #e8f5ed 0%, #d5ecde 100%);
	color: #1f7a3e;
	font-size: 12px;
	font-weight: 500;
	text-align: center;
	border-bottom: 1px solid #c4e3cf;
	flex-shrink: 0;
	animation: pnc-banner-slide 0.2s ease;
}
@keyframes pnc-banner-slide {
	from { opacity: 0; max-height: 0; padding-top: 0; padding-bottom: 0; }
	to   { opacity: 1; max-height: 60px; }
}

/* ---------------------------------------------------------------------
 * Closed banner *
 * Appears above the composer when the conversation has been closed.
 * Composer is also disabled.
 * ------------------------------------------------------------------ */

.pnc-closed-banner {
	padding: 10px 14px;
	background: #f1f2f5;
	color: #6b7a99;
	font-size: 12.5px;
	text-align: center;
	border-top: 1px solid #e5edf7;
	font-style: italic;
}

/* Status indicator offline state (used when conversation is closed) */
.pnc-panel-status.pnc-status-offline::before {
	background: #a7aaad;
	animation: none;
}

/* ---------------------------------------------------------------------
 * Messages list
 * ------------------------------------------------------------------ */

.pnc-messages {
	flex: 1;
	overflow-y: auto;
	padding: 14px 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: #fafbfd;
}

.pnc-msg {
	max-width: 80%;
	padding: 9px 12px;
	border-radius: 12px;
	font-size: 13.5px;
	line-height: 1.45;
	word-wrap: break-word;
	overflow-wrap: anywhere;
}
.pnc-msg-visitor {
	align-self: flex-end;
	background: var(--pnc-blue);
	color: var(--pnc-white);
	border-bottom-right-radius: 4px;
}
.pnc-msg-ai,
.pnc-msg-operator {
	align-self: flex-start;
	background: var(--pnc-white);
	color: var(--pnc-text);
	border: 1px solid var(--pnc-line);
	border-bottom-left-radius: 4px;
}
.pnc-msg-operator {
	border-color: var(--pnc-blue-100);
	background: var(--pnc-blue-50);
}

/* Sender label above operator messages so visitors know it's a human */
.pnc-msg-sender-label {
	font-size: 10.5px;
	color: var(--pnc-muted);
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	margin-bottom: 4px;
	display: block;
}

/* System message — centered timeline note (operator joined, conversation
   closed, etc.). Not a chat bubble. Sits in the message list flow but
   visually separate from visitor/AI/operator messages. */
.pnc-msg-system {
	align-self: center;
	max-width: 85%;
	padding: 6px 12px;
	margin: 4px 0;
	font-size: 12px;
	line-height: 1.4;
	color: var(--pnc-muted);
	text-align: center;
	background: transparent;
	border: none;
	font-style: italic;
}

/* RTL message alignment flips */
[dir="rtl"] .pnc-msg-visitor,
.pnc-widget[dir="rtl"] .pnc-msg-visitor {
	align-self: flex-start;
	border-bottom-right-radius: 12px;
	border-bottom-left-radius: 4px;
}
[dir="rtl"] .pnc-msg-ai,
[dir="rtl"] .pnc-msg-operator,
.pnc-widget[dir="rtl"] .pnc-msg-ai,
.pnc-widget[dir="rtl"] .pnc-msg-operator {
	align-self: flex-end;
	border-bottom-left-radius: 12px;
	border-bottom-right-radius: 4px;
}

/* Typing indicator (used during AI response in ) */
.pnc-typing {
	align-self: flex-start;
	display: flex;
	gap: 4px;
	padding: 10px 14px;
	background: var(--pnc-white);
	border: 1px solid var(--pnc-line);
	border-radius: 12px;
	border-bottom-left-radius: 4px;
}
.pnc-typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--pnc-muted);
	animation: pnc-typing-bounce 1.2s infinite;
}
.pnc-typing span:nth-child(2) { animation-delay: 0.15s; }
.pnc-typing span:nth-child(3) { animation-delay: 0.30s; }
@keyframes pnc-typing-bounce {
	0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
	30%           { opacity: 1;   transform: translateY(-3px); }
}

/* ---------------------------------------------------------------------
 * Composer (text input + send button)
 * ------------------------------------------------------------------ */

.pnc-composer {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px;
	background: var(--pnc-white);
	border-top: 1px solid var(--pnc-line);
	flex-shrink: 0;
}
.pnc-input {
	flex: 1;
	min-height: 38px;
	max-height: 120px;
	padding: 8px 12px;
	border: 1px solid var(--pnc-line);
	border-radius: 18px;
	font: inherit;
	color: var(--pnc-text);
	resize: none;
	outline: none;
	background: #fafbfd;
	transition: border-color 0.15s ease, background 0.15s ease;
	font-family: inherit;
}
.pnc-input:focus {
	border-color: var(--pnc-blue);
	background: var(--pnc-white);
}
.pnc-input::placeholder {
	color: var(--pnc-muted);
}

.pnc-send {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: var(--pnc-blue);
	color: var(--pnc-white);
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: background 0.15s ease, opacity 0.15s ease;
	padding: 0;
}
.pnc-send:hover:not(:disabled) {
	background: var(--pnc-navy);
}
.pnc-send:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}
.pnc-send:focus-visible {
	outline: 2px solid var(--pnc-blue-100);
	outline-offset: 2px;
}

/* ---------------------------------------------------------------------
 * Email collection card * Inline form inside the messages list, styled as an AI bubble but
 * with an input + Save / Skip buttons.
 * ------------------------------------------------------------------ */

.pnc-email-card {
	max-width: 92% !important;
	padding: 12px !important;
}
.pnc-email-card-text {
	margin-bottom: 8px;
}
.pnc-email-card-row {
	display: flex;
	gap: 6px;
	align-items: stretch;
}
.pnc-email-card-input {
	flex: 1;
	min-width: 0;
	padding: 7px 10px;
	border: 1px solid var(--pnc-line);
	border-radius: 8px;
	font: inherit;
	font-size: 13px;
	background: var(--pnc-white);
	color: var(--pnc-text);
	outline: none;
}
.pnc-email-card-input:focus {
	border-color: var(--pnc-blue);
}
.pnc-email-card-save {
	background: var(--pnc-blue);
	color: var(--pnc-white);
	border: none;
	border-radius: 8px;
	padding: 0 14px;
	cursor: pointer;
	font: inherit;
	font-size: 13px;
	font-weight: 600;
}
.pnc-email-card-save:hover {
	background: var(--pnc-navy);
}
.pnc-email-card-save:disabled {
	opacity: 0.55;
	cursor: not-allowed;
}
.pnc-email-card-skip-row {
	margin-top: 6px;
	text-align: right;
}
.pnc-email-card-skip {
	background: transparent;
	border: none;
	color: var(--pnc-muted);
	cursor: pointer;
	font: inherit;
	font-size: 12px;
	padding: 2px 4px;
	text-decoration: underline;
}
.pnc-email-card-skip:hover {
	color: var(--pnc-navy);
}

/* ---------------------------------------------------------------------
 * Proactive prompt bubble *
 * Small speech bubble that appears next to the chat icon after a delay
 * on configured pages. Tappable to open the chat; X to dismiss.
 * Position: directly above-and-right-aligned with the chat icon.
 * ------------------------------------------------------------------ */

.pnc-proactive {
	position: absolute;
	bottom: 78px;          /* sits above the 60px bubble + 18px gap */
	right: 0;
	width: 260px;          /* fixed width — the chat bubble parent is only 60px wide */
	max-width: calc(100vw - 40px);
	padding: 12px 32px 12px 14px;
	background: var(--pnc-white);
	color: var(--pnc-text);
	border: 1px solid var(--pnc-line);
	border-radius: 14px;
	box-shadow: 0 8px 24px rgba(17, 56, 125, 0.14);
	font-size: 13px;
	line-height: 1.4;
	cursor: pointer;
	animation: pnc-proactive-in 0.25s ease;
	transition: transform 0.15s ease;
	box-sizing: border-box;
}
.pnc-proactive:hover {
	transform: translateY(-1px);
	border-color: var(--pnc-blue-100);
}
.pnc-proactive:focus-visible {
	outline: 3px solid var(--pnc-blue-100);
	outline-offset: 2px;
}
.pnc-proactive::after {
	/* Speech-bubble tail pointing down toward the chat icon */
	content: '';
	position: absolute;
	bottom: -7px;
	right: 22px;
	width: 14px;
	height: 14px;
	background: var(--pnc-white);
	border-right: 1px solid var(--pnc-line);
	border-bottom: 1px solid var(--pnc-line);
	transform: rotate(45deg);
}

[dir="rtl"] .pnc-proactive,
.pnc-widget[dir="rtl"] .pnc-proactive {
	right: auto;
	left: 0;
	padding: 12px 14px 12px 32px;
}
[dir="rtl"] .pnc-proactive::after,
.pnc-widget[dir="rtl"] .pnc-proactive::after {
	right: auto;
	left: 22px;
}

.pnc-proactive-text {
	display: block;
	font-weight: 500;
}

.pnc-proactive-close {
	position: absolute;
	top: 6px;
	right: 8px;
	background: transparent;
	border: none;
	color: var(--pnc-muted);
	cursor: pointer;
	font-size: 18px;
	line-height: 1;
	padding: 2px 6px;
	border-radius: 4px;
	font-family: inherit;
}
.pnc-proactive-close:hover {
	background: var(--pnc-blue-50);
	color: var(--pnc-navy);
}
[dir="rtl"] .pnc-proactive-close,
.pnc-widget[dir="rtl"] .pnc-proactive-close {
	right: auto;
	left: 8px;
}

@keyframes pnc-proactive-in {
	from { opacity: 0; transform: translateY(8px); }
	to   { opacity: 1; transform: translateY(0); }
}

/* Hide the proactive bubble when the chat panel is open — they'd
   overlap and look messy. */
.pnc-widget[data-state="open"] .pnc-proactive {
	display: none;
}

@media (max-width: 480px) {
	.pnc-proactive {
		max-width: calc(100vw - 60px);
	}
}

@media (prefers-reduced-motion: reduce) {
	.pnc-proactive { animation: none; transition: none; }
}

/* ---------------------------------------------------------------------
 * Utility: screen-reader only
 * ------------------------------------------------------------------ */

.pnc-sr-only {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* ---------------------------------------------------------------------
 * Animations
 * ------------------------------------------------------------------ */

.pnc-widget[data-state="open"] .pnc-panel {
	animation: pnc-panel-in 0.18s ease;
}
@keyframes pnc-panel-in {
	from { opacity: 0; transform: translateY(8px); }
	to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
	.pnc-bubble,
	.pnc-panel,
	.pnc-typing span {
		animation: none !important;
		transition: none !important;
	}
}
