/**
 * CSFX Social Widget styles.
 * Classes are prefixed with .csfx- to avoid clashing with theme styles.
 */

:root {
	--csfx-sw-brand: #00FF00;           /* outer circle for every button */
	--csfx-sw-brand-ink: #000000;       /* icon color on every button */
	--csfx-sw-hover-bg: #000000;        /* outer circle becomes solid black on hover */
	--csfx-sw-shadow: 0 8px 20px rgba(0, 0, 0, .3);
	--csfx-sw-btn-size: 42px;
	--csfx-sw-icon-size: 18px;
	--csfx-sw-gap: 10px;
	--csfx-sw-offset: 20px;             /* edge offset on the "free" axis — matches LiveChat's default 20px */
	--csfx-sw-bottom-offset: var(--csfx-sw-offset); /* Vertical layout: distance from the bottom edge — overridden inline to clear LiveChat's bubble */
	--csfx-sw-side-offset: var(--csfx-sw-offset);   /* Horizontal layout: distance from the left/right edge — overridden inline to clear LiveChat's bubble */
}

/* Fixed to the real viewport (not a scrolling/transformed ancestor), and a
   z-index high enough to sit above most theme headers/mobile menus. The
   !important flags are intentional hardening: some themes/mobile-menu
   plugins apply broad utility rules (e.g. hiding fixed elements, resetting
   position) at mobile breakpoints, which is the most common reason a
   widget like this "disappears" only on phones. */
.csfx-social-widget {
	position: fixed !important;
	display: flex !important;
	visibility: visible !important;
	opacity: 1 !important;
	right: var(--csfx-sw-offset);
	bottom: var(--csfx-sw-offset);
	align-items: center;
	gap: var(--csfx-sw-gap);
	z-index: 999999;
}

.csfx-social-widget.csfx-sw-left {
	right: auto;
	left: var(--csfx-sw-offset);
}

/* ---------- Layout: Vertical (stacks above the LiveChat bubble) ---------- */
.csfx-social-widget.csfx-sw-vertical {
	flex-direction: column-reverse; /* icons stack upward from the bottom offset */
	bottom: var(--csfx-sw-bottom-offset);
}

/* ---------- Layout: Horizontal (sits to the side of the LiveChat bubble) ---------- */
.csfx-social-widget.csfx-sw-horizontal {
	flex-direction: row-reverse; /* first icon sits nearest the right edge, i.e. nearest the LiveChat bubble */
	flex-wrap: nowrap;
	right: var(--csfx-sw-side-offset);
}

.csfx-social-widget.csfx-sw-horizontal.csfx-sw-left {
	flex-direction: row; /* mirrored: first icon nearest the left edge, i.e. nearest the LiveChat bubble */
	right: auto;
	left: var(--csfx-sw-side-offset);
}

.csfx-sw-btn {
	width: var(--csfx-sw-btn-size);
	height: var(--csfx-sw-btn-size);
	border-radius: 50%;
	border: none;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	box-shadow: var(--csfx-sw-shadow);
	background: var(--csfx-sw-brand);
	color: var(--csfx-sw-brand-ink);
	padding: 0;
	font-family: inherit;
	transition: background-color .2s ease, transform .2s ease;
}

/* Every button (toggle + channel items) fills solid black on hover/focus. */
.csfx-sw-btn:hover,
.csfx-sw-btn:focus-visible {
	background-color: var(--csfx-sw-hover-bg);
}

.csfx-sw-btn svg {
	width: var(--csfx-sw-icon-size);
	height: var(--csfx-sw-icon-size);
}

/* Menu items — same green outer / black icon theme, uniform across every channel.
   No grouping/toggle: every enabled item (controlled in Settings) is always visible. */
.csfx-sw-item {
	opacity: 1;
	transform: none;
	pointer-events: auto;
	transition: transform .18s ease, background-color .2s ease;
	text-decoration: none;
	position: relative;
}

.csfx-sw-item:hover {
	transform: scale(1.06);
}

/* Hover/focus tooltip label next to each channel button */
.csfx-sw-tooltip {
	position: absolute;
	top: 50%;
	right: calc(100% + 12px);
	transform: translateY(-50%) translateX(4px);
	white-space: nowrap;
	background: var(--csfx-sw-hover-bg);
	color: #fff;
	font-family: inherit;
	font-size: 13px;
	font-weight: 500;
	line-height: 1;
	padding: 8px 12px;
	border-radius: 6px;
	opacity: 0;
	pointer-events: none;
	transition: opacity .18s ease, transform .18s ease;
	box-shadow: var(--csfx-sw-shadow);
}

