/* BookRocket chat widget. Themable via --bc-accent / --bc-accent-text. */

#brkchat {
	--bc-accent: #0d5bd8;
	--bc-accent-text: #fff;
	position: fixed;
	right: 18px;
	bottom: 18px;
	/* Must sit ABOVE the site's cookie-consent bar (z-index 99999) and any
	   bottom-fixed banners, otherwise on mobile those overlays intercept taps
	   meant for the chat (the FAB and the input). This was the real reason
	   "the ✕ / bubble don't respond" on phones. */
	z-index: 2147483000;
	font-family: system-ui, Arial, sans-serif;
	font-size: 15px;
}

#brkchat-fab {
	width: 58px;
	height: 58px;
	border: 0;
	border-radius: 50%;
	background: var(--bc-accent);
	color: var(--bc-accent-text);
	font-size: 26px;
	cursor: pointer;
	box-shadow: 0 10px 28px rgba(0, 0, 0, .28);
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform .15s;
}

#brkchat-fab:hover {
	transform: translateY(-2px);
}

.bc-badge {
	position: absolute;
	top: -4px;
	right: -4px;
	min-width: 21px;
	height: 21px;
	border-radius: 11px;
	background: #d6303c;
	color: #fff;
	font-size: 12px;
	font-weight: 700;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0 5px;
	box-sizing: border-box;
}

/* Small "you have an active chat" dot (no number) when the panel is minimized. */
.bc-badge.bc-dot {
	min-width: 0;
	width: 13px;
	height: 13px;
	padding: 0;
	top: -2px;
	right: -2px;
	border: 2px solid #fff;
}

#brkchat-panel {
	position: absolute;
	right: 0;
	bottom: 72px;
	width: min(360px, calc(100vw - 36px));
	background: #fff;
	/* The widget lives inside arbitrary themes (dark ones included): never
	   inherit the page text color — the panel is light, so text is dark. */
	color: #1f2733;
	border: 1px solid rgba(0, 0, 0, .1);
	border-radius: 16px;
	box-shadow: 0 24px 60px rgba(0, 0, 0, .3);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	will-change: transform;
	/* Shorter panel: keeps the header (with ✕) comfortably reachable and off
	   the top browser UI on phones. vh line is the fallback for old browsers. */
	max-height: min(520px, 80vh);
	max-height: min(520px, 80dvh);
}

@media (max-height: 560px) {
	#brkchat-panel { max-height: min(400px, 82dvh); }
}

/* Elements that set an explicit `display` need this or the [hidden] attribute
   is a no-op (author display beats the UA [hidden] rule) — same trap as the
   panel above. Covers hiding the badge, the input form and the opt-in bar
   (e.g. when the booking is cancelled and the chat is closed). */
.bc-badge[hidden],
.bc-form[hidden],
.bc-optin[hidden],
.bc-cal[hidden] {
	display: none !important;
}

/* CRITICAL: make the [hidden] attribute actually hide the panel.
   The base rule above sets `display:flex` with ID specificity, which silently
   OVERRODE the UA `[hidden]{display:none}` rule — so `panel.hidden = true` did
   nothing and the panel stayed on screen. That is the real reason the ✕ and
   the drag-to-dismiss "did not close" across many releases (the handlers always
   ran; the panel just refused to disappear). !important settles it for good,
   including the fullscreen variant. */
#brkchat-panel[hidden] { display: none !important; }

/* Fullscreen mode (bc-full on #brkchat): the panel takes the whole viewport. */
#brkchat.bc-full #brkchat-panel {
	position: fixed;
	inset: 0;
	width: 100vw;
	max-height: none;
	height: 100vh;
	height: 100dvh;
	border-radius: 0;
	border: 0;
}

#brkchat.bc-full #brkchat-fab {
	display: none;
}

.bc-head {
	background: var(--bc-accent);
	color: var(--bc-accent-text);
	padding: 16px 16px 12px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	position: relative;
	/* Tap the bar to minimize; drag it DOWN to dismiss. touch-action:none lets
	   the vertical drag work on touch instead of scrolling the page. */
	cursor: grab;
	user-select: none;
	-webkit-user-select: none;
	touch-action: none;
}

.bc-head:active {
	cursor: grabbing;
}

/* Little grip so the bar reads as draggable. pointer-events:none so it never
   swallows a tap on the bar. */
.bc-head::before {
	content: "";
	position: absolute;
	top: 5px;
	left: 50%;
	transform: translateX(-50%);
	width: 42px;
	height: 4px;
	border-radius: 2px;
	background: rgba(255, 255, 255, .38);
	pointer-events: none;
}

