/* ==========================================================================
   PBSD Chatbot Widget
   Copyright (C) 2026 Palm Beach Software Design, Inc.
   ========================================================================== */

.pbsd-chatbot *,
.pbsd-chatbot *::before,
.pbsd-chatbot *::after {
	box-sizing: border-box;
}

/* Widget container — fixed bottom-right */
.pbsd-chatbot {
	--pbsd-color: #2563eb;
	--pbsd-radius: 16px;
	--pbsd-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
	--pbsd-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

	position: fixed;
	bottom: 24px;
	right: 24px;
	z-index: 999999;
	font-family: var(--pbsd-font);
	font-size: 15px;
	line-height: 1.5;
}

/* Toggle button */
.pbsd-chatbot__toggle {
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background: var(--pbsd-color);
	color: #fff;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: var(--pbsd-shadow);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
	position: relative;
}

.pbsd-chatbot__toggle:hover {
	transform: scale(1.07);
	box-shadow: 0 12px 36px rgba(0, 0, 0, 0.22);
}

.pbsd-chatbot__toggle:focus-visible {
	outline: 3px solid var(--pbsd-color);
	outline-offset: 3px;
}

/* Icon swap — chat icon visible by default, close icon hidden */
.pbsd-chatbot__close-icon {
	display: none;
	position: absolute;
}

.pbsd-chatbot--open .pbsd-chatbot__toggle svg:not(.pbsd-chatbot__close-icon) {
	display: none;
}

.pbsd-chatbot--open .pbsd-chatbot__close-icon {
	display: block;
}

/* Chat panel */
.pbsd-chatbot__panel {
	position: absolute;
	bottom: 68px;
	right: 0;
	width: 360px;
	max-width: calc(100vw - 32px);
	height: 520px;
	max-height: calc(100vh - 120px);
	background: #fff;
	border-radius: var(--pbsd-radius);
	box-shadow: var(--pbsd-shadow);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	animation: pbsd-slide-up 0.22s ease;
}

.pbsd-chatbot__panel[hidden] {
	display: none;
}

@keyframes pbsd-slide-up {
	from {
		opacity: 0;
		transform: translateY(12px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* Header */
.pbsd-chatbot__header {
	background: var(--pbsd-color);
	color: #fff;
	padding: 14px 18px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
}

.pbsd-chatbot__title {
	font-weight: 600;
	font-size: 15px;
}

.pbsd-chatbot__status {
	font-size: 12px;
	opacity: 0.85;
	display: flex;
	align-items: center;
	gap: 5px;
}

.pbsd-chatbot__status::before {
	content: "";
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #4ade80;
	display: inline-block;
}

/* Messages area */
.pbsd-chatbot__messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	scroll-behavior: smooth;
}

.pbsd-chatbot__messages::-webkit-scrollbar {
	width: 4px;
}

.pbsd-chatbot__messages::-webkit-scrollbar-track {
	background: transparent;
}

.pbsd-chatbot__messages::-webkit-scrollbar-thumb {
	background: #d1d5db;
	border-radius: 4px;
}

/* Individual message bubbles */
.pbsd-chatbot__bubble {
	max-width: 80%;
	padding: 10px 14px;
	border-radius: 14px;
	font-size: 14px;
	line-height: 1.5;
	word-break: break-word;
}

.pbsd-chatbot__bubble--assistant {
	background: #f3f4f6;
	color: #111827;
	align-self: flex-start;
	border-bottom-left-radius: 4px;
}

.pbsd-chatbot__bubble--user {
	background: var(--pbsd-color);
	color: #fff;
	align-self: flex-end;
	border-bottom-right-radius: 4px;
}

/* Markdown elements inside assistant bubbles */
.pbsd-chatbot__bubble--assistant p {
	margin: 0 0 6px;
}
.pbsd-chatbot__bubble--assistant p:last-child {
	margin-bottom: 0;
}
.pbsd-chatbot__bubble--assistant ul,
.pbsd-chatbot__bubble--assistant ol {
	margin: 4px 0 6px;
	padding-left: 18px;
}
.pbsd-chatbot__bubble--assistant li {
	margin-bottom: 3px;
}
.pbsd-chatbot__bubble--assistant strong {
	font-weight: 600;
}
.pbsd-chatbot__bubble--assistant em {
	font-style: italic;
}
.pbsd-chatbot__bubble--assistant code {
	background: rgba(0,0,0,0.07);
	border-radius: 3px;
	padding: 1px 4px;
	font-size: 13px;
	font-family: monospace;
}

/* Typing indicator */
.pbsd-chatbot__typing {
	align-self: flex-start;
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 10px 14px;
	background: #f3f4f6;
	border-radius: 14px;
	border-bottom-left-radius: 4px;
}

.pbsd-chatbot__typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #9ca3af;
	animation: pbsd-bounce 1.2s infinite;
}

.pbsd-chatbot__typing span:nth-child(2) { animation-delay: 0.2s; }
.pbsd-chatbot__typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes pbsd-bounce {
	0%, 80%, 100% { transform: translateY(0); }
	40%            { transform: translateY(-6px); }
}

/* Input form */
.pbsd-chatbot__form {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 12px 14px;
	border-top: 1px solid #e5e7eb;
	flex-shrink: 0;
	background: #fff;
}

.pbsd-chatbot__input {
	flex: 1;
	border: 1px solid #d1d5db;
	border-radius: 22px;
	padding: 9px 14px;
	font-size: 14px;
	font-family: var(--pbsd-font);
	outline: none;
	transition: border-color 0.15s;
	background: #f9fafb;
	color: #111827;
}

.pbsd-chatbot__input:focus {
	border-color: var(--pbsd-color);
	background: #fff;
}

.pbsd-chatbot__input::placeholder {
	color: #9ca3af;
}

.pbsd-chatbot__send {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: var(--pbsd-color);
	color: #fff;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: background 0.15s, transform 0.15s;
}

.pbsd-chatbot__send:hover {
	filter: brightness(1.1);
}

.pbsd-chatbot__send:active {
	transform: scale(0.94);
}

.pbsd-chatbot__send:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.pbsd-chatbot__send:focus-visible {
	outline: 3px solid var(--pbsd-color);
	outline-offset: 2px;
}

/* Mobile adjustments */
@media (max-width: 480px) {
	.pbsd-chatbot {
		bottom: 16px;
		right: 16px;
	}

	.pbsd-chatbot__panel {
		width: calc(100vw - 32px);
		right: -16px;
		bottom: 72px;
		height: calc(100vh - 120px);
	}
}
