/**
 * CMC Chart Styles
 *
 * Theme colors are set via CSS custom properties on .cmc-chart-wrapper,
 * injected by ChartAssets.php from admin settings.
 *
 * Uses !important on button styles to override WordPress theme globals.
 */

/* Container */
.cmc-chart-wrapper {
	position: relative;
	background: var(--chart-bg, #0D1421);
	border-radius: 8px;
	overflow: hidden;
	font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

/* Control bar */
.cmc-chart-controls {
	display: flex !important;
	flex-direction: row !important;
	align-items: center !important;
	justify-content: space-between !important;
	padding: 12px 16px 0 !important;
	gap: 12px !important;
	flex-wrap: wrap !important;
}

.cmc-chart-metrics {
	display: inline-flex !important;
	flex-direction: row !important;
	gap: 2px !important;
	background: rgba(255,255,255,0.06) !important;
	border-radius: 6px !important;
	padding: 2px !important;
}

/* Shared button reset — override all theme button styles */
.cmc-chart-wrapper button.cmc-metric-btn,
.cmc-chart-wrapper button.cmc-range-btn,
.cmc-chart-wrapper button.cmc-log-btn {
	padding: 6px 14px !important;
	border: none !important;
	border-radius: 5px !important;
	background: transparent !important;
	color: var(--chart-text, #E1E4EB) !important;
	font-size: 12px !important;
	font-weight: 500 !important;
	cursor: pointer !important;
	transition: background 0.15s, color 0.15s !important;
	box-sizing: border-box !important;
	line-height: 1.4 !important;
	margin: 0 !important;
	text-transform: none !important;
	letter-spacing: normal !important;
	min-width: auto !important;
	box-shadow: none !important;
	outline: none !important;
}

.cmc-chart-wrapper button.cmc-metric-btn {
	padding: 6px 16px !important;
	font-size: 13px !important;
}

.cmc-chart-wrapper button.cmc-metric-btn:hover,
.cmc-chart-wrapper button.cmc-range-btn:hover,
.cmc-chart-wrapper button.cmc-log-btn:hover {
	background: rgba(255,255,255,0.08) !important;
}

.cmc-chart-wrapper button.cmc-metric-btn.active,
.cmc-chart-wrapper button.cmc-range-btn.active,
.cmc-chart-wrapper button.cmc-log-btn.active {
	background: rgba(255,255,255,0.15) !important;
	color: #fff !important;
}

/* Timeframe controls container */
.cmc-chart-timeframes {
	display: inline-flex !important;
	flex-direction: row !important;
	align-items: center !important;
	gap: 2px !important;
	background: rgba(255,255,255,0.06) !important;
	border-radius: 6px !important;
	padding: 2px !important;
}

/* Desktop: show buttons, hide dropdown */
.cmc-range-buttons-desktop {
	display: inline-flex !important;
	flex-direction: row !important;
	gap: 2px !important;
}

.cmc-range-select-mobile {
	display: none !important;
}

.cmc-chart-wrapper button.cmc-log-btn {
	margin-left: 4px !important;
}

/* Chart header (live price on hover) */
.cmc-chart-header {
	padding: 8px 16px 0;
	min-height: 32px;
	display: flex;
	align-items: baseline;
	gap: 8px;
	flex-wrap: wrap;
}

.cmc-chart-value {
	font-size: 20px;
	font-weight: 600;
	color: #fff;
}

/* Subscript styling for small-value prices */
.cmc-chart-value sub {
	font-size: 0.7em;
	vertical-align: baseline;
	position: relative;
	bottom: -0.15em;
	color: rgba(255,255,255,0.6);
}

.cmc-chart-change {
	font-size: 14px;
	font-weight: 500;
	color: rgba(255,255,255,0.6);
}

.cmc-chart-change.positive { color: var(--chart-positive, #16C784); }
.cmc-chart-change.negative { color: var(--chart-negative, #EA3943); }

.cmc-chart-date {
	font-size: 12px;
	color: rgba(255,255,255,0.4);
}

/* Floating tooltip */
.cmc-chart-tooltip {
	display: none;
	position: absolute;
	z-index: 20;
	padding: 8px 12px;
	background: rgba(15, 23, 42, 0.92);
	border: 1px solid rgba(255,255,255,0.1);
	border-radius: 6px;
	pointer-events: none;
	white-space: nowrap;
	backdrop-filter: blur(8px);
	box-shadow: 0 4px 12px rgba(0,0,0,0.3);
	font-family: inherit;
}

.cmc-tooltip-price {
	font-size: 14px;
	font-weight: 600;
	color: #fff;
	line-height: 1.4;
}

.cmc-tooltip-price sub {
	font-size: 0.7em;
	vertical-align: baseline;
	position: relative;
	bottom: -0.15em;
	color: rgba(255,255,255,0.6);
}

.cmc-tooltip-vol {
	font-size: 11px;
	color: rgba(255,255,255,0.5);
	line-height: 1.4;
}

.cmc-tooltip-date {
	font-size: 11px;
	color: rgba(255,255,255,0.4);
	line-height: 1.4;
}

/* Chart canvas */
.cmc-chart-canvas {
	width: 100% !important;
	min-height: 400px;
	position: relative;
}

/* Loading overlay */
.cmc-chart-loading {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	display: none;
	align-items: center;
	justify-content: center;
	background: rgba(13, 20, 33, 0.75);
	z-index: 10;
	transition: opacity 0.2s ease;
}

.cmc-chart-loading.visible {
	display: flex;
}

.cmc-chart-spinner {
	width: 32px;
	height: 32px;
	border: 3px solid rgba(255,255,255,0.15);
	border-top-color: var(--chart-positive, #16C784);
	border-radius: 50%;
	animation: cmc-chart-spin 0.8s linear infinite;
}

@keyframes cmc-chart-spin {
	to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 600px) {
	.cmc-chart-controls {
		flex-direction: row !important;
		align-items: center !important;
		justify-content: space-between !important;
	}

	/* Hide pill buttons, show dropdown */
	.cmc-range-buttons-desktop {
		display: none !important;
	}

	.cmc-range-select-mobile {
		display: inline-block !important;
		appearance: none !important;
		-webkit-appearance: none !important;
		padding: 6px 28px 6px 10px !important;
		border: none !important;
		border-radius: 5px !important;
		background: rgba(255,255,255,0.10) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23ffffff80'/%3E%3C/svg%3E") no-repeat right 8px center !important;
		color: #fff !important;
		font-size: 12px !important;
		font-weight: 500 !important;
		font-family: inherit !important;
		cursor: pointer !important;
		outline: none !important;
		min-width: 70px !important;
	}

	.cmc-range-select-mobile option {
		background: #1E293B;
		color: #fff;
	}

	.cmc-chart-value {
		font-size: 16px;
	}
}
