/* Resultados Copérnico - frontend */

.crp-wrap {
	--crp-border: #e2e6ea;
	--crp-head-bg: #0f2b46;
	--crp-head-fg: #ffffff;
	--crp-zebra: #f7f9fb;
	--crp-hover: #eef4fa;
	--crp-muted: #64748b;
	--crp-accent: #0b7285;
	--crp-card-bg: #ffffff;
	--crp-radius: 10px;

	box-sizing: border-box;
	width: 100%;
	margin: 1.5em 0;
	font-size: 15px;
	line-height: 1.45;
}

.crp-wrap *,
.crp-wrap *::before,
.crp-wrap *::after {
	box-sizing: inherit;
}

/* En escritorio el bloque ocupa el 95% de su contenedor y queda centrado. */
@media (min-width: 641px) {
	.crp-wrap {
		width: 95%;
		max-width: 95%;
		margin-left: auto;
		margin-right: auto;
	}
}

.crp-title {
	margin: 0 0 .6em;
}

/* ------------------------------ Barra superior ---------------------------- */

.crp-toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: .5em;
	margin-bottom: .8em;
}

.crp-toolbar .crp-search {
	flex: 1 1 220px;
	min-width: 160px;
	max-width: 100%;
	padding: .5em .7em;
	border: 1px solid var(--crp-border);
	border-radius: 6px;
	font-size: 1em;
	font-family: inherit;
}

.crp-toolbar .crp-filter {
	flex: 0 1 auto;
	max-width: 100%;
	padding: .5em .6em;
	border: 1px solid var(--crp-border);
	border-radius: 6px;
	background: #fff;
	font-size: .95em;
	font-family: inherit;
}

/* El selector de orden solo hace falta en móvil, donde no hay cabecera visible. */
.crp-sort-group {
	display: none;
	gap: .4em;
	align-items: stretch;
}

.crp-sort-group .crp-sort {
	flex: 1 1 auto;
	min-width: 0;
	padding: .5em .6em;
	border: 1px solid var(--crp-border);
	border-radius: 6px;
	background: #fff;
	font-size: .95em;
	font-family: inherit;
}

.crp-sort-group .crp-sort-dir {
	flex: 0 0 auto;
	width: 2.6em;
	border: 1px solid var(--crp-border);
	border-radius: 6px;
	background: #fff;
	cursor: pointer;
	font-size: 1em;
	line-height: 1;
}

.crp-sort-group .crp-sort-dir[disabled] {
	opacity: .45;
	cursor: default;
}

.crp-toolbar .crp-count {
	color: var(--crp-muted);
	font-size: .88em;
	margin-left: auto;
	white-space: nowrap;
}

.crp-toolbar .crp-reload {
	padding: .5em .9em;
	border: 1px solid var(--crp-border);
	border-radius: 6px;
	background: #fff;
	cursor: pointer;
	font-size: .9em;
	font-family: inherit;
}

.crp-toolbar .crp-reload:hover {
	background: var(--crp-hover);
}

.crp-toolbar .crp-reload[disabled] {
	opacity: .6;
	cursor: default;
}

/* --------------------------------- Tabla ---------------------------------- */

