/**
 * Fatma AI Chatbot — storefront widget
 */

.fatma-chat {
	--fatma-accent: #cf8e78;
	--fatma-surface: #17140f;
	--fatma-surface-2: #211d17;
	--fatma-line: rgba(207, 142, 120, 0.22);
	--fatma-text: #f2ece5;
	--fatma-muted: #a79b8e;

	position: fixed;
	bottom: 22px;
	z-index: 99990;
	font-family: "Marcellus", Georgia, serif;
	font-size: 15px;
	line-height: 1.6;
	color: var(--fatma-text);
}

.fatma-chat[hidden] {
	display: none;
}

.fatma-chat *,
.fatma-chat *::before,
.fatma-chat *::after {
	box-sizing: border-box;
}

.fatma-chat--bottom-right {
	right: 22px;
}

.fatma-chat--bottom-left {
	left: 22px;
}

/* ---------------------------------------------------------------- Launcher */

.fatma-chat__launcher {
	display: inline-flex;
	align-items: center;
	gap: 9px;
	padding: 13px 20px;
	border: none;
	border-radius: 999px;
	background: var(--fatma-accent);
	color: #1a1510;
	font-family: inherit;
	font-size: 15px;
	letter-spacing: 0.02em;
	cursor: pointer;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.32);
	transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.fatma-chat__launcher:hover {
	transform: translateY(-2px);
	box-shadow: 0 14px 34px rgba(0, 0, 0, 0.4);
}

.fatma-chat__launcher:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 3px;
}

.fatma-chat__launcher-icon {
	display: inline-flex;
	line-height: 0;
}

.fatma-chat.is-open .fatma-chat__launcher {
	opacity: 0;
	pointer-events: none;
}

/* ------------------------------------------------------------------- Panel */

.fatma-chat__panel {
	position: absolute;
	bottom: 0;
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 540px;
	max-height: calc(100vh - 60px);
	display: flex;
	flex-direction: column;
	background: var(--fatma-surface);
	border: 1px solid var(--fatma-line);
	border-radius: 18px;
	overflow: hidden;
	box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
	opacity: 0;
	transform: translateY(12px) scale(0.98);
	transition: opacity 0.18s ease, transform 0.18s ease;
}

.fatma-chat__panel[hidden] {
	display: none;
}

.fatma-chat.is-open .fatma-chat__panel {
	opacity: 1;
	transform: none;
}

.fatma-chat--bottom-right .fatma-chat__panel {
	right: 0;
}

.fatma-chat--bottom-left .fatma-chat__panel {
	left: 0;
}

.fatma-chat__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 16px 18px;
	border-bottom: 1px solid var(--fatma-line);
	background: var(--fatma-surface-2);
}

.fatma-chat__title {
	margin: 0;
	padding: 0;
	font-family: inherit;
	font-size: 17px;
	font-weight: 400;
	letter-spacing: 0.01em;
	color: var(--fatma-text);
}

.fatma-chat__close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border: none;
	border-radius: 50%;
	background: transparent;
	color: var(--fatma-muted);
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease;
}

.fatma-chat__close:hover {
	background: rgba(255, 255, 255, 0.07);
	color: var(--fatma-text);
}

/* --------------------------------------------------------------------- Log */

.fatma-chat__log {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 18px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	scrollbar-width: thin;
	scrollbar-color: rgba(207, 142, 120, 0.4) transparent;
}

.fatma-chat__log::-webkit-scrollbar {
	width: 6px;
}

.fatma-chat__log::-webkit-scrollbar-thumb {
	background: rgba(207, 142, 120, 0.35);
	border-radius: 3px;
}

.fatma-chat__message {
	max-width: 84%;
	padding: 11px 15px;
	border-radius: 14px;
	font-size: 14.5px;
	line-height: 1.65;
	white-space: pre-wrap;
	word-wrap: break-word;
	overflow-wrap: anywhere;
	animation: fatma-chat-in 0.22s ease;
}

