/**
 * Memaar AI Assistant — public chat widget styles.
 */

.maa-widget {
	--maa-primary: #000000;
	--maa-secondary: #ffffff;
	--maa-chat-bg: #ffffff;
	--maa-text: #000000;
	--maa-border: #e2e2e2;
	--maa-shadow: 0 8px 32px rgba(0, 0, 0, 0.16);
	--maa-radius: 12px;
	--maa-radius-round: 50%;
	--maa-transition: 0.2s ease;
	--maa-error: #b00020;
	--maa-focus: #005fcc;
	--maa-panel-width: 380px;
	--maa-panel-max-height: 650px;
	--maa-z-launcher: 99998;
	--maa-z-panel: 99999;
	position: fixed;
	bottom: 20px;
	z-index: var(--maa-z-launcher);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
	font-size: 14px;
	line-height: 1.5;
	color: var(--maa-text);
	box-sizing: border-box;
}

.maa-widget *,
.maa-widget *::before,
.maa-widget *::after {
	box-sizing: border-box;
}

.maa-position-bottom-right {
	right: 20px;
	left: auto;
}

.maa-position-bottom-left {
	left: 20px;
	right: auto;
}

/* Launcher */
.maa-launcher {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 60px;
	height: 60px;
	border: 2px solid var(--maa-secondary);
	border-radius: var(--maa-radius-round);
	background-color: var(--maa-primary);
	color: var(--maa-secondary);
	cursor: pointer;
	box-shadow: var(--maa-shadow);
	transition: transform var(--maa-transition), box-shadow var(--maa-transition);
	padding: 0;
}

.maa-launcher:hover {
	transform: scale(1.05);
	box-shadow: 0 10px 36px rgba(0, 0, 0, 0.2);
}

.maa-launcher:focus {
	outline: none;
}

.maa-launcher:focus-visible {
	outline: 3px solid var(--maa-focus);
	outline-offset: 3px;
}

.maa-launcher__icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
}

.maa-launcher__logo {
	width: 32px;
	height: 32px;
	object-fit: contain;
	border-radius: 4px;
}

.maa-launcher__svg {
	display: block;
}

/* Panel */
.maa-panel {
	position: fixed;
	bottom: 90px;
	width: var(--maa-panel-width);
	max-width: calc(100vw - 24px);
	max-height: var(--maa-panel-max-height);
	background: var(--maa-chat-bg);
	color: var(--maa-text);
	border: 1px solid var(--maa-border);
	border-radius: var(--maa-radius);
	box-shadow: var(--maa-shadow);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	z-index: var(--maa-z-panel);
}

.maa-position-bottom-right .maa-panel {
	right: 20px;
	left: auto;
}

.maa-position-bottom-left .maa-panel {
	left: 20px;
	right: auto;
}

.maa-panel[hidden] {
	display: none !important;
}

/* Header */
.maa-panel__header {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 14px 16px;
	border-bottom: 1px solid var(--maa-border);
	background: var(--maa-chat-bg);
	flex-shrink: 0;
}

.maa-panel__back {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	border: none;
	background: transparent;
	color: var(--maa-text);
	cursor: pointer;
	padding: 4px 8px;
	border-radius: 6px;
	font-size: 13px;
	flex-shrink: 0;
}

.maa-panel__back:hover {
	background: rgba(0, 0, 0, 0.05);
}

.maa-panel__back:focus-visible {
	outline: 2px solid var(--maa-focus);
	outline-offset: 2px;
}

.maa-panel__back[hidden] {
	display: none !important;
}

.maa-panel__heading {
	display: flex;
	align-items: center;
	gap: 10px;
	flex: 1;
	min-width: 0;
}

.maa-panel__logo {
	width: 28px;
	height: 28px;
	object-fit: contain;
	border-radius: 4px;
	flex-shrink: 0;
}

.maa-panel__titles {
	min-width: 0;
}

