/* MEFMA Chatbot — professional B2B theme (LTR base). PRD §15, §17.
   Palette: MEFMA navy + gold accent, clean white surfaces. */
.mefma-cb {
	--cb-navy: #0e2f57;
	--cb-navy-2: #16456f;
	--cb-gold: #c8a24a;
	--cb-gold-dark: #b08d36;
	--cb-bg: #ffffff;
	--cb-surface: #f4f6f9;
	--cb-text: #1c2733;
	--cb-muted: #6b7785;
	--cb-border: #e3e8ee;
	--cb-user: #16456f;
	--cb-radius: 16px;
	--cb-shadow: 0 18px 50px rgba(14, 47, 87, 0.22);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	font-size: 15px;
	line-height: 1.5;
}
.mefma-cb *, .mefma-cb *::before, .mefma-cb *::after { box-sizing: border-box; }
/* Ensure the [hidden] attribute always wins over component display rules
   (panel + feedback set display:flex, which would otherwise override it). */
.mefma-cb [hidden] { display: none !important; }

/* ---------- Launcher ---------- */
.mefma-cb-launcher {
	position: fixed;
	bottom: 24px;
	right: 24px;
	display: flex;
	align-items: center;
	gap: 10px;
	height: 60px;
	padding: 0 8px;
	border: none;
	border-radius: 32px;
	background: var(--cb-navy);
	color: #fff;
	cursor: pointer;
	box-shadow: var(--cb-shadow);
	z-index: 99998;
	transition: transform 0.18s ease, background 0.18s ease, border-radius 0.18s ease;
}
.mefma-cb-launcher:hover { background: var(--cb-navy-2); transform: translateY(-2px); }
.mefma-cb-launcher .mefma-cb-launcher-open,
.mefma-cb-launcher .mefma-cb-launcher-close {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	flex: 0 0 auto;
}
.mefma-cb-launcher-close { display: none; }
.mefma-cb-bubble {
	font-size: 14px;
	font-weight: 600;
	padding-inline-end: 12px;
	white-space: nowrap;
}
/* Open state: collapse to a circle, swap icon */
.mefma-cb.is-open .mefma-cb-launcher { border-radius: 50%; padding: 0; width: 60px; }
.mefma-cb.is-open .mefma-cb-launcher-open { display: none; }
.mefma-cb.is-open .mefma-cb-launcher-close { display: flex; }
.mefma-cb.is-open .mefma-cb-bubble { display: none; }

/* ---------- Panel ---------- */
.mefma-cb-panel {
	position: fixed;
	bottom: 100px;
	right: 24px;
	width: 384px;
	max-width: calc(100vw - 32px);
	height: 620px;
	max-height: calc(100vh - 130px);
	background: var(--cb-bg);
	border: 1px solid var(--cb-border);
	border-radius: var(--cb-radius);
	box-shadow: var(--cb-shadow);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	z-index: 99999;
	transform-origin: bottom right;
	animation: mefma-cb-pop 0.22s cubic-bezier(0.2, 0.8, 0.3, 1);
}
@keyframes mefma-cb-pop {
	from { opacity: 0; transform: translateY(14px) scale(0.97); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Header ---------- */
.mefma-cb-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 16px;
	background: linear-gradient(135deg, var(--cb-navy) 0%, var(--cb-navy-2) 100%);
	color: #fff;
}
.mefma-cb-avatar {
	width: 42px;
	height: 42px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.14);
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	border: 1px solid rgba(255, 255, 255, 0.18);
}
.mefma-cb-head-text { display: flex; flex-direction: column; line-height: 1.25; flex: 1; min-width: 0; }
.mefma-cb-title { font-weight: 700; font-size: 16px; }
.mefma-cb-status { font-size: 12px; opacity: 0.85; display: flex; align-items: center; gap: 6px; }
.mefma-cb-dot {
	width: 8px; height: 8px; border-radius: 50%;
	background: #4ade80; display: inline-block;
	box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.6);
	animation: mefma-cb-pulse 2s infinite;
}
@keyframes mefma-cb-pulse {
	0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.5); }
	70% { box-shadow: 0 0 0 6px rgba(74, 222, 128, 0); }
	100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}
