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

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

.phoneease-button-container {
	display: inline-block;
}

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

.phoneease-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: 4px;
	--btn-border-width: 0;
	--btn-border-color: transparent;
	--btn-box-shadow: none;
	--btn-icon-size: 18px;
	--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);
	background: var(--btn-background);
	color: var(--btn-text-color);
	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) 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;
}

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

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

.phoneease-button-widget:hover {
	background: var(--btn-hover-background);
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/* Show spinner and hide icon when thinking/connecting */
.phoneease-button-widget.state-thinking .phoneease-button-icon,
.phoneease-button-widget.state-connecting .phoneease-button-icon {
	display: none;
}

.phoneease-button-widget.state-thinking .phoneease-button-spinner,
.phoneease-button-widget.state-connecting .phoneease-button-spinner {
	display: inline-flex;
}

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

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

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

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

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

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

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

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

.phoneease-button-widget.state-listening {
	background: var(--btn-listening-color);
	animation: phoneease-button-pulse-listening 1.5s ease-in-out infinite;
}

@keyframes phoneease-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
   =========================== */

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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