/* ============================================
   Muñoz Acoustics & Tile - Chatbot Widget CSS
   ============================================ */

/* Scope all variables to the chatbot container */
#munoz-chatbot {
	--mcb-primary: #1b2e59;
	--mcb-accent: #db2228;
	--mcb-white: #ffffff;
	--mcb-bg: #dbe6ff;
	--mcb-light: #f0f4ff;
	--mcb-gray: #6b7280;
	--mcb-border: #e5e7eb;
	--mcb-shadow: 0 8px 32px rgba(27, 46, 89, 0.18);
	--mcb-radius: 20px;
	--mcb-font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

	font-family: var(--mcb-font);
	font-size: 16px;
	line-height: 1.5;
	color: var(--mcb-primary);
}

/* Override aggressive global resets from globals.css */
#munoz-chatbot *,
#munoz-chatbot *::before,
#munoz-chatbot *::after {
	position: static;
	display: revert;
	margin: 0;
	padding: 0;
	border: 0;
	outline: 0;
	box-sizing: border-box;
	font-size: inherit;
	font-family: inherit;
	font-weight: inherit;
	line-height: inherit;
	flex-shrink: initial;
	resize: none;
	text-transform: none;
	scroll-behavior: auto;
}

/* ---- TOGGLE BUTTON (Premium Soft Bubble) ---- */
#mcb-toggle {
	position: fixed;
	bottom: 24px;
	right: 24px;
	z-index: 9999;
	width: 64px;
	height: 64px;
	border-radius: 22px;
	background: linear-gradient(135deg, #db2228 0%, #b01d22 40%, #1b2e59 100%);
	color: var(--mcb-white);
	border: none;
	cursor: pointer;
	box-shadow:
		0 4px 15px rgba(219, 34, 40, 0.3),
		0 0 40px rgba(219, 34, 40, 0.1);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.35s ease;
	padding: 0;
	/* Entry animation: start invisible */
	opacity: 0;
	transform: scale(0);
}

#mcb-toggle.mcb-entered {
	animation: mcb-bounce-in 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

#mcb-toggle.mcb-visible {
	opacity: 1;
	transform: scale(1);
}

#mcb-toggle:hover {
	transform: scale(1.12);
	box-shadow:
		0 6px 25px rgba(219, 34, 40, 0.45),
		0 0 60px rgba(219, 34, 40, 0.2);
}

#mcb-toggle:active {
	transform: scale(0.95);
}

#mcb-toggle svg {
	width: 28px;
	height: 28px;
	fill: var(--mcb-white);
	display: block;
	filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.15));
}

/* Heartbeat glow effect */
#mcb-toggle.mcb-heartbeat {
	animation: mcb-heartbeat-glow 2s ease-in-out;
}

/* ---- TOOLTIP ---- */
#mcb-tooltip {
	position: fixed;
	bottom: 38px;
	right: 100px;
	z-index: 9999;
	background: var(--mcb-white);
	color: var(--mcb-primary);
	font-size: 14px;
	font-weight: 600;
	padding: 10px 18px;
	border-radius: 20px;
	box-shadow: 0 4px 20px rgba(27, 46, 89, 0.15);
	white-space: nowrap;
	line-height: 1;
	opacity: 0;
	transform: translateX(10px);
	transition: opacity 0.4s ease, transform 0.4s ease;
	pointer-events: none;
}

#mcb-tooltip::after {
	content: '';
	position: absolute;
	top: 50%;
	right: -6px;
	transform: translateY(-50%);
	width: 0;
	height: 0;
	border-top: 6px solid transparent;
	border-bottom: 6px solid transparent;
	border-left: 6px solid var(--mcb-white);
}

#mcb-tooltip.mcb-visible {
	opacity: 1;
	transform: translateX(0);
	pointer-events: auto;
}

#mcb-tooltip.mcb-hidden {
	opacity: 0;
	transform: translateX(10px);
	pointer-events: none;
}

/* Notification badge */
#mcb-badge {
	position: absolute;
	top: -5px;
	right: -5px;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
	color: var(--mcb-white);
	font-size: 11px;
	font-weight: 700;
	display: flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
	border: 2px solid var(--mcb-white);
	box-shadow: 0 2px 8px rgba(34, 197, 94, 0.4);
	animation: mcb-badge-pulse 2s infinite;
}

#mcb-badge.mcb-hidden {
	display: none;
}