.maa-panel__title {
	margin: 0;
	font-size: 16px;
	font-weight: 600;
	line-height: 1.3;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.maa-panel__status {
	margin: 2px 0 0;
	font-size: 12px;
	color: #555;
}

.maa-panel__close {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border: none;
	background: transparent;
	color: var(--maa-text);
	cursor: pointer;
	border-radius: 6px;
	font-size: 22px;
	line-height: 1;
	flex-shrink: 0;
	padding: 0;
}

.maa-panel__close:hover {
	background: rgba(0, 0, 0, 0.05);
}

.maa-panel__close:focus-visible {
	outline: 2px solid var(--maa-focus);
	outline-offset: 2px;
}

/* Progress */
.maa-progress {
	padding: 10px 16px;
	border-bottom: 1px solid var(--maa-border);
	flex-shrink: 0;
}

.maa-progress__list {
	display: flex;
	gap: 8px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.maa-progress__item {
	display: flex;
	align-items: center;
	gap: 6px;
	flex: 1;
	font-size: 11px;
	color: #888;
}

.maa-progress__dot {
	width: 8px;
	height: 8px;
	border-radius: var(--maa-radius-round);
	background: #ccc;
	flex-shrink: 0;
}

.maa-progress__item--active {
	color: var(--maa-text);
	font-weight: 600;
}

.maa-progress__item--active .maa-progress__dot,
.maa-progress__item--done .maa-progress__dot {
	background: var(--maa-primary);
}

.maa-progress__item--done {
	color: var(--maa-text);
}

.maa-progress__label {
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Content */
.maa-panel__content {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	-webkit-overflow-scrolling: touch;
}

.maa-screen[hidden] {
	display: none !important;
}

.maa-screen__title {
	margin: 0 0 8px;
	font-size: 18px;
	font-weight: 600;
	line-height: 1.35;
}

.maa-screen__intro {
	margin: 0 0 16px;
	font-size: 14px;
	color: #444;
}

/* Language list */
.maa-language-list {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.maa-language-option {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	padding: 12px 14px;
	border: 1px solid var(--maa-border);
	border-radius: 8px;
	background: var(--maa-chat-bg);
	color: var(--maa-text);
	cursor: pointer;
	font-size: 14px;
	text-align: inherit;
	transition: border-color var(--maa-transition), background var(--maa-transition);
}

.maa-language-option:hover {
	border-color: var(--maa-primary);
	background: rgba(0, 0, 0, 0.02);
}

.maa-language-option:focus-visible {
	outline: 2px solid var(--maa-focus);
	outline-offset: 2px;
}

.maa-language-option--default {
	border-color: var(--maa-primary);
	font-weight: 600;
}

.maa-language-option--selected {
	background: var(--maa-primary);
	color: var(--maa-secondary);
	border-color: var(--maa-primary);
}

.maa-language-option__badge {
	font-size: 11px;
	padding: 2px 6px;
	border-radius: 4px;
	background: rgba(0, 0, 0, 0.08);
}

.maa-language-option--selected .maa-language-option__badge {
	background: rgba(255, 255, 255, 0.2);
}

/* Form */
.maa-form {
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.maa-field {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.maa-field[hidden],
.maa-field--optional[hidden] {
	display: none !important;
}

.maa-field__label {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 13px;
	font-weight: 600;
}

.maa-field__badge {
	font-size: 10px;
	font-weight: 500;
	padding: 1px 5px;
	border-radius: 3px;
	text-transform: uppercase;
	letter-spacing: 0.03em;
}

.maa-field__badge--required {
	background: rgba(0, 0, 0, 0.08);
	color: var(--maa-text);
}

.maa-field__badge--optional {
	background: #f0f0f0;
	color: #666;
}

.maa-field__input {
	width: 100%;
	padding: 10px 12px;
	border: 1px solid var(--maa-border);
	border-radius: 8px;
	font-size: 14px;
	color: var(--maa-text);
	background: var(--maa-chat-bg);
	transition: border-color var(--maa-transition);
}

.maa-field__input:focus {
	outline: none;
	border-color: var(--maa-primary);
	box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.08);
}

.maa-field__input[aria-invalid="true"] {
	border-color: var(--maa-error);
}

.maa-field__input--readonly {
	background: #f7f7f7;
	color: #555;
	cursor: default;
}

.maa-field__error {
	margin: 0;
	font-size: 12px;
	color: var(--maa-error);
}

.maa-field__error[hidden] {
	display: none !important;
}

.maa-form__privacy {
	margin: 0;
	font-size: 11px;
	color: #666;
	line-height: 1.45;
}

.maa-form__error {
	color: #b32d2e;
	font-size: 13px;
	margin: 0 0 12px;
}

.maa-screen__followup {
	margin: 0 0 16px;
	font-size: 14px;
	line-height: 1.5;
}

/* Chat interface */
.maa-screen--chat {
	display: flex;
	flex-direction: column;
	height: 100%;
	min-height: 320px;
}

.maa-chat {
	flex: 1;
	display: flex;
	flex-direction: column;
	min-height: 0;
	margin-bottom: 12px;
}

.maa-chat__messages {
	flex: 1;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 4px 0;
	max-height: 340px;
	-webkit-overflow-scrolling: touch;
}

.maa-chat__message {
	display: flex;
	flex-direction: column;
	max-width: 88%;
}

.maa-chat__message--user {
	align-self: flex-end;
	align-items: flex-end;
}

.maa-chat__message--bot {
	align-self: flex-start;
	align-items: flex-start;
}

.maa-chat__bubble {
	padding: 10px 12px;
	border-radius: 10px;
	font-size: 14px;
	line-height: 1.5;
	word-wrap: break-word;
}

.maa-chat__message--user .maa-chat__bubble {
	background: var(--maa-primary);
	color: var(--maa-secondary);
	border-bottom-right-radius: 4px;
}

.maa-chat__message--bot .maa-chat__bubble {
	background: #f2f2f2;
	color: var(--maa-text);
	border-bottom-left-radius: 4px;
}

.maa-chat__message--bot .maa-chat__bubble p {
	margin: 0 0 8px;
}

.maa-chat__message--bot .maa-chat__bubble p:last-child {
	margin-bottom: 0;
}

.maa-chat__message--bot .maa-chat__bubble ul,
.maa-chat__message--bot .maa-chat__bubble ol {
	margin: 0 0 8px;
	padding-left: 20px;
}

.maa-chat__fallback-note {
	margin: 4px 0 0;
	font-size: 11px;
	color: #666;
	font-style: italic;
}

.maa-chat__website-note {
	margin: 4px 0 0;
	font-size: 11px;
	color: #666;
	font-style: italic;
}

.maa-chat__source-link {
	display: inline-block;
	margin-top: 8px;
	font-size: 12px;
	font-weight: 600;
	color: var(--maa-primary);
	text-decoration: underline;
}

.maa-chat__source-link:hover,
.maa-chat__source-link:focus {
	color: var(--maa-primary);
	text-decoration: none;
}

.maa-chat__loading {
	padding: 8px 0;
	font-size: 13px;
	color: #666;
}

.maa-chat__loading[hidden] {
	display: none !important;
}

.maa-chat__loading-text::after {
	content: '…';
	animation: maa-dots 1.2s steps(4, end) infinite;
}

@keyframes maa-dots {
	0%, 20% { content: ''; }
	40% { content: '.'; }
	60% { content: '..'; }
	80%, 100% { content: '...'; }
}

.maa-chat__form {
	display: flex;
	flex-direction: column;
	gap: 8px;
	flex-shrink: 0;
}

.maa-chat__input {
	width: 100%;
	padding: 10px 12px;
	border: 1px solid var(--maa-border);
	border-radius: 8px;
	font-size: 14px;
	font-family: inherit;
	color: var(--maa-text);
	background: var(--maa-chat-bg);
	resize: none;
	min-height: 44px;
	max-height: 120px;
}

.maa-chat__input:focus {
	outline: none;
	border-color: var(--maa-primary);
	box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.08);
}

.maa-chat__input:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

.maa-chat__error {
	margin: 0;
	font-size: 12px;
	color: var(--maa-error);
}

.maa-chat__error[hidden] {
	display: none !important;
}

.maa-chat__send {
	flex-shrink: 0;
}

.maa-widget[dir="rtl"] .maa-chat__message--user {
	align-self: flex-start;
	align-items: flex-start;
}

.maa-widget[dir="rtl"] .maa-chat__message--bot {
	align-self: flex-end;
	align-items: flex-end;
}

.maa-widget[dir="rtl"] .maa-chat__message--user .maa-chat__bubble {
	border-bottom-right-radius: 10px;
	border-bottom-left-radius: 4px;
}

.maa-widget[dir="rtl"] .maa-chat__message--bot .maa-chat__bubble {
	border-bottom-left-radius: 10px;
	border-bottom-right-radius: 4px;
}

.maa-widget[dir="rtl"] .maa-chat__message--bot .maa-chat__bubble ul,
.maa-widget[dir="rtl"] .maa-chat__message--bot .maa-chat__bubble ol {
	padding-left: 0;
	padding-right: 20px;
}

/* Buttons */
.maa-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	padding: 12px 16px;
	border: none;
	border-radius: 8px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: opacity var(--maa-transition), transform var(--maa-transition);
}

.maa-btn:focus-visible {
	outline: 2px solid var(--maa-focus);
	outline-offset: 2px;
}

.maa-btn--primary {
	background: var(--maa-primary);
	color: var(--maa-secondary);
}

.maa-btn--primary:hover {
	opacity: 0.9;
}

.maa-btn--primary:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

.maa-btn--secondary {
	background: transparent;
	color: var(--maa-text);
	border: 1px solid var(--maa-border);
}

.maa-btn--secondary:hover {
	background: rgba(0, 0, 0, 0.04);
}

/* Meeting actions and form */
.maa-meeting-actions {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 0 0 12px;
}

.maa-meeting-actions[hidden],
.maa-meeting-action[hidden] {
	display: none !important;
}

.maa-field__textarea {
	resize: vertical;
	min-height: 72px;
	font-family: inherit;
}

.maa-screen--meeting-success .maa-screen__status-note {
	margin: 0 0 16px;
}

.maa-badge--pending {
	display: inline-block;
	padding: 4px 10px;
	border-radius: 4px;
	background: rgba(0, 0, 0, 0.08);
	font-size: 12px;
	font-weight: 600;
}

.maa-meeting-success-actions {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.maa-meeting-success-actions .maa-btn--whatsapp {
	width: 100%;
}

/* WhatsApp handover */
.maa-whatsapp {
	padding: 0 16px 12px;
}

.maa-btn--whatsapp {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: 100%;
	padding: 11px 16px;
	border: 2px solid var(--maa-primary);
	border-radius: 8px;
	background: var(--maa-secondary);
	color: var(--maa-primary);
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: background var(--maa-transition), color var(--maa-transition), opacity var(--maa-transition);
}

.maa-btn--whatsapp:hover {
	background: var(--maa-primary);
	color: var(--maa-secondary);
}

.maa-btn--whatsapp:focus {
	outline: none;
}

.maa-btn--whatsapp:focus-visible {
	outline: 3px solid var(--maa-focus);
	outline-offset: 2px;
}

.maa-whatsapp__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.maa-whatsapp__svg {
	display: block;
}

.maa-whatsapp__label {
	line-height: 1.3;
}

/* RTL support */
.maa-widget[dir="rtl"] .maa-panel__header {
	flex-direction: row-reverse;
}

.maa-widget[dir="rtl"] .maa-panel__heading {
	flex-direction: row-reverse;
	text-align: right;
}

.maa-widget[dir="rtl"] .maa-panel__back-icon {
	transform: scaleX(-1);
}

.maa-widget[dir="rtl"] .maa-field__label {
	flex-direction: row-reverse;
}

.maa-widget[dir="rtl"] .maa-language-option {
	text-align: right;
}

.maa-widget[dir="rtl"] .maa-progress__list {
	flex-direction: row-reverse;
}

/* Honeypot — visually hidden, not removed from DOM */
.maa-honeypot {
	position: absolute;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
}

.maa-honeypot__input {
	width: 1px;
	height: 1px;
	padding: 0;
	border: 0;
}

/* Screen reader only */
.maa-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Body scroll lock on mobile */
body.maa-scroll-lock {
	overflow: hidden;
}

/* Mobile */
@media (max-width: 480px) {
	.maa-widget {
		bottom: 12px;
	}

	.maa-position-bottom-right {
		right: 12px;
	}

	.maa-position-bottom-left {
		left: 12px;
	}

	.maa-launcher {
		width: 54px;
		height: 54px;
	}

	.maa-panel {
		bottom: 76px;
		width: calc(100vw - 24px);
		max-height: calc(100vh - 100px);
		border-radius: 10px;
	}

	.maa-position-bottom-right .maa-panel {
		right: 12px;
	}

	.maa-position-bottom-left .maa-panel {
		left: 12px;
	}

	.maa-progress__label {
		font-size: 10px;
	}
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
	.maa-launcher,
	.maa-language-option,
	.maa-field__input,
	.maa-btn {
		transition: none;
	}

	.maa-launcher:hover {
		transform: none;
	}
}
