/**
 * WooCommerce Add-Ons - User Account Icon Styles
 *
 * Comprehensive styles for the User Account Icon widget including dropdown menus,
 * mobile behaviors, animations, and Elementor widget container overrides.
 *
 * @package WooCommerce_Addons
 * @version 1.2.2
 * @since 1.0.0
 * @lastmod 2025-10-15
 *
 * Changelog:
 * v1.2.2 (2025-10-15) - Session 43: Mobile touch device fix
 *   - Fixed focus/active state conflict on mobile (lines 399-404)
 *   - Click background color now works on touch devices
 * v1.2.1 (2025-10-15) - Session 40: Safari iOS sticky hover fix
 *   - Added @media (hover: none) to disable hover on touch devices
 * v1.2.0 (2025-10-14) - Session 39: Separate text styling controls
 */

/* Elementor Widget Container - Remove focus outline */
.elementor-widget-wcao-user-account-menu .elementor-widget-container,
.elementor-widget-wcao-user-account-menu .elementor-widget-container:focus,
.elementor-widget-wcao-user-account-menu .elementor-widget-container:active {
	outline: none !important;
	box-shadow: none !important;
}

/* Container */
.wcao-user-menu-wrapper {
	display: inline-block;
	position: relative;
	outline: none !important;
}

.wcao-user-menu-wrapper:focus,
.wcao-user-menu-wrapper:active {
	outline: none !important;
	box-shadow: none !important;
}

/* User Menu (logged in) */
.wcao-user-menu {
	position: relative;
	display: inline-block;
}

.wcao-menu-trigger {
	background: none;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px 12px;
	font-family: inherit;
	font-size: inherit;
	transition: all 0.3s ease;
	outline: none;
	-webkit-tap-highlight-color: transparent;
	-webkit-touch-callout: none;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
}

.wcao-menu-trigger:focus,
.wcao-menu-trigger:active {
	outline: none !important;
	box-shadow: none !important;
}

/* Icon */
.wcao-user-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
}

.wcao-user-icon svg,
.wcao-user-icon img {
	display: block;
	max-width: 100%;
	height: auto;
}

/* Username beside icon */
.wcao-username {
	font-weight: 500;
}

/* Dropdown */
.wcao-dropdown {
	position: absolute;
	top: 100%;
	margin-top: 8px;
	background: #ffffff;
	border: 1px solid #e0e0e0;
	border-radius: 4px;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
	z-index: 9999;
	overflow: hidden;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Dropdown Position */
.wcao-dropdown.wcao-dropdown-left {
	left: 0;
	right: auto;
}

.wcao-dropdown.wcao-dropdown-right {
	right: 0;
	left: auto;
}

/* Dropdown Show State */
.wcao-dropdown.wcao-show {
	display: block !important;
	opacity: 1;
	visibility: visible;
}

/* Dropdown Animations */
.wcao-dropdown[data-animation="fade"] {
	transition: opacity 0.3s ease, visibility 0.3s ease;
}

.wcao-dropdown[data-animation="slide"] {
	transform: translateY(-10px);
	transition: transform 0.3s ease, opacity 0.3s ease, visibility 0.3s ease;
}

.wcao-dropdown[data-animation="slide"].wcao-show {
	transform: translateY(0);
}

.wcao-dropdown[data-animation="fadeslide"] {
	transform: translateY(-10px);
	transition: transform 0.3s ease, opacity 0.3s ease, visibility 0.3s ease;
}

.wcao-dropdown[data-animation="fadeslide"].wcao-show {
	transform: translateY(0);
}

/* Username in dropdown */
.wcao-dropdown-username {
	padding: 12px 16px;
	background: #f5f5f5;
	border-bottom: 1px solid #e0e0e0;
	font-weight: 600;
	color: #333;
	pointer-events: none; /* Never clickable/focusable */
	user-select: none;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
}

/* Menu Items */
.wcao-menu-item {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 12px 16px;
	color: #333;
	text-decoration: none;
	transition: all 0.2s ease;
	white-space: nowrap;
	-webkit-tap-highlight-color: transparent;
	-webkit-touch-callout: none;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
}

/* Note: Hover styles are defined in @media (hover: hover) to prevent sticky hover on touch devices */

.wcao-menu-item:first-child {
	border-top: none;
}

/* Custom Menu Item Icons */
.wcao-menu-item .wcao-item-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
	font-size: 14px;
}

.wcao-menu-item .wcao-item-icon svg {
	width: 1em;
	height: 1em;
}

.wcao-menu-item .wcao-item-label {
	flex: 1;
}

/* Login Button (logged out) */
.wcao-login-button {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 8px 16px;
	background: none;
	color: inherit;
	text-decoration: none;
	transition: all 0.3s ease;
	outline: none !important;
	border: none !important;
	-webkit-tap-highlight-color: transparent !important;
	-webkit-touch-callout: none;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
}

.wcao-login-button:hover,
.wcao-login-button:focus,
.wcao-login-button:active,
.wcao-login-button:focus-visible,
.wcao-login-button:focus-within {
	outline: none !important;
	box-shadow: none !important;
	border: none !important;
	-webkit-tap-highlight-color: transparent !important;
}

/* Remove outline from all children including SVG */
.wcao-login-button *,
.wcao-login-button *:focus,
.wcao-login-button *:active,
.wcao-login-button *:hover,
.wcao-login-button svg,
.wcao-login-button svg *,
.wcao-login-button .wcao-user-icon,
.wcao-login-button .wcao-user-icon * {
	outline: none !important;
	box-shadow: none !important;
	border: none !important;
	-webkit-tap-highlight-color: transparent !important;
}