@keyframes fatma-chat-in {
	from {
		opacity: 0;
		transform: translateY(6px);
	}
}

.fatma-chat__message--bot {
	align-self: flex-start;
	background: var(--fatma-surface-2);
	border: 1px solid var(--fatma-line);
	border-bottom-left-radius: 5px;
}

.fatma-chat__message--user {
	align-self: flex-end;
	background: var(--fatma-accent);
	color: #1a1510;
	border-bottom-right-radius: 5px;
}

.fatma-chat__message--error {
	align-self: flex-start;
	background: rgba(180, 60, 60, 0.14);
	border: 1px solid rgba(220, 120, 120, 0.35);
	color: #f0c9c9;
	border-bottom-left-radius: 5px;
}

/* Typing indicator */

.fatma-chat__typing {
	align-self: flex-start;
	display: inline-flex;
	gap: 5px;
	padding: 14px 16px;
	background: var(--fatma-surface-2);
	border: 1px solid var(--fatma-line);
	border-radius: 14px;
	border-bottom-left-radius: 5px;
}

.fatma-chat__typing span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--fatma-accent);
	opacity: 0.5;
	animation: fatma-chat-blink 1.2s infinite ease-in-out;
}

.fatma-chat__typing span:nth-child(2) {
	animation-delay: 0.18s;
}

.fatma-chat__typing span:nth-child(3) {
	animation-delay: 0.36s;
}

@keyframes fatma-chat-blink {
	0%, 60%, 100% {
		opacity: 0.35;
		transform: translateY(0);
	}
	30% {
		opacity: 1;
		transform: translateY(-3px);
	}
}

/* -------------------------------------------------------------------- Form */

.fatma-chat__form {
	display: flex;
	align-items: flex-end;
	gap: 10px;
	padding: 12px 14px;
	border-top: 1px solid var(--fatma-line);
	background: var(--fatma-surface-2);
}

.fatma-chat__input {
	flex: 1 1 auto;
	max-height: 120px;
	padding: 10px 14px;
	border: 1px solid var(--fatma-line);
	border-radius: 12px;
	background: rgba(0, 0, 0, 0.28);
	color: var(--fatma-text);
	font-family: inherit;
	font-size: 14.5px;
	line-height: 1.5;
	resize: none;
	overflow-y: auto;
}

.fatma-chat__input::placeholder {
	color: var(--fatma-muted);
}

.fatma-chat__input:focus {
	outline: none;
	border-color: var(--fatma-accent);
}

.fatma-chat__send {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 42px;
	height: 42px;
	padding: 0;
	border: none;
	border-radius: 12px;
	background: var(--fatma-accent);
	color: #1a1510;
	cursor: pointer;
	transition: opacity 0.15s ease, transform 0.15s ease;
}

.fatma-chat__send:hover {
	transform: translateY(-1px);
}

.fatma-chat__send[disabled] {
	opacity: 0.45;
	cursor: default;
	transform: none;
}

.fatma-chat__note {
	margin: 0;
	padding: 0 16px 12px;
	background: var(--fatma-surface-2);
	font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
	font-size: 11px;
	line-height: 1.5;
	color: var(--fatma-muted);
	text-align: center;
}

.fatma-chat .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(1px, 1px, 1px, 1px);
	white-space: nowrap;
}

/* ------------------------------------------------------------------ Mobile */

@media screen and (max-width: 600px) {
	.fatma-chat {
		bottom: 16px;
	}

	.fatma-chat--bottom-right {
		right: 16px;
	}

	.fatma-chat--bottom-left {
		left: 16px;
	}

	.fatma-chat__panel {
		position: fixed;
		inset: 0;
		width: 100%;
		max-width: 100%;
		height: 100%;
		max-height: 100%;
		border-radius: 0;
		border: none;
	}

	.fatma-chat__message {
		max-width: 88%;
	}
}

@media (prefers-reduced-motion: reduce) {
	.fatma-chat *,
	.fatma-chat *::before,
	.fatma-chat *::after {
		animation: none !important;
		transition: none !important;
	}
}
