/**
 * Mobile Hamburger Menu
 * 
 * Slide-in drawer navigation for mobile devices.
 * Bloomberg/Finance-grade UX with smooth animations.
 * 
 * @package ZL\Theme
 */

/* ============================================
   MOBILE USER AVATAR (in header)
   ============================================ */

.mobile-user-avatar {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	color: white;
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.5px;
	flex-shrink: 0;
	border: none;
	cursor: pointer;
	transition: all 0.2s ease;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.mobile-user-avatar:hover,
.mobile-user-avatar:active {
	transform: scale(1.05);
	box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* ============================================
   HAMBURGER BUTTON
   ============================================ */

.mobile-menu-button {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0.5rem;
	color: var(--text-secondary);
	transition: color 0.2s ease;
	cursor: pointer;
	border-radius: 6px;
	
	/* Touch target: 44x44px minimum */
	min-width: 44px;
	min-height: 44px;
	
	/* Prevent tap highlight on touch devices */
	-webkit-tap-highlight-color: transparent;
}

.mobile-menu-button:hover {
	color: var(--text-primary);
	background: var(--bg-secondary);
}

.mobile-menu-button:active {
	transform: scale(0.95);
}

/* ============================================
   HAMBURGER/CLOSE ICON TOGGLE (CSS-based)
   MAXIMUM SPECIFICITY - Nuclear option
   ============================================ */

/* Default state: Hamburger visible, Close hidden */
html body #hamburger-icon,
html body button #hamburger-icon {
	display: block !important;
	visibility: visible !important;
	opacity: 1 !important;
	width: 1.5rem !important;
	height: 1.5rem !important;
	position: static !important;
}

html body #close-icon,
html body button #close-icon {
	display: none !important;
	visibility: hidden !important;
	opacity: 0 !important;
	width: 0 !important;
	height: 0 !important;
	position: absolute !important;
	pointer-events: none !important;
}

/* When menu is open: Hide hamburger, show close */
html body.mobile-menu-open #hamburger-icon,
html body.mobile-menu-open button #hamburger-icon {
	display: none !important;
	visibility: hidden !important;
	opacity: 0 !important;
	width: 0 !important;
	height: 0 !important;
	position: absolute !important;
	pointer-events: none !important;
}

html body.mobile-menu-open #close-icon,
html body.mobile-menu-open button #close-icon {
	display: block !important;
	visibility: visible !important;
	opacity: 1 !important;
	width: 1.5rem !important;
	height: 1.5rem !important;
	position: static !important;
	pointer-events: auto !important;
}

/* ============================================
   MOBILE MENU OVERLAY (Backdrop)
   ============================================ */

.mobile-menu-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.6);
	backdrop-filter: blur(4px);
	z-index: 1000;
	/* Hidden by default */
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity 0.2s ease-out, visibility 0.2s ease-out;
}

/* When menu is open */
.mobile-menu-overlay.active {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
}

html:not(.dark) .mobile-menu-overlay {
	background: rgba(0, 0, 0, 0.4);
}

/* ============================================
   MOBILE MENU DRAWER
   ============================================ */

.mobile-menu-drawer {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	width: 85vw;
	max-width: 360px;
	background: var(--bg-primary);
	border-left: 1px solid var(--border-primary);
	box-shadow: -4px 0 24px rgba(0, 0, 0, 0.3);
	z-index: 1001;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	/* Hidden by default - off screen */
	transform: translateX(100%);
	visibility: hidden;
	pointer-events: none;
	transition: transform 0.3s ease-out, visibility 0.3s ease-out;
	
	/* Safe area inset for iPhone X+ */
	padding-bottom: env(safe-area-inset-bottom);
}

/* When menu is open */
.mobile-menu-drawer.active {
	transform: translateX(0);
	visibility: visible;
	pointer-events: auto;
}

html:not(.dark) .mobile-menu-drawer {
	background: #ffffff;
	border-left-color: #e5e7eb;
	box-shadow: -4px 0 24px rgba(0, 0, 0, 0.1);
}

/* ============================================
   MENU STATUS (Badges + Theme Toggle)
   ============================================ */

.mobile-menu-status {
	display: flex;
	flex-direction: row; /* STESSO RIGA - Bloomberg style */
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 16px 20px;
	border-bottom: 1px solid var(--border-primary);
	background: var(--bg-secondary);
}

/* Badge completo (full text, override mobile compression) */
.mobile-status-badge {
	display: flex;
	flex: 1; /* Prende spazio disponibile */
	min-width: 0; /* Prevent flex overflow */
}

