/* Website chat (src/Leads/Chat.php, assets/chat.js). Brand rules: black, white and grey; tangerine only on the
   call-to-action buttons (the main answer and "Send my request"), always with ink text. */
.ms-chat {
	--chat-ink: var(--wp--preset--color--ink, #111);
	--chat-line: var(--wp--preset--color--line, #ddd);
	--chat-paper: var(--wp--preset--color--paper, #f5f5f5);
	--chat-muted: var(--wp--preset--color--text-muted, #5e5e5e);
	--chat-cta: var(--wp--preset--color--cta, #ff8a3d);
	--chat-cta-hover: var(--wp--preset--color--cta-hover, #f06a12);
	position: fixed; z-index: 9990; right: 20px; bottom: 20px; /* above the sticky site header */
	font-family: inherit; color: var(--chat-ink); line-height: 1.45;
	display: flex; flex-direction: column; align-items: flex-end; gap: 12px;
}
.ms-chat [hidden] { display: none !important; }
.ms-chat-teaser, .ms-chat-panel { order: -1; } /* above the round button */
.ms-chat .ms-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Launcher */
.ms-chat-launch {
	display: inline-flex; align-items: center; gap: 10px; min-height: 56px; padding: 0 22px 0 16px;
	border: 0; border-radius: 999px; background: var(--chat-ink); color: #fff; cursor: pointer;
	font: inherit; font-weight: 700; font-size: 1rem; box-shadow: 0 1px 2px rgba(0,0,0,.18), 0 6px 18px rgba(0,0,0,.14);
}
.ms-chat-launch:hover { background: #000; }
.ms-chat-launch-short { display: none; }

.ms-chat.is-open .ms-chat-launch-short { display: none; }
.ms-chat-launch:focus-visible, .ms-chat button:focus-visible, .ms-chat a:focus-visible, .ms-chat input:focus-visible, .ms-chat select:focus-visible {
	outline: 3px solid var(--chat-ink); outline-offset: 2px;
}
.ms-chat-launch:focus-visible { outline-color: var(--chat-cta); }
.ms-chat.is-open .ms-chat-launch-label { display: none; }
.ms-chat.is-open .ms-chat-launch { padding: 0 15px; }

/* Teaser bubble */
.ms-chat-teaser {
	position: relative; max-width: 290px; background: #fff; border: 1px solid var(--chat-line); border-radius: 16px 16px 4px 16px;
	box-shadow: 0 6px 18px rgba(0,0,0,.10); animation: ms-chat-in .25s ease-out;
}
.ms-chat-teaser-msg {
	display: block; width: 100%; padding: 14px 34px 14px 16px; border: 0; background: none; text-align: left; cursor: pointer;
	font: inherit; font-size: .95rem; color: var(--chat-ink);
}
.ms-chat-teaser-x {
	position: absolute; top: 4px; right: 4px; width: 30px; height: 30px; border: 0; border-radius: 50%; background: none;
	font-size: 1.25rem; line-height: 1; color: var(--chat-muted); cursor: pointer;
}

/* Panel */
.ms-chat-panel {
	width: 380px; height: min(620px, calc(100vh - 110px)); display: flex; flex-direction: column; overflow: hidden;
	background: #fff; border: 1px solid var(--chat-line); border-radius: 18px; box-shadow: 0 12px 40px rgba(0,0,0,.18);
	animation: ms-chat-in .2s ease-out;
}
.ms-chat-head { display: flex; align-items: center; gap: 10px; padding: 12px 10px 12px 14px; background: var(--chat-ink); color: #fff; }
.ms-chat-avatar { flex: 0 0 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: #3a3a3a; }
.ms-chat-avatar img { display: block; width: 22px; height: 22px; object-fit: contain; }
.ms-chat-who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ms-chat-who strong { font-size: 1rem; }
.ms-chat-who span { font-size: .78rem; color: var(--wp--preset--color--text-on-dark, #cfcfcf); }
.ms-chat-restart { border: 0; background: none; color: var(--wp--preset--color--text-on-dark, #cfcfcf); font: inherit; font-size: .8rem; text-decoration: underline; cursor: pointer; padding: 6px; }
.ms-chat-close { flex: 0 0 40px; height: 40px; border: 0; border-radius: 50%; background: none; color: #fff; font-size: 1.6rem; line-height: 1; cursor: pointer; }
.ms-chat-close:hover, .ms-chat-restart:hover { color: #fff; background: rgba(255,255,255,.08); }

.ms-chat-log { flex: 1; overflow-y: auto; padding: 16px 14px 8px; background: var(--chat-paper); display: flex; flex-direction: column; gap: 8px; overscroll-behavior: contain; }
.ms-chat-msg { max-width: 85%; padding: 10px 14px; border-radius: 16px; font-size: .95rem; white-space: pre-line; overflow-wrap: anywhere; animation: ms-chat-in .18s ease-out; }
.ms-chat-msg.is-bot { align-self: flex-start; background: #fff; border: 1px solid var(--chat-line); border-bottom-left-radius: 4px; }
.ms-chat-msg.is-me { align-self: flex-end; background: var(--chat-ink); color: #fff; border-bottom-right-radius: 4px; }
.ms-chat-msg a { color: inherit; text-decoration: underline; font-weight: 700; }
.ms-chat-msg.is-typing { display: inline-flex; gap: 4px; padding: 14px; }
.ms-chat-msg.is-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--chat-muted); animation: ms-chat-dot 1s infinite ease-in-out; }
.ms-chat-msg.is-typing i:nth-child(2) { animation-delay: .15s; }
.ms-chat-msg.is-typing i:nth-child(3) { animation-delay: .3s; }

.ms-chat-foot { border-top: 1px solid var(--chat-line); padding: 10px 12px 10px; background: #fff; }
.ms-chat-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; max-height: 250px; overflow-y: auto; }
.ms-chat-chips:empty { display: none; }
.ms-chat-chip {
	min-height: 36px; padding: 6px 12px; border: 1.5px solid var(--chat-ink); border-radius: 999px; background: #fff; color: var(--chat-ink);
	font: inherit; font-size: .86rem; font-weight: 600; line-height: 1.25; text-align: left; cursor: pointer;
}
.ms-chat-chip:hover { background: var(--wp--preset--color--tint, #ededed); }
.ms-chat-chip.is-primary, .ms-chat-send { background: var(--chat-cta); border-color: var(--chat-cta); color: var(--chat-ink); font-weight: 800; }
.ms-chat-chip.is-primary:hover, .ms-chat-send:hover { background: var(--chat-cta-hover); border-color: var(--chat-cta-hover); }

.ms-chat-row { display: flex; gap: 8px; }
.ms-chat-chips:not(:empty) + .ms-chat-form { margin-top: 10px; }
.ms-chat-chips:not(:empty) + .ms-chat-form .ms-chat-send { background: var(--chat-ink); border-color: var(--chat-ink); color: #fff; } /* plain Send next to the buttons */
.ms-chat-row input, .ms-chat-row select {
	flex: 1; min-width: 0; min-height: 46px; padding: 0 14px; border: 1.5px solid var(--chat-line); border-radius: 12px;
	font: inherit; font-size: 16px; color: var(--chat-ink); background: #fff;
}
.ms-chat-row input:focus, .ms-chat-row select:focus { border-color: var(--chat-ink); }
.ms-chat-send { flex: 0 0 auto; min-height: 46px; padding: 0 16px; border: 0; border-radius: 12px; font: inherit; font-weight: 800; cursor: pointer; }
.ms-chat-err { margin: 6px 0 0; font-size: .85rem; font-weight: 700; color: var(--chat-ink); }
.ms-chat-err::before { content: "! "; }
.ms-chat-consent { margin: 8px 0 0; font-size: .72rem; color: var(--chat-muted); }
.ms-chat-consent a { color: inherit; }
.ms-chat-call { margin: 8px 0 0; font-size: .8rem; color: var(--chat-muted); text-align: center; }
/* v2: the AI notice (a small grey line, not a bubble) and the "Book a call" link that stays visible in the AI chat */
.ms-chat-msg.is-note { align-self: center; max-width: 92%; padding: 2px 6px; background: none; border: 0; font-size: .76rem; color: var(--chat-muted); text-align: center; }
.ms-chat-book { margin-right: 10px; padding: 0; border: 0; background: none; font: inherit; font-weight: 700; color: var(--chat-ink); text-decoration: underline; cursor: pointer; }
.ms-chat-book[hidden] { display: none; }
.ms-chat-call a { color: var(--chat-ink); font-weight: 700; }

@keyframes ms-chat-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes ms-chat-dot { 0%, 80%, 100% { opacity: .3; transform: none; } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) {
	.ms-chat-teaser, .ms-chat-panel, .ms-chat-msg, .ms-chat-msg.is-typing i { animation: none; }
}

/* Phones: a round button (above the landing pages' bottom bar), and the chat fills the screen when open. */
@media (max-width: 781px) {
	.ms-chat { right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); }
	.ms-chat.has-sticky { bottom: calc(84px + env(safe-area-inset-bottom)); }
	.ms-chat-launch { min-height: 52px; padding: 0 18px 0 14px; gap: 8px; font-size: .95rem; }
	.ms-chat-launch-label { display: none; }
	.ms-chat-launch-short { display: inline; }
	.ms-chat-teaser { max-width: min(290px, calc(100vw - 28px)); }
	.ms-chat.is-open { inset: 0; gap: 0; }
	.ms-chat.is-open .ms-chat-launch { display: none; }
	.ms-chat-panel { width: 100%; height: 100%; height: 100dvh; border: 0; border-radius: 0; box-shadow: none; }
	.ms-chat-foot { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
	.ms-chat-chips { max-height: 42vh; }
	.ms-chat-chip { min-height: 40px; }
	html.ms-chat-is-open, html.ms-chat-is-open body { overflow: hidden; }
}

/* Small phones (iPhone SE and similar): the header line wrapped to 4 lines. Drop the round logo and make "Start over"
   an icon so "AI assistant. Answers aren't final. Real people follow up." fits in two or three short lines. */
@media (max-width: 400px) {
	.ms-chat-head { gap: 6px; padding: 10px 6px 10px 12px; }
	.ms-chat-avatar { display: none; }
	.ms-chat-who .ms-chat-sub { font-size: .74rem; line-height: 1.3; }
	.ms-chat-restart { font-size: 0; text-decoration: none; padding: 0; flex: 0 0 36px; height: 36px; border-radius: 50%; }
	.ms-chat-restart::before { content: "\21BB"; font-size: 1.3rem; line-height: 36px; color: #fff; }
}