/* ---- CHAT WINDOW ---- */
#mcb-window {
	position: fixed;
	bottom: 100px;
	right: 24px;
	z-index: 9998;
	width: 380px;
	height: 520px;
	max-height: calc(100vh - 140px);
	border-radius: var(--mcb-radius);
	background: var(--mcb-white);
	box-shadow: var(--mcb-shadow);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	opacity: 0;
	transform: translateY(20px) scale(0.95);
	pointer-events: none;
	transition: opacity 0.3s ease, transform 0.3s ease;
}

#mcb-window.mcb-open {
	opacity: 1;
	transform: translateY(0) scale(1);
	pointer-events: all;
}

/* ---- HEADER ---- */
#mcb-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 20px;
	background: linear-gradient(135deg, var(--mcb-primary) 0%, #243b6a 100%);
	color: var(--mcb-white);
	flex-shrink: 0;
}

#mcb-logo {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: var(--mcb-white);
	padding: 6px;
	display: block;
	object-fit: contain;
	flex-shrink: 0;
}

#mcb-header-info {
	flex: 1;
	min-width: 0;
}

#mcb-header-title {
	font-size: 15px;
	font-weight: 700;
	line-height: 1.3;
	color: var(--mcb-white);
	display: block;
}

#mcb-header-status {
	font-size: 12px;
	font-weight: 400;
	opacity: 0.8;
	line-height: 1.3;
	color: var(--mcb-white);
	display: block;
}

#mcb-close {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.15);
	color: var(--mcb-white);
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 20px;
	font-weight: 400;
	line-height: 1;
	transition: background 0.2s ease;
	flex-shrink: 0;
	padding: 0;
}

#mcb-close:hover {
	background: rgba(255, 255, 255, 0.25);
}

/* ---- MESSAGES AREA ---- */
#mcb-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: var(--mcb-light);
}

#mcb-messages::-webkit-scrollbar {
	width: 4px;
}

#mcb-messages::-webkit-scrollbar-track {
	background: transparent;
}

#mcb-messages::-webkit-scrollbar-thumb {
	background: rgba(27, 46, 89, 0.2);
	border-radius: 4px;
}

/* ---- MESSAGE BUBBLES ---- */
.mcb-msg {
	max-width: 82%;
	padding: 10px 16px;
	word-wrap: break-word;
	overflow-wrap: break-word;
	font-size: 14px;
	line-height: 1.5;
	animation: mcb-slide-in 0.25s ease-out;
}

.mcb-msg-user {
	align-self: flex-end;
	background: var(--mcb-primary);
	color: var(--mcb-white);
	border-radius: 16px 16px 4px 16px;
	font-weight: 400;
}

.mcb-msg-assistant {
	align-self: flex-start;
	background: var(--mcb-white);
	color: var(--mcb-primary);
	border-radius: 16px 16px 16px 4px;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
	font-weight: 400;
}

/* Markdown in bot messages */
.mcb-msg-assistant strong {
	font-weight: 700;
	display: inline;
}

.mcb-msg-assistant em {
	font-style: italic;
	display: inline;
}

.mcb-msg-assistant a {
	color: var(--mcb-accent);
	text-decoration: underline;
	display: inline;
	cursor: pointer;
}

.mcb-msg-assistant ul,
.mcb-msg-assistant ol {
	display: block;
	margin: 6px 0;
	padding-left: 20px;
}

.mcb-msg-assistant li {
	display: list-item;
	margin: 2px 0;
	line-height: 1.5;
}

.mcb-msg-assistant br {
	display: block;
}

/* ---- TYPING INDICATOR ---- */
#mcb-typing {
	align-self: flex-start;
	background: var(--mcb-white);
	border-radius: 16px 16px 16px 4px;
	padding: 12px 18px;
	display: flex;
	gap: 5px;
	align-items: center;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

#mcb-typing.mcb-hidden {
	display: none;
}

#mcb-typing span {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--mcb-gray);
	display: block;
	animation: mcb-typing-dot 1.4s infinite ease-in-out;
}

#mcb-typing span:nth-child(2) {
	animation-delay: 0.2s;
}

#mcb-typing span:nth-child(3) {
	animation-delay: 0.4s;
}

/* ---- QUICK BUTTONS ---- */
#mcb-quick-buttons {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 0 16px 12px;
	background: var(--mcb-light);
}