/* Override default mobile compression - force full badge */
.mobile-status-badge .status-badge,
.mobile-status-badge .stale-badge {
	padding: 6px 12px !important; /* Compatto per stessa riga */
	font-size: 12px !important;
	gap: 6px !important;
	white-space: nowrap !important; /* Single line */
}

.mobile-status-badge .stale-badge-icon {
	width: 14px !important;
	height: 14px !important;
}

.mobile-status-badge .stale-badge-icon svg {
	width: 14px !important;
	height: 14px !important;
}

.mobile-status-badge .stale-badge-text {
	font-size: 12px !important;
	display: inline !important;
	white-space: nowrap !important; /* Single line */
}

/* FORCE text visibility in drawer (override hidden sm:inline) */
.mobile-status-badge .status-badge span {
	display: inline !important;
}

.mobile-status-badge .hidden {
	display: inline !important;
}

.mobile-status-badge [x-text] {
	display: inline !important;
}

/* Mobile Theme Toggle - Minimal Bloomberg-style (no label) */
.mobile-menu-theme-toggle {
	position: relative;
	width: 56px; /* Più compatto per layout orizzontale */
	height: 28px;
	background: rgba(99, 102, 241, 0.08);
	border: 2px solid rgba(99, 102, 241, 0.15);
	border-radius: 20px;
	cursor: pointer;
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	padding: 0;
	overflow: hidden;
	flex-shrink: 0; /* Non comprimere */
	display: block;
}

.mobile-menu-theme-toggle:hover,
.mobile-menu-theme-toggle:active {
	background: rgba(99, 102, 241, 0.12);
	border-color: rgba(99, 102, 241, 0.25);
	box-shadow: 0 0 20px rgba(99, 102, 241, 0.2);
	transform: scale(1.02);
}

.mobile-theme-toggle-slider {
	position: absolute;
	top: 2px;
	left: 2px;
	width: 22px; /* Proporzionato al nuovo size */
	height: 22px;
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	border-radius: 50%;
	transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 3px 12px rgba(0, 0, 0, 0.3);
}

.mobile-theme-icon {
	width: 14px; /* Proporzionato al nuovo size */
	height: 14px;
	color: white;
	position: absolute;
	transition: opacity 0.25s ease;
}

/* Dark mode: Sun visible */
html.dark .mobile-theme-icon-sun {
	opacity: 1;
}

html.dark .mobile-theme-icon-moon {
	opacity: 0;
}

/* Light mode: Moon visible, slider moved right */
html:not(.dark) .mobile-theme-toggle-slider {
	transform: translateX(30px); /* Ricalcolato: 56-22-4 = 30px */
}

html:not(.dark) .mobile-theme-icon-sun {
	opacity: 0;
}

html:not(.dark) .mobile-theme-icon-moon {
	opacity: 1;
}

/* Light mode colors */
html:not(.dark) .mobile-menu-theme-toggle {
	background: rgba(251, 191, 36, 0.08);
	border-color: rgba(251, 191, 36, 0.15);
}

html:not(.dark) .mobile-menu-theme-toggle:hover,
html:not(.dark) .mobile-menu-theme-toggle:active {
	background: rgba(251, 191, 36, 0.12);
	border-color: rgba(251, 191, 36, 0.25);
	box-shadow: 0 0 20px rgba(251, 191, 36, 0.2);
}

html:not(.dark) .mobile-theme-toggle-slider {
	background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
}

/* ============================================
   MENU HEADER
   ============================================ */

.mobile-menu-header {
	padding: 1.5rem 1rem;
	border-bottom: 1px solid var(--border-primary);
	flex-shrink: 0;
}

html:not(.dark) .mobile-menu-header {
	border-bottom-color: #e5e7eb;
}

/* User Info (logged in) */
.user-info-mobile {
	display: flex;
	align-items: center;
	gap: 1rem;
}

.user-avatar-large {
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--accent-primary), #6366f1);
	display: flex;
	align-items: center;
	justify-content: center;
	color: white;
	font-weight: 600;
	font-size: 1.25rem;
	letter-spacing: 0.05em;
	flex-shrink: 0;
}

