/**
 * Public Analytics Dashboard – frontend styles.
 * Intentionally standalone; uses no OJS backend CSS variables.
 */

/* =====================================================================
   Layout shell
   ===================================================================== */

.pub-analytics {
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	font-size: 16px; /* anchor rem baseline regardless of theme root size */
	color: #2d3748;
	line-height: 1.5;
}

.pub-analytics__container {
	max-width: 1100px;
	margin: 0 auto;
	padding: 2rem 1.25rem 3rem;
}

/* =====================================================================
   Hero banner
   ===================================================================== */

.pub-analytics__hero {
	background: linear-gradient(135deg, #1a365d 0%, #2b6cb0 100%);
	color: #fff;
	padding: 2.5rem 1.25rem;
}

.pub-analytics__hero--article {
	background: linear-gradient(135deg, #1c4532 0%, #276749 100%);
}

.pub-analytics__hero-inner {
	max-width: 1100px;
	margin: 0 auto;
}

.pub-analytics__hero-title {
	font-size: 1.75rem;
	font-weight: 700;
	margin: 0.5rem 0 0.25rem;
	line-height: 1.25;
}

.pub-analytics__hero-title--article {
	font-size: 1.35rem;
}

.pub-analytics__hero-sub {
	margin: 0.25rem 0 0;
	opacity: 0.85;
	font-size: 0.95rem;
}

/* =====================================================================
   Breadcrumb
   ===================================================================== */

.pub-analytics__breadcrumb {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 0.25rem;
	font-size: 0.85rem;
	margin-bottom: 0.75rem;
	opacity: 0.9;
}

.pub-analytics__breadcrumbLink {
	color: #bee3f8;
	text-decoration: none;
}

.pub-analytics__breadcrumbLink:hover {
	text-decoration: underline;
	color: #fff;
}

.pub-analytics__breadcrumbSep {
	color: rgba(255, 255, 255, 0.5);
	margin: 0 0.15rem;
}

.pub-analytics__breadcrumbCurrent {
	color: #fff;
}

/* =====================================================================
   Date-range filter
   ===================================================================== */

.pub-analytics__filter {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem;
	margin-bottom: 2rem;
	padding: 1rem;
	background: #f7fafc;
	border: 1px solid #e2e8f0;
	border-radius: 8px;
}

.pub-analytics__filterLabel {
	font-size: 0.85rem;
	font-weight: 600;
	color: #4a5568;
}

.pub-analytics__filterBtn {
	padding: 0.3rem 0.75rem;
	font-size: 0.82rem;
	border-radius: 20px;
	background: #edf2f7;
	color: #2b6cb0;
	text-decoration: none;
	border: 1px solid #cbd5e0;
	transition: background 0.15s, color 0.15s;
	cursor: pointer;
}

.pub-analytics__filterBtn:hover {
	background: #bee3f8;
	border-color: #2b6cb0;
}

.pub-analytics__filterBtn--active {
	background: #2b6cb0;
	color: #fff;
	border-color: #2b6cb0;
	cursor: default;
}

/* =====================================================================
   KPI cards
   ===================================================================== */

.pub-analytics__kpis {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
	gap: 1rem;
	margin-bottom: 2.5rem;
}

.pub-analytics__kpi {
	background: #fff;
	border: 1px solid #e2e8f0;
	border-radius: 10px;
	padding: 1.25rem 1rem;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
	display: flex;
	flex-direction: column;
	gap: 0.2rem;
}

.pub-analytics__kpi--lg {
	border-left: 4px solid #2b6cb0;
}

.pub-analytics__kpiValue {
	font-size: 2rem;
	font-weight: 700;
	line-height: 1.1;
	color: #1a365d;
}

.pub-analytics__kpiValue--sm {
	font-size: 1rem;
}

.pub-analytics__kpiLabel {
	font-size: 0.82rem;
	font-weight: 600;
	color: #4a5568;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.pub-analytics__kpiNote {
	font-size: 0.75rem;
	color: #718096;
}

/* =====================================================================
   Sections
   ===================================================================== */

.pub-analytics__section {
	margin-bottom: 2.5rem;
}

.pub-analytics__sectionTitle {
	font-size: 1.1rem;
	font-weight: 600;
	color: #2d3748;
	margin: 0 0 1rem;
	padding-bottom: 0.5rem;
	border-bottom: 2px solid #e2e8f0;
}

/* =====================================================================
   Charts
   ===================================================================== */

.pub-analytics__chartWrap {
	background: #fff;
	border: 1px solid #e2e8f0;
	border-radius: 10px;
	padding: 1.25rem;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.pub-analytics__chartWrap--bar {
	max-width: 600px;
}

/* =====================================================================
   Citation pie + legend
   ===================================================================== */

.pub-analytics__citationWrap {
	display: flex;
	flex-wrap: wrap;
	gap: 1.5rem;
	align-items: flex-start;
}

.pub-analytics__citationSvg {
	flex: 0 0 auto;
	max-width: 220px;
}

.pub-analytics__citationSvg svg {
	width: 100%;
	height: auto;
}

.pub-analytics__citationLegend {
	flex: 1 1 240px;
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 0.4rem;
}

.pub-analytics__citationItem {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	font-size: 0.85rem;
}

.pub-analytics__citationDot {
	display: inline-block;
	width: 12px;
	height: 12px;
	border-radius: 50%;
	flex-shrink: 0;
}

.pub-analytics__citationTitle {
	flex: 1;
	color: #2d3748;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.pub-analytics__citationMeta {
	font-size: 0.78rem;
	color: #718096;
	white-space: nowrap;
}

/* =====================================================================
   Tables
   ===================================================================== */

.pub-analytics__tableWrap {
	overflow-x: auto;
	border-radius: 10px;
	border: 1px solid #e2e8f0;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.pub-analytics__table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.88rem;
	background: #fff;
}

.pub-analytics__table th {
	background: #f7fafc;
	font-weight: 600;
	text-align: left;
	padding: 0.75rem 1rem;
	border-bottom: 1px solid #e2e8f0;
	color: #4a5568;
	font-size: 0.8rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.pub-analytics__table td {
	padding: 0.7rem 1rem;
	border-bottom: 1px solid #f0f4f8;
	vertical-align: middle;
}

.pub-analytics__table tr:last-child td {
	border-bottom: none;
}

.pub-analytics__table tr:hover td {
	background: #f7fafc;
}

.pub-analytics__numCol {
	text-align: right;
	white-space: nowrap;
}

.pub-analytics__dateCol {
	white-space: nowrap;
}

.pub-analytics__articleTitle {
	max-width: 340px;
}

/* =====================================================================
   Article metadata
   ===================================================================== */

.pub-analytics__articleMeta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.25rem 0.5rem;
	margin-top: 0.5rem;
	font-size: 0.9rem;
	opacity: 0.9;
}

.pub-analytics__articleDot {
	opacity: 0.5;
}

/* =====================================================================
   Links
   ===================================================================== */

.pub-analytics__link {
	color: #2b6cb0;
	text-decoration: none;
	font-weight: 500;
	font-size: 0.85rem;
}

.pub-analytics__link:hover {
	text-decoration: underline;
}

.pub-analytics__link--back {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	font-size: 0.9rem;
}

/* =====================================================================
   Pagination
   ===================================================================== */

.pub-analytics__pagination {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-top: 1rem;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.pub-analytics__paginationInfo {
	font-size: 0.85rem;
	color: #718096;
}

.pub-analytics__paginationArrows {
	display: flex;
	gap: 0.5rem;
}

.pub-analytics__paginationBtn {
	padding: 0.4rem 0.9rem;
	border: 1px solid #cbd5e0;
	border-radius: 6px;
	font-size: 0.85rem;
	text-decoration: none;
	color: #2b6cb0;
	background: #fff;
	transition: background 0.15s;
}

.pub-analytics__paginationBtn:hover {
	background: #ebf8ff;
}

.pub-analytics__paginationBtn--disabled {
	color: #a0aec0;
	cursor: default;
	pointer-events: none;
}

/* =====================================================================
   Misc
   ===================================================================== */

.pub-analytics__articlesSummary {
	font-size: 0.85rem;
	color: #718096;
	margin-bottom: 0.75rem;
}

.pub-analytics__empty {
	color: #718096;
	font-style: italic;
}

.pub-analytics__backLink {
	margin-top: 2rem;
}

.pub-analytics__section--abstract {
	background: #f7fafc;
	border: 1px solid #e2e8f0;
	border-radius: 10px;
	padding: 1.25rem;
}

.pub-analytics__abstract {
	font-size: 0.92rem;
	color: #4a5568;
	line-height: 1.7;
	margin: 0;
}

/* =====================================================================
   Custom date-range picker (inline expander after preset buttons)
   ===================================================================== */

.pub-analytics__customRange {
	display: none;
	align-items: center;
	flex-wrap: wrap;
	gap: 0.5rem;
	width: 100%;
	margin-top: 0.6rem;
	padding: 0.65rem 0.85rem;
	background: #f7fafc;
	border: 1px solid #e2e8f0;
	border-radius: 8px;
}

.pub-analytics__customRange--open {
	display: flex;
}

.pub-analytics__customLabel {
	font-size: 0.8rem;
	font-weight: 600;
	color: #4a5568;
	white-space: nowrap;
}

.pub-analytics__dateInput {
	border: 1px solid #cbd5e0;
	border-radius: 6px;
	padding: 0.35rem 0.6rem;
	font-size: 0.875rem;
	color: #2d3748;
	background: #fff;
	outline: none;
}

.pub-analytics__dateInput:focus {
	border-color: #2563eb;
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.pub-analytics__applyBtn {
	padding: 0.38rem 1rem;
	background: #2563eb;
	color: #fff;
	border: none;
	border-radius: 6px;
	font-size: 0.85rem;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.15s;
}

.pub-analytics__applyBtn:hover {
	background: #1d4ed8;
}

/* =====================================================================
   Table header row: title + search in one flex row
   ===================================================================== */

.pub-analytics__tableHeader {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 0.75rem;
	justify-content: space-between;
	margin-bottom: 0.75rem;
}

.pub-analytics__tableHeader .pub-analytics__sectionTitle {
	margin-bottom: 0;
}

/* Search form */
.pub-analytics__search {
	flex-shrink: 0;
}

.pub-analytics__searchInner {
	display: flex;
	align-items: center;
	background: #fff;
	border: 1px solid #cbd5e0;
	border-radius: 6px;
	overflow: hidden;
}

.pub-analytics__searchInput {
	border: none;
	outline: none;
	padding: 0.45rem 0.75rem;
	font-size: 0.875rem;
	min-width: 200px;
	color: #2d3748;
	background: transparent;
}

.pub-analytics__searchBtn {
	background: none;
	border: none;
	padding: 0.45rem 0.65rem;
	cursor: pointer;
	color: #718096;
	display: flex;
	align-items: center;
}

.pub-analytics__searchBtn:hover {
	color: #2d3748;
}

.pub-analytics__searchClear {
	padding: 0.35rem 0.6rem;
	font-size: 1rem;
	color: #a0aec0;
	text-decoration: none;
	line-height: 1;
}

.pub-analytics__searchClear:hover {
	color: #718096;
}

/* Sortable column headers */
.pub-analytics__sortable {
	white-space: nowrap;
}

.pub-analytics__sortLink {
	color: inherit;
	text-decoration: none;
	display: inline-flex;
	align-items: center;
	gap: 0.25rem;
	font-weight: 600;
	font-size: 0.78rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.pub-analytics__sortLink:hover {
	color: #2563eb;
}

.pub-analytics__sortLink--active {
	color: #2563eb;
}

/* =====================================================================
   Injected analytics button block (mirrors Global Impact Map embed pattern)
   ===================================================================== */

.pub-analytics-block-wrapper {
	margin: 0;
	padding: 0;
}

.pub-analytics-block {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 0.75rem;
	padding: 0.85rem 1.5rem;
	background: linear-gradient(90deg, #ebf8ff 0%, #e6fffa 100%);
	border-bottom: 2px solid #bee3f8;
}

.pub-analytics-block__text {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	font-size: 0.875rem;
	color: #2d3748;
}

.pub-analytics-block__icon {
	font-size: 1.1rem;
	color: #2563eb;
}

.pub-analytics-block__subtitle {
	color: #4a5568;
}

.pub-analytics-block__btn {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	padding: 0.45rem 1rem;
	background: #2563eb;
	color: #fff !important;
	border-radius: 6px;
	font-size: 0.85rem;
	font-weight: 600;
	text-decoration: none;
	white-space: nowrap;
	transition: background 0.15s;
}

.pub-analytics-block__btn:hover {
	background: #1d4ed8;
	color: #fff !important;
	text-decoration: none;
}

.pub-analytics-block__arrow {
	flex-shrink: 0;
}

/* =====================================================================
   "View Analytics" injected button on article page
   ===================================================================== */

.pub-analytics-article-btn {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	margin-top: 1rem;
	padding: 0.45rem 1rem;
	background: #ebf8ff;
	border: 1px solid #bee3f8;
	border-radius: 6px;
	color: #2b6cb0;
	font-size: 0.875rem;
	font-weight: 500;
	text-decoration: none;
	transition: background 0.15s, border-color 0.15s;
}

.pub-analytics-article-btn:hover {
	background: #bee3f8;
	border-color: #2b6cb0;
	color: #1a365d;
}

/* =====================================================================
   Responsive
   ===================================================================== */

@media (max-width: 640px) {
	.pub-analytics__kpis {
		grid-template-columns: repeat(2, 1fr);
	}

	.pub-analytics__hero-title {
		font-size: 1.35rem;
	}

	.pub-analytics__citationWrap {
		flex-direction: column;
	}

	.pub-analytics__citationSvg {
		max-width: 180px;
	}
}
