/**
 * SiteStaffr Button Widget Styles
 *
 * Styles for the inline button widget ([sitestaffr_button] shortcode).
 * Supports extensive customization via CSS custom properties set inline by PHP.
 *
 * @package    SiteStaffr
 * @since      0.11.76
 */

/* ===========================
   BUTTON CONTAINER
   =========================== */

.sitestaffr-button-container {
	display: inline-block;
	position: relative;
}

/* ===========================
   BUTTON BASE STYLES
   =========================== */

.sitestaffr-button-widget {
	/* CSS custom properties (set inline by PHP) */
	--btn-text-color: #ffffff;
	--btn-font-size: 16px;
	--btn-font-weight: 600;
	--btn-text-transform: none;
	--btn-background: #0073aa;
	--btn-hover-background: #005a87;
	--btn-padding-x: 24px;
	--btn-padding-y: 12px;
	--btn-border-radius: 80px;
	--btn-border-width: 0;
	--btn-border-color: transparent;
	--btn-box-shadow: none;
	--btn-icon-size: 18px;
	--btn-icon-color: var(--btn-text-color);
	--btn-listening-color: #e74c3c;

	/* Apply custom properties */
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-width: 150px;
	padding: var(--btn-padding-y) var(--btn-padding-x);
	font-size: var(--btn-font-size);
	font-weight: var(--btn-font-weight);
	text-transform: var(--btn-text-transform);
	border-radius: var(--btn-border-radius);
	border: var(--btn-border-width) var(--btn-border-style, solid) var(--btn-border-color);
	box-shadow: var(--btn-box-shadow);
	cursor: pointer;
	transition: all 0.3s ease;
	outline: none;
	font-family: inherit;
	line-height: 1.5;
	text-decoration: none;
	user-select: none;
	-webkit-tap-highlight-color: transparent;
}

/* Color properties use attribute selector for Elementor specificity */
[data-sitestaffr-widget] .sitestaffr-button-widget {
	background: var(--btn-background);
	color: var(--btn-text-color);
}

/* Full width variant */
.sitestaffr-button-widget.full-width {
	width: 100%;
}

/* ===========================
   HOVER STATES
   =========================== */

/* Hover colors — idle state only (listening/speaking/thinking states have fixed colors) */
[data-sitestaffr-widget] .sitestaffr-button-widget:not(.state-listening):not(.state-thinking):not(.state-speaking):not(.state-searching):not(.state-error):hover {
	background: var(--btn-hover-background);
	color: var(--btn-hover-icon-color, var(--btn-icon-color));
}

[data-sitestaffr-widget] .sitestaffr-button-widget:not(.state-listening):not(.state-thinking):not(.state-speaking):not(.state-searching):not(.state-error):hover svg {
	color: var(--btn-hover-icon-color, var(--btn-icon-color));
}

.sitestaffr-button-widget:focus {
	outline: 2px solid var(--btn-background);
	outline-offset: 2px;
}

.sitestaffr-button-widget:active {
	transform: scale(0.98);
}

/* ===========================
   HOVER ANIMATIONS
   =========================== */

/* Scale animation */
.sitestaffr-button-widget.hover-animation-scale:hover {
	transform: scale(1.05);
}

/* Glow animation */
.sitestaffr-button-widget.hover-animation-glow:hover {
	box-shadow: 0 0 20px rgba(0, 115, 170, 0.6);
}

/* Pulse animation */
.sitestaffr-button-widget.hover-animation-pulse {
	animation: sitestaffr-button-pulse 2s infinite;
}

@keyframes sitestaffr-button-pulse {
	0%, 100% {
		transform: scale(1);
	}
	50% {
		transform: scale(1.02);
	}
}

/* ===========================
   ICON STYLES
   =========================== */

.sitestaffr-button-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

[data-sitestaffr-widget] .sitestaffr-button-icon {
	color: var(--btn-icon-color, var(--btn-text-color));
}

.sitestaffr-button-icon svg,
.sitestaffr-button-mic svg {
	width: var(--btn-icon-size);
	height: var(--btn-icon-size);
	display: block;
}

