/* ==========================================================================
   oChats Widget — Frontend Styles
   Uses CSS custom properties set inline by JS:
     --ochats-color  : main button background colour
     --ochats-size   : button diameter in px
   ========================================================================== */

/* ── Floating widget container ─────────────────────────────────────────── */
#ochats-widget {
	position: fixed;
	bottom: 24px;
	z-index: 99999;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 8px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 14px;
	line-height: 1.4;
	box-sizing: border-box;
}

/* iOS safe area — prevents widget hiding behind iPhone home bar */
@supports (padding: max(0px)) {
	#ochats-widget {
		bottom: max(24px, env(safe-area-inset-bottom));
	}
}

#ochats-widget.ochats-pos-right {
	right: 24px;
	align-items: flex-end;
}

#ochats-widget.ochats-pos-left {
	left: 24px;
	align-items: flex-start;
}

/* ── Toggle button ─────────────────────────────────────────────────────── */
.ochats-toggle-btn {
	width:  var(--ochats-size, 56px);
	height: var(--ochats-size, 56px);
	min-width:  44px; /* WCAG 2.5.8 minimum tap target */
	min-height: 44px;
	border-radius: 50%;
	background-color: var(--ochats-color, #25D366);
	color: #ffffff;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
	padding: 0;
	flex-shrink: 0;
	order: 2; /* button always at bottom */
}

.ochats-toggle-btn:hover {
	transform: scale(1.07);
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* WCAG 2.4.11: visible focus indicator */
.ochats-toggle-btn:focus-visible {
	outline: 3px solid #ffffff;
	outline-offset: 3px;
	box-shadow: 0 0 0 5px var(--ochats-color, #25D366), 0 4px 16px rgba(0, 0, 0, 0.25);
}

.ochats-toggle-btn svg {
	width:  calc(var(--ochats-size, 56px) * 0.45);
	height: calc(var(--ochats-size, 56px) * 0.45);
	min-width:  20px;
	min-height: 20px;
	fill: #ffffff;
	transition: opacity 0.15s ease, transform 0.2s ease;
}

/* Show/hide open vs close icons */
.ochats-icon-close {
	display: none;
	position: absolute;
}

#ochats-widget.is-open .ochats-icon-open  { display: none; }
#ochats-widget.is-open .ochats-icon-close { display: flex; }

/* ── Widget panel ──────────────────────────────────────────────────────── */
.ochats-panel {
	order: 1; /* panel sits above the button */
	background: #ffffff;
	border-radius: 16px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
	width: 290px;
	overflow: hidden;

	/* Hidden by default */
	opacity: 0;
	transform: scale(0.92) translateY(12px);
	pointer-events: none;
	transition: opacity 0.2s ease, transform 0.2s ease;
	transform-origin: bottom right;
}

.ochats-pos-left .ochats-panel {
	transform-origin: bottom left;
}

/* Open state */
#ochats-widget.is-open .ochats-panel {
	opacity: 1;
	transform: scale(1) translateY(0);
	pointer-events: auto;
}

/* Panel header */
.ochats-panel-header {
	background: var(--ochats-color, #25D366);
	padding: 14px 16px 12px;
}

.ochats-cta-text {
	margin: 0;
	color: #ffffff;
	font-size: 15px;
	font-weight: 600;
}

/* ── Channel buttons ───────────────────────────────────────────────────── */
.ochats-channels-list {
	padding: 10px 12px 8px;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.ochats-channel-btn {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 12px;
	border-radius: 10px;
	background: #F9FAFB;
	text-decoration: none;
	color: #111827;
	font-size: 13px;
	font-weight: 500;
	transition: background 0.15s ease, transform 0.1s ease;
	cursor: pointer;
	min-height: 44px; /* WCAG tap target */
}

.ochats-channel-btn:hover {
	background: #F3F4F6;
	transform: translateX(2px);
}

.ochats-channel-btn:focus-visible {
	outline: 2px solid var(--ochats-ch-color, #25D366);
	outline-offset: 2px;
}

/* Channel icon circle */
.ochats-ch-icon {
	width: 34px;
	height: 34px;
	border-radius: 50%;
	background-color: var(--ochats-ch-color, #6B7280);
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.ochats-ch-icon svg {
	width: 18px;
	height: 18px;
	fill: #ffffff;
}

.ochats-ch-label {
	flex: 1;
}

/* ── Attribution backlink ──────────────────────────────────────────────── */
/*
  IMPORTANT: Never set display:none, visibility:hidden, or opacity:0 here.
  The link must be visible in the DOM for the backlink to be counted by Google.
*/
.ochats-attribution {
	margin: 0;
	padding: 8px 12px 10px;
	text-align: center;
	font-size: 10px;
	color: #9CA3AF;
	border-top: 1px solid #F3F4F6;
}

.ochats-attribution a {
	color: #6B7280;
	text-decoration: none;
}

.ochats-attribution a:hover {
	text-decoration: underline;
}

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
	.ochats-panel {
		width: calc(100vw - 48px);
		max-width: 290px;
	}

	#ochats-widget.ochats-pos-right {
		right: 16px;
	}

	#ochats-widget.ochats-pos-left {
		left: 16px;
	}
}
