:root {
  --mcaw-primary: #2563eb;
  --mcaw-primary-hover: #1d4ed8;
  --mcaw-bg: #ffffff;
  --mcaw-text: #1f2937;
  --mcaw-text-light: #6b7280;
  --mcaw-border: #e5e7eb;
  --mcaw-user-bg: #eff6ff;
  --mcaw-bot-bg: #f9fafb;
  --mcaw-bot-text: #1f2937;
  --mcaw-user-text: #1f2937;
  --mcaw-radius: 12px;
  --mcaw-panel-width: 380px;
  --mcaw-panel-height: 500px;
  --mcaw-anim-duration: 0.3s;
}

/* Base widget */
.mcaw-widget {
	position: fixed;
	bottom: 20px;
	z-index: 99999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	font-size: 14px;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
}

/* Position variants */
.mcaw-widget--pos-br {
	right: 20px;
}

.mcaw-widget--pos-bl {
	left: 20px;
	align-items: flex-start;
}

.mcaw-widget--pos-bl .mcaw-widget__panel {
	right: auto;
	left: 0;
}

/* Button label */
.mcaw-widget__label {
	background: var(--mcaw-bg);
	color: var(--mcaw-text);
	padding: 6px 12px;
	border-radius: 8px;
	font-size: 13px;
	font-weight: 500;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
	margin-bottom: 8px;
	white-space: nowrap;
}

.mcaw-widget--open .mcaw-widget__label {
	display: none;
}

/* Toggle button */
.mcaw-widget__toggle {
	border-radius: 50%;
	background: var(--mcaw-primary);
	color: #fff;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
	transition: background 0.2s, transform 0.2s;
}

.mcaw-widget__toggle:hover {
	background: var(--mcaw-primary-hover);
	transform: scale(1.05);
}

/* Button sizes */
.mcaw-widget--size-small .mcaw-widget__toggle {
	width: 44px;
	height: 44px;
}

.mcaw-widget--size-small .mcaw-widget__icon {
	width: 20px;
	height: 20px;
}

.mcaw-widget--size-medium .mcaw-widget__toggle {
	width: 56px;
	height: 56px;
}

.mcaw-widget--size-medium .mcaw-widget__icon {
	width: 24px;
	height: 24px;
}

.mcaw-widget--size-large .mcaw-widget__toggle {
	width: 68px;
	height: 68px;
}

.mcaw-widget--size-large .mcaw-widget__icon {
	width: 28px;
	height: 28px;
}

/* Icon states */
.mcaw-widget__icon--close {
	display: none;
}

.mcaw-widget--open .mcaw-widget__icon--chat {
	display: none;
}

.mcaw-widget--open .mcaw-widget__icon--close {
	display: block;
}

/* Panel */
.mcaw-widget__panel {
	display: none;
	position: absolute;
	bottom: 70px;
	right: 0;
	width: var(--mcaw-panel-width);
	max-width: calc(100vw - 40px);
	height: var(--mcaw-panel-height);
	max-height: calc(100vh - 120px);
	background: var(--mcaw-bg);
	border-radius: var(--mcaw-radius);
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
	border: 1px solid var(--mcaw-border);
	flex-direction: column;
	overflow: hidden;
}

.mcaw-widget--open .mcaw-widget__panel {
	display: flex;
}

/* Animations — using @keyframes so they fire on display:none→flex */
@keyframes mcaw-slide-in {
	from {
		transform: translateY(10px);
		opacity: 0;
	}
	to {
		transform: translateY(0);
		opacity: 1;
	}
}

@keyframes mcaw-fade-in {
	from { opacity: 0; }
	to { opacity: 1; }
}

.mcaw-widget--anim-slide.mcaw-widget--open .mcaw-widget__panel {
	animation: mcaw-slide-in var(--mcaw-anim-duration) ease forwards;
}

.mcaw-widget--anim-fade.mcaw-widget--open .mcaw-widget__panel {
	animation: mcaw-fade-in var(--mcaw-anim-duration) ease forwards;
}

.mcaw-widget--anim-none .mcaw-widget__panel {
	/* No animation */
}

/* Header */
.mcaw-widget__header {
	padding: 16px;
	border-bottom: 1px solid var(--mcaw-border);
	font-weight: 600;
	font-size: 15px;
	color: var(--mcaw-text);
	display: flex;
	align-items: center;
	justify-content: space-between;
}

/* Header action buttons */
.mcaw-widget__header-actions {
	display: flex;
	gap: 4px;
	align-items: center;
}

.mcaw-widget__close {
	width: 28px;
	height: 28px;
	border: none;
	background: transparent;
	color: var(--mcaw-text-light);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 4px;
	transition: background 0.2s;
}

.mcaw-widget__close:hover {
	background: var(--mcaw-border);
}

.mcaw-widget__close svg {
	width: 16px;
	height: 16px;
}

