/* ===== LAUNCHER WRAPPER ===== */
#sds-chat-launcher {
	position: fixed;
	bottom: 20px;
	right: 20px;
	z-index: 9998;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 0;
	/* Increased bottom margin to create breathing space above the WhatsApp icon */
	margin-bottom: 90px; 
}

/* ===== TOGGLE BUTTON ===== */
#chatbot-toggle {
	background-color: #2c3e50;
	color: #fff;
	border: none;
	padding: 13px 22px;
	border-radius: 30px;
	cursor: pointer;
	box-shadow: 0 4px 16px rgba(0,0,0,0.22);
	font-weight: 700;
	font-size: 15px;
	letter-spacing: 0.3px;
	transition: background-color 0.25s, transform 0.15s;
	white-space: nowrap;
}

#chatbot-toggle:hover {
	background-color: #1a252f;
	transform: translateY(-2px);
}

/* ===== CHAT WINDOW ===== */
#chatbot-window {
	position: fixed;
	bottom: 130px; /* Adjusted to match launcher margin */
	right: 20px;
	z-index: 9999;
	width: 390px;
	height: 570px;
	background: #fff;
	border: 1px solid #dde3ea;
	border-radius: 16px;
	display: flex;
	flex-direction: column;
	box-shadow: 0 12px 40px rgba(0,0,0,0.18);
	overflow: hidden;
	font-family: 'Segoe UI', Arial, sans-serif;
}

/* ===== HEADER ===== */
#chatbot-header {
	background: linear-gradient(135deg, #2c3e50 0%, #3d5a73 100%);
	color: #fff;
	padding: 14px 18px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-weight: 700;
	font-size: 15px;
	letter-spacing: 0.4px;
}

#chatbot-close {
	background: transparent;
	border: none;
	color: #fff;
	font-size: 22px;
	cursor: pointer;
	line-height: 1;
	padding: 0 4px;
	opacity: 0.8;
	transition: opacity 0.2s;
}

#chatbot-close:hover {
	opacity: 1;
}

/* ===== MESSAGES AREA ===== */
#chatbot-messages {
	flex-grow: 1;
	padding: 16px;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: #f7f9fb;
}

.chat-message {
	padding: 11px 15px;
	border-radius: 12px;
	max-width: 88%;
	line-height: 1.55;
	font-size: 13.5px;
	white-space: pre-wrap;
	word-wrap: break-word;
	animation: fadeInMsg 0.25s ease;
}

@keyframes fadeInMsg {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: translateY(0); }
}

.chat-user {
	align-self: flex-end;
	background: #d4e8f7;
	color: #0d3a5c;
	border-bottom-right-radius: 3px;
}

.chat-ai {
	align-self: flex-start;
	background: #fff;
	color: #2c3e50;
	border: 1px solid #e4eaf0;
	border-bottom-left-radius: 3px;
}

.chat-message a {
	color: #1a6fa8;
	text-decoration: underline;
	font-weight: 600;
}

.chat-message a:hover {
	color: #0d4f7a;
}

.chat-typing {
	align-self: flex-start;
	background: #fff;
	border: 1px solid #e4eaf0;
	border-radius: 12px;
	border-bottom-left-radius: 3px;
	padding: 10px 16px;
	font-size: 13px;
	color: #888;
	font-style: italic;
}

/* ===== INPUT AREA ===== */
#chatbot-input-area {
	padding: 12px 14px;
	border-top: 1px solid #e4eaf0;
	display: flex;
	gap: 8px;
	background: #fff;
}

#chatbot-input {
	flex-grow: 1;
	padding: 10px 14px;
	border: 1px solid #c8d6e0;
	border-radius: 24px;
	font-size: 13.5px;
	outline: none;
	transition: border-color 0.2s;
}

#chatbot-input:focus {
	border-color: #2c3e50;
}

#chatbot-send {
	padding: 10px 18px;
	background: #2c3e50;
	color: #fff;
	border: none;
	border-radius: 24px;
	cursor: pointer;
	font-weight: 700;
	font-size: 13px;
	transition: background 0.2s;
	white-space: nowrap;
}

#chatbot-send:hover {
	background: #1a252f;
}

/* ===== LEAD FORM ===== */
#chatbot-lead-form {
	padding: 16px;
	border-top: 1px solid #e4eaf0;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: #f7f9fb;
}

#lead-form-intro {
	margin: 0;
	font-size: 13px;
	color: #555;
	line-height: 1.4;
}

#lead-name, #lead-email {
	padding: 10px 14px;
	border: 1px solid #c8d6e0;
	border-radius: 8px;
	font-size: 13.5px;
	outline: none;
	transition: border-color 0.2s;
}

#lead-name:focus, #lead-email:focus {
	border-color: #2c3e50;
}

#lead-submit {
	padding: 11px 16px;
	background: #2c7a4b;
	color: #fff;
	border: none;
	border-radius: 8px;
	cursor: pointer;
	font-weight: 700;
	font-size: 13.5px;
	transition: background 0.2s;
}

#lead-submit:hover {
	background: #1e5c38;
}

/* ===== HUMAN HANDOVER OPTIONS ===== */
.handover-options {
	display: flex;
	flex-direction: column;
	gap: 10px;
	margin-top: 10px;
}

.handover-btn {
	padding: 10px 15px;
	border: none;
	border-radius: 8px;
	font-weight: 600;
	font-size: 14px;
	cursor: pointer;
	text-align: center;
	text-decoration: none;
	transition: background 0.2s, transform 0.1s;
	display: inline-block;
}

.handover-btn:hover {
	transform: translateY(-2px);
}

.whatsapp-btn {
	background-color: #25D366;
	color: white;
}
.whatsapp-btn:hover {
	background-color: #1EBE5D;
}

.email-btn {
	background-color: #2c3e50;
	color: white;
}
.email-btn:hover {
	background-color: #1a252f;
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 480px) {
	#chatbot-window {
		width: calc(100vw - 20px);
		height: 75vh;
		bottom: 100px; /* adjusted for margin */
		right: 10px;
	}
	#sds-chat-launcher {
		right: 10px;
		margin-bottom: 80px;
	}
}

/* Admin bar offset */
body.admin-bar #chatbot-window {
	bottom: calc(130px + var(--wp-admin--admin-bar--height, 32px));
}
body.admin-bar #sds-chat-launcher {
	bottom: calc(20px + var(--wp-admin--admin-bar--height, 32px));
}