/* Footloom admin. Everything is scoped under .footloom. */

.footloom {
	--an-surface: #fff;
	--an-rule: #e2e4e7;
	--an-rule-soft: #f0f0f1;
	--an-ink: #1d2327;
	--an-muted: #646970;
	--an-accent: #2271b1;
	--an-accent-dark: #135e96;
	--an-accent-soft: #eef4fa;
	--an-live: #00a32a;
	--an-warn: #996800;
	--an-warn-soft: #fcf9e8;
	--an-radius: 8px;

	color: var(--an-ink);
	font-variant-numeric: tabular-nums;
	max-width: 1320px;
}

.footloom a {
	color: var(--an-accent);
	text-decoration: none;
}

.footloom a:hover {
	color: var(--an-accent-dark);
	text-decoration: underline;
}

.footloom a:focus-visible,
.footloom button:focus-visible,
.footloom select:focus-visible,
.footloom input:focus-visible {
	outline: 2px solid var(--an-accent);
	outline-offset: 2px;
	box-shadow: none;
}

.footloom .an-muted {
	color: var(--an-muted);
}

/* Header bar */

.an-bar {
	position: sticky;
	top: 32px;
	z-index: 20;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px 24px;
	margin: 12px 0 16px;
	padding: 12px 16px;
	background: var(--an-surface);
	border: 1px solid var(--an-rule);
	border-radius: var(--an-radius);
}

.footloom .an-bar h1 {
	margin: 0;
	padding: 0;
	font-size: 20px;
	font-weight: 600;
	line-height: 1.3;
}

.an-bar-stats {
	display: flex;
	flex-wrap: wrap;
	gap: 4px 20px;
	margin-right: auto;
	color: var(--an-muted);
}

.an-stat strong {
	color: var(--an-ink);
	font-size: 15px;
	font-weight: 600;
	margin-right: 2px;
}

.an-stat-live {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

.an-stat-live strong {
	color: var(--an-live);
}

.an-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--an-live);
	animation: an-pulse 2s infinite;
}

@keyframes an-pulse {
	0% { box-shadow: 0 0 0 0 rgba(0, 163, 42, .45); }
	70% { box-shadow: 0 0 0 7px rgba(0, 163, 42, 0); }
	100% { box-shadow: 0 0 0 0 rgba(0, 163, 42, 0); }
}

.an-range {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
}

.an-range #an-custom:not([hidden]) {
	display: inline-flex;
	gap: 8px;
}

/* Panel with tabs */

.an-panel {
	background: var(--an-surface);
	border: 1px solid var(--an-rule);
	border-radius: var(--an-radius);
}

.an-tabs {
	display: flex;
	gap: 4px;
	padding: 0 12px;
	border-bottom: 1px solid var(--an-rule);
	overflow-x: auto;
	scrollbar-width: none;
}

.an-tabs::-webkit-scrollbar {
	display: none;
}

.footloom .an-tab {
	flex: none;
	padding: 14px 10px 12px;
	color: var(--an-muted);
	font-size: 14px;
	font-weight: 500;
	border-bottom: 2px solid transparent;
	margin-bottom: -1px;
}

.footloom .an-tab:hover {
	color: var(--an-ink);
	text-decoration: none;
}

.footloom .an-tab.is-active {
	color: var(--an-accent);
	border-bottom-color: var(--an-accent);
}

.an-subtabs {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	padding: 12px 20px 0;
}

.an-subtabs[hidden] {
	display: none;
}

.footloom .an-subtab {
	padding: 5px 12px;
	border-radius: 999px;
	color: var(--an-muted);
	font-weight: 500;
}

.footloom .an-subtab:hover {
	background: var(--an-rule-soft);
	color: var(--an-ink);
	text-decoration: none;
}

.footloom .an-subtab.is-active {
	background: var(--an-accent-soft);
	color: var(--an-accent-dark);
}

.an-view {
	padding: 20px;
	min-height: 320px;
}

/* Sections */

.an-section + .an-section {
	margin-top: 32px;
}

.an-section-head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 12px;
}

.footloom .an-section-head h2 {
	margin: 0;
	font-size: 15px;
	font-weight: 600;
}

.an-view-all {
	font-size: 13px;
}

.an-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr));
	gap: 32px 40px;
	margin-top: 32px;
}

.an-grid .an-section + .an-section {
	margin-top: 0;
}

.an-hint {
	margin: -4px 0 16px;
	color: var(--an-muted);
}

/* Tiles */

.an-tiles {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
	border: 1px solid var(--an-rule);
	border-radius: var(--an-radius);
	overflow: hidden;
	margin-bottom: 32px;
}

