/* Extracted from new-connect-chat.html (Phase 1 CSS externalization) */
body {
	margin: 0;
	font-family: Arial, sans-serif;
}
.chat-wrapper {
	position: fixed;
	bottom: 20px;
	right: 20px;
	z-index: 1000;
}
#chat-container {
	width: 360px;
	height: 650px;
	background: white;
	border-radius: 10px;
	box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	transition: all 0.3s ease;
	transform: translateY(calc(100% + 20px));
	opacity: 0;
	position: relative;
}
#chat-container.open {
	transform: translateY(0);
	opacity: 1;
}
/* hidden state (only toggle visible) */
#chat-container.closed {
	transform: translateY(calc(100% + 20px));
	opacity: 0;
}
/* minimized bar (header visible) */
#chat-container.minimized {
	transform: translateY(calc(100% - 60px));
	opacity: 1;
}
#chat-header {
	background: #232f3e; /* cache buster - changed to red for testing */
	color: white;
	padding: 15px;
	font-weight: bold;
	cursor: pointer;
	user-select: none;
	display: flex;
	justify-content: space-between;
	align-items: center;
}
#header-logo {
	height: 25px;
	width: auto;
	object-fit: contain;
}
#chat-header .minimize {
	height: 16px;
	width: 16px;
	vertical-align: middle;
	transition: transform 0.3s ease;
}
#chat-container.open #chat-header .minimize {
	transform: rotate(180deg);
}
#chat-messages {
	flex-grow: 1;
	overflow-y: auto;
	padding: 15px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	/* Ensure proper spacing */
	padding-bottom: 20px;
}
.message {
	max-width: 80%;
	padding: 10px;
	border-radius: 10px;
	margin: 5px 0;
	/* Add margin to prevent cut-off */
	margin-bottom: 10px;
}
.customer-message {
	background: #b1ee69;
	color: #333;
	align-self: flex-end;
}
.agent-message,
.bot-message {
	background: #e9ecef;
	align-self: flex-start;
}
.agent-message > *:first-child,
.bot-message > *:first-child {
	margin-top: 0;
}
.agent-message > *:last-child,
.bot-message > *:last-child {
	margin-bottom: 0;
}
.system {
	background: #f8f9fa;
	color: #6c757d;
	align-self: center;
	font-style: italic;
	font-size: 0.9em;
	max-width: 90%;
	text-align: center;
}
.system-message {
	background: #f8f9fa;
	color: #6c757d;
	align-self: center;
	font-style: italic;
	font-size: 0.9em;
	max-width: 90%;
	text-align: center;
}
.typing-indicator {
	display: none;
	background: #e9ecef;
	padding: 8px 12px;
	border-radius: 15px;
	margin: 10px 15px;
	min-height: 20px;
	opacity: 0.9;
	align-items: center;
	/* Fixed positioning in its own space */
	flex-shrink: 0;
	position: relative;
	width: fit-content;
	align-self: flex-start;
}
.typing-indicator.visible {
	display: flex;
	align-items: center;
	justify-content: flex-start;
	margin: 10px 15px;
	width: fit-content;
	align-self: flex-start;
}
.typing-indicator span {
	display: inline-block;
	width: 8px;
	height: 8px;
	background: #93959a;
	border-radius: 50%;
	margin-right: 5px;
	animation: typing 1.4s infinite;
}
.typing-indicator span:nth-child(2) {
	animation-delay: 0.2s;
}
.typing-indicator span:nth-child(3) {
	animation-delay: 0.4s;
}
@keyframes typing {
	0%,
	100% {
		transform: translateY(0);
	}
	50% {
		transform: translateY(-5px);
	}
}
#chat-input-container {
	background-color: white;
	box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}
