/* ── WP Chatbot Widget ──────────────────────────────── */

:root {
	--wpc-primary:            #0073aa;
	--wpc-primary-dark:       #005a87;
	--wpc-radius:             22px;
	--wpc-shadow:             0 24px 64px rgba(0,0,0,0.14), 0 6px 20px rgba(0,0,0,0.08);
	--wpc-font:               -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
	--wpc-messages-bg:        #f4f6f8;
	--wpc-bot-bubble-bg:      #ffffff;
	--wpc-bot-bubble-text:    #1a1a1a;
	--wpc-window-width:       380px;
	--wpc-chat-height:        360px;
	/* Customisable appearance extras */
	--wpc-bubble-radius:      16px;
	--wpc-toggle-shape:       50%;
	--wpc-user-bubble-bg:     var(--wpc-primary);
	--wpc-user-bubble-text:   #ffffff;
	--wpc-toggle-glow:        rgba(0,115,170,0.30);
}

.wpc-icon {
	display: block;
	background-position: center;
	background-repeat: no-repeat;
	background-size: contain;
	flex-shrink: 0;
}

.wpc-icon-chat {
	width: 26px;
	height: 26px;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23ffffff' d='M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H5.17L4 17.17V4h16v12z'/%3E%3C/svg%3E");
}

.wpc-icon-close {
	width: 20px;
	height: 20px;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23ffffff' stroke='%23ffffff' stroke-width='1' d='M18.3 5.71 12 12l6.3 6.29-1.41 1.41L10.59 13.41 4.29 19.7 2.88 18.29 9.17 12 2.88 5.71 4.29 4.3l6.3 6.29 6.29-6.3z'/%3E%3C/svg%3E");
}

.wpc-icon-avatar {
	width: 22px;
	height: 22px;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23ffffff' d='M9 11a2 2 0 1 0 0-4 2 2 0 0 0 0 4Zm6 0a2 2 0 1 0 0-4 2 2 0 0 0 0 4Zm-9.5 7.5v-1A3.5 3.5 0 0 1 9 14h6a3.5 3.5 0 0 1 3.5 3.5v1h-13ZM10 3.25h4a1.75 1.75 0 0 1 1.75 1.75V6h1.75A2.5 2.5 0 0 1 20 8.5v5A2.5 2.5 0 0 1 17.5 16H17v-1A5 5 0 0 0 12 10a5 5 0 0 0-5 5v1h-.5A2.5 2.5 0 0 1 4 13.5v-5A2.5 2.5 0 0 1 6.5 6h1.75V5A1.75 1.75 0 0 1 10 3.25Z'/%3E%3C/svg%3E");
}

.wpc-icon-send {
	width: 17px;
	height: 17px;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23ffffff' d='M3.4 20.4 21.5 12 3.4 3.6l.2 6.1 11.1 2.3-11.1 2.3-.2 6.1Z'/%3E%3C/svg%3E");
}

/* ── Toggle button ──────────────────────────────────── */
.wpc-toggle {
	position: fixed;
	bottom: 24px;
	z-index: 999999;
	width: 60px;
	height: 60px;
	border-radius: var(--wpc-toggle-shape);
	border: none;
	background: var(--wpc-primary);
	color: #fff;
	cursor: pointer;
	box-shadow: 0 6px 22px rgba(0,0,0,0.22);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.2s ease, box-shadow 0.2s ease, border-radius 0.2s ease;
}
/* Default hover: scale */
.wpc-toggle:hover {
	transform: scale(1.07);
	box-shadow: 0 10px 30px rgba(0,0,0,0.28);
}
/* Glow hover */
.wpc-hover-glow .wpc-toggle:hover {
	transform: scale(1.03);
	box-shadow: 0 6px 22px rgba(0,0,0,0.18), 0 0 0 6px var(--wpc-toggle-glow);
}
/* Lift hover */
.wpc-hover-lift .wpc-toggle:hover {
	transform: translateY(-5px) scale(1.03);
	box-shadow: 0 16px 40px rgba(0,0,0,0.30);
}
/* No hover */
.wpc-hover-none .wpc-toggle:hover {
	transform: none;
	box-shadow: 0 6px 22px rgba(0,0,0,0.22);
}
.wpc-toggle:focus-visible {
	outline: 3px solid var(--wpc-primary);
	outline-offset: 3px;
}
.wpc-toggle .wpc-icon {
	pointer-events: none;
	transition: opacity 0.2s, transform 0.25s cubic-bezier(0.34,1.56,0.64,1);
}
.wpc-toggle .wpc-icon-close  { display: none; }
.wpc-toggle.wpc-open .wpc-icon-chat  { display: none; }
.wpc-toggle.wpc-open .wpc-icon-close { display: block; }