.an-tile {
	display: flex;
	flex-direction: column;
	gap: 2px;
	padding: 16px 20px;
	box-shadow: -1px 0 0 var(--an-rule);
}

.an-tile-label {
	color: var(--an-muted);
	font-weight: 500;
}

.an-tile strong {
	font-size: 26px;
	font-weight: 600;
	line-height: 1.3;
	letter-spacing: -.01em;
}

.an-tile-note {
	color: var(--an-muted);
	font-size: 12px;
}

.an-chart {
	position: relative;
	height: 260px;
}

/* Tables */

.an-scroll {
	overflow-x: auto;
}

.an-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 13px;
}

.an-table th {
	position: sticky;
	top: 0;
	background: var(--an-surface);
	padding: 8px 12px;
	color: var(--an-muted);
	font-weight: 500;
	text-align: left;
	white-space: nowrap;
	border-bottom: 1px solid var(--an-rule);
}

.an-table td {
	padding: 10px 12px;
	border-bottom: 1px solid var(--an-rule-soft);
	vertical-align: middle;
}

.an-table tbody tr:hover > td {
	background: #f9fafb;
}

.an-table th:first-child,
.an-table td:first-child {
	padding-left: 4px;
}

.an-table .an-num {
	text-align: right;
	white-space: nowrap;
}

.an-log td {
	height: 24px;
}

.an-time {
	white-space: nowrap;
	color: var(--an-muted);
}

.an-wide {
	width: 50%;
	max-width: 0;
}

/* Ranked lists: a quiet share bar under the label */

.an-ranked .an-rank-label {
	position: relative;
	width: 70%;
	max-width: 0;
}

