/**
 * Market Maps - Bloomberg Terminal Grade Heatmap
 * 
 * Professional treemap visualization with finance-grade styling.
 */

/* ==========================================================================
   EXPLAIN PANEL - Unified Bloomberg Style
   ========================================================================== */

/* Trigger Button */
.explain-trigger {
	display: inline-flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	padding: 0.875rem 1.25rem;
	background: rgba(11, 15, 25, 0.6);
	border: 1px solid rgba(75, 85, 99, 0.25);
	border-radius: 10px;
	color: var(--text-secondary);
	cursor: pointer;
	transition: all 200ms ease;
	font-size: 0.9375rem;
	font-weight: 500;
	backdrop-filter: blur(8px);
	-webkit-backdrop-filter: blur(8px);
}

.explain-trigger:hover {
	background: rgba(11, 15, 25, 0.85);
	border-color: rgba(96, 165, 250, 0.4);
	color: var(--accent-primary);
	box-shadow: 0 2px 8px rgba(96, 165, 250, 0.1);
}

.explain-trigger:active {
	transform: scale(0.99);
}

.explain-trigger-text {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	font-weight: 500;
}

.explain-chevron {
	width: 1.25rem;
	height: 1.25rem;
	transition: transform 250ms ease;
	flex-shrink: 0;
}

/* Panel Content */
.explain-panel {
	overflow: hidden;
}

.explain-content {
	overflow: hidden;
	transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1);
	margin-top: 0.75rem;
}

.explain-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
	gap: 1.5rem;
	background: rgba(11, 15, 25, 0.95);
	border: 1px solid rgba(75, 85, 99, 0.35);
	border-radius: 12px;
	padding: 1.5rem;
	backdrop-filter: blur(16px) saturate(180%);
	-webkit-backdrop-filter: blur(16px) saturate(180%);
	box-shadow: 
		0 4px 20px rgba(0, 0, 0, 0.4),
		inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.explain-section {
	min-width: 0;
}

.explain-section-title {
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--accent-primary);
	text-transform: uppercase;
	letter-spacing: 0.5px;
	margin-bottom: 0.625rem;
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.explain-section-text {
	font-size: 0.875rem;
	line-height: 1.6;
	color: var(--text-secondary);
}

.explain-section-text strong {
	color: var(--text-primary);
	font-weight: 600;
}

/* Mobile Responsive */
@media (max-width: 768px) {
	.explain-trigger {
		padding: 0.75rem 1rem;
		font-size: 0.875rem;
	}
	
	.explain-chevron {
		width: 1rem;
		height: 1rem;
	}
	
	.explain-grid {
		grid-template-columns: 1fr;
		gap: 1.25rem;
		padding: 1.25rem;
	}
	
	.explain-section-title {
		font-size: 0.8125rem;
	}
	
	.explain-section-text {
		font-size: 0.8125rem;
	}
}

/* ==========================================================================
   SIGNAL FILTER (Dashboard-Identical)
   ========================================================================== */

/* Map Depth Display (Dashboard-style) */
.filter-results-display {
	display: flex;
	align-items: baseline;
	gap: 8px;
	padding: 12px 20px;
	background: rgba(16, 185, 129, 0.08);
	border: 1px solid rgba(16, 185, 129, 0.2);
	border-radius: 12px;
}

.filter-results-control {
	position: relative;
	min-width: 0;
}