.bc-head-txt {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.bc-sub {
	font-size: 12px;
	opacity: .85;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.bc-close,
.bc-max {
	border: 0;
	background: transparent;
	color: inherit;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	opacity: .85;
	flex: 0 0 auto;
	/* Finger-sized tap targets: tiny glyphs on mobile were nearly unclickable. */
	width: 40px;
	height: 40px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 10px;
	padding: 0;
}

.bc-max {
	font-size: 19px;
}

.bc-close:hover,
.bc-max:hover,
.bc-close:active,
.bc-max:active {
	opacity: 1;
	background: rgba(255, 255, 255, .14);
}

.bc-head-btns {
	display: flex;
	align-items: center;
	gap: 2px;
	margin-right: -8px;
}

.bc-msgs {
	padding: 14px;
	overflow-y: auto;
	flex: 1;
	background: #f6f7f9;
	/* min-height:0 so the message area yields room to the controls below —
	   otherwise a tall block (e.g. the cancel-confirm box) overflows the fixed
	   panel height and its buttons get clipped. */
	min-height: 0;
}

.bc-m {
	margin: 8px 0;
	display: flex;
}

.bc-m .bc-b {
	max-width: 82%;
	padding: 9px 12px;
	border-radius: 13px;
	line-height: 1.45;
	white-space: pre-wrap;
	word-wrap: break-word;
	unicode-bidi: plaintext;
}

.bc-m.me {
	justify-content: flex-end;
}

.bc-m.me .bc-b {
	background: var(--bc-accent);
	color: var(--bc-accent-text);
	border-bottom-right-radius: 4px;
}

.bc-m.them .bc-b {
	background: #fff;
	color: #1f2733;
	border: 1px solid rgba(0, 0, 0, .08);
	border-bottom-left-radius: 4px;
}

.bc-t {
	display: block;
	font-size: 10.5px;
	opacity: .6;
	margin-top: 3px;
}

/* Reschedule proposal banner. No `display` here on purpose so the [hidden]
   attribute keeps working (an explicit display would override it). */
.bc-proposal {
	background: #fff8ec;
	border: 1px solid #f0dfb0;
	border-radius: 12px;
	padding: 11px 12px;
	margin: 8px 0 2px;
}

.bc-prop-txt {
	font-size: 13px;
	font-weight: 600;
	color: #8a5a00;
	margin-bottom: 8px;
}

.bc-prop-btns {
	display: flex;
	gap: 8px;
}

.bc-prop-ok,
.bc-prop-no {
	flex: 1;
	text-align: center;
	text-decoration: none;
	border-radius: 9px;
	padding: 10px;
	font-weight: 700;
	font-size: 13px;
	font-family: inherit;
	cursor: pointer;
	border: 0;
}

.bc-prop-ok { background: #1f7a3d; color: #fff; }
.bc-prop-no { background: #fff; color: #8a1f1f; border: 1px solid #e6b3b3; }
.bc-prop-ok:disabled,
.bc-prop-no:disabled { opacity: .6; cursor: default; }

/* In-widget result overlay (proposal accepted / rejected): themed card + ✕ that
   stays until closed — no page navigation. Absolute over the panel body. */
.bc-overlay {
	position: absolute;
	inset: 0;
	z-index: 5;
	background: rgba(11, 26, 43, .55);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
}

.bc-overlay[hidden] { display: none !important; }

.bc-ov-card {
	position: relative;
	background: #fff;
	border-radius: 16px;
	padding: 26px 20px 20px;
	width: 100%;
	max-width: 320px;
	text-align: center;
	box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
	max-height: 100%;
	overflow-y: auto;
}

.bc-ov-x {
	position: absolute;
	top: 8px;
	right: 8px;
	width: 34px;
	height: 34px;
	border: 0;
	background: transparent;
	color: #7a8aa0;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	border-radius: 9px;
}

.bc-ov-x:hover { background: #f0f2f5; color: #1f2733; }

.bc-ov-ico {
	width: 64px;
	height: 64px;
	margin: 0 auto 14px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
}

.bc-ov-ico.ok { background: #e7f6ec; }
.bc-ov-ico.no { background: #fbeed7; }
.bc-ov-title { font-size: 18px; font-weight: 700; color: #0b1a2b; }
.bc-ov-sub { font-size: 14px; color: #46566b; line-height: 1.5; margin-top: 6px; }

.bc-ov-cal { margin-top: 18px; background: #243258; border-radius: 12px; padding: 13px; }
.bc-ov-cal-t { color: #dfe6f5; font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.bc-ov-cal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }

.bc-ov-cal-btn {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 7px;
	min-height: 58px;
	padding: 11px 6px;
	background: rgba(255, 255, 255, .07);
	border: 1px solid rgba(255, 255, 255, .11);
	border-radius: 10px;
	text-decoration: none;
	color: #eef2fb;
	font-size: 13px;
	font-weight: 500;
}

.bc-ov-cal-btn:hover { background: rgba(255, 255, 255, .15); }
.bc-ov-cal-ico { height: 24px; display: flex; align-items: center; }
.bc-ov-cal-ico svg { display: block; }

/* Small "add to calendar" message in the chat thread (mini navy chips) — shown
   once the appointment is confirmed; scrolls with the messages. */
.bc-cal-msg { text-align: center; margin: 12px 0 4px; }
.bc-cal-msg-lbl { font-size: 11.5px; color: #5a6b62; margin-bottom: 7px; }
.bc-cal-msg-row { display: inline-flex; gap: 9px; }

.bc-cal-chip {
	width: 42px;
	height: 42px;
	border-radius: 11px;
	background: #243258;
	display: flex;
	align-items: center;
	justify-content: center;
	text-decoration: none;
}

.bc-cal-chip:hover { background: #2f3f6e; }
.bc-cal-chip svg { display: block; }

/* "Add to calendar" card (shown once the appointment is confirmed). Dark navy
   panel with a 2×2 grid of branded buttons — sits inside the light chat panel
   as a distinct call-to-action. No `display` in the base rule so [hidden] keeps
   working (the guard above adds !important for the explicit-display case). */
.bc-cal {
	margin: 10px 12px;
	padding: 12px 12px 14px;
	background: #243258;
	border-radius: 12px;
}

.bc-cal-title {
	text-align: center;
	color: #dfe6f5;
	font-size: 13px;
	font-weight: 700;
	letter-spacing: .2px;
	margin-bottom: 11px;
}

.bc-cal-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
}

.bc-cal-btn {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 7px;
	min-height: 62px;
	padding: 12px 8px;
	background: rgba(255, 255, 255, .07);
	border: 1px solid rgba(255, 255, 255, .11);
	border-radius: 10px;
	text-decoration: none;
	color: #eef2fb;
	transition: background .14s, transform .14s;
}

.bc-cal-btn:hover {
	background: rgba(255, 255, 255, .15);
	transform: translateY(-1px);
}

.bc-cal-ico {
	height: 24px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.bc-cal-ico svg {
	display: block;
}

.bc-cal-lbl {
	font-size: 12.5px;
	font-weight: 600;
	line-height: 1;
}

.bc-optin {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	padding: 8px 10px;
	background: #eef3fb;
	border-top: 1px solid rgba(0, 0, 0, .06);
}

.bc-optin-lbl {
	font-size: 11.5px;
	color: #46566b;
	flex: 1 1 100%;
}

.bc-optin-btn {
	border: 1px solid rgba(13, 91, 216, .35);
	background: #fff;
	color: #0d5bd8;
	border-radius: 999px;
	padding: 5px 11px;
	font-size: 12.5px;
	font-weight: 600;
	cursor: pointer;
	text-decoration: none;
	line-height: 1.2;
}

.bc-optin-btn:hover { background: #f2f6fe; }

.bc-optin-btn.on {
	border-color: #1f7a3d;
	color: #1f7a3d;
	background: #eafaef;
	cursor: default;
}

.bc-optin-msg {
	flex: 1 1 100%;
	font-size: 11.5px;
	line-height: 1.4;
	color: #8a5a00;
	margin-top: 2px;
}

.bc-form {
	display: flex;
	gap: 8px;
	padding: 10px;
	border-top: 1px solid rgba(0, 0, 0, .08);
	background: #fff;
}

.bc-form textarea {
	flex: 1;
	border: 1px solid rgba(0, 0, 0, .16);
	border-radius: 10px;
	padding: 8px 11px;
	font: inherit;
	color: #1f2733;
	background: #fff;
	resize: none;
	unicode-bidi: plaintext;
}

.bc-form button {
	border: 0;
	background: var(--bc-accent);
	color: var(--bc-accent-text);
	border-radius: 10px;
	padding: 0 16px;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

.bc-form button:disabled {
	opacity: .55;
}

.bc-note {
	font-size: 11px;
	opacity: .6;
	text-align: center;
	padding: 0 10px 9px;
	background: #fff;
}

/* While confirming a cancellation, free vertical room so the two confirm
   buttons are never clipped on small screens: hide the input, opt-in bar, note
   and any proposal/calendar card. Removing the class restores their own state. */
#brkchat-panel.bc-confirming .bc-form,
#brkchat-panel.bc-confirming .bc-optin,
#brkchat-panel.bc-confirming .bc-note,
#brkchat-panel.bc-confirming .bc-proposal,
#brkchat-panel.bc-confirming .bc-cal {
	display: none !important;
}

/* Cancel-booking control. Elements toggled via [hidden] deliberately set no
   `display`, so the attribute keeps working. */
.bc-cancel {
	padding: 0 12px 10px;
	background: #fff;
	text-align: center;
}

/* Leaving the chat — deliberately calmer than "cancel booking": nothing is
   lost, provided the client takes the case number with them. */
.bc-exit {
	text-align: center;
	padding: 0 10px 6px;
}

.bc-exit-link {
	border: 0;
	background: transparent;
	color: #46617f;
	font: inherit;
	font-size: 12px;
	cursor: pointer;
	text-decoration: underline;
	padding: 2px 6px;
}

.bc-exit-confirm {
	background: #f3f7fc;
	border: 1px solid #cddcec;
	border-radius: 10px;
	padding: 12px;
	margin-top: 4px;
	text-align: center;
}

.bc-exit-warn {
	font-size: 12.5px;
	color: #23425f;
	font-weight: 600;
	line-height: 1.4;
}

.bc-exit-code {
	font-family: ui-monospace, "Courier New", monospace;
	font-size: 26px;
	font-weight: 700;
	letter-spacing: 3px;
	color: #0b1a2b;
	background: #fff;
	border: 2px dashed #c9a227;
	border-radius: 10px;
	padding: 9px 6px;
	margin: 9px 0 7px;
	word-break: break-all;
}

.bc-exit-code.bc-exit-none {
	font-size: 15px;
	letter-spacing: 0;
	border-style: solid;
	border-color: #cddcec;
	color: #5a6472;
}

.bc-exit-hint {
	font-size: 11.8px;
	color: #4a5b6d;
	line-height: 1.45;
	margin-bottom: 10px;
}

.bc-exit-yes {
	flex: 1;
	border: 0;
	border-radius: 8px;
	padding: 9px 10px;
	font: inherit;
	font-size: 12.5px;
	font-weight: 700;
	cursor: pointer;
	background: #0b1a2b;
	color: #f3e6c8;
}

.bc-left {
	margin: 8px 12px 12px;
	padding: 11px 12px;
	border-radius: 10px;
	background: #eef4fb;
	border: 1px solid #cddcec;
	color: #23425f;
	font-size: 12.5px;
	line-height: 1.45;
	text-align: center;
}

.bc-cancel-link {
	border: 0;
	background: transparent;
	color: #8a1f1f;
	font: inherit;
	font-size: 12px;
	cursor: pointer;
	text-decoration: underline;
	padding: 2px 6px;
}

.bc-cancel-confirm {
	background: #fde8e8;
	border: 1px solid #f3c2c2;
	border-radius: 10px;
	padding: 11px 12px;
	margin-top: 4px;
	text-align: left;
}

.bc-cancel-warn {
	font-size: 12.5px;
	color: #8a1f1f;
	margin-bottom: 9px;
	line-height: 1.45;
}

.bc-cancel-btns {
	display: flex;
	gap: 8px;
}

.bc-cancel-yes {
	flex: 1;
	border: 0;
	background: #8a1f1f;
	color: #fff;
	border-radius: 8px;
	padding: 9px 10px;
	font: inherit;
	font-weight: 700;
	font-size: 13px;
	cursor: pointer;
}

.bc-cancel-no {
	flex: 1;
	border: 1px solid #ccd3dd;
	background: #fff;
	color: #1f2733;
	border-radius: 8px;
	padding: 9px 10px;
	font: inherit;
	font-weight: 600;
	font-size: 13px;
	cursor: pointer;
}

.bc-terminated {
	padding: 14px 12px;
	background: #eafaef;
	color: #1f7a3d;
	font-weight: 600;
	text-align: center;
	font-size: 13px;
}

/* Avviso e contatore: compaiono solo quando servono. L'avviso non e' un errore
   da correggere ma un'informazione ("aspetta 3 secondi"), quindi tono neutro. */
#brkchat .bc-warn{margin:0 12px 8px;padding:9px 11px;border-radius:9px;background:#fdf3e3;border:1px solid #e8cf9c;color:#6b4e12;font-size:13.5px;line-height:1.45}
#brkchat .bc-warn[hidden]{display:none!important}
#brkchat .bc-count{margin:-4px 12px 8px;text-align:right;font-size:12px;color:#8a8271}
#brkchat .bc-count[hidden]{display:none!important}
#brkchat .bc-count.bc-over{color:#a3341f;font-weight:600}