#chat-input {
	display: flex;
	padding: 15px;
	position: relative;
}
#message-input {
	flex-grow: 1;
	padding: 8px 40px 6px 8px;
	border: 1px solid #ced4da;
	border-radius: 4px;
	margin-right: 0;
	resize: none;
	overflow-y: auto;
	white-space: pre-wrap;
	word-wrap: break-word;
	line-height: 1.4;
	height: 42px; /* fixed height */
	min-height: 42px;
	max-height: 42px;
	transition:
		border-color 0.15s ease-in-out,
		box-shadow 0.15s ease-in-out;
}
#message-input:focus {
	outline: none;
	border-color: #999;
	box-shadow: 0 0 0 0.2rem rgba(153, 153, 153, 0.25);
}
#send-button {
	background: none;
	border: none;
	padding: 0;
	position: absolute;
	top: 28px;
	right: 30px;
	width: 24px;
	height: 24px;
	cursor: pointer;
	color: #007bff;
}
#send-button:hover {
	background: none;
	color: #0056b3;
}
#send-button:disabled {
	color: #aaa;
	cursor: default;
}
#send-button svg {
	fill: currentColor;
	width: 100%;
	height: 100%;
}
#chat-actions {
	display: flex;
	padding: 10px 15px;
	border-top: 1px solid #dee2e6;
	justify-content: flex-end;
}
#end-chat-button {
	background: none;
	border: none;
	width: 35px;
	height: 35px;
	padding: 0;
	margin: 0;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
}
#end-chat-button:hover:not(.disabled-icon) {
	filter: brightness(0) saturate(100%) invert(27%) sepia(51%) saturate(2878%) hue-rotate(346deg)
		brightness(104%) contrast(97%);
	transition: filter 0.2s ease;
}
#chat-toggle {
	display: none;
}
#chat-toggle.hidden {
	opacity: 0;
	pointer-events: none;
}
#chat-toggle img {
	width: 30px;
	height: 30px;
	filter: invert(1);
}
#submit-email-button {
	background-color: #b1ee69;
	border-color: #b1ee69;
	color: #333;
	outline: 2px solid transparent; /* reserve space to avoid layout shift */
	outline-offset: 2px;
	transition:
		background-color 0.15s ease,
		border-color 0.15s ease,
		outline-color 0.15s ease,
		box-shadow 0.15s ease;
}
#submit-email-button:hover:not(:disabled) {
	background-color: #9cdb57;
	border-color: #9cdb57;
	color: #333;
	outline-color: #333; /* subtle dark outline */
}
#submit-email-button:focus-visible:not(:disabled) {
	outline-color: #222;
	box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.15);
}
#submit-email-button:active:not(:disabled) {
	box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.12) inset;
}
#submit-email-button:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}
.disabled-icon {
	opacity: 0.5;
	cursor: default;
	pointer-events: none;
}
/* End Chat Confirmation Dialog */
.confirmation-overlay {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background-color: rgba(0, 0, 0, 0.5);
	z-index: 9999;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 10px;
}
.confirmation-dialog {
	background: white;
	border-radius: 10px;
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
	max-width: 400px;
	width: 90%;
	max-height: 90vh;
	overflow: hidden;
}
.confirmation-content {
	padding: 24px;
	text-align: center;
}
.confirmation-content h3 {
	margin: 0 0 12px 0;
	color: #333;
	font-size: 18px;
	font-weight: bold;
}
.confirmation-content p {
	margin: 0 0 24px 0;
	color: #666;
	font-size: 14px;
	line-height: 1.4;
}
.confirmation-buttons {
	display: flex;
	gap: 12px;
	justify-content: center;
}
.confirm-button {
	background-color: #dc3545;
	color: white;
	border: none;
	padding: 10px 20px;
	border-radius: 5px;
	cursor: pointer;
	font-size: 14px;
	font-weight: 500;
}
.confirm-button:hover {
	background-color: #c82333;
}
.cancel-button {
	background-color: #6c757d;
	color: white;
	border: none;
	padding: 10px 20px;
	border-radius: 5px;
	cursor: pointer;
	font-size: 14px;
	font-weight: 500;
}
.cancel-button:hover {
	background-color: #5a6268;
}
@media (max-width: 600px) {
	.chat-wrapper {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		width: 100vw;
		height: 100vh;
		height: 100dvh;
	}
	#chat-container.open {
		width: 100vw;
		height: 100vh;
		height: 100dvh;
		max-width: none;
		max-height: none;
		left: 0;
		top: 0;
		right: 0;
		bottom: 0;
		border-radius: 0;
		transform: none;
		padding-bottom: env(safe-area-inset-bottom, 0px);
		display: flex;
		flex-direction: column;
		position: relative;
	}
	#chat-container.closed {
		transform: translateY(calc(100% - 50px));
	}
	#chat-interface {
		padding-left: 25px;
		padding-right: 15px;
		box-sizing: border-box;
		display: flex;
		flex-direction: column;
		height: 100%;
	}
	#chat-input-container {
		flex-shrink: 0;
		background-color: white;
		z-index: 10;
		box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
	}
	#chat-input {
		margin-left: -20px;
		margin-right: -10px;
	}
	#chat-messages {
		width: 100%;
		box-sizing: border-box;
		flex: 1 1 auto;
		overflow-y: auto;
		min-height: 0;
		-webkit-overflow-scrolling: touch;
	}
	.typing-indicator {
		display: none;
		background: #e9ecef;
		padding: 8px 12px;
		border-radius: 15px;
		margin: 10px 15px;
		min-height: 20px;
		opacity: 0.9;
		flex-shrink: 0;
		position: relative;
		width: fit-content;
		align-self: flex-start;
	}
	.typing-indicator.visible {
		display: flex;
		align-items: center;
		justify-content: flex-start;
		margin: 10px 15px;
		width: fit-content;
		align-self: flex-start;
	}
	#email-input-container {
		padding: 20px 15px 20px 25px;
		box-sizing: border-box;
	}
	#email-input,
	#message-input {
		font-size: 16px;
	}
	#chat-actions {
		display: none;
	}
	#chat-header {
		justify-content: space-between;
	}
}
#loading-indicator {
	display: none;
	align-items: center;
	justify-content: center;
	padding: 10px 0;
	box-sizing: border-box;
	width: 100%;
}
.loading-spinner {
	width: 16px;
	height: 16px;
	border: 2px solid rgba(0, 0, 0, 0.1);
	border-top-color: #232f3e;
	border-radius: 50%;
	animation: spin 0.8s linear infinite;
	margin-right: 8px;
}
@keyframes spin {
	to {
		transform: rotate(360deg);
	}
}
#loading-indicator p {
	margin: 0;
	font-size: 0.9em;
	color: #555;
}
/* Markdown styles */
#chat-messages .message ol {
	/* Option A: smaller outside indent */
	padding-left: 1.1em; /* tweak (default ~2em / 32-40px) */
	margin-left: 0; /* ensure no extra margin */
	list-style-position: outside; /* keep hanging indent under text */
}
/* Align unordered list bullets with paragraph pseudo bullets */
#chat-messages .message ul {
	padding-left: 0.6em; /* match p.bullet-fix */
	margin: 0 0 0.8em; /* same bottom spacing */
	list-style-position: outside;
}
#chat-messages .message ul li {
	margin: 0 0 0.4em;
}
#chat-messages .message ul li:last-child {
	margin-bottom: 0;
}
#chat-messages .message p {
	margin: 0 0 0.8em;
}
#chat-messages .message p:first-child {
	margin-top: 0;
}
#chat-messages .message p.bullet-fix {
	position: relative;
	padding-left: 0.6em;
	margin: 0 0 0.8em;
	text-indent: 0;
}
#chat-messages .message p.bullet-fix::before {
	content: '•';
	position: absolute;
	left: 0;
	top: 0;
	line-height: 1.4;
}
/* Inline email validation styles */
#email-field-wrapper {
	display: flex;
	flex-direction: column;
	gap: 6px;
	width: 100%;
}
#email-input.invalid {
	border-color: #e55353;
	box-shadow: 0 0 0 0.15rem rgba(229, 83, 83, 0.25);
}
#email-error {
	min-height: 16px;
	font-size: 12px;
	line-height: 1.2;
	color: #e55353;
	font-weight: 500;
	visibility: hidden;
}
#email-error.visible {
	visibility: visible;
}
#submit-email-button:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}
