/* Reef visitor widget */

.reef-root {
	position: fixed;
	bottom: 20px;
	width: max-content;
	z-index: 99999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.reef-root.reef--right,
.reef-panel.reef--right { right: 20px; }
.reef-root.reef--left,
.reef-panel.reef--left { left: 20px; }

/* Launcher */
.reef-launcher {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 12px 16px;
	border: none;
	border-radius: 999px;
	background: var(--reef-brand, #0e7490);
	color: #fff;
	cursor: pointer;
	box-shadow: 0 6px 24px rgba(0, 0, 0, .22);
	transition: transform .15s ease, box-shadow .15s ease;
	position: relative;
}
.reef-launcher:hover {
	transform: translateY(-2px);
	box-shadow: 0 10px 28px rgba(0, 0, 0, .26);
}
.reef-launcher svg {
	width: 22px;
	height: 22px;
	flex: 0 0 auto;
}
.reef-launcher__label {
	font-size: 14px;
	font-weight: 600;
	white-space: nowrap;
}
.reef-launcher__dot {
	position: absolute;
	top: 9px;
	left: 40px;
	width: 10px;
	height: 10px;
	border-radius: 50%;
	border: 2px solid #fff;
}
.reef-launcher:not(:has(.reef-launcher__label)) .reef-launcher__dot { left: 30px; }
.reef-launcher__dot.is-online { background: #34d399; }
.reef-launcher__dot.is-offline { background: #9ca3af; }
.reef-launcher__badge {
	position: absolute;
	top: -6px;
	right: -4px;
	min-width: 20px;
	height: 20px;
	padding: 0 5px;
	border-radius: 999px;
	background: #ef4444;
	color: #fff;
	font-size: 12px;
	font-weight: 700;
	line-height: 20px;
	text-align: center;
}

/* Panel */
.reef-panel {
	position: fixed;
	bottom: 84px;
	width: min(380px, calc(100vw - 32px));
	max-height: min(600px, calc(100vh - 120px));
	display: flex;
	flex-direction: column;
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 18px 60px rgba(15, 23, 42, .25);
	border: 1px solid #e5e7eb;
	overflow: hidden;
}
.reef-panel.is-opening { animation: reef-pop .18s ease-out; }
@keyframes reef-pop {
	from { opacity: 0; transform: translateY(10px) scale(.98); }
	to   { opacity: 1; transform: none; }
}

.reef-panel__head {
	padding: 14px 16px 12px;
	background: #fff;
	color: #111;
	border-bottom: 1px solid #ececec;
}
.reef-panel__title-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
}
.reef-panel__title {
	font-size: 16px;
	font-weight: 800;
	letter-spacing: .02em;
	text-transform: uppercase;
	line-height: 1.25;
}
.reef-panel__status-row {
	display: flex;
	align-items: center;
	gap: 7px;
	margin-top: 5px;
	font-size: 13px;
	color: #333;
}
.reef-panel__dot {
	width: 9px;
	height: 9px;
	border-radius: 50%;
	flex: 0 0 auto;
}
.reef-panel__dot.is-online { background: #22c55e; }
.reef-panel__dot.is-offline { background: #9ca3af; }
.reef-panel__avatar {
	width: 34px;
	height: 34px;
	border-radius: 50%;
	object-fit: cover;
}
.reef-panel__close {
	background: transparent;
	border: none;
	color: #333;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
	padding: 0 2px 4px;
	border-radius: 6px;
}
.reef-panel__close:hover { color: #000; }

/* Pre-chat */
.reef-prechat {
	padding: 18px 16px 20px;
	overflow-y: auto;
}
.reef-prechat__greet {
	margin: 0 0 14px;
	font-size: 14px;
	color: #374151;
	line-height: 1.5;
}
.reef-field { display: block; margin-bottom: 12px; }
.reef-field > span {
	display: block;
	font-size: 12px;
	font-weight: 600;
	color: #4b5563;
	margin-bottom: 4px;
}
.reef-field input,
.reef-field select,
.reef-field textarea {
	width: 100%;
	box-sizing: border-box;
	padding: 9px 11px;
	border: 1px solid #d1d5db;
	border-radius: 8px;
	font-size: 14px;
	font-family: inherit;
	background: #fff;
	color: #111827;
}
.reef-field textarea { resize: vertical; }
.reef-field :focus {
	outline: 2px solid var(--reef-brand, #0e7490);
	outline-offset: 1px;
	border-color: transparent;
}

/* Buttons */
.reef-btn {
	border: none;
	border-radius: 8px;
	padding: 10px 16px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: filter .12s ease, opacity .12s ease;
}
.reef-btn--primary {
	background: var(--reef-brand, #0e7490);
	color: #fff;
	width: 100%;
}
.reef-btn--primary:hover { filter: brightness(1.08); }
.reef-btn.is-busy { opacity: .6; pointer-events: none; }

/* Thread */
.reef-thread {
	display: flex;
	flex-direction: column;
	min-height: 320px;
	flex: 1 1 auto;
}
.reef-thread__log {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 14px 14px 6px;
	background: #f8fafc;
	display: flex;
	flex-direction: column;
	gap: 10px;
	scrollbar-width: thin;
}
.reef-datepill {
	align-self: center;
	background: #6b7280;
	color: #fff;
	font-size: 10.5px;
	font-weight: 600;
	letter-spacing: .08em;
	padding: 4px 12px;
	border-radius: 6px;
	margin: 2px 0 6px;
}
.reef-thread__ref {
	margin: 0 0 2px;
	text-align: center;
	font-size: 11px;
	color: #94a3b8;
	letter-spacing: .06em;
}
.reef-msg {
	max-width: 86%;
	padding: 8px 12px;
	border-radius: 12px;
	font-size: 13.5px;
	line-height: 1.45;
	word-break: break-word;
}
.reef-msg--customer {
	align-self: flex-end;
	background: var(--reef-brand, #0e7490);
	color: #fff;
	border-bottom-right-radius: 4px;
}
.reef-msg--agent {
	align-self: flex-start;
	background: #fff;
	border: 1px solid #e5e7eb;
	border-bottom-left-radius: 4px;
}
.reef-msg--system,
.reef-msg.is-note {
	align-self: center;
	background: transparent;
	color: #64748b;
	font-size: 12px;
	padding: 2px 6px;
}
.reef-msg__meta {
	display: flex;
	justify-content: space-between;
	gap: 10px;
	font-size: 10.5px;
	margin-bottom: 3px;
	opacity: .75;
}
.reef-msg__body { white-space: pre-wrap; }
.reef-msg__file {
	display: inline-block;
	margin-top: 6px;
	font-size: 12px;
	color: inherit;
	text-decoration: underline;
}
.reef-msg--customer .reef-msg__file { color: #fff; }
.reef-msg__emailed {
	margin-top: 4px;
	font-size: 10.5px;
	opacity: .8;
	font-style: italic;
}

/* Agent (staff) messages: avatar + white bubble, like the reference */
.reef-agent-row {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	max-width: 92%;
	align-self: flex-start;
}
.reef-agent-avatar {
	flex: 0 0 auto;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	background: var(--reef-brand, #0e7490);
	color: #fff;
	font-size: 10px;
	font-weight: 700;
	display: flex;
	align-items: center;
	justify-content: center;
	letter-spacing: .03em;
}
.reef-agent-bubble {
	background: #fff;
	border-radius: 14px;
	border-bottom-left-radius: 4px;
	padding: 10px 14px;
	font-size: 13.5px;
	line-height: 1.45;
	box-shadow: 0 1px 2px rgba(15,23,42,.06);
	word-break: break-word;
}
.reef-agent-check {
	font-weight: 700;
	margin-right: 2px;
}

/* Guest contact card, styled as part of the conversation */
.reef-contact-card {
	background: #fff;
	border-radius: 14px;
	padding: 12px 14px 14px;
	margin-left: 36px;
	box-shadow: 0 1px 2px rgba(15,23,42,.06);
	display: flex;
	flex-direction: column;
	gap: 10px;
}
.reef-contact-card .reef-field { margin-bottom: 0; }
.reef-contact-card .reef-btn--primary { margin-top: 2px; }

/* Composer */
.reef-composer {
	border-top: 1px solid #e5e7eb;
	padding: 10px 14px;
	background: #fff;
}
.reef-composer.is-disabled { opacity: .65; }
.reef-composer.is-disabled textarea { background: #f8fafc; }
.reef-composer__pending { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.reef-chip {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-size: 11.5px;
	background: #f3ece6;
	color: #6b3f2c;
	padding: 3px 8px;
	border-radius: 999px;
}
.reef-chip__x {
	border: none;
	background: transparent;
	color: inherit;
	cursor: pointer;
	font-size: 13px;
	line-height: 1;
	padding: 0 0 0 2px;
}
.reef-composer textarea {
	display: block;
	width: 100%;
	max-height: 132px;
	box-sizing: border-box;
	border: none;
	border-bottom: 1px solid #e5e7eb;
	border-radius: 0;
	padding: 6px 2px 8px;
	font: inherit;
	font-size: 14.5px;
	resize: none;
	overflow-y: auto;
	background: transparent;
}
.reef-composer textarea:focus {
	outline: 2px solid var(--reef-brand, #0e7490);
	outline-offset: 1px;
	border-color: transparent;
}
.reef-composer__actions {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 12px;
	margin-top: 4px;
}
.reef-iconbtn { color: #6b7280; }
.reef-sendbtn {
	border: none;
	background: transparent;
	color: var(--reef-brand, #0e7490);
	cursor: pointer;
	padding: 4px;
	border-radius: 8px;
	display: flex;
	align-items: center;
}
.reef-sendbtn:disabled { opacity: .35; cursor: default; }
.reef-sendbtn:not(:disabled):hover { background: #f3ece6; }
.reef-iconbtn {
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	font-size: 17px;
	line-height: 1;
	padding: 4px;
	border-radius: 6px;
}
.reef-iconbtn:hover { background: #f1f5f9; }

/* Ended state */
.reef-ended {
	padding: 28px 20px;
	text-align: center;
	color: #4b5563;
	font-size: 14px;
}
.reef-ended .reef-btn { width: auto; margin-top: 14px; }

@media (max-width: 480px) {
	.reef-launcher__label { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	.reef-panel { animation: none; }
	.reef-launcher { transition: none; }
}

/* Required marker */
.reef-req {
	color: #e0245e;
	font-style: normal;
	font-weight: 700;
	cursor: help;
}

/* Accessible controls retain the editable studio branding. */
.reef-root { font-family:Karla,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; }
.reef-root :is(button,input,textarea):focus-visible { outline:3px solid #945b42; outline-offset:3px; }
.reef-panel__title { font-family:Fraunces,Georgia,serif; }
.reef-panel__close,.reef-iconbtn,.reef-sendbtn { min-width:44px; min-height:44px; }
/* overflow:hidden matters: WebKit lets the invisible file input's own
   "Choose file / no file selected" content spill past this 44px box and
   swallow taps meant for the Send button next to it (iPhone Safari). */
.reef-iconbtn { position:relative; overflow:hidden; }
.reef-file-input { position:absolute; inset:0; width:100%; height:100%; opacity:0; cursor:pointer; }
.reef-iconbtn:focus-within { outline:3px solid #945b42; outline-offset:2px; }
.reef-panel { max-height:calc(100dvh - 110px); }
.reef-panel:focus:not(:focus-visible) { outline:none; }
@media(prefers-reduced-motion:reduce) { .reef-root * { transition:none !important; animation:none !important; } }

/* iOS zooms the page into any field under 16px, which pushed the composer
   off screen; touch screens keep chat fields at 16px. */
@media (pointer: coarse) {
	.reef-field input,
	.reef-composer textarea { font-size: 16px; }
}

/* Phones: the open chat is a full-screen sheet sized to the visual viewport
   (widget.js keeps --reef-vh/--reef-vt in step with the on-screen keyboard),
   so the message box and Send button always sit right above the keyboard. */
html.reef-sheet-open,
html.reef-sheet-open body { overflow: hidden; }
.reef-root.is-sheet .reef-panel {
	top: var(--reef-vt, 0px);
	right: 0;
	bottom: auto;
	left: 0;
	width: auto;
	height: var(--reef-vh, 100dvh);
	max-height: none;
	border: 0;
	border-radius: 0;
	box-shadow: none;
}
.reef-root.is-sheet .reef-panel.is-opening { animation-name: reef-sheet; }
@keyframes reef-sheet {
	from { opacity: 0; transform: translateY(24px); }
	to   { opacity: 1; transform: none; }
}
.reef-root.is-sheet .reef-launcher { display: none; }
.reef-root.is-sheet .reef-panel__head { padding: max(12px, env(safe-area-inset-top)) 10px 10px 16px; }
.reef-root.is-sheet .reef-panel__close { font-size: 30px; }
.reef-root.is-sheet.is-keyboard .reef-panel__status-row { display: none; }
.reef-root.is-sheet .reef-thread { min-height: 0; }
.reef-root.is-sheet .reef-thread__log { overscroll-behavior: contain; }
/* Guests fill in the contact card first; an inert composer only eats space. */
.reef-root.is-sheet .reef-composer.is-disabled { display: none; }
.reef-root.is-sheet .reef-composer {
	display: grid;
	grid-template-columns: 44px minmax(0, 1fr) 44px;
	grid-template-areas: "pending pending pending" "attach text send";
	align-items: end;
	column-gap: 6px;
	padding: 8px 10px max(8px, env(safe-area-inset-bottom));
}
.reef-root.is-sheet.is-keyboard .reef-composer { padding-bottom: 8px; }
.reef-root.is-sheet .reef-composer__pending { grid-area: pending; }
.reef-root.is-sheet .reef-composer__pending:empty { display: none; }
.reef-root.is-sheet .reef-composer__actions { display: contents; }
.reef-root.is-sheet .reef-iconbtn { grid-area: attach; }
.reef-root.is-sheet .reef-composer textarea {
	grid-area: text;
	min-height: 44px;
	padding: 11px 14px;
	border: 1px solid #d6d3d1;
	border-radius: 22px;
	background: #fafaf9;
	line-height: 1.3;
}
.reef-root.is-sheet .reef-sendbtn,
.reef-root.is-sheet .reef-sendbtn:not(:disabled):hover {
	grid-area: send;
	justify-content: center;
	border-radius: 50%;
	background: var(--reef-brand, #0e7490);
	color: #fff;
}
.reef-root.is-sheet .reef-sendbtn:disabled { opacity: .45; }
.reef-root.is-sheet .reef-field input { min-height: 44px; }

/* Tablets: keep the floating panel but lift it above the keyboard. */
.reef-root.is-keyboard:not(.is-sheet) .reef-panel {
	top: calc(var(--reef-vt) + var(--reef-vh) - 12px);
	bottom: auto;
	max-height: calc(var(--reef-vh) - 24px);
	translate: 0 -100%;
}
.reef-root.is-keyboard .reef-thread { min-height: 0; }