.sitestaffr-button-mic {
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

/* Icon position variants */
.sitestaffr-button-widget.icon-position-right {
	flex-direction: row-reverse;
}

/* ===========================
   BUTTON TEXT
   =========================== */

.sitestaffr-button-text {
	display: inline-block;
	white-space: nowrap;
}

/* ===========================
   LOADING SPINNER
   =========================== */

.sitestaffr-button-spinner {
	display: none;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.sitestaffr-button-spinner svg {
	width: var(--btn-icon-size);
	height: var(--btn-icon-size);
	animation: sitestaffr-button-spin 1s linear infinite;
}

@keyframes sitestaffr-button-spin {
	from {
		transform: rotate(0deg);
	}
	to {
		transform: rotate(360deg);
	}
}

/* Mic and spinner hidden by default */
.sitestaffr-button-mic,
.sitestaffr-button-spinner,
.sitestaffr-button-soundwave {
	display: none;
}

/* Hide custom icon during all active states */
.sitestaffr-button-widget.state-listening .sitestaffr-button-icon,
.sitestaffr-button-widget.state-thinking .sitestaffr-button-icon,
.sitestaffr-button-widget.state-connecting .sitestaffr-button-icon,
.sitestaffr-button-widget.state-searching .sitestaffr-button-icon,
.sitestaffr-button-widget.state-speaking .sitestaffr-button-icon {
	display: none;
}

/* Show microphone icon when listening */
.sitestaffr-button-widget.state-listening .sitestaffr-button-mic {
	display: inline-flex;
}

/* Show spinner when thinking/connecting/searching */
.sitestaffr-button-widget.state-thinking .sitestaffr-button-spinner,
.sitestaffr-button-widget.state-connecting .sitestaffr-button-spinner,
.sitestaffr-button-widget.state-searching .sitestaffr-button-spinner {
	display: inline-flex;
}

/* Show soundwave when speaking */
.sitestaffr-button-widget.state-speaking .sitestaffr-button-soundwave {
	display: inline-flex;
}

/* ===========================
   SOUNDWAVE ANIMATION
   =========================== */

.sitestaffr-button-soundwave {
	align-items: center;
	justify-content: center;
	gap: 2px;
	height: 18px;
	flex-shrink: 0;
}

.sitestaffr-button-soundwave span {
	width: 3px;
	background-color: currentColor;
	border-radius: 2px;
	animation: sitestaffr-button-soundwave 1s ease-in-out infinite;
}

.sitestaffr-button-soundwave span:nth-child(1) {
	animation-delay: 0s;
	height: 8px;
}

.sitestaffr-button-soundwave span:nth-child(2) {
	animation-delay: 0.2s;
	height: 12px;
}

.sitestaffr-button-soundwave span:nth-child(3) {
	animation-delay: 0.4s;
	height: 8px;
}

@keyframes sitestaffr-button-soundwave {
	0%, 100% {
		transform: scaleY(0.5);
	}
	50% {
		transform: scaleY(1);
	}
}

/* ===========================
   LISTENING STATE
   =========================== */

.sitestaffr-button-widget.state-listening {
	background: #e74c3c !important;
	color: #ffffff !important;
	border-color: transparent !important;
	animation: sitestaffr-button-pulse-listening 1.5s ease-in-out infinite;
}

.sitestaffr-button-widget.state-listening .sitestaffr-button-mic svg {
	stroke: #ffffff !important;
	fill: none !important;
}

@keyframes sitestaffr-button-pulse-listening {
	0%, 100% {
		box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7);
	}
	50% {
		box-shadow: 0 0 0 10px rgba(231, 76, 60, 0);
	}
}

/* ===========================
   SPEAKING STATE
   =========================== */

.sitestaffr-button-widget.state-speaking {
	/* Keep normal appearance but add subtle animation */
	animation: sitestaffr-button-speaking 1s ease-in-out infinite;
}

@keyframes sitestaffr-button-speaking {
	0%, 100% {
		opacity: 1;
	}
	50% {
		opacity: 0.9;
	}
}

/* ===========================
   ERROR STATE
   =========================== */

.sitestaffr-button-widget.state-error {
	background: #e74c3c;
	animation: sitestaffr-button-shake 0.5s ease;
}

@keyframes sitestaffr-button-shake {
	0%, 100% {
		transform: translateX(0);
	}
	25% {
		transform: translateX(-5px);
	}
	75% {
		transform: translateX(5px);
	}
}

/* ===========================
   BUTTON WIDGET TOOLTIP
   =========================== */

.sitestaffr-button-widget-tooltip {
	position: absolute;
	white-space: nowrap;
	background: rgba(0, 0, 0, 0.8);
	color: #fff;
	padding: 6px 12px;
	border-radius: 6px;
	font-size: 13px;
	pointer-events: none;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.2s ease, visibility 0.2s ease;
	z-index: 999999;
	bottom: calc(100% + 8px);
	left: 50%;
	transform: translateX(-50%);
}

.sitestaffr-button-widget-tooltip::after {
	content: '';
	position: absolute;
	top: 100%;
	left: 50%;
	transform: translateX(-50%);
	border: 5px solid transparent;
	border-top-color: rgba(0, 0, 0, 0.8);
}

/* Show on hover */
.sitestaffr-button-container:hover .sitestaffr-button-widget-tooltip {
	opacity: 1;
	visibility: visible;
}

/* Persistent mode */
.sitestaffr-button-container.sitestaffr-tooltip--persistent .sitestaffr-button-widget-tooltip {
	opacity: 1;
	visibility: visible;
}

/* ===========================
   DISABLED STATE
   =========================== */

.sitestaffr-button-widget:disabled {
	opacity: 0.6;
	cursor: not-allowed;
	pointer-events: none;
}

/* ===========================
   ACCESSIBILITY
   =========================== */

/* High contrast mode support */
@media (prefers-contrast: high) {
	.sitestaffr-button-widget {
		border: 2px solid currentColor;
	}
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
	.sitestaffr-button-widget,
	.sitestaffr-button-spinner svg {
		transition: none;
		animation: none;
	}
}

/* ===========================
   MOBILE RESPONSIVE
   =========================== */

@media (max-width: 768px) {
	/* Ensure touch targets are at least 44px */
	.sitestaffr-button-widget {
		min-height: 44px;
		padding: max(var(--btn-padding-y), 10px) max(var(--btn-padding-x), 16px);
	}

	/* Adjust font size for mobile */
	.sitestaffr-button-widget {
		font-size: max(var(--btn-font-size), 14px);
	}
}

/* ===========================
   TABLET RESPONSIVE
   =========================== */

@media (min-width: 768px) and (max-width: 1024px) {
	.sitestaffr-button-widget.full-width {
		/* Full width on tablet too */
		width: 100%;
	}
}

/* ===== Hero Button Variant ===== */
.sitestaffr-button-widget.sitestaffr-button--hero {
	font-size: 1.15em;
	padding: 16px 36px;
	position: relative;
	overflow: hidden;
	box-shadow: none;
	animation: none;
}

.sitestaffr-button-widget.sitestaffr-button--hero::before {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	width: 60%;
	height: 100%;
	background: linear-gradient(90deg, transparent, rgba(255,255,255,0.25), transparent);
	animation: sitestaffr-hero-shimmer 3s ease-in-out infinite;
	pointer-events: none;
	will-change: transform;
}

@keyframes sitestaffr-hero-shimmer {
	0% { transform: translateX(-260%); }
	50%, 100% { transform: translateX(260%); }
}

/* ===== Onboarding Card ===== */
.sitestaffr-onboarding-card {
	max-width: 400px;
	margin: 20px auto 0;
	padding: 24px;
	background: #E0F7FA;
	border-radius: 12px;
	border: 1px solid #1FB6CC;
	text-align: left;
	animation: sitestaffr-card-appear 0.4s ease-out;
}

.sitestaffr-onboarding-card h3 {
	color: #00838F;
	margin: 0 0 16px;
	font-size: 18px;
	font-weight: 600;
}

.sitestaffr-onboarding-field {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 10px 0;
	border-bottom: 1px solid rgba(0, 0, 0, 0.08);
	opacity: 0.35;
	transform: translateY(4px);
	transition: opacity 0.4s ease, transform 0.4s ease;
}

.sitestaffr-onboarding-field:last-of-type {
	border-bottom: none;
}

.sitestaffr-onboarding-field.is-filling,
.sitestaffr-onboarding-field.is-filled {
	opacity: 1;
	transform: translateY(0);
}

.sitestaffr-onboarding-field.is-filling {
	animation: sitestaffr-field-glow 0.6s ease-out;
}

.sitestaffr-onboarding-label {
	font-weight: 600;
	color: #004D40;
	font-size: 14px;
	flex-shrink: 0;
	margin-right: 12px;
}

.sitestaffr-onboarding-value {
	color: #00838F;
	font-size: 14px;
	text-align: right;
	word-break: break-word;
}

@keyframes sitestaffr-card-appear {
	from { opacity: 0; transform: translateY(12px) scale(0.97); }
	to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes sitestaffr-field-glow {
	0% { background: rgba(31, 182, 204, 0.2); }
	100% { background: transparent; }
}

/* ===== Onboarding Success State ===== */
.sitestaffr-onboarding-success {
	text-align: center;
	padding: 20px 0;
	animation: sitestaffr-success-appear 0.5s ease-out;
}

.sitestaffr-onboarding-success__icon {
	margin: 0 auto 16px;
	width: 48px;
	height: 48px;
}

.sitestaffr-checkmark-circle {
	stroke-dasharray: 138;
	stroke-dashoffset: 138;
	animation: sitestaffr-circle-draw 0.6s ease-out 0.1s forwards;
}

.sitestaffr-checkmark-check {
	stroke-dasharray: 40;
	stroke-dashoffset: 40;
	animation: sitestaffr-check-draw 0.4s ease-out 0.5s forwards;
}

.sitestaffr-onboarding-success__title {
	color: #00838F;
	font-size: 1.3rem;
	font-weight: 700;
	margin: 0 0 8px;
}

.sitestaffr-onboarding-success__text {
	color: #555;
	font-size: 0.95rem;
	line-height: 1.5;
	margin: 0;
}

@keyframes sitestaffr-success-appear {
	from { opacity: 0; transform: scale(0.9); }
	to { opacity: 1; transform: scale(1); }
}

@keyframes sitestaffr-circle-draw {
	to { stroke-dashoffset: 0; }
}

@keyframes sitestaffr-check-draw {
	to { stroke-dashoffset: 0; }
}