.crp-table-holder {
	width: 100%;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

table.crp-table {
	width: 100%;
	border-collapse: collapse;
	margin: 0;
	font-variant-numeric: tabular-nums;
}

table.crp-table th,
table.crp-table td {
	padding: .55em .7em;
	border-bottom: 1px solid var(--crp-border);
	text-align: left;
	white-space: nowrap;
	vertical-align: middle;
}

table.crp-table thead th {
	background: var(--crp-head-bg);
	color: var(--crp-head-fg);
	font-weight: 600;
	font-size: .78em;
	letter-spacing: .04em;
	text-transform: uppercase;
	position: sticky;
	top: 0;
	z-index: 2;
}

table.crp-sortable thead th {
	cursor: pointer;
	user-select: none;
}

table.crp-sortable thead th::after {
	content: "";
	display: inline-block;
	margin-left: .4em;
	opacity: .45;
	font-size: .85em;
}

table.crp-sortable thead th[data-dir="asc"]::after {
	content: "\25B2";
	opacity: 1;
}

table.crp-sortable thead th[data-dir="desc"]::after {
	content: "\25BC";
	opacity: 1;
}

table.crp-table tbody tr.crp-alt {
	background: var(--crp-zebra);
}

table.crp-table tbody tr[hidden] {
	display: none;
}

table.crp-table tbody tr:hover {
	background: var(--crp-hover);
}

table.crp-table td.crp-align-right,
table.crp-table th.crp-align-right {
	text-align: right;
}

table.crp-table td.crp-align-center,
table.crp-table th.crp-align-center {
	text-align: center;
}

/* Papeles de columna: jerarquía en la tabla de escritorio.
   Van dentro de la consulta de escritorio para no competir con la tarjeta. */

@media (min-width: 641px) {
	table.crp-table th.crp-col-pos,
	table.crp-table td.crp-cell-pos {
		width: 1%;
		text-align: center;
		font-weight: 700;
	}

	table.crp-table th.crp-col-bib,
	table.crp-table td.crp-cell-bib {
		width: 1%;
		text-align: center;
		color: var(--crp-muted);
	}

	table.crp-table td.crp-cell-name,
	table.crp-table td.crp-cell-surname {
		white-space: normal;
		font-weight: 600;
		min-width: 9rem;
	}

	table.crp-table td.crp-cell-time {
		font-weight: 700;
		text-align: right;
	}

	table.crp-table td.crp-cell-meta {
		white-space: normal;
	}
}

table.crp-table td.crp-cell-empty::after {
	content: "\2014";
	color: var(--crp-muted);
}

table.crp-table tr.crp-group-row td {
	background: #eef2f6;
	font-weight: 700;
	text-transform: uppercase;
	font-size: .8em;
	letter-spacing: .04em;
	color: #334155;
}

table.crp-table tr.crp-group-row td.crp-cell-empty::after {
	content: "";
}

/* -------------------------------- Paginación ------------------------------ */

.crp-pager {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: .35em;
	margin-top: .9em;
}

.crp-pager button {
	min-width: 2.2em;
	padding: .4em .6em;
	border: 1px solid var(--crp-border);
	background: #fff;
	border-radius: 6px;
	cursor: pointer;
	font-size: .9em;
	font-family: inherit;
}

.crp-pager button[aria-current="true"] {
	background: var(--crp-accent);
	border-color: var(--crp-accent);
	color: #fff;
}

.crp-pager button[disabled] {
	opacity: .45;
	cursor: default;
}

/* ---------------------------------- Avisos -------------------------------- */

.crp-updated,
.crp-empty {
	margin: .7em 0 0;
	color: var(--crp-muted);
	font-size: .85em;
}

.crp-admin-notice {
	padding: .6em .9em;
	border-left: 4px solid #dba617;
	background: #fcf9e8;
	color: #6b5200;
	font-size: .88em;
	margin: 0 0 .8em;
}

.crp-error {
	padding: .8em 1em;
	border-left: 4px solid #d63638;
	background: #fcf0f1;
	color: #6d2224;
	font-size: .92em;
}

.crp-wrap.is-loading {
	opacity: .55;
	transition: opacity .15s ease;
}

.crp-no-results td {
	text-align: center;
	color: var(--crp-muted);
	padding: 1.2em;
}

/* ================================== Móvil ================================= */

@media (max-width: 640px) {
	.crp-wrap {
		width: 100%;
		font-size: 15px;
	}

	.crp-toolbar {
		gap: .45em;
	}

	.crp-toolbar .crp-search,
	.crp-toolbar .crp-filter {
		flex: 1 1 100%;
		width: 100%;
	}

	.crp-sort-group {
		display: flex;
		flex: 1 1 100%;
		width: 100%;
		order: 8;
	}

	.crp-toolbar .crp-count {
		margin-left: 0;
		order: 9;
	}

	.crp-toolbar .crp-reload {
		margin-left: auto;
		order: 10;
	}

	.crp-table-holder {
		overflow-x: visible;
	}

	table.crp-table,
	table.crp-table tbody,
	table.crp-table tr,
	table.crp-table td {
		display: block;
		width: 100%;
	}

	table.crp-table thead {
		display: none;
	}

	table.crp-table tbody tr[hidden] {
		display: none;
	}

	table.crp-table tbody tr {
		border: 1px solid var(--crp-border);
		border-radius: var(--crp-radius);
		background: var(--crp-card-bg);
		box-shadow: 0 1px 2px rgba(15, 43, 70, .06);
		margin-bottom: .55em;
		padding: .7em .8em;
	}

	table.crp-table tbody tr.crp-alt,
	table.crp-table tbody tr:hover {
		background: var(--crp-card-bg);
	}

	table.crp-table td {
		border: 0;
		padding: 0;
		white-space: normal;
	}

	/* Tarjeta: distintivo, nombre y tiempo arriba; después los datos. */

	table.crp-table tbody tr.crp-card {
		display: grid;
		grid-template-columns: 3rem minmax(0, 1fr) auto;
		column-gap: .7em;
		row-gap: .1em;
		align-items: start;
	}

	table.crp-table tbody tr.crp-card--norank {
		grid-template-columns: 0 minmax(0, 1fr) auto;
		column-gap: 0;
	}

	table.crp-table tbody tr.crp-card td.crp-cell-pos,
	table.crp-table tbody tr.crp-card--bibrank td.crp-cell-bib {
		grid-column: 1;
		grid-row: 1;
		align-self: start;
		background: var(--crp-head-bg);
		color: var(--crp-head-fg);
		border-radius: 8px;
		text-align: center;
		font-weight: 700;
		font-size: .95em;
		line-height: 1.6;
		padding: .1em .2em;
		min-width: 3rem;
	}

	table.crp-table tbody tr.crp-card td.crp-cell-bib {
		grid-column: 1;
		grid-row: 2;
		text-align: center;
		font-size: .72em;
		line-height: 1.3;
		color: var(--crp-muted);
		white-space: nowrap;
	}

	/* El dorsal va bajo el distintivo, con un «nº» que lo identifica sin ocupar línea. */
	table.crp-table tbody tr.crp-card td.crp-cell-bib::before {
		content: "n\00BA\00A0";
	}

	table.crp-table tbody tr.crp-card--bibrank td.crp-cell-bib::before {
		content: "";
	}

	table.crp-table tbody tr.crp-card td.crp-cell-name {
		grid-column: 2;
		grid-row: 1;
		font-weight: 700;
		font-size: 1em;
		line-height: 1.25;
		min-width: 0;
		overflow-wrap: anywhere;
	}

	table.crp-table tbody tr.crp-card td.crp-cell-surname {
		grid-column: 2;
		grid-row: 2;
		font-weight: 700;
		font-size: 1em;
		line-height: 1.25;
		overflow-wrap: anywhere;
	}

	table.crp-table tbody tr.crp-card td.crp-cell-time {
		grid-column: 3;
		grid-row: 1;
		text-align: right;
		font-weight: 700;
		font-size: 1.05em;
		white-space: nowrap;
	}

	table.crp-table tbody tr.crp-card td.crp-cell-meta {
		grid-column: 2 / -1;
		font-size: .78em;
		color: var(--crp-muted);
		line-height: 1.35;
	}

	table.crp-table tbody tr.crp-card td.crp-cell-meta.crp-cell-empty {
		display: none;
	}

	table.crp-table tbody tr.crp-card td.crp-cell-detail {
		grid-column: 1 / -1;
		display: flex;
		align-items: baseline;
		justify-content: space-between;
		gap: 1em;
		font-size: .82em;
		padding-top: .3em;
		margin-top: .25em;
		border-top: 1px dotted var(--crp-border);
	}

	table.crp-table tbody tr.crp-card td.crp-cell-detail::before {
		content: attr(data-label);
		font-size: .82em;
		text-transform: uppercase;
		letter-spacing: .04em;
		color: var(--crp-muted);
		font-weight: 600;
		flex: 0 0 auto;
	}

	/* Sin papeles reconocibles: pares etiqueta/valor. */

	table.crp-table tbody tr:not(.crp-card) td {
		display: flex;
		justify-content: space-between;
		gap: 1em;
		padding: .3em 0;
	}

	table.crp-table tbody tr:not(.crp-card) td::before {
		content: attr(data-label);
		font-size: .74em;
		text-transform: uppercase;
		letter-spacing: .04em;
		color: var(--crp-muted);
		font-weight: 600;
		flex: 0 0 auto;
	}

	/* Cabecera de grupo y fila sin resultados */

	table.crp-table tbody tr.crp-group-row {
		display: block;
		background: transparent;
		border: 0;
		box-shadow: none;
		padding: .5em 0 .25em;
		margin: 0;
	}

	table.crp-table tr.crp-group-row td {
		background: #eef2f6;
		border-radius: 6px;
		padding: .45em .7em;
		text-align: center;
	}

	table.crp-table tbody tr.crp-no-results {
		display: block;
	}

	.crp-pager {
		justify-content: center;
	}

	.crp-pager button {
		min-width: 2.4em;
		padding: .45em .6em;
	}
}

/* Pantallas muy estrechas: más sitio para el nombre. */
@media (max-width: 359px) {
	table.crp-table tbody tr.crp-card {
		grid-template-columns: 2.5rem minmax(0, 1fr) auto;
		column-gap: .5em;
	}

	table.crp-table tbody tr.crp-card td.crp-cell-pos,
	table.crp-table tbody tr.crp-card--bibrank td.crp-cell-bib {
		min-width: 2.5rem;
		font-size: .9em;
	}

	table.crp-table tbody tr.crp-card td.crp-cell-name,
	table.crp-table tbody tr.crp-card td.crp-cell-surname {
		font-size: .95em;
	}

	table.crp-table tbody tr.crp-card td.crp-cell-time {
		font-size: 1em;
	}

	table.crp-table tbody tr {
		padding: .65em .6em;
	}
}