/* Unread dot */
.wpc-badge {
	position: absolute;
	top: 0;
	right: 0;
	width: 14px;
	height: 14px;
	background: #e74c3c;
	border-radius: 50%;
	border: 2px solid #fff;
	display: none;
}
.wpc-badge.wpc-visible { display: block; }

/* Position helpers */
.wpc-pos-bottom-right .wpc-toggle,
.wpc-pos-bottom-right .wpc-window { right: 24px; }
.wpc-pos-bottom-left  .wpc-toggle,
.wpc-pos-bottom-left  .wpc-window { left: 24px; }

/* ── Chat window ────────────────────────────────────── */
.wpc-window {
	position: fixed;
	bottom: 96px;
	z-index: 999999;
	width: var(--wpc-window-width, 380px);
	border-radius: var(--wpc-radius);
	background: #fff;
	box-shadow: var(--wpc-shadow);
	display: none;
	flex-direction: column;
	overflow: hidden;
	font-family: var(--wpc-font);
	font-size: 14px;
	line-height: 1.55;
}
.wpc-window.wpc-visible {
	display: flex;
	animation: wpcSlideUp 0.32s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes wpcSlideUp {
	from { opacity: 0; transform: translateY(18px) scale(0.96); }
	to   { opacity: 1; transform: translateY(0)   scale(1); }
}

/* ── Header ─────────────────────────────────────────── */
.wpc-header {
	background: linear-gradient(135deg, var(--wpc-primary) 0%, var(--wpc-primary-dark) 100%);
	color: #fff;
	padding: 14px 16px;
	display: flex;
	align-items: center;
	gap: 11px;
	flex-shrink: 0;
}
.wpc-header-avatar {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: rgba(255,255,255,0.18);
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}
.wpc-header-info { flex: 1; min-width: 0; }
.wpc-header-name {
	font-weight: 700;
	font-size: 15px;
	line-height: 1.2;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.wpc-header-status {
	font-size: 11.5px;
	opacity: 0.85;
	display: flex;
	align-items: center;
	gap: 5px;
	margin-top: 3px;
}
.wpc-status-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #2ecc71;
	flex-shrink: 0;
	animation: wpcPulse 2.4s infinite ease-in-out;
}
@keyframes wpcPulse {
	0%, 100% { box-shadow: 0 0 0 0 rgba(46,204,113,0.5); }
	50%       { box-shadow: 0 0 0 4px rgba(46,204,113,0); }
}
.wpc-header-close {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	border: 2px solid rgba(255,255,255,0.55);
	background: rgba(255,255,255,0.18);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.wpc-header-close:hover {
	background: rgba(255,255,255,0.35);
	border-color: rgba(255,255,255,0.9);
	transform: scale(1.08);
}
.wpc-header-close:focus-visible {
	outline: 3px solid #fff;
	outline-offset: 2px;
}

/* ── Messages area ──────────────────────────────────── */
.wpc-messages {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 14px 14px 6px;
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-height: 180px;
	max-height: var(--wpc-chat-height, 360px);
	background: var(--wpc-messages-bg, #f4f6f8);
	scroll-behavior: smooth;
}
.wpc-messages::-webkit-scrollbar { width: 4px; }
.wpc-messages::-webkit-scrollbar-track { background: transparent; }
.wpc-messages::-webkit-scrollbar-thumb {
	background: #d0d5dd;
	border-radius: 4px;
}

/* ── Bubbles ────────────────────────────────────────── */
.wpc-msg {
	max-width: 80%;
	padding: 9px 13px;
	border-radius: var(--wpc-bubble-radius);
	word-break: break-word;
	position: relative;
	animation: wpcFadeIn 0.18s ease;
}
@keyframes wpcFadeIn {
	from { opacity: 0; transform: translateY(5px); }
	to   { opacity: 1; transform: translateY(0); }
}

.wpc-msg-user {
	align-self: flex-end;
	background: var(--wpc-user-bubble-bg);
	color: var(--wpc-user-bubble-text);
	border-bottom-right-radius: 4px;
	margin-bottom: 10px;
}
.wpc-msg-bot {
	align-self: flex-start;
	background: var(--wpc-bot-bubble-bg, #fff);
	color: var(--wpc-bot-bubble-text, #1a1a1a);
	border-bottom-left-radius: 4px;
	box-shadow: 0 1px 3px rgba(0,0,0,0.08);
	border: 1px solid rgba(0,0,0,0.06);
	margin-bottom: 10px;
}

/* Markdown inside bot bubbles */
.wpc-md a { color: var(--wpc-primary); text-decoration: underline; }
.wpc-md strong { font-weight: 600; }
.wpc-md em { font-style: italic; }
.wpc-md code {
	background: rgba(0,0,0,0.07);
	border-radius: 4px;
	padding: 1px 5px;
	font-size: 12.5px;
	font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}
.wpc-md ul,
.wpc-md ol {
	margin: 5px 0 5px 18px;
	padding: 0;
}
.wpc-md li { margin: 2px 0; }
.wpc-md p  { margin: 0 0 6px; }
.wpc-md p:last-child { margin-bottom: 0; }
.wpc-md br { display: block; content: ""; margin-top: 4px; }

/* Timestamp */
.wpc-timestamp {
	display: block;
	font-size: 10px;
	color: rgba(0,0,0,0.32);
	margin-top: 4px;
	text-align: right;
}
.wpc-msg-bot .wpc-timestamp { color: rgba(0,0,0,0.28); text-align: left; }
.wpc-msg-user .wpc-timestamp { color: rgba(255,255,255,0.65); }

/* ── Typing indicator ───────────────────────────────── */
.wpc-typing {
	align-self: flex-start;
	display: none;
	gap: 5px;
	padding: 11px 15px;
	background: var(--wpc-bot-bubble-bg, #fff);
	border-radius: 16px;
	border-bottom-left-radius: 4px;
	box-shadow: 0 1px 3px rgba(0,0,0,0.08);
	border: 1px solid rgba(0,0,0,0.06);
	margin-bottom: 10px;
	animation: wpcFadeIn 0.18s ease;
}
.wpc-typing.wpc-visible { display: flex; }
.wpc-typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #bbb;
	animation: wpcBounce 1.2s infinite ease-in-out;
}
.wpc-typing span:nth-child(2) { animation-delay: 0.18s; }
.wpc-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes wpcBounce {
	0%, 60%, 100% { transform: translateY(0); background: #ccc; }
	30%            { transform: translateY(-7px); background: #888; }
}

/* ── Input area ─────────────────────────────────────── */
.wpc-input-area {
	display: flex;
	flex-direction: column;
	border-top: 1px solid #eaecef;
	flex-shrink: 0;
	background: #fff;
}
.wpc-input-row {
	display: flex;
	align-items: flex-end;
	padding: 10px 12px 6px;
	gap: 8px;
}
.wpc-input-area textarea {
	flex: 1;
	border: 1.5px solid #e0e3e7;
	border-radius: 22px;
	outline: none;
	padding: 9px 15px;
	font-size: 14px;
	font-family: inherit;
	resize: none;
	max-height: 100px;
	line-height: 1.45;
	background: #f8f9fb;
	transition: border-color 0.18s, background 0.18s, box-shadow 0.18s;
	color: #1a1a1a;
}
.wpc-input-area textarea:focus {
	border-color: var(--wpc-primary);
	background: #fff;
	box-shadow: 0 0 0 3px rgba(0,115,170,0.1);
}
.wpc-input-area textarea::placeholder { color: #aab0ba; }
.wpc-send-btn {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: var(--wpc-primary);
	border: none;
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: transform 0.15s, filter 0.15s, opacity 0.15s;
}
.wpc-send-btn:hover:not(:disabled) {
	transform: scale(1.1);
	filter: brightness(1.1);
}
.wpc-send-btn:disabled { opacity: 0.32; cursor: default; }

.wpc-input-footer {
	display: flex;
	justify-content: flex-end;
	padding: 0 16px 8px;
	min-height: 16px;
}
.wpc-char-count {
	font-size: 10px;
	color: transparent;
	transition: color 0.15s;
}
.wpc-char-count.wpc-warn  { color: #e67e22; }
.wpc-char-count.wpc-limit { color: #e74c3c; }

/* ── Screen reader only ─────────────────────────────── */
.wpc-sr-only {
	position: absolute;
	width: 1px; height: 1px;
	padding: 0; margin: -1px;
	overflow: hidden;
	clip: rect(0,0,0,0);
	white-space: nowrap;
	border: 0;
}

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 440px) {
	.wpc-window {
		width: calc(100vw - 16px);
		left: 8px !important;
		right: 8px !important;
		bottom: 86px;
		max-height: 76vh;
		border-radius: min(var(--wpc-radius), 16px);
	}
	.wpc-toggle { width: 54px; height: 54px; }
}