.mefma-cb-lang {
	background: rgba(255, 255, 255, 0.14);
	color: #fff;
	border: 1px solid rgba(255, 255, 255, 0.22);
	border-radius: 8px;
	font-size: 12px;
	font-weight: 700;
	min-width: 32px;
	height: 28px;
	cursor: pointer;
	flex: 0 0 auto;
}
.mefma-cb-lang:hover { background: rgba(255, 255, 255, 0.24); }
.mefma-cb-close {
	background: none; border: none; color: #fff; cursor: pointer;
	display: flex; align-items: center; padding: 4px; opacity: 0.85; flex: 0 0 auto;
}
.mefma-cb-close:hover { opacity: 1; }

/* ---------- Messages ---------- */
.mefma-cb-messages {
	flex: 1;
	padding: 18px 16px;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: var(--cb-surface);
}
.mefma-cb-messages::-webkit-scrollbar { width: 7px; }
.mefma-cb-messages::-webkit-scrollbar-thumb { background: #cdd5de; border-radius: 4px; }

.mefma-cb-msg {
	max-width: 82%;
	padding: 11px 14px;
	border-radius: 14px;
	font-size: 14.5px;
	white-space: pre-wrap;
	word-wrap: break-word;
	animation: mefma-cb-fade 0.2s ease;
}
@keyframes mefma-cb-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.mefma-cb-msg-user {
	align-self: flex-end;
	background: var(--cb-user);
	color: #fff;
	border-bottom-right-radius: 4px;
}
.mefma-cb-msg-bot {
	align-self: flex-start;
	background: #fff;
	color: var(--cb-text);
	border: 1px solid var(--cb-border);
	border-bottom-left-radius: 4px;
	box-shadow: 0 1px 2px rgba(16, 42, 74, 0.04);
}
.mefma-cb-msg-bot a { color: var(--cb-navy-2); font-weight: 600; text-decoration: underline; word-break: break-word; }
.mefma-cb-msg-bot p { margin: 0 0 8px; }
.mefma-cb-msg-bot p:last-child { margin-bottom: 0; }
.mefma-cb-msg-bot ul, .mefma-cb-msg-bot ol { margin: 6px 0; padding-inline-start: 20px; }
.mefma-cb-msg-bot li { margin: 4px 0; }
.mefma-cb-msg-bot li::marker { color: var(--cb-gold-dark); }
.mefma-cb-msg-bot strong { font-weight: 700; color: var(--cb-navy); }
.mefma-cb-msg-bot em { font-style: italic; }

/* Typing indicator */
.mefma-cb-typing { display: inline-flex; gap: 4px; align-items: center; padding: 4px 2px; }
.mefma-cb-typing span {
	width: 7px; height: 7px; border-radius: 50%; background: #9aa6b2;
	animation: mefma-cb-bounce 1.2s infinite ease-in-out;
}
.mefma-cb-typing span:nth-child(2) { animation-delay: 0.15s; }
.mefma-cb-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes mefma-cb-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-5px); opacity: 1; } }

/* Source chips */
.mefma-cb-sources { align-self: flex-start; display: flex; flex-wrap: wrap; gap: 6px; }
.mefma-cb-sources a {
	font-size: 12px; color: var(--cb-navy-2); text-decoration: none;
	border: 1px solid var(--cb-border); border-radius: 20px; padding: 3px 11px; background: #fff;
}
.mefma-cb-sources a:hover { border-color: var(--cb-navy-2); }