html:not(.dark) .user-avatar-large {
	background: linear-gradient(135deg, #3b82f6, #6366f1);
}

.user-name-mobile {
	font-size: 1rem;
	font-weight: 600;
	color: var(--text-primary);
	margin-bottom: 0.25rem;
}

.user-tier-mobile {
	font-size: 0.875rem;
	color: var(--text-secondary);
}

html:not(.dark) .user-name-mobile {
	color: #1f2937;
}

html:not(.dark) .user-tier-mobile {
	color: #6b7280;
}

/* Guest Header */
.guest-header-mobile h3 {
	font-size: 1.125rem;
	font-weight: 600;
	color: var(--text-primary);
	margin-bottom: 0.25rem;
}

.guest-header-mobile p {
	font-size: 0.875rem;
	color: var(--text-secondary);
}

html:not(.dark) .guest-header-mobile h3 {
	color: #1f2937;
}

html:not(.dark) .guest-header-mobile p {
	color: #6b7280;
}

/* ============================================
   MENU NAV
   ============================================ */

.mobile-menu-nav {
	flex: 1;
	padding: 0.5rem 0;
	overflow-y: auto;
}

.mobile-menu-item {
	display: flex;
	align-items: center;
	gap: 1rem;
	padding: 1rem 1.25rem;
	color: var(--text-secondary);
	transition: all 0.2s ease;
	text-decoration: none;
	
	/* Touch target: 60px height */
	min-height: 60px;
	
	/* Prevent tap highlight */
	-webkit-tap-highlight-color: transparent;
}

.mobile-menu-item:hover {
	background: var(--bg-secondary);
	color: var(--text-primary);
}

.mobile-menu-item:active {
	background: var(--bg-tertiary);
}

html:not(.dark) .mobile-menu-item {
	color: #6b7280;
}

html:not(.dark) .mobile-menu-item:hover {
	background: #f9fafb;
	color: #1f2937;
}

html:not(.dark) .mobile-menu-item:active {
	background: #f3f4f6;
}

.mobile-menu-item .menu-icon {
	width: 24px;
	height: 24px;
	flex-shrink: 0;
	stroke-width: 2;
}

.mobile-menu-item span {
	font-size: 1rem;
	font-weight: 500;
}

/* Primary item (Log In) */
.mobile-menu-item-primary {
	color: var(--accent-primary);
}

html:not(.dark) .mobile-menu-item-primary {
	color: #3b82f6;
}

/* CTA item (Sign Up) */
.mobile-menu-item-cta {
	background: var(--accent-primary);
	color: white;
	margin: 0.5rem 1rem;
	border-radius: 8px;
	font-weight: 600;
}

.mobile-menu-item-cta:hover {
	background: #2563eb;
	color: white;
}

html:not(.dark) .mobile-menu-item-cta {
	background: #3b82f6;
}

html:not(.dark) .mobile-menu-item-cta:hover {
	background: #2563eb;
}

/* Menu Divider */
.mobile-menu-divider {
	height: 1px;
	background: var(--border-primary);
	margin: 0.5rem 1rem;
}

html:not(.dark) .mobile-menu-divider {
	background: #e5e7eb;
}

/* ============================================
   MENU FOOTER
   ============================================ */

.mobile-menu-footer {
	padding: 1rem 1.25rem;
	border-top: 1px solid var(--border-primary);
	flex-shrink: 0;
	text-align: center;
}

html:not(.dark) .mobile-menu-footer {
	border-top-color: #e5e7eb;
}

.mobile-menu-footer p {
	color: var(--text-tertiary);
}

html:not(.dark) .mobile-menu-footer p {
	color: #9ca3af;
}

/* ============================================
   HIDE ON DESKTOP
   ============================================ */

@media (min-width: 768px) {
	.mobile-menu-button,
	.mobile-menu-overlay,
	.mobile-menu-drawer {
		display: none !important;
	}
}

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

/* Focus visible for keyboard navigation */
.mobile-menu-button:focus-visible,
.mobile-menu-item:focus-visible {
	outline: 2px solid var(--accent-primary);
	outline-offset: 2px;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
	.mobile-menu-button,
	.mobile-menu-overlay,
	.mobile-menu-drawer,
	.mobile-menu-item {
		animation: none !important;
		transition: none !important;
	}
	
	.mobile-menu-button:active {
		transform: none !important;
	}
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */

.mobile-menu-drawer::-webkit-scrollbar {
	width: 6px;
}

.mobile-menu-drawer::-webkit-scrollbar-track {
	background: transparent;
}

.mobile-menu-drawer::-webkit-scrollbar-thumb {
	background: var(--border-primary);
	border-radius: 3px;
}

.mobile-menu-drawer::-webkit-scrollbar-thumb:hover {
	background: var(--text-tertiary);
}

html:not(.dark) .mobile-menu-drawer::-webkit-scrollbar-thumb {
	background: #e5e7eb;
}

html:not(.dark) .mobile-menu-drawer::-webkit-scrollbar-thumb:hover {
	background: #d1d5db;
}

/* ============================================
   PRINT - HIDE MENU
   ============================================ */

@media print {
	.mobile-menu-button,
	.mobile-menu-overlay,
	.mobile-menu-drawer {
		display: none !important;
	}
}