.csfx-sw-tooltip::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 100%;
	transform: translateY(-50%);
	border: 5px solid transparent;
	border-left-color: var(--csfx-sw-hover-bg);
}

.csfx-sw-item:hover .csfx-sw-tooltip,
.csfx-sw-item:focus-visible .csfx-sw-tooltip {
	opacity: 1;
	transform: translateY(-50%) translateX(0);
}

/* Mirror tooltip to the opposite side when the widget sits bottom-left */
.csfx-sw-left .csfx-sw-tooltip {
	right: auto;
	left: calc(100% + 12px);
	transform: translateY(-50%) translateX(-4px);
}
.csfx-sw-left .csfx-sw-tooltip::after {
	left: auto;
	right: 100%;
	border-left-color: transparent;
	border-right-color: var(--csfx-sw-hover-bg);
}
.csfx-sw-left .csfx-sw-item:hover .csfx-sw-tooltip,
.csfx-sw-left .csfx-sw-item:focus-visible .csfx-sw-tooltip {
	transform: translateY(-50%) translateX(0);
}

/* In horizontal layout, icons sit side by side, so a sideways tooltip would
   overlap the next icon — show it above the button instead. */
.csfx-sw-horizontal .csfx-sw-tooltip {
	top: auto;
	bottom: calc(100% + 12px);
	right: auto;
	left: 50%;
	transform: translateX(-50%) translateY(4px);
}
.csfx-sw-horizontal .csfx-sw-tooltip::after {
	top: 100%;
	left: 50%;
	right: auto;
	transform: translateX(-50%);
	border-left-color: transparent;
	border-top-color: var(--csfx-sw-hover-bg);
}
.csfx-sw-horizontal .csfx-sw-item:hover .csfx-sw-tooltip,
.csfx-sw-horizontal .csfx-sw-item:focus-visible .csfx-sw-tooltip {
	transform: translateX(-50%) translateY(0);
}

/* Tooltips rely on :hover, which touch devices don't have — hide them there
   so nothing gets stuck open after a tap. */
@media (hover: none) {
	.csfx-sw-tooltip {
		display: none;
	}
}

@media (max-width: 600px) {
	:root {
		/* Fallback only — normally overridden by the inline
		   --csfx-sw-btn-size / --csfx-sw-icon-size set from Settings >
		   Social Widget > Icon Size, which applies at every screen size so
		   the icons keep matching the Live Chat bubble on mobile too. */
		--csfx-sw-btn-size: 36px;
		--csfx-sw-icon-size: 15px;
		--csfx-sw-gap: 8px;
		--csfx-sw-offset: 14px;
	}

	/* Re-assert visibility at the mobile breakpoint specifically — this is
	   the exact width range where theme mobile-menu CSS most often adds a
	   competing `display: none` or repositions fixed elements. */
	.csfx-social-widget {
		position: fixed !important;
		display: flex !important;
		visibility: visible !important;
		opacity: 1 !important;
		z-index: 999999 !important;
	}
}

/* When reserving space next to/above the LiveChat bubble, keep the reserved
   amount even on mobile — an inline style on .csfx-social-widget sets
   --csfx-sw-bottom-offset (vertical layout) or --csfx-sw-side-offset
   (horizontal layout) directly, and takes precedence over this block. */

@media (prefers-reduced-motion: reduce) {
	.csfx-sw-item {
		transition: none;
	}
}

/* ---------- Click to Call modal ---------- */
.csfx-sw-modal {
	position: fixed;
	inset: 0;
	z-index: 1000000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
}
.csfx-sw-modal[hidden] {
	display: none;
}
.csfx-sw-modal-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(10, 20, 35, .55);
	border: none;
	cursor: pointer;
}
.csfx-sw-modal-panel {
	position: relative;
	background: #fff;
	border-radius: 12px;
	max-width: 420px;
	width: 100%;
	max-height: 86vh;
	overflow: auto;
	padding: 32px 24px 24px;
	box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
}
.csfx-sw-modal-close {
	position: absolute;
	top: 10px;
	right: 10px;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	border: none;
	background: #f1f2f4;
	color: #1c2027;
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
}
.csfx-sw-modal-close:hover {
	background: #e4e6e9;
}
