/* Website chat (plugin "CSD Chat Helper"). Uses the theme's colour tokens, with fall-backs. */

.csd-chat {
	--chat-deep: var(--csd-deep, #14505B);
	--chat-teal: var(--csd-teal, #1E7F8F);
	--chat-ink: var(--csd-ink, #14343C);
	--chat-muted: var(--csd-muted, #4A6570);
	--chat-pale: var(--csd-pale, #E3F1F3);
	--chat-line: var(--csd-line, #CFE3E7);
	--chat-bg: var(--csd-bg, #F9F6F1);
	--chat-coral: var(--csd-coral, #D93A1E);
	--chat-coral-dark: var(--csd-coral-dark, #BF3016);
	--chat-coral-pale: var(--csd-coral-pale, #FBE9E4);
	font-family: var(--csd-sans, 'Nunito Sans', 'Segoe UI', Arial, sans-serif);
	color: var(--chat-ink);
	line-height: 1.5;
}
.csd-chat *, .csd-chat *::before, .csd-chat *::after { box-sizing: border-box; }
.csd-chat [hidden] { display: none !important; }
/* Low specificity, so the component rules below win. */
:where(.csd-chat) button, :where(.csd-chat) input { font: inherit; margin: 0; }
.csd-chat svg { display: block; flex: none; }

.csd-chat__sr {
	position: absolute !important;
	width: 1px; height: 1px;
	margin: -1px; padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* ---------- The round button ---------- */
.csd-chat__launcher {
	position: fixed;
	right: max(16px, env(safe-area-inset-right));
	bottom: max(16px, env(safe-area-inset-bottom));
	z-index: 9990;
	display: inline-flex; align-items: center; justify-content: center; gap: 10px;
	min-height: 56px; min-width: 56px;
	padding: 0 22px 0 16px;
	border: 0; border-radius: 999px;
	background: var(--chat-deep); color: #fff;
	font-weight: 800; font-size: 16px; line-height: 1.2;
	box-shadow: 0 10px 28px rgba(20, 52, 60, 0.28);
	cursor: pointer;
	transition: transform 0.15s ease-out, box-shadow 0.2s ease-out, background 0.15s;
}
.csd-chat__launcher:hover { background: #0F434C; transform: translateY(-2px); box-shadow: 0 14px 32px rgba(20, 52, 60, 0.32); }
.csd-chat__launcher:focus-visible { outline: 3px solid var(--chat-coral); outline-offset: 3px; }

/* ---------- The chat window ---------- */
.csd-chat__panel {
	position: fixed;
	right: max(16px, env(safe-area-inset-right));
	bottom: calc(max(16px, env(safe-area-inset-bottom)) + 68px);
	z-index: 9991;
	display: flex; flex-direction: column;
	width: 384px;
	height: 600px;
	max-height: calc(100vh - 112px);
	max-height: calc(100dvh - 112px);
	background: #fff;
	border: 1px solid var(--chat-line);
	border-radius: 20px;
	box-shadow: 0 18px 48px rgba(20, 52, 60, 0.24);
	overflow: hidden;
	overflow: clip;
	animation: csd-chat-in 0.18s ease-out;
}
.csd-chat__panel:focus { outline: none; }

.csd-chat__head {
	display: flex; align-items: center; justify-content: space-between; gap: 12px;
	padding: 14px 12px 14px 18px;
	background: var(--chat-deep); color: #fff;
}
.csd-chat__head-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.csd-chat .csd-chat__title { margin: 0; font-family: var(--csd-serif, 'DM Serif Display', Georgia, serif); font-size: 20px; line-height: 1.2; font-weight: 400; color: #fff; }
.csd-chat .csd-chat__sub { margin: 0; font-size: 13px; line-height: 1.3; opacity: 0.88; color: #fff; }
.csd-chat__close {
	display: inline-flex; align-items: center; justify-content: center;
	width: 44px; height: 44px; padding: 0;
	border: 0; border-radius: 999px;
	background: transparent; color: #fff; cursor: pointer;
}
.csd-chat__close:hover { background: rgba(255, 255, 255, 0.16); }
.csd-chat__close:focus-visible { outline: 3px solid #fff; outline-offset: -3px; }

.csd-chat__body {
	position: relative;
	flex: 1 1 auto;
	min-height: 0;
	display: flex; flex-direction: column; gap: 14px;
	padding: 16px 14px;
	overflow-y: auto;
	overscroll-behavior: contain;
	background: var(--chat-bg);
}
.csd-chat__log { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Messages ---------- */
.csd-chat__msg {
	display: flex; flex-direction: column; gap: 8px;
	max-width: 90%;
	padding: 10px 14px;
	font-size: 15.5px; line-height: 1.5;
	overflow-wrap: break-word;
	animation: csd-chat-in 0.2s ease-out;
}
.csd-chat__msg--bot {
	align-self: flex-start;
	background: #fff; color: var(--chat-ink);
	border: 1px solid var(--chat-line);
	border-radius: 16px 16px 16px 4px;
}
.csd-chat__msg--me {
	align-self: flex-end;
	background: var(--chat-deep); color: #fff;
	border-radius: 16px 16px 4px 16px;
}
.csd-chat .csd-chat__p { margin: 0; }
.csd-chat .csd-chat__link { color: var(--chat-deep); font-weight: 800; text-decoration: underline; text-underline-offset: 2px; }
.csd-chat .csd-chat__link:hover { color: var(--chat-teal); }
.csd-chat .csd-chat__link[href^="tel:"] { white-space: nowrap; }
.csd-chat__msg--me .csd-chat__link { color: #fff; }

.csd-chat__hours { width: 100%; border-collapse: collapse; font-size: 15px; margin: 0; }
.csd-chat__hours th, .csd-chat__hours td { padding: 4px 8px; border: 0; text-align: left; vertical-align: top; background: none; }
.csd-chat__hours th { font-weight: 700; white-space: nowrap; color: var(--chat-muted); }
.csd-chat__hours td { text-align: right; }
.csd-chat__hours tr.is-today th, .csd-chat__hours tr.is-today td { background: var(--chat-pale); color: var(--chat-ink); font-weight: 800; }
.csd-chat__hours tr.is-today th { border-radius: 8px 0 0 8px; }
.csd-chat__hours tr.is-today td { border-radius: 0 8px 8px 0; }

.csd-chat__details { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; padding: 10px 12px; background: var(--chat-pale); border-radius: 10px; }
.csd-chat__details dt { margin: 0; font-weight: 700; color: var(--chat-muted); }
.csd-chat__details dd { margin: 0; font-weight: 700; color: var(--chat-ink); overflow-wrap: break-word; min-width: 0; }

.csd-chat .csd-chat__alert {
	margin: 0;
	padding: 10px 12px;
	background: var(--chat-coral-pale);
	border-left: 4px solid var(--chat-coral);
	border-radius: 8px;
	color: var(--chat-ink);
}

.csd-chat .csd-chat__button {
	align-self: flex-start;
	display: inline-flex; align-items: center; justify-content: center;
	min-height: 48px; padding: 0 22px;
	border: 0; border-radius: 999px;
	background: var(--chat-coral); color: #fff;
	font-weight: 800; font-size: 16px; line-height: 1.2;
	text-decoration: none;
	box-shadow: 0 8px 20px rgba(217, 58, 30, 0.24);
	cursor: pointer;
}
.csd-chat .csd-chat__button:hover { background: var(--chat-coral-dark); color: #fff; }

.csd-chat .csd-chat__wait { margin: 0; align-self: flex-start; font-size: 14px; font-style: italic; color: var(--chat-muted); }

/* ---------- Choices ---------- */
.csd-chat__chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.csd-chat__chips:focus { outline: none; }
.csd-chat__chip {
	display: inline-flex; align-items: center;
	min-height: 40px; padding: 6px 14px;
	border: 2px solid var(--chat-teal); border-radius: 999px;
	background: #fff; color: var(--chat-deep);
	font-weight: 700; font-size: 15px; line-height: 1.25; text-align: left;
	cursor: pointer;
	transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.csd-chat__chip:hover { background: var(--chat-pale); }
.csd-chat__chip--main { background: var(--chat-coral); border-color: var(--chat-coral); color: #fff; }
.csd-chat__chip--main:hover { background: var(--chat-coral-dark); border-color: var(--chat-coral-dark); }

.csd-chat__chip:focus-visible, .csd-chat__send:focus-visible, .csd-chat .csd-chat__button:focus-visible, .csd-chat .csd-chat__link:focus-visible {
	outline: 3px solid var(--chat-teal); outline-offset: 2px;
}

/* ---------- Typing box ---------- */
.csd-chat__form {
	position: relative;
	display: flex; align-items: center; gap: 8px;
	padding: 10px 12px;
	border-top: 1px solid var(--chat-line);
	background: #fff;
}
.csd-chat__input {
	flex: 1 1 auto; min-width: 0;
	min-height: 48px; padding: 0 16px;
	border: 1.5px solid var(--chat-muted); border-radius: 999px;
	background: #fff; color: var(--chat-ink);
	font-size: 16px; line-height: 1.3;
}
.csd-chat__input::placeholder { color: var(--chat-muted); opacity: 1; }
.csd-chat__input:focus { outline: 2px solid var(--chat-teal); outline-offset: 1px; border-color: var(--chat-teal); }
.csd-chat__input[readonly] { background: #F2F5F6; }
.csd-chat__trap { position: absolute !important; left: -10000px; top: auto; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.csd-chat__send {
	display: inline-flex; align-items: center; justify-content: center;
	width: 48px; height: 48px; padding: 0;
	border: 0; border-radius: 999px;
	background: var(--chat-deep); color: #fff; cursor: pointer;
}
.csd-chat__send:hover { background: #0F434C; }
.csd-chat__send[aria-disabled="true"] { opacity: 0.5; cursor: default; }

.csd-chat .csd-chat__foot {
	margin: 0;
	padding: 0 14px 10px;
	background: #fff;
	font-size: 13px; line-height: 1.4; text-align: center;
	color: var(--chat-muted);
}
.csd-chat__foot .csd-chat__link { font-weight: 800; }

@keyframes csd-chat-in {
	from { opacity: 0; transform: translateY(6px); }
	to { opacity: 1; transform: none; }
}

/* ---------- Phones: the chat fills the screen ---------- */
@media (max-width: 600px) {
	.csd-chat__launcher { padding: 0; width: 60px; height: 60px; }
	.csd-chat__launcher-text {
		position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
		overflow: hidden; clip: rect(0, 0, 0, 0); clip-path: inset(50%); white-space: nowrap; border: 0;
	}
	.csd-chat.is-open .csd-chat__launcher { display: none; }
	.csd-chat__panel {
		inset: 0;
		width: 100%;
		height: 100%;
		height: 100dvh;
		max-height: none;
		border: 0;
		border-radius: 0;
		padding-bottom: env(safe-area-inset-bottom);
	}
	html.csd-chat-is-open, html.csd-chat-is-open body { overflow: hidden; }
}

/* Short screens (small laptops, zoomed pages, phones on their side) */
@media (min-width: 601px) and (min-height: 561px) and (max-height: 700px) {
	.csd-chat__panel { height: calc(100vh - 104px); height: calc(100dvh - 104px); }
}
@media (min-width: 601px) and (max-height: 560px) {
	.csd-chat__panel { top: 8px; bottom: 8px; height: auto; max-height: none; }
	.csd-chat.is-open .csd-chat__launcher { display: none; }
	.csd-chat .csd-chat__sub { display: none; }
	.csd-chat__head { padding-block: 4px; }
	.csd-chat__body { padding-block: 8px; }
	.csd-chat .csd-chat__foot { font-size: 12px; padding-bottom: 4px; }
}

/* Signed-in staff: keep the short-screen window below the WordPress admin bar */
@media (min-width: 601px) and (max-height: 560px) {
	body.admin-bar .csd-chat__panel { top: 40px; }
}
@media (min-width: 601px) and (max-width: 782px) and (max-height: 560px) {
	body.admin-bar .csd-chat__panel { top: 54px; }
}

/* Phone layout on a very short screen (a page zoomed to 300-400%): compact top and bottom,
   and keep some room for messages; the window itself scrolls if it has to. */
@media (max-width: 600px) and (max-height: 480px) {
	.csd-chat .csd-chat__sub { display: none; }
	.csd-chat__head { padding-block: 4px; }
	.csd-chat__body { padding-block: 8px; }
	.csd-chat .csd-chat__foot { font-size: 12px; padding-bottom: 4px; }
}
@media (max-height: 360px) {
	.csd-chat__panel { overflow-y: auto; }
	.csd-chat__body { flex: 1 0 96px; }
}

/* Very narrow phones: labels above their values in the details card */
@media (max-width: 400px) {
	.csd-chat__details { grid-template-columns: 1fr; gap: 0; }
	.csd-chat__details dd + dt { margin-top: 6px; }
}

/* Room at the end of the page, so the chat button does not sit on the footer's last line */
body:has(> #csd-chat) .csd-footer { padding-bottom: 88px; }

@media (prefers-reduced-motion: reduce) {
	.csd-chat__panel, .csd-chat__msg { animation: none; }
	.csd-chat__launcher, .csd-chat__chip { transition: none; }
	.csd-chat__launcher:hover { transform: none; }
}

@media print {
	.csd-chat { display: none !important; }
}