.filter-results-trigger {
	appearance: none;
	width: 100%;
	align-items: center;
	justify-content: center;
	border: 1px solid rgba(16, 185, 129, 0.2);
	color: inherit;
	font: inherit;
	cursor: pointer;
	white-space: nowrap;
	transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.filter-results-trigger:hover,
.filter-results-trigger:focus-visible {
	background: rgba(16, 185, 129, 0.12);
	border-color: rgba(16, 185, 129, 0.45);
	box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
	outline: none;
}

.filter-results-trigger:active {
	transform: translateY(1px);
}

.filter-results-chevron {
	width: 16px;
	height: 16px;
	flex: 0 0 16px;
	color: var(--text-tertiary);
	transition: transform 160ms ease, color 160ms ease;
}

.filter-results-chevron.open {
	color: var(--accent-primary);
	transform: rotate(180deg);
}

.filter-results-menu {
	position: absolute;
	top: calc(100% + 8px);
	right: 0;
	z-index: 80;
	min-width: 236px;
	padding: 10px;
	background: rgba(15, 23, 42, 0.98);
	backdrop-filter: blur(16px) saturate(160%);
	border: 1px solid rgba(59, 130, 246, 0.24);
	border-radius: 12px;
	box-shadow: 0 18px 42px rgba(0, 0, 0, 0.36), 0 0 0 1px rgba(255, 255, 255, 0.03) inset;
	transform-origin: top right;
}

.filter-results-menu-title {
	padding: 2px 4px 8px;
	color: var(--text-tertiary);
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

.filter-results-option {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	min-height: 38px;
	padding: 8px 10px;
	background: transparent;
	border: 1px solid transparent;
	border-radius: 8px;
	color: var(--text-secondary);
	cursor: pointer;
	transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}

.filter-results-option:hover,
.filter-results-option:focus-visible {
	background: rgba(59, 130, 246, 0.1);
	border-color: rgba(59, 130, 246, 0.2);
	color: var(--text-primary);
	outline: none;
}

.filter-results-option.active {
	background: rgba(16, 185, 129, 0.14);
	border-color: rgba(16, 185, 129, 0.36);
	color: var(--accent-primary);
}

.filter-results-option-value {
	font-family: 'JetBrains Mono', monospace;
	font-size: 15px;
	font-weight: 800;
}

.filter-results-option-label {
	color: var(--text-tertiary);
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.filter-results-custom {
	margin-top: 8px;
	padding-top: 10px;
	border-top: 1px solid rgba(148, 163, 184, 0.16);
}

.filter-results-custom-label {
	display: block;
	margin-bottom: 6px;
	color: var(--text-tertiary);
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

.filter-results-custom-row {
	display: flex;
	gap: 8px;
}

.filter-results-custom-input {
	width: 100%;
	min-width: 0;
	height: 38px;
	padding: 0 10px;
	background: rgba(2, 6, 23, 0.52);
	border: 1px solid rgba(148, 163, 184, 0.22);
	border-radius: 8px;
	color: var(--text-primary);
	font-family: 'JetBrains Mono', monospace;
	font-size: 14px;
	font-weight: 800;
}

.filter-results-custom-input:focus {
	border-color: rgba(59, 130, 246, 0.55);
	box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.14);
	outline: none;
}

.filter-results-custom-apply {
	height: 38px;
	padding: 0 12px;
	background: rgba(59, 130, 246, 0.14);
	border: 1px solid rgba(59, 130, 246, 0.28);
	border-radius: 8px;
	color: #60a5fa;
	font-size: 12px;
	font-weight: 800;
	cursor: pointer;
	transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}

.filter-results-custom-apply:hover,
.filter-results-custom-apply:focus-visible {
	background: rgba(59, 130, 246, 0.22);
	border-color: rgba(59, 130, 246, 0.44);
	color: #93c5fd;
	outline: none;
}

.filter-results-hint {
	margin-top: 7px;
	color: var(--text-tertiary);
	font-size: 11px;
	line-height: 1.3;
}

.filter-results-count {
	display: flex;
	align-items: baseline;
	gap: 4px;
	font-size: 20px;
	font-weight: 700;
	color: var(--accent-primary);
	font-family: 'JetBrains Mono', monospace;
	line-height: 1;
}

.filter-results-separator {
	font-size: 14px;
	font-weight: 500;
	color: var(--text-tertiary);
	margin: 0 2px;
}

.filter-results-label {
	font-size: 13px;
	font-weight: 600;
	color: var(--text-secondary);
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

/* Clear All Button (Dashboard-style) */
.clear-all-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 12px 20px;
	background: rgba(239, 68, 68, 0.1);
	border: 1px solid rgba(239, 68, 68, 0.2);
	border-radius: 12px;
	font-size: 14px;
	font-weight: 600;
	color: #ef4444;
	cursor: pointer;
	transition: all 200ms cubic-bezier(0.4, 0, 0.2, 1);
	white-space: nowrap;
}

.clear-all-btn:hover {
	background: rgba(239, 68, 68, 0.2);
	border-color: #ef4444;
	transform: translateY(-1px);
	box-shadow: 0 4px 16px rgba(239, 68, 68, 0.3);
}

.clear-all-btn svg {
	width: 16px;
	height: 16px;
}

/* ==========================================================================
   CONTROL BAR - Bloomberg Terminal Style
   ========================================================================== */

.maps-control-bar {
	display: flex;
	flex-wrap: wrap;
	gap: 24px;
	align-items: center;
	padding: 24px;
	background: var(--bg-elevated);
	border: 1px solid var(--border-color);
	border-radius: 16px;
	margin-bottom: 32px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
	transition: box-shadow 200ms ease;
}

.maps-control-bar:hover {
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

/* Type Tabs (Crypto / Indices) */
.maps-type-tabs {
	display: flex;
	gap: 8px;
	background: var(--bg-secondary);
	padding: 4px;
	border-radius: 12px;
}

.maps-tab {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 20px;
	border: none;
	background: transparent;
	color: var(--text-secondary);
	font-size: 15px;
	font-weight: 600;
	border-radius: 8px;
	cursor: pointer;
	transition: all 200ms cubic-bezier(0.4, 0, 0.2, 1);
	position: relative;
}

.maps-tab svg {
	width: 20px;
	height: 20px;
	transition: transform 200ms;
}

.maps-tab:hover {
	background: rgba(16, 185, 129, 0.08);
	color: var(--accent-primary);
	transform: translateY(-1px);
}

.maps-tab:hover svg {
	transform: scale(1.1);
}

.maps-tab.active {
	background: var(--accent-primary);
	color: white;
	box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.maps-tab.active svg {
	transform: scale(1.05);
}

.maps-tab-count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 24px;
	height: 24px;
	padding: 0 6px;
	background: rgba(255, 255, 255, 0.25);
	backdrop-filter: blur(12px);
	border-radius: 12px;
	font-size: 12px;
	font-weight: 700;
	margin-left: 4px;
}

/* Range Selector (1M / 3M / 6M / YTD / 1Y / 3Y / 5Y / MAX) */
.maps-range-selector {
	display: flex;
	align-items: center;
	gap: 12px;
}

.maps-range-label {
	font-size: 13px;
	font-weight: 600;
	color: var(--text-secondary);
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

.maps-layout-selector {
	display: flex;
	align-items: center;
	gap: 12px;
}

.maps-layout-label {
	font-size: 13px;
	font-weight: 600;
	color: var(--text-secondary);
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

.maps-layout-control .segmented-btn {
	min-width: 72px;
}

.segmented-control {
	display: flex;
	background: var(--bg-secondary);
	padding: 4px;
	border-radius: 12px;
	border: 1px solid var(--border-color);
}

.segmented-btn {
	padding: 8px 20px;
	border: none;
	background: transparent;
	color: var(--text-secondary);
	font-size: 14px;
	font-weight: 600;
	border-radius: 8px;
	cursor: pointer;
	transition: all 200ms cubic-bezier(0.4, 0, 0.2, 1);
	min-width: 56px;
	text-align: center;
}

.segmented-btn:hover {
	background: rgba(16, 185, 129, 0.08);
	color: var(--text-primary);
}

.segmented-btn.active {
	background: white;
	color: var(--accent-primary);
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

/* Dark mode adjustments */
:root[data-theme="dark"] .segmented-btn.active {
	background: var(--bg-elevated);
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Rank Preset Selector (Top/Bottom 15 / 30 / 50) */
.maps-subset-selector {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-left: auto; /* Push to right on desktop */
}

.maps-subset-label {
	font-size: 13px;
	font-weight: 600;
	color: var(--text-secondary);
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

.rank-preset-groups {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	justify-content: flex-end;
}

.rank-preset-group {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	min-height: 40px;
	padding: 3px;
	background: var(--bg-primary);
	border: 1px solid var(--border-color);
	border-radius: 10px;
}

.rank-preset-label {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 0 9px;
	color: var(--text-secondary);
	font-size: 12px;
	font-weight: 700;
	line-height: 1;
	white-space: nowrap;
}

.rank-preset-label svg {
	width: 15px;
	height: 15px;
	flex-shrink: 0;
}

.rank-preset-values {
	display: inline-flex;
	gap: 3px;
}

.rank-preset-btn {
	min-width: 38px;
	height: 32px;
	padding: 0 10px;
	border: none;
	background: transparent;
	color: var(--text-secondary);
	font-family: 'JetBrains Mono', monospace;
	font-size: 12px;
	font-weight: 800;
	border-radius: 7px;
	cursor: pointer;
	transition: all 180ms ease;
}

.rank-preset-btn:hover {
	background: rgba(16, 185, 129, 0.08);
	color: var(--text-primary);
}

.rank-preset-btn.active {
	color: white;
}

.rank-preset-group-top .rank-preset-btn.active {
	background: #059669;
	box-shadow: 0 3px 10px rgba(5, 150, 105, 0.35);
}

.rank-preset-group-bottom .rank-preset-btn.active {
	background: #dc2626;
	box-shadow: 0 3px 10px rgba(220, 38, 38, 0.35);
}

/* Display Limit Selector (for large datasets like Stocks) */
.maps-limit-selector {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-left: auto;
}

.limit-dropdown {
	position: relative;
}

.limit-dropdown-trigger {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px 16px;
	background: var(--bg-secondary);
	border: 1px solid var(--border-color);
	border-radius: 10px;
	color: var(--text-primary);
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	transition: all 200ms ease;
	white-space: nowrap;
}

.limit-dropdown-trigger:hover {
	background: var(--bg-elevated);
	border-color: var(--accent-primary);
}

.limit-dropdown-menu {
	position: absolute;
	top: calc(100% + 8px);
	right: 0;
	min-width: 140px;
	background: var(--bg-card);
	border: 1px solid var(--border-color);
	border-radius: 12px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
	z-index: 50;
	overflow: hidden;
}

.limit-dropdown-option {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	padding: 10px 16px;
	background: transparent;
	border: none;
	color: var(--text-secondary);
	font-size: 13px;
	font-weight: 500;
	cursor: pointer;
	transition: all 150ms ease;
}

.limit-dropdown-option:hover {
	background: var(--bg-hover);
	color: var(--text-primary);
}

.limit-dropdown-option.active {
	background: var(--accent-primary-alpha);
	color: var(--accent-primary);
	font-weight: 600;
}

.limit-dropdown-option svg {
	color: var(--accent-primary);
}

/* Custom Input for Limit */
.limit-custom-wrapper {
	border-top: 1px solid var(--border-color);
}

.limit-custom-input {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px 12px;
}

.limit-input {
	flex: 1;
	padding: 8px 12px;
	background: var(--bg-secondary);
	border: 1px solid var(--border-color);
	border-radius: 8px;
	color: var(--text-primary);
	font-size: 13px;
	font-weight: 500;
	outline: none;
	transition: all 150ms ease;
}

.limit-input:focus {
	border-color: var(--accent-primary);
	box-shadow: 0 0 0 3px var(--accent-primary-alpha);
}

.limit-input::placeholder {
	color: var(--text-tertiary);
}

.limit-apply-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	background: var(--accent-primary);
	border: none;
	border-radius: 8px;
	color: white;
	cursor: pointer;
	transition: all 150ms ease;
}

.limit-apply-btn:hover {
	background: var(--accent-primary-hover);
	transform: scale(1.05);
}

/* Segmented Control (iOS Style) - ORIGINAL STYLE */
.segmented-control {
	display: inline-flex;
	background: var(--bg-secondary);
	padding: 4px;
	border-radius: 10px;
	border: 1px solid var(--border-color);
	gap: 4px;
}

.segmented-btn {
	padding: 8px 20px;
	border: none;
	background: transparent;
	color: var(--text-secondary);
	font-size: 13px;
	font-weight: 600;
	border-radius: 7px;
	cursor: pointer;
	transition: all 200ms cubic-bezier(0.4, 0, 0.2, 1);
	white-space: nowrap;
	letter-spacing: 0.015em;
}

.segmented-btn:hover {
	color: var(--text-primary);
	background: rgba(255, 255, 255, 0.05);
}

.segmented-btn.active {
	background: var(--bg-elevated);
	color: var(--text-primary);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Compact variant for multi-row time windows (1M, 3M, 6M, YTD, 1Y, 2Y, 3Y, 5Y, ALL) */
.segmented-btn-compact {
	padding: 6px 14px;
	font-size: 12px;
	min-width: 48px;
}

.segmented-btn-compact:hover {
	transform: translateY(-1px);
}

.segmented-btn-compact.active {
	transform: translateY(0);
}

/* ==========================================================================
   D3.JS TREEMAP CONTAINER - Bloomberg Finance Grade
   ========================================================================== */

.treemap-wrapper {
	position: relative;
	animation: fadeIn 400ms ease;
	margin-bottom: 32px;
	transition: opacity 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Bloomberg-grade transition state (smooth fade, no height jump) */
.treemap-wrapper[x-show="transitioning"] {
	opacity: 0.3;
	pointer-events: none;
	position: relative;
}

/* Maintain height during transition to prevent layout shift */
.treemap-wrapper[x-show="transitioning"] .treemap-d3-container {
	min-height: 600px; /* Force height during transition */
}

.treemap-sort-label {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 16px;
	margin-bottom: 12px;
	background: rgba(59, 130, 246, 0.1);
	border: 1px solid rgba(59, 130, 246, 0.3);
	border-radius: 8px;
	color: var(--text-secondary);
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.02em;
}

.treemap-sort-label svg {
	color: var(--accent-primary);
	flex-shrink: 0;
}

.treemap-sort-label-mobile {
	display: none;
}

.maps-podium {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 8px;
	margin-bottom: 12px;
}

.maps-podium-item {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
	padding: 9px 12px;
	background: rgba(15, 23, 42, 0.72);
	border: 1px solid rgba(59, 130, 246, 0.2);
	border-radius: 8px;
	color: var(--text-primary);
	cursor: pointer;
	transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.maps-podium-item:hover {
	background: rgba(18, 27, 46, 0.88);
	border-color: rgba(59, 130, 246, 0.42);
	transform: translateY(-1px);
}

.maps-podium-medal {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	flex: 0 0 28px;
	font-size: 21px;
	line-height: 1;
	filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}

.maps-podium-main {
	display: flex;
	flex: 1;
	flex-direction: column;
	min-width: 0;
	gap: 2px;
	text-align: left;
}

.maps-podium-name,
.maps-podium-symbol {
	display: block;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.maps-podium-name {
	color: var(--text-primary);
	font-size: 12px;
	font-weight: 700;
}

.maps-podium-symbol {
	color: var(--text-tertiary);
	font-family: 'JetBrains Mono', monospace;
	font-size: 10px;
	font-weight: 600;
	text-transform: uppercase;
}

.maps-podium-performance {
	flex: 0 0 auto;
	color: var(--gain);
	font-family: 'JetBrains Mono', monospace;
	font-size: 13px;
	font-weight: 800;
}

.treemap-d3-container {
	position: relative;
	width: 100%;
	min-height: 600px;
	background: rgba(17, 24, 39, 0.3); /* Subtle dark background */
	border-radius: 16px;
	padding: 12px;
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
	overflow: hidden;
}

/* Bloomberg-grade Transition Overlay (Skeleton Loader) */
.treemap-transition-overlay {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(17, 24, 39, 0.95);
	backdrop-filter: blur(8px);
	-webkit-backdrop-filter: blur(8px);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	z-index: 50;
	animation: fadeIn 200ms ease;
	border-radius: 16px;
	padding: 12px;
}

.treemap-skeleton-grid {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 8px;
	width: 100%;
	max-width: 900px;
	margin-bottom: 20px;
}

.skeleton-tile {
	border-radius: 8px;
	background: linear-gradient(
		90deg,
		rgba(75, 85, 99, 0.3) 0%,
		rgba(107, 114, 128, 0.4) 50%,
		rgba(75, 85, 99, 0.3) 100%
	);
	background-size: 200% 100%;
	animation: shimmer 1.5s ease-in-out infinite;
	min-height: 120px;
}

.skeleton-tile-lg {
	grid-column: span 2;
	grid-row: span 2;
	min-height: 250px;
}

.skeleton-tile-md {
	grid-column: span 1;
	grid-row: span 1;
	min-height: 120px;
}

.skeleton-tile-sm {
	grid-column: span 1;
	grid-row: span 1;
	min-height: 100px;
}

@keyframes shimmer {
	0% {
		background-position: -200% 0;
	}
	100% {
		background-position: 200% 0;
	}
}

.skeleton-loader-text {
	color: var(--text-tertiary);
	font-size: 14px;
	font-weight: 500;
	letter-spacing: 0.05em;
	animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
	0%, 100% {
		opacity: 0.5;
	}
	50% {
		opacity: 1;
	}
}

/* Light mode overrides */
:root:not(.dark) .treemap-d3-container {
	background: rgba(249, 250, 251, 0.8);
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
	border: 1px solid var(--border-primary);
}

:root:not(.dark) .treemap-transition-overlay {
	background: rgba(249, 250, 251, 0.95);
}

:root:not(.dark) .skeleton-tile {
	background: linear-gradient(
		90deg,
		rgba(209, 213, 219, 0.5) 0%,
		rgba(229, 231, 235, 0.7) 50%,
		rgba(209, 213, 219, 0.5) 100%
	);
	background-size: 200% 100%;
}

:root:not(.dark) .maps-tab {
	color: var(--text-primary);
	background: var(--bg-secondary);
}

:root:not(.dark) .maps-tab.active {
	color: white; /* Keep white on blue accent */
}

:root:not(.dark) .rank-preset-group {
	color: var(--text-primary);
	background: var(--bg-secondary);
	border-color: var(--border-primary);
}

:root:not(.dark) .rank-preset-label,
:root:not(.dark) .rank-preset-btn {
	color: var(--text-secondary);
}

:root:not(.dark) .rank-preset-btn:hover {
	background: rgba(59, 130, 246, 0.08);
	color: var(--text-primary);
}

:root:not(.dark) .rank-preset-btn.active {
	color: white !important;
}

:root:not(.dark) .rank-preset-group-top .rank-preset-btn.active {
	background: #059669 !important;
	box-shadow: 0 3px 10px rgba(5, 150, 105, 0.35) !important;
}

:root:not(.dark) .rank-preset-group-bottom .rank-preset-btn.active {
	background: #dc2626 !important;
	box-shadow: 0 3px 10px rgba(220, 38, 38, 0.35) !important;
}

:root:not(.dark) .filter-results-menu {
	background: rgba(255, 255, 255, 0.98);
	border-color: rgba(59, 130, 246, 0.18);
	box-shadow: 0 18px 42px rgba(15, 23, 42, 0.14), 0 0 0 1px rgba(15, 23, 42, 0.03) inset;
}

:root:not(.dark) .filter-results-custom {
	border-top-color: rgba(15, 23, 42, 0.1);
}

:root:not(.dark) .filter-results-custom-input {
	background: rgba(248, 250, 252, 0.96);
	border-color: rgba(15, 23, 42, 0.14);
	color: var(--text-primary);
}

:root:not(.dark) .maps-stats {
	background: var(--bg-secondary);
	border-color: var(--border-primary);
}

:root:not(.dark) .stat-label {
	color: var(--text-secondary);
}

:root:not(.dark) .stat-value {
	color: var(--text-primary);
}

:root:not(.dark) .treemap-sort-label {
	color: var(--text-primary);
	background: rgba(59, 130, 246, 0.08);
}

:root:not(.dark) .maps-podium-item {
	background: rgba(255, 255, 255, 0.92);
	border-color: rgba(59, 130, 246, 0.18);
	box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
}

:root:not(.dark) .maps-podium-item:hover {
	background: rgba(248, 250, 252, 1);
	border-color: rgba(59, 130, 246, 0.36);
}

:root:not(.dark) .maps-podium-name {
	color: #0f172a;
}

:root:not(.dark) .maps-podium-symbol {
	color: #64748b;
}

/* Bloomberg-grade Loading Skeleton */
.treemap-skeleton {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	padding: 24px;
}

.skeleton-grid {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 12px;
	height: 100%;
}

.skeleton-tile {
	background: linear-gradient(
		90deg,
		rgba(71, 85, 105, 0.3) 0%,
		rgba(100, 116, 139, 0.5) 50%,
		rgba(71, 85, 105, 0.3) 100%
	);
	background-size: 200% 100%;
	animation: shimmer 1.5s infinite;
	border-radius: 12px;
	border: 2px solid rgba(96, 165, 250, 0.1);
}

.skeleton-tile-xl {
	grid-column: span 2;
	grid-row: span 2;
}

.skeleton-tile-lg {
	grid-column: span 2;
}

.skeleton-tile-md {
	grid-column: span 1;
}

.skeleton-tile-sm {
	grid-column: span 1;
}

@keyframes shimmer {
	0% {
		background-position: -200% 0;
	}
	100% {
		background-position: 200% 0;
	}
}

/* D3 SVG Treemap Styles */
.treemap-svg {
	display: block;
	font-family: Inter, system-ui, sans-serif;
}

/* Treemap Tile Group */
.treemap-tile {
	transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Text inside tiles - handled by D3 */
.tile-symbol,
.tile-performance {
	text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
	user-select: none;
}

/* Responsive adjustments */
@media (max-width: 767px) {
	.treemap-d3-container {
		min-height: 500px;
		padding: 8px;
		border-radius: 12px;
	}
	
	.treemap-skeleton-grid {
		grid-template-columns: repeat(2, 1fr);
		gap: 6px;
	}
	
	.skeleton-tile-lg {
		min-height: 180px;
	}
}

@media (min-width: 1920px) {
	.treemap-d3-container {
		min-height: 700px;
	}
}

/* Note: Treemap tiles are now rendered by D3.js SVG.
   CSS styling is applied inline via D3 for better performance.
   See main-standalone.js > renderTreemap() for visual styling. */

/* ==========================================================================
   D3 TOOLTIP - Bloomberg Terminal Elite
   ========================================================================== */

.treemap-tooltip-d3 {
	position: absolute;
	z-index: 999999;
	background: linear-gradient(135deg, rgba(17, 24, 39, 0.98) 0%, rgba(31, 41, 55, 0.98) 100%);
	backdrop-filter: blur(20px) saturate(180%);
	border: 1px solid rgba(96, 165, 250, 0.3);
	border-radius: 16px;
	padding: 20px;
	box-shadow: 
		0 12px 48px rgba(0, 0, 0, 0.5),
		0 0 0 1px rgba(255, 255, 255, 0.05) inset;
	pointer-events: none;
	transform: translate(-50%, calc(-100% - 16px));
	min-width: 240px;
	animation: tooltipSlideUp 250ms cubic-bezier(0.16, 1, 0.3, 1);
	font-family: Inter, system-ui, sans-serif;
}

@keyframes tooltipSlideUp {
	from {
		opacity: 0;
		transform: translate(-50%, calc(-100% - 8px));
	}
	to {
		opacity: 1;
		transform: translate(-50%, calc(-100% - 16px));
	}
}

.tooltip-header {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-bottom: 12px;
}

.tooltip-rank {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
	border-radius: 8px;
	font-size: 14px;
	font-weight: 900;
	color: white;
	box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.tooltip-symbol {
	font-size: 22px;
	font-weight: 900;
	color: white;
	letter-spacing: -0.02em;
	text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.tooltip-name {
	font-size: 13px;
	font-weight: 500;
	color: rgba(255, 255, 255, 0.75);
	margin-bottom: 16px;
	line-height: 1.4;
}

.tooltip-perf {
	display: flex;
	align-items: baseline;
	gap: 4px;
	font-size: 28px;
	font-weight: 900;
	font-family: 'JetBrains Mono', monospace;
	font-variant-numeric: tabular-nums;
	margin-bottom: 12px;
	line-height: 1;
}

.tooltip-perf.gain {
	color: #10b981;
	text-shadow: 0 0 24px rgba(16, 185, 129, 0.4);
}

.tooltip-perf.loss {
	color: #ef4444;
	text-shadow: 0 0 24px rgba(239, 68, 68, 0.4);
}

.tooltip-sign {
	font-size: 20px;
	font-weight: 700;
}

.tooltip-vs-avg {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 10px 14px;
	background: rgba(0, 0, 0, 0.3);
	border-radius: 10px;
	font-size: 13px;
	font-weight: 600;
	margin-bottom: 14px;
	font-family: 'JetBrains Mono', monospace;
}

.tooltip-vs-avg .tooltip-label {
	color: rgba(255, 255, 255, 0.6);
	text-transform: uppercase;
	letter-spacing: 0.05em;
	font-size: 11px;
}

.tooltip-vs-avg.gain {
	color: #10b981;
	background: rgba(16, 185, 129, 0.1);
	border: 1px solid rgba(16, 185, 129, 0.2);
}

.tooltip-vs-avg.loss {
	color: #ef4444;
	background: rgba(239, 68, 68, 0.1);
	border: 1px solid rgba(239, 68, 68, 0.2);
}

.tooltip-hint {
	text-align: center;
	font-size: 11px;
	font-weight: 500;
	color: rgba(255, 255, 255, 0.4);
	text-transform: uppercase;
	letter-spacing: 0.08em;
	padding-top: 10px;
	border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* Old tooltip - keep for backwards compatibility */
.maps-tooltip {
	position: fixed;
	z-index: 999999;
	background: rgba(31, 41, 55, 0.98);
	backdrop-filter: blur(16px) saturate(150%);
	border: 1px solid rgba(255, 255, 255, 0.1);
	border-radius: 12px;
	padding: 16px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
	pointer-events: none;
	transform: translate(-50%, -100%);
	min-width: 200px;
	animation: tooltipFadeIn 200ms ease;
}

@keyframes tooltipFadeIn {
	from {
		opacity: 0;
		transform: translate(-50%, calc(-100% - 8px));
	}
	to {
		opacity: 1;
		transform: translate(-50%, -100%);
	}
}

.maps-tooltip-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 8px;
}

.maps-tooltip-symbol {
	font-size: 20px;
	font-weight: 900;
	color: white;
	letter-spacing: -0.02em;
}

.maps-tooltip-perf {
	font-size: 16px;
	font-weight: 700;
	padding: 4px 10px;
	border-radius: 8px;
	font-variant-numeric: tabular-nums;
}

.maps-tooltip-perf.gain {
	background: rgba(5, 150, 105, 0.2);
	color: #10b981;
}

.maps-tooltip-perf.loss {
	background: rgba(220, 38, 38, 0.2);
	color: #ef4444;
}

.maps-tooltip-name {
	font-size: 14px;
	font-weight: 500;
	color: rgba(255, 255, 255, 0.9);
	margin-bottom: 4px;
}

.maps-tooltip-type {
	font-size: 11px;
	font-weight: 600;
	color: rgba(255, 255, 255, 0.5);
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

/* ==========================================================================
   STATS CARDS - Summary Metrics
   ========================================================================== */

.maps-stats {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
	gap: 16px;
	margin-top: 32px;
}

.stat-card {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 20px;
	background: var(--bg-elevated);
	border: 1px solid var(--border-color);
	border-radius: 12px;
	transition: all 200ms ease;
}

.stat-card:hover {
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
	transform: translateY(-2px);
}

.stat-card-gain {
	border-left: 4px solid #10b981;
}

.stat-card-loss {
	border-left: 4px solid #ef4444;
}

.stat-label {
	font-size: 13px;
	font-weight: 600;
	color: var(--text-secondary);
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

.stat-value {
	font-size: 32px;
	font-weight: 900;
	color: var(--text-primary);
	letter-spacing: -0.02em;
	font-variant-numeric: tabular-nums;
}

.stat-value.gain {
	color: #10b981;
}

.stat-value.loss {
	color: #ef4444;
}

@media (max-width: 767px) {
	.maps-stats {
		grid-template-columns: repeat(2, 1fr);
	}
	
	.stat-value {
		font-size: 24px;
	}
}

/* ==========================================================================
   LOADING STATE
   ========================================================================== */

.maps-loading {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	min-height: 500px;
	gap: 24px;
}

.loading-spinner {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 16px;
}

.loading-spinner svg {
	color: var(--accent-primary);
}

.loading-spinner p {
	font-size: 16px;
	font-weight: 600;
	color: var(--text-secondary);
	animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
	0%, 100% {
		opacity: 1;
	}
	50% {
		opacity: 0.5;
	}
}

/* ==========================================================================
   EMPTY STATE
   ========================================================================== */

.empty-state {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 500px;
	padding: 48px;
}

.empty-state-content {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 24px;
	max-width: 400px;
	text-align: center;
}

.empty-state-icon {
	width: 64px;
	height: 64px;
	color: var(--text-tertiary);
	opacity: 0.5;
}

.empty-state h3 {
	font-size: 24px;
	font-weight: 700;
	color: var(--text-primary);
	margin: 0;
}

.empty-state p {
	font-size: 16px;
	color: var(--text-secondary);
	margin: 0;
	line-height: 1.6;
}

.empty-state .btn-primary {
	margin-top: 8px;
	padding: 12px 24px;
	font-size: 15px;
	font-weight: 600;
	background: var(--accent-primary);
	color: white;
	border: none;
	border-radius: 10px;
	cursor: pointer;
	transition: all 200ms ease;
}

.empty-state .btn-primary:hover {
	background: #059669;
	transform: translateY(-2px);
	box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

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

@keyframes fadeIn {
	from {
		opacity: 0;
		transform: translateY(16px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* ==========================================================================
   RESPONSIVE ADJUSTMENTS
   ========================================================================== */

@media (max-width: 767px) {
	.maps-control-bar {
		flex-direction: column;
		align-items: stretch;
		gap: 16px;
	}

	.maps-type-tabs,
	.maps-range-selector,
	.maps-subset-selector {
		width: 100%;
	}

	.maps-range-selector,
	.maps-subset-selector {
		flex-direction: column;
		align-items: stretch;
		gap: 8px;
	}

	.segmented-control,
	.rank-preset-groups {
		width: 100%;
		justify-content: stretch;
	}

	.segmented-btn {
		flex: 1;
		justify-content: center;
	}

	.rank-preset-group {
		flex: 1 1 0;
		justify-content: space-between;
	}

	.maps-subset-selector {
		margin-left: 0;
	}
}

@media (min-width: 768px) and (max-width: 1023px) {
	.maps-control-bar {
		justify-content: space-between;
	}

	.maps-subset-selector {
		margin-left: 0;
	}
}