/* ---------- Suggested questions (compact single-row strip) ---------- */
.mefma-cb-suggestions { padding: 8px 12px 6px; background: var(--cb-surface); flex: 0 0 auto; }
.mefma-cb-suggest-label {
	display: block; font-size: 10px; font-weight: 700; letter-spacing: 0.04em;
	text-transform: uppercase; color: var(--cb-muted); margin-bottom: 6px;
}
.mefma-cb-chips {
	display: flex; flex-wrap: nowrap; gap: 6px;
	overflow-x: auto; padding-bottom: 4px; scrollbar-width: none;
}
.mefma-cb-chips::-webkit-scrollbar { height: 0; }
.mefma-cb-chip {
	flex: 0 0 auto;
	white-space: nowrap;
	background: #fff;
	border: 1px solid var(--cb-border);
	color: var(--cb-navy);
	border-radius: 18px;
	padding: 6px 12px;
	font-size: 12.5px;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.15s ease;
}
.mefma-cb-chip:hover { border-color: var(--cb-gold); background: #fffbf0; color: var(--cb-gold-dark); }

/* ---------- Feedback ---------- */
.mefma-cb-feedback {
	display: flex; align-items: center; gap: 8px;
	padding: 10px 16px; font-size: 13px; color: var(--cb-muted);
	background: var(--cb-surface);
}
.mefma-cb-fb {
	border: 1px solid var(--cb-border); background: #fff; color: var(--cb-navy);
	border-radius: 16px; padding: 4px 16px; cursor: pointer; font-size: 13px; font-weight: 600;
}
.mefma-cb-fb:hover { background: var(--cb-navy); color: #fff; border-color: var(--cb-navy); }

/* ---------- Composer ---------- */
.mefma-cb-form {
	display: flex; gap: 8px; align-items: center;
	padding: 12px; border-top: 1px solid var(--cb-border); background: #fff;
}
.mefma-cb-input {
	flex: 1; border: 1px solid var(--cb-border); border-radius: 24px;
	padding: 11px 16px; font-size: 14.5px; outline: none; color: var(--cb-text);
	transition: border-color 0.15s ease;
}
.mefma-cb-input:focus { border-color: var(--cb-navy-2); box-shadow: 0 0 0 3px rgba(22, 69, 111, 0.08); }
.mefma-cb-send {
	flex: 0 0 auto; width: 44px; height: 44px; border: none; border-radius: 50%;
	background: var(--cb-navy); color: #fff; cursor: pointer;
	display: flex; align-items: center; justify-content: center; transition: background 0.15s ease;
}
.mefma-cb-send:hover { background: var(--cb-gold); }

/* ---------- Footer ---------- */
.mefma-cb-foot {
	display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap;
	padding: 8px 12px; font-size: 11px; color: var(--cb-muted);
	background: #fff; border-top: 1px solid var(--cb-border);
}
.mefma-cb-powered { font-weight: 600; color: var(--cb-navy); }
.mefma-cb-sep { opacity: 0.5; }

/* ---------- Event cards ---------- */
.mefma-cb-cards { align-self: stretch; display: flex; flex-direction: column; gap: 8px; }
.mefma-cb-card {
	display: flex; align-items: center; gap: 12px;
	background: #fff; border: 1px solid var(--cb-border); border-radius: 12px;
	padding: 10px 12px; text-decoration: none; color: inherit;
	transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.mefma-cb-card:hover { border-color: var(--cb-navy-2); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(14, 47, 87, 0.1); }
.mefma-cb-card-date {
	flex: 0 0 auto; width: 48px; text-align: center;
	background: var(--cb-surface); border-radius: 8px; padding: 6px 4px; line-height: 1.1;
}
.mefma-cb-card-day { display: block; font-size: 18px; font-weight: 700; color: var(--cb-navy); }
.mefma-cb-card-mon { display: block; font-size: 10px; font-weight: 600; text-transform: uppercase; color: var(--cb-gold-dark); letter-spacing: 0.03em; }
.mefma-cb-card-body { flex: 1; min-width: 0; }
.mefma-cb-card-title { font-size: 13.5px; font-weight: 600; color: var(--cb-text); display: block; }
.mefma-cb-card-cta { font-size: 12px; color: var(--cb-navy-2); font-weight: 600; display: inline-flex; align-items: center; gap: 3px; margin-top: 2px; }
.mefma-cb-card-arrow { flex: 0 0 auto; color: var(--cb-muted); }

/* ---------- Help button ---------- */
.mefma-cb-help {
	display: flex; align-items: center; gap: 7px;
	margin: 0 16px 4px; padding: 7px 12px;
	background: var(--cb-surface); border: 1px solid var(--cb-border);
	border-radius: 20px; color: var(--cb-navy); font-size: 12.5px; font-weight: 600;
	cursor: pointer; transition: all 0.15s ease; align-self: start;
}
.mefma-cb-help:hover { border-color: var(--cb-gold); color: var(--cb-gold-dark); background: #fffbf0; }

/* ---------- Mobile ---------- */
@media (max-width: 480px) {
	.mefma-cb-panel {
		width: 100vw; height: 100dvh; max-height: 100dvh; max-width: 100vw;
		bottom: 0; right: 0; border-radius: 0; border: none;
	}
	.mefma-cb-launcher { bottom: 16px; right: 16px; }
}

@media (prefers-reduced-motion: reduce) {
	.mefma-cb-panel, .mefma-cb-msg { animation: none; }
	.mefma-cb-dot, .mefma-cb-typing span { animation: none; }
}