.wcao-login-text {
	font-weight: 500;
}

/* Mobile Behavior - Hide on Mobile */
.wcao-user-menu-wrapper.wcao-mobile-hide {
	display: inline-block;
}

@media (max-width: 768px) {
	.wcao-user-menu-wrapper.wcao-mobile-hide {
		display: none !important;
	}
}

/* Mobile Behavior - Full-Width Overlay */
.wcao-user-menu-wrapper.wcao-mobile-fullwidth .wcao-dropdown {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	width: 100%;
	max-width: 100%;
	margin: 0;
	border-radius: 0;
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	background: rgba(0, 0, 0, 0.95);
	z-index: 999999;
}

/* Close Button for Full-Width Overlay */
.wcao-close-overlay {
	position: absolute;
	top: 20px;
	right: 20px;
	background: transparent;
	border: 2px solid rgba(255, 255, 255, 0.3);
	color: #ffffff;
	font-size: 32px;
	line-height: 1;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.3s ease;
	padding: 0;
	z-index: 1000000;
}

.wcao-close-overlay:hover {
	background: rgba(255, 255, 255, 0.1);
	border-color: rgba(255, 255, 255, 0.6);
	transform: scale(1.1);
}

.wcao-close-overlay:focus {
	outline: 2px solid #ffffff;
	outline-offset: 2px;
}

@media (max-width: 768px) {
	.wcao-user-menu-wrapper.wcao-mobile-fullwidth .wcao-dropdown.wcao-show {
		transform: none;
	}

	.wcao-user-menu-wrapper.wcao-mobile-fullwidth .wcao-menu-item {
		font-size: 18px;
		padding: 16px 24px;
		color: #ffffff;
		width: 100%;
		max-width: 300px;
		text-align: center;
		border-bottom: 1px solid rgba(255, 255, 255, 0.1);
	}

	/* Note: Full-width overlay hover handled by @media (hover: hover) below */

	.wcao-user-menu-wrapper.wcao-mobile-fullwidth .wcao-dropdown-username {
		background: transparent;
		color: #ffffff;
		font-size: 20px;
		border-bottom: 1px solid rgba(255, 255, 255, 0.2);
	}
}

/* Responsive - Default Dropdown Behavior */
@media (max-width: 768px) {
	.wcao-dropdown {
		min-width: 200px;
	}

	.wcao-menu-trigger {
		padding: 6px 10px;
	}

	.wcao-login-button {
		padding: 6px 12px;
	}
}

/* Menu Item Focus - Desktop only */
.wcao-menu-item:focus {
	outline: none;
}

.wcao-menu-item:focus-visible {
	background: #f5f5f5;
	color: #0073aa;
	outline: 2px solid #0073aa;
	outline-offset: -2px;
}

/* Active/Current Menu Item Styling */
/* Note: Active colors and borders are controlled via Elementor widget settings */
/* If you add a left border, adjust padding manually via Elementor's Menu Item Padding control */

/* CRITICAL FIX: Disable :hover on touch devices to prevent sticky hover bug */
/* On touch devices, :hover triggers when tapping and stays "stuck" */
/* Use @media (hover: none) to detect touch-only devices */
@media (hover: none) {
	/* Force disable ALL hover states on touch devices */
	/* Use highest specificity to override Elementor and other theme styles */
	.wcao-menu-item:hover,
	.wcao-dropdown .wcao-menu-item:hover,
	.wcao-user-menu .wcao-menu-item:hover,
	.wcao-user-menu-wrapper .wcao-menu-item:hover,
	.elementor-widget .wcao-menu-item:hover {
		background-color: transparent !important;
		background: transparent !important;
		color: inherit !important;
	}

	/* Note: Active/current state colors are controlled via Elementor widget settings */
	/* This only ensures active items don't get hover states on touch devices */
	.wcao-menu-item.is-active:hover {
		/* Prevent hover from applying to active items - use widget settings instead */
		background-color: inherit !important;
		background: inherit !important;
		color: inherit !important;
	}

	/* Disable focus outline on touch devices (but preserve :active background) */
	.wcao-menu-item:focus,
	.wcao-menu-item:focus-visible,
	.wcao-menu-item:focus-within {
		outline: none !important;
	}

	/**
	 * CRITICAL FIX (Session 43): Only remove background on focus when NOT actively clicking
	 *
	 * Problem: On mobile/touch devices, :focus was overriding :active background color
	 * Solution: Use :not(:active) pseudo-class to preserve click background
	 * Result: Click background color now works on both desktop AND mobile
	 */
	.wcao-menu-item:focus:not(:active),
	.wcao-menu-item:focus-visible:not(:active),
	.wcao-menu-item:focus-within:not(:active) {
		background-color: transparent !important;
	}

	/* Disable tap highlight */
	.wcao-menu-item {
		-webkit-tap-highlight-color: transparent !important;
		-webkit-touch-callout: none !important;
	}
}

/* Desktop hover devices only - enable hover effects (colors controlled by Elementor widget) */
@media (hover: hover) {
	/* Note: Background and text colors are controlled via Elementor widget settings */
	/* This media query only ensures hover works on desktop but not on touch devices */

	/* Full-width overlay hover on desktop devices */
	.wcao-user-menu-wrapper.wcao-mobile-fullwidth .wcao-menu-item:hover {
		background: rgba(255, 255, 255, 0.1);
		color: #ffffff;
	}
}

/* SAFARI iOS FIX: Disable tap highlight on touch devices */
@supports (-webkit-touch-callout: none) {
	.wcao-menu-item {
		-webkit-tap-highlight-color: rgba(0,0,0,0) !important;
		-webkit-touch-callout: none !important;
	}
}