.an-rank-label > span:last-child {
	display: block;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.an-rank-label::after {
	content: "";
	position: absolute;
	left: 4px;
	bottom: 0;
	height: 2px;
	width: calc(var(--share) - 4px);
	background: var(--an-accent);
	opacity: .5;
}

.an-rank-label .an-flag {
	float: left;
	margin-right: 8px;
}

/* Cells */

.an-page {
	display: flex;
	align-items: baseline;
	gap: 10px;
	min-width: 0;
}

.an-path {
	flex: none;
	max-width: 60%;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.an-title {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	color: var(--an-muted);
}

.an-visitor {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	white-space: nowrap;
}

.footloom .an-code {
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 12px;
}

.an-flag {
	display: inline-block;
	width: 20px;
	font-size: 16px;
	line-height: 1;
	text-align: center;
}

.an-flag-none {
	color: var(--an-muted);
	font-size: 11px;
	border: 1px dashed var(--an-rule);
	border-radius: 3px;
}

.an-badge {
	display: inline-block;
	padding: 1px 6px;
	border-radius: 4px;
	background: var(--an-accent-soft);
	color: var(--an-accent-dark);
	font-size: 11px;
	font-weight: 600;
	line-height: 1.6;
}

.an-badge-warn {
	background: var(--an-warn-soft);
	color: var(--an-warn);
}

.an-ref {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	white-space: nowrap;
	max-width: 220px;
}

.an-ref a {
	overflow: hidden;
	text-overflow: ellipsis;
}

.footloom .an-icon {
	width: 16px;
	height: 16px;
	font-size: 16px;
	color: var(--an-muted);
	flex: none;
}

.an-action {
	display: flex;
	align-items: baseline;
	gap: 8px;
	min-width: 0;
}

.an-action .an-icon {
	position: relative;
	top: 3px;
}

.an-action .an-page {
	flex: 1;
}

tr.is-event .an-icon {
	color: #dba617;
}

.an-event {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 4px 10px;
}

.an-value {
	padding: 0 6px;
	border-radius: 4px;
	background: #edfaef;
	color: #00761f;
	font-weight: 600;
}

/* Expand buttons */

.footloom .an-actions {
	display: inline-flex;
	align-items: center;
	gap: 2px;
	padding: 4px 10px 4px 4px;
	border: 1px solid var(--an-rule);
	border-radius: 6px;
	background: var(--an-surface);
	color: var(--an-accent);
	font: inherit;
	white-space: nowrap;
	cursor: pointer;
}

.footloom .an-actions:hover {
	border-color: var(--an-accent);
}

.an-actions .an-icon {
	color: inherit;
	transition: transform .15s ease;
}

.an-actions.is-open {
	background: var(--an-accent-soft);
	border-color: var(--an-accent);
}

.an-actions.is-open .an-icon {
	transform: rotate(90deg);
}

.an-table tr.an-detail > td,
.an-table tr.an-detail:hover > td {
	background: #f9fafb;
	padding: 4px 12px 16px 16px;
}

/* Session timeline: the one distinctive element */

.an-timeline {
	position: relative;
	margin: 8px 0 0;
	padding: 0;
	list-style: none;
}

.an-timeline::before {
	content: "";
	position: absolute;
	top: 12px;
	bottom: 12px;
	left: 67px;
	width: 2px;
	background: var(--an-rule);
}

.an-timeline li {
	position: relative;
	display: grid;
	grid-template-columns: 56px 1fr;
	gap: 28px;
	align-items: baseline;
	margin: 0;
	padding: 6px 0;
}

.an-timeline li::before {
	content: "";
	position: absolute;
	left: 63px;
	top: 12px;
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: var(--an-surface);
	border: 2px solid var(--an-accent);
	box-sizing: border-box;
}

.an-timeline li.is-event::before {
	border-radius: 2px;
	transform: rotate(45deg);
	background: #dba617;
	border-color: #dba617;
}

.an-timeline-at {
	color: var(--an-muted);
	text-align: right;
	font-size: 12px;
}

.an-timeline-page {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 4px 12px;
	min-width: 0;
}

.an-timeline-page .an-page {
	max-width: 100%;
}

/* Filters */

.an-filters {
	position: relative;
	margin-bottom: 16px;
}

.an-filter-row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
}

.footloom .an-filter-add {
	display: inline-flex;
	align-items: center;
	gap: 4px;
}

.an-filter-add .an-icon {
	color: inherit;
}

.an-chip {
	display: inline-flex;
	align-items: center;
	gap: 2px;
	padding: 3px 4px 3px 4px;
	border-radius: 999px;
	background: var(--an-accent-soft);
	color: var(--an-accent-dark);
}

.footloom .an-chip-x {
	display: inline-grid;
	place-items: center;
	width: 20px;
	height: 20px;
	border-radius: 50%;
	color: var(--an-accent-dark);
	font-size: 16px;
	line-height: 1;
}

.footloom .an-chip-x:hover {
	background: #d5e5f3;
	text-decoration: none;
}

.an-profile {
	display: flex;
	flex-wrap: wrap;
	gap: 4px 20px;
	margin-bottom: 16px;
	padding: 12px 16px;
	border-left: 3px solid var(--an-accent);
	background: var(--an-accent-soft);
	border-radius: 0 var(--an-radius) var(--an-radius) 0;
}

.an-profile span {
	color: var(--an-muted);
}

.footloom .an-more {
	display: block;
	margin: 16px auto 0;
}

/* Chip text is a button that reopens the value list. */
.footloom .an-chip-text {
	padding: 0 4px 0 6px;
	border: 0;
	border-radius: 999px;
	background: none;
	color: inherit;
	font: inherit;
	cursor: pointer;
}

.footloom span.an-chip-text {
	cursor: default;
}

.footloom button.an-chip-text:hover strong {
	text-decoration: underline;
}

/* Filter picker */

.an-picker {
	position: absolute;
	top: calc(100% + 6px);
	left: 0;
	z-index: 30;
	width: 320px;
	max-width: calc(100vw - 48px);
	padding: 8px;
	background: var(--an-surface);
	border: 1px solid var(--an-rule);
	border-radius: var(--an-radius);
	box-shadow: 0 8px 24px rgba(29, 35, 39, .12);
}

.an-picker[hidden] {
	display: none;
}

.footloom .an-picker-title {
	margin: 4px 8px 8px;
	color: var(--an-muted);
	font-weight: 500;
}

.an-picker-head {
	margin-bottom: 4px;
}

.footloom .an-picker-back {
	display: inline-flex;
	align-items: center;
	gap: 2px;
	padding: 4px 8px 4px 2px;
	border: 0;
	border-radius: 6px;
	background: none;
	color: var(--an-ink);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

.footloom .an-picker-back:hover {
	background: var(--an-rule-soft);
}

.footloom .an-picker-search {
	width: 100%;
	margin: 4px 0 6px;
}

.an-picker-list {
	margin: 0;
	list-style: none;
}

.an-picker-values {
	max-height: 320px;
	overflow-y: auto;
}

.an-picker-list li {
	margin: 0;
}

.footloom .an-picker-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	width: 100%;
	padding: 7px 8px;
	border: 0;
	border-radius: 6px;
	background: none;
	color: var(--an-ink);
	font: inherit;
	text-align: left;
	cursor: pointer;
}

.footloom .an-picker-item:hover,
.footloom .an-picker-item:focus-visible {
	background: var(--an-accent-soft);
	outline: none;
}

.an-picker-item.is-current {
	font-weight: 600;
}

.an-picker-item .an-icon {
	color: var(--an-muted);
}

.an-picker-value {
	display: flex;
	align-items: center;
	gap: 8px;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.an-picker-count {
	flex: none;
	color: var(--an-muted);
}

.footloom .an-picker-note {
	padding: 10px 8px;
	color: var(--an-muted);
}

/* Pages table */

.footloom .an-page-toggle {
	max-width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
}

.an-row-links {
	display: flex;
	justify-content: flex-end;
	align-items: center;
	gap: 10px;
}

.an-row-links .an-icon {
	color: var(--an-accent);
}

/* Heatmap */

.an-heat {
	border-collapse: separate;
	border-spacing: 3px;
	width: 100%;
	min-width: 640px;
	table-layout: fixed;
}

.an-heat th {
	font-weight: 400;
	font-size: 11px;
	color: var(--an-muted);
	text-align: left;
	width: auto;
}

.an-heat th:first-child {
	width: 36px;
}

.an-heat td {
	height: 22px;
	border-radius: 3px;
	background: rgba(34, 113, 177, calc(.05 + var(--a) * .95));
}

/* States */

.an-empty {
	padding: 32px 16px;
	text-align: center;
	color: var(--an-muted);
}

.an-empty p {
	margin: 0 0 12px;
	font-size: 13px;
}

.an-error {
	padding: 12px 16px;
	border-left: 3px solid #d63638;
	background: #fcf0f1;
	color: #8a2424;
}

.an-skeleton-row {
	padding: 12px 4px;
	border-bottom: 1px solid var(--an-rule-soft);
}

.an-skeleton-row span {
	display: block;
	height: 12px;
	width: 70%;
	border-radius: 4px;
	background: linear-gradient(90deg, #f0f0f1 0%, #e6e7e8 50%, #f0f0f1 100%);
	background-size: 200% 100%;
	animation: an-shimmer 1.4s infinite;
}

.an-skeleton-row:nth-child(3n + 2) span {
	width: 55%;
}

.an-skeleton-row:nth-child(3n) span {
	width: 85%;
}

@keyframes an-shimmer {
	from { background-position: 100% 0; }
	to { background-position: -100% 0; }
}

.an-credit {
	color: var(--an-muted);
	font-size: 12px;
}

/* Settings and custom event screens */

.footloom .an-card {
	background: var(--an-surface);
	border: 1px solid var(--an-rule);
	border-radius: var(--an-radius);
	padding: 20px 24px;
	margin: 0 0 16px;
}

.footloom .an-card h2 {
	margin-top: 0;
	font-size: 15px;
	font-weight: 600;
}

.footloom .an-card .widefat {
	border: 0;
	box-shadow: none;
}

.footloom .an-card .widefat th {
	color: var(--an-muted);
	font-weight: 500;
	border-bottom: 1px solid var(--an-rule);
}

.footloom .an-card .widefat.striped > tbody > :nth-child(odd) {
	background: transparent;
}

.footloom .an-card .widefat td {
	border-bottom: 1px solid var(--an-rule-soft);
	vertical-align: middle;
}

.an-form input[type="text"],
.an-form select {
	max-width: 100%;
}

.an-inline {
	display: inline;
}

.footloom pre {
	background: #f6f7f7;
	padding: 10px 12px;
	border-radius: 6px;
	overflow-x: auto;
}

/* Small screens */

@media (max-width: 782px) {
	.an-bar {
		top: 46px;
	}

	.an-view {
		padding: 16px;
	}

	.an-log {
		min-width: 720px;
	}
}

@media (max-width: 600px) {
	.an-bar {
		position: static;
	}
}

/* Spy: rows that arrived since the last refresh */

.an-table tr.is-fresh > td {
	animation: an-fresh 2.5s ease-out;
}

@keyframes an-fresh {
	from { background: var(--an-accent-soft); }
	to { background: transparent; }
}

@media (prefers-reduced-motion: reduce) {
	.an-dot,
	.an-skeleton-row span {
		animation: none;
	}

	.an-actions .an-icon {
		transition: none;
	}

	/* Keep the highlight, without the fade. */
	.an-table tr.is-fresh > td {
		animation: none;
		background: var(--an-accent-soft);
	}
}

.footloom .an-more[hidden] {
	display: none;
}

.footloom .an-filter-add .an-icon {
	line-height: 1;
	vertical-align: middle;
}

/* Green dot after the visitor code for visitors who are active right now. */
.an-live-dot {
	flex: none;
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--an-live);
	box-shadow: 0 0 0 3px rgba(0, 163, 42, .15);
}

.an-visitor {
	gap: 6px;
}