.mcb-quick-btn {
	padding: 8px 14px;
	border: 1.5px solid var(--mcb-primary);
	border-radius: 20px;
	background: var(--mcb-white);
	color: var(--mcb-primary);
	font-size: 13px;
	font-weight: 500;
	cursor: pointer;
	transition: background 0.2s ease, color 0.2s ease;
	white-space: nowrap;
	line-height: 1.3;
	display: inline-flex;
}

.mcb-quick-btn:hover {
	background: var(--mcb-primary);
	color: var(--mcb-white);
}

/* ---- INPUT AREA ---- */
#mcb-input-area {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 12px 16px;
	border-top: 1px solid var(--mcb-border);
	background: var(--mcb-white);
	flex-shrink: 0;
}

#mcb-input {
	flex: 1;
	border: 1px solid var(--mcb-border);
	border-radius: 12px;
	padding: 10px 14px;
	font-size: 14px;
	font-family: var(--mcb-font);
	line-height: 1.4;
	color: var(--mcb-primary);
	background: var(--mcb-white);
	max-height: 96px;
	overflow-y: auto;
	resize: none;
	display: block;
	text-transform: none;
	transition: border-color 0.2s ease;
}

#mcb-input::placeholder {
	color: var(--mcb-gray);
	font-size: 14px;
	line-height: 1.4;
	text-transform: none;
}

#mcb-input:focus {
	border-color: var(--mcb-primary);
	outline: none;
}

#mcb-send {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: var(--mcb-accent);
	color: var(--mcb-white);
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: background 0.2s ease, transform 0.15s ease;
	padding: 0;
}

#mcb-send:hover {
	background: #c41e24;
	transform: scale(1.05);
}

#mcb-send:disabled {
	opacity: 0.5;
	cursor: not-allowed;
	transform: none;
}

#mcb-send svg {
	width: 18px;
	height: 18px;
	fill: var(--mcb-white);
	display: block;
}

/* ---- ANIMATIONS ---- */

/* Bounce-in for toggle button entry */
@keyframes mcb-bounce-in {
	0% {
		opacity: 0;
		transform: scale(0);
	}
	50% {
		opacity: 1;
		transform: scale(1.15);
	}
	70% {
		transform: scale(0.95);
	}
	100% {
		opacity: 1;
		transform: scale(1);
	}
}

/* Heartbeat glow */
@keyframes mcb-heartbeat-glow {
	0%, 100% {
		box-shadow:
			0 4px 15px rgba(219, 34, 40, 0.3),
			0 0 40px rgba(219, 34, 40, 0.1);
	}
	25% {
		box-shadow:
			0 4px 20px rgba(219, 34, 40, 0.5),
			0 0 60px rgba(219, 34, 40, 0.25),
			0 0 0 8px rgba(219, 34, 40, 0.08);
	}
	50% {
		box-shadow:
			0 4px 15px rgba(219, 34, 40, 0.3),
			0 0 40px rgba(219, 34, 40, 0.1);
	}
	75% {
		box-shadow:
			0 4px 20px rgba(219, 34, 40, 0.5),
			0 0 60px rgba(219, 34, 40, 0.25),
			0 0 0 8px rgba(219, 34, 40, 0.08);
	}
}

/* Badge pulse */
@keyframes mcb-badge-pulse {
	0%, 100% {
		transform: scale(1);
		box-shadow: 0 2px 8px rgba(34, 197, 94, 0.4);
	}
	50% {
		transform: scale(1.1);
		box-shadow: 0 2px 12px rgba(34, 197, 94, 0.6);
	}
}

@keyframes mcb-typing-dot {
	0%, 60%, 100% {
		transform: translateY(0);
		opacity: 0.4;
	}
	30% {
		transform: translateY(-5px);
		opacity: 1;
	}
}

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

/* ---- RESPONSIVE ---- */
@media screen and (max-width: 480px) {
	#mcb-window {
		width: calc(100vw - 16px);
		height: calc(100vh - 100px);
		max-height: none;
		bottom: 88px;
		right: 8px;
		border-radius: 16px;
	}

	#mcb-toggle {
		width: 56px;
		height: 56px;
		bottom: 16px;
		right: 16px;
		border-radius: 18px;
	}

	#mcb-toggle svg {
		width: 24px;
		height: 24px;
	}

	#mcb-tooltip {
		display: none;
	}
}

/* ---- REDUCED MOTION ---- */
@media (prefers-reduced-motion: reduce) {
	#munoz-chatbot *,
	#munoz-chatbot *::before,
	#munoz-chatbot *::after {
		animation-duration: 0.01ms !important;
		transition-duration: 0.01ms !important;
	}
}