.mcaw-widget__new-chat {
	border: 1px solid var(--mcaw-border);
	background: transparent;
	color: var(--mcaw-text-light);
	cursor: pointer;
	border-radius: 4px;
	padding: 3px 8px;
	font-size: 11px;
	font-weight: 500;
	transition: background 0.2s, color 0.2s;
}

.mcaw-widget__new-chat:hover {
	background: var(--mcaw-border);
	color: var(--mcaw-text);
}

/* Messages */
.mcaw-widget__messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

/* Message row (icon + bubble) */
.mcaw-widget__msg-row {
	display: flex;
	align-items: flex-end;
	gap: 8px;
}

.mcaw-widget__msg-row--user {
	justify-content: flex-end;
}

.mcaw-widget__msg-row--bot,
.mcaw-widget__msg-row--welcome {
	justify-content: flex-start;
}

.mcaw-widget__msg-row--error,
.mcaw-widget__msg-row--loading {
	justify-content: flex-start;
}

/* Message icon */
.mcaw-widget__msg-icon {
	width: 24px;
	height: 24px;
	min-width: 24px;
	border-radius: 50%;
	background: var(--mcaw-border);
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.mcaw-widget__msg-icon svg {
	width: 14px;
	height: 14px;
	color: var(--mcaw-text-light);
}

.mcaw-widget__msg-icon-emoji {
	font-size: 14px;
	line-height: 1;
}

.mcaw-widget__msg {
	max-width: 85%;
	padding: 10px 14px;
	border-radius: 10px;
	line-height: 1.5;
	word-wrap: break-word;
}

.mcaw-widget__msg--user {
  background: var(--mcaw-user-bg);
  color: var(--mcaw-user-text);
}

.mcaw-widget__msg--bot {
  background: var(--mcaw-bot-bg);
  color: var(--mcaw-bot-text);
}

.mcaw-widget__msg--welcome {
	background: var(--mcaw-bot-bg);
	color: var(--mcaw-text-light);
	font-style: italic;
}

.mcaw-widget__msg--error {
	background: #fef2f2;
	color: #991b1b;
}

.mcaw-widget__msg--loading {
	background: var(--mcaw-bot-bg);
	color: var(--mcaw-text-light);
	font-style: italic;
}

/* Lead Form */
.mcaw-widget__lead-form {
	padding: 20px 16px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	flex: 1;
	justify-content: center;
}

.mcaw-widget__lead-title {
	margin: 0;
	font-size: 14px;
	color: var(--mcaw-text);
	font-weight: 500;
}

.mcaw-widget__lead-fields {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.mcaw-widget__lead-input {
	border: 1px solid var(--mcaw-border);
	border-radius: 8px;
	padding: 10px 12px;
	font-size: 14px;
	outline: none;
	transition: border-color 0.2s;
	width: 100%;
	box-sizing: border-box;
}

.mcaw-widget__lead-input:focus {
	border-color: var(--mcaw-primary);
}

.mcaw-widget__lead-submit {
	background: var(--mcaw-primary);
	color: #fff;
	border: none;
	border-radius: 8px;
	padding: 10px;
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
	transition: background 0.2s;
}

.mcaw-widget__lead-submit:hover {
	background: var(--mcaw-primary-hover);
}

.mcaw-widget__lead-skip {
	background: transparent;
	border: none;
	color: var(--mcaw-text-light);
	font-size: 13px;
	cursor: pointer;
	text-align: center;
	padding: 6px;
}

.mcaw-widget__lead-skip:hover {
	color: var(--mcaw-text);
}

/* Form */
.mcaw-widget__form {
	display: flex;
	padding: 12px;
	border-top: 1px solid var(--mcaw-border);
	gap: 8px;
}

.mcaw-widget__input {
	flex: 1;
	border: 1px solid var(--mcaw-border);
	border-radius: 8px;
	padding: 10px 12px;
	font-size: 14px;
	outline: none;
	transition: border-color 0.2s;
}

.mcaw-widget__input:focus {
	border-color: var(--mcaw-primary);
}

.mcaw-widget__send {
	width: 40px;
	height: 40px;
	border-radius: 8px;
	background: var(--mcaw-primary);
	color: #fff;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.2s;
}

.mcaw-widget__send:hover {
	background: var(--mcaw-primary-hover);
}

.mcaw-widget__send:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.mcaw-widget__send svg {
  width: 18px;
  height: 18px;
}

.mcaw-widget__msg-icon-img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
}

.mcaw-widget__icon--custom {
  object-fit: contain;
  border-radius: 0;
  box-sizing: border-box;
}

.mcaw-widget--size-small .mcaw-widget__icon--custom {
  width: 32px;
  height: 32px;
}

.mcaw-widget--size-medium .mcaw-widget__icon--custom {
  width: 42px;
  height: 42px;
}

.mcaw-widget--size-large .mcaw-widget__icon--custom {
  width: 54px;
  height: 54px;
}
