/*
 * Statistics dashboard.
 * Everything is scoped under .ars-dashboard so other wp-admin screens stay untouched.
 * Data colors are fixed so charts read the same under every admin color scheme;
 * links and the period switch follow the admin accent.
 */

.ars-dashboard {
	--ars-accent: var(--wp-admin-theme-color, #2271b1);
	--ars-surface: #fff;
	--ars-border: #dcdcde;
	--ars-text: #1d2327;
	--ars-text-secondary: #50575e;
	--ars-muted: #757575;
	--ars-grid: #ececec;
	--ars-baseline: #c3c4c7;
	--ars-radius: 8px;

	/* Data colors: categorical slots 1-3, track, status. */
	--ars-series-1: #2a78d6;
	--ars-series-2: #eb6834;
	--ars-series-3: #1baf7a;
	--ars-track: #e5eefa;
	--ars-good: #0ca30c;
	--ars-good-text: #006300;
	--ars-warning: #c98500;
	--ars-critical: #d03b3b;
	--ars-notice: #898781;

	container-type: inline-size;
	max-width: 1440px;
	color: var(--ars-text);
}

.ars-dashboard h1 {
	margin-bottom: 4px;
}

/* Sections */

.ars-dash-section {
	display: flex;
	flex-direction: column;
	gap: 16px;
	margin-top: 28px;
}

.ars-dash-section__head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

.ars-dash-section__title {
	margin: 0;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.4;
}

/* Period switch */

.ars-dash-range {
	display: inline-flex;
	padding: 3px;
	border: 1px solid var(--ars-border);
	border-radius: 6px;
	background: var(--ars-surface);
}

.ars-dash-range__item {
	padding: 4px 12px;
	border-radius: 4px;
	color: var(--ars-text-secondary);
	font-size: 13px;
	line-height: 20px;
	text-decoration: none;
	white-space: nowrap;
}

.ars-dash-range__item:hover {
	background: #f0f0f1;
	color: var(--ars-text);
}

.ars-dash-range__item:focus {
	box-shadow: 0 0 0 2px var(--ars-accent);
	outline: none;
}

.ars-dash-range__item[aria-current="page"] {
	background: var(--ars-accent);
	color: #fff;
	font-weight: 600;
}

/* Notes */

.ars-dash-note {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	padding: 10px 14px;
	border: 1px solid var(--ars-border);
	border-left: 4px solid var(--ars-accent);
	border-radius: 4px;
	background: var(--ars-surface);
}

.ars-dash-note .dashicons {
	flex: none;
	color: var(--ars-accent);
}

.ars-dash-note p {
	margin: 0;
	color: var(--ars-text-secondary);
}

/* Tiles */

.ars-dash-tiles {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 16px;
}

.ars-dash-tile,
.ars-dash-card {
	min-width: 0;
	border: 1px solid var(--ars-border);
	border-radius: var(--ars-radius);
	background: var(--ars-surface);
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.ars-dash-tile {
	display: flex;
	flex-direction: column;
	gap: 6px;
	padding: 16px 18px;
}

.ars-dash-tile__label {
	display: flex;
	align-items: center;
	gap: 6px;
	color: var(--ars-text-secondary);
	font-size: 13px;
}

.ars-dash-tile__label .dashicons {
	width: 16px;
	height: 16px;
	color: var(--ars-muted);
	font-size: 16px;
}

.ars-dash-tile__value {
	font-size: 28px;
	font-weight: 600;
	line-height: 1.2;
	overflow-wrap: anywhere;
}

.ars-dash-tile__meta {
	color: var(--ars-muted);
	font-size: 12px;
	line-height: 1.5;
}

.ars-dash-delta {
	display: inline-flex;
	align-items: center;
	margin-right: 4px;
	font-weight: 600;
}

.ars-dash-delta .dashicons {
	width: 14px;
	height: 14px;
	font-size: 14px;
}

.ars-dash-delta--up {
	color: var(--ars-good-text);
}

.ars-dash-delta--down {
	color: var(--ars-critical);
}

.ars-dash-delta--flat {
	color: var(--ars-text-secondary);
}

/* Cards */

.ars-dash-grid {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 16px;
}

.ars-dash-card {
	display: flex;
	flex-direction: column;
	gap: 14px;
	padding: 18px;
}

.ars-dash-card__head {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: 4px 12px;
}

.ars-dash-card__title {
	margin: 0;
	font-size: 14px;
	font-weight: 600;
}

.ars-dash-card__meta {
	color: var(--ars-muted);
	font-size: 12px;
}

a.ars-dash-card__meta {
	color: var(--ars-accent);
}

.ars-dash-empty {
	margin: 0;
	padding: 24px 0;
	color: var(--ars-muted);
	text-align: center;
}

/* Charts (drawn by dashboard.js) */

.ars-chart {
	position: relative;
	height: 240px;
}

.ars-chart svg {
	display: block;
	overflow: visible;
}

.ars-chart svg:focus {
	outline: none;
}

.ars-chart svg:focus-visible {
	border-radius: 4px;
	box-shadow: 0 0 0 2px var(--ars-accent);
}

.ars-chart__grid {
	stroke: var(--ars-grid);
	stroke-width: 1;
	shape-rendering: crispEdges;
}

.ars-chart__baseline {
	stroke: var(--ars-baseline);
	stroke-width: 1;
	shape-rendering: crispEdges;
}

.ars-chart__tick {
	fill: var(--ars-muted);
	font-size: 11px;
	font-variant-numeric: tabular-nums;
}

.ars-chart__line {
	fill: none;
	stroke: var(--ars-series-1);
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.ars-chart__area {
	fill: var(--ars-series-1);
	fill-opacity: 0.1;
}

.ars-chart__crosshair {
	stroke: var(--ars-baseline);
	stroke-width: 1;
	shape-rendering: crispEdges;
}

.ars-chart__dot {
	fill: var(--ars-series-1);
	stroke: var(--ars-surface);
	stroke-width: 2;
}

.ars-chart__bar {
	fill: var(--ars-series-1);
	transition: opacity 0.12s;
}

.ars-chart--hovering .ars-chart__bar:not(.is-active) {
	opacity: 0.45;
}

.ars-chart__hit {
	fill: transparent;
	cursor: default;
}

.ars-chart__tooltip {
	position: absolute;
	z-index: 2;
	top: 0;
	left: 0;
	min-width: 120px;
	padding: 8px 10px;
	border: 1px solid var(--ars-border);
	border-radius: 6px;
	background: var(--ars-surface);
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
	pointer-events: none;
	white-space: nowrap;
}

.ars-chart__tooltip[hidden] {
	display: none;
}

.ars-chart__tooltip-title {
	margin-bottom: 4px;
	color: var(--ars-text-secondary);
	font-size: 12px;
}

.ars-chart__tooltip-row {
	display: flex;
	align-items: center;
	gap: 8px;
}

.ars-chart__tooltip-key {
	width: 12px;
	height: 2px;
	border-radius: 1px;
	background: var(--ars-series-1);
}

.ars-chart__tooltip-value {
	font-size: 14px;
	font-weight: 600;
}

.ars-chart__tooltip-series {
	color: var(--ars-text-secondary);
	font-size: 12px;
}

/* Table view of a chart */

.ars-dash-table summary {
	width: fit-content;
	color: var(--ars-accent);
	font-size: 12px;
	cursor: pointer;
}

.ars-dash-table table {
	margin-top: 8px;
}

.ars-dashboard .num {
	font-variant-numeric: tabular-nums;
	text-align: right;
}

/* Horizontal bars (top episodes) */

.ars-dash-bars {
	display: flex;
	flex-direction: column;
	gap: 12px;
	margin: 0;
	list-style: none;
}

.ars-dash-bars__item {
	margin: 0;
}

.ars-dash-bars__text {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 4px;
}

.ars-dash-bars__label {
	overflow: hidden;
	color: var(--ars-text);
	text-decoration: none;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.ars-dash-bars__label:hover {
	color: var(--ars-accent);
	text-decoration: underline;
}

.ars-dash-bars__value {
	flex: none;
	font-variant-numeric: tabular-nums;
	font-weight: 600;
}

.ars-dash-bars__track {
	display: block;
	height: 8px;
	border-radius: 4px;
	background: var(--ars-track);
}

.ars-dash-bars__fill {
	display: block;
	min-width: 4px;
	height: 100%;
	border-radius: 4px;
	background: var(--ars-series-1);
}

/* Episode types: one 100% stacked bar */

.ars-dash-stack {
	display: flex;
	gap: 2px;
	height: 16px;
	overflow: hidden;
	border-radius: 4px;
}

.ars-dash-stack__part {
	flex-basis: 0;
	min-width: 4px;
}

.ars-dash-stack__part--full {
	background: var(--ars-series-1);
}

.ars-dash-stack__part--trailer {
	background: var(--ars-series-2);
}

.ars-dash-stack__part--bonus {
	background: var(--ars-series-3);
}

.ars-dash-legend {
	display: flex;
	flex-direction: column;
	gap: 0;
	margin: 0;
	list-style: none;
}

.ars-dash-legend__item {
	display: grid;
	grid-template-columns: 12px minmax(0, 1fr) auto 56px;
	align-items: center;
	gap: 10px;
	margin: 0;
	padding: 10px 0;
	border-bottom: 1px solid var(--ars-grid);
}

.ars-dash-legend__item:last-child {
	border-bottom: 0;
}

.ars-dash-legend__swatch {
	width: 12px;
	height: 12px;
	border-radius: 3px;
}

.ars-dash-legend__value {
	font-variant-numeric: tabular-nums;
	font-weight: 600;
}

.ars-dash-legend__share {
	color: var(--ars-muted);
	font-variant-numeric: tabular-nums;
	text-align: right;
}

/* Ranking table */

.ars-dash-scroll {
	overflow-x: auto;
}

.ars-dash-ranking {
	border-color: var(--ars-grid);
}

.ars-dash-ranking td,
.ars-dash-ranking th {
	vertical-align: middle;
	white-space: nowrap;
}

.ars-dash-ranking td:nth-child(2) {
	width: 100%;
	white-space: normal;
}

.ars-dash-ranking__rank {
	width: 2em;
	color: var(--ars-muted);
	font-variant-numeric: tabular-nums;
}

.ars-dash-ranking__title {
	font-weight: 600;
	text-decoration: none;
}

.ars-dash-ranking__view {
	margin-left: 8px;
	font-size: 12px;
	visibility: hidden;
}

.ars-dash-ranking tr:hover .ars-dash-ranking__view,
.ars-dash-ranking__view:focus {
	visibility: visible;
}

/* Feed health */

.ars-dash-checks {
	display: flex;
	flex-direction: column;
	margin: 0;
	list-style: none;
}

.ars-dash-check {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	margin: 0;
	padding: 10px 0;
	border-bottom: 1px solid var(--ars-grid);
}

.ars-dash-check:last-child {
	border-bottom: 0;
}

.ars-dash-check__body {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.ars-dash-check__label {
	font-weight: 600;
}

.ars-dash-check__help {
	color: var(--ars-muted);
	font-size: 12px;
}

.ars-dash-check__list summary {
	width: fit-content;
	margin-top: 4px;
	color: var(--ars-accent);
	font-size: 12px;
	cursor: pointer;
}

.ars-dash-check__list ul {
	margin: 6px 0 0 18px;
	list-style: disc;
}

.ars-dash-check__list li {
	margin-bottom: 2px;
}

.ars-dash-check__more {
	color: var(--ars-muted);
	list-style: none;
}

.ars-dash-status {
	display: inline-flex;
	flex: none;
	align-items: center;
	gap: 4px;
	min-width: 88px;
	color: var(--ars-text-secondary);
	font-size: 12px;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.ars-dash-check--episodes .ars-dash-status {
	min-width: 96px;
	padding-top: 1px;
}

.ars-dash-status .dashicons {
	width: 18px;
	height: 18px;
	font-size: 18px;
}

.ars-dash-status--good .dashicons {
	color: var(--ars-good);
}

.ars-dash-status--warning .dashicons {
	color: var(--ars-warning);
}

.ars-dash-status--critical .dashicons {
	color: var(--ars-critical);
}

.ars-dash-status--notice .dashicons {
	color: var(--ars-notice);
}

/* Layout */

@container (min-width: 900px) {
	.ars-dash-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.ars-dash-grid--wide {
		grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
	}

	.ars-dash-grid--narrow {
		grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
	}
}

@container (max-width: 899px) {
	.ars-dash-tiles {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@container (max-width: 480px) {
	.ars-dash-tiles {
		gap: 10px;
	}

	.ars-dash-tile {
		padding: 12px 14px;
	}

	.ars-dash-tile__value {
		font-size: 22px;
	}
}

@container (max-width: 320px) {
	.ars-dash-tiles {
		grid-template-columns: minmax(0, 1fr);
	}
}
