/*
 * AP Estadística: navegador de documentos.
 * Hereda tipografía del tema; los colores se ajustan redefiniendo las variables --ape-*.
 */

.ap-estadistica {
	--ape-primary: #081c59;
	--ape-text: #666666;
	--ape-muted: #8a8f9c;
	--ape-border: #e2e5ec;
	--ape-soft: #f4f6fa;
	--ape-focus: #081c59;
	margin: 0 0 2em;
	color: var(--ape-text);
}

.ap-estadistica *,
.ap-estadistica *::before,
.ap-estadistica *::after {
	box-sizing: border-box;
}

.ap-estadistica button {
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	color: inherit;
	font: inherit;
	letter-spacing: inherit;
	text-transform: none;
	box-shadow: none;
	cursor: pointer;
}

.ap-estadistica ul,
.ap-estadistica ol {
	margin: 0 !important;
	padding: 0 !important;
	list-style: none !important;
	line-height: inherit;
}

.ap-estadistica li {
	margin: 0;
	padding: 0;
}

.ap-estadistica li::before,
.ap-estadistica li::marker {
	content: none;
}

.ape-icon {
	display: block;
	width: 1em;
	height: 1em;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.5;
	stroke-linecap: round;
	stroke-linejoin: round;
	flex: none;
}

.ap-estadistica :focus {
	outline: none;
}

.ap-estadistica :focus-visible {
	outline: 2px solid var(--ape-focus);
	outline-offset: 3px;
}

/* ---------- Cabecera: "Volver" + herramientas ---------- */

.ape-header {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 12px 24px;
	min-height: 53px;
	padding-bottom: 14px;
	border-bottom: 1px solid var(--ape-border);
}

.ape-header-start {
	display: flex;
	flex: 1 1 auto;
	align-items: center;
	min-width: 0;
}

.ap-estadistica .ape-back {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: var(--ape-primary);
	font-size: 15px;
	font-weight: 700;
	line-height: 1.4;
}

.ape-back .ape-icon {
	width: 18px;
	height: 18px;
	stroke-width: 2;
	transition: transform 0.15s ease;
}

.ape-back:hover span {
	text-decoration: underline;
	text-underline-offset: 3px;
}

.ape-back:hover .ape-icon {
	transform: translateX(-3px);
}

.ape-tools {
	display: flex;
	align-items: center;
	gap: 10px;
}

.ape-search {
	position: relative;
	display: block;
	width: 240px;
	margin: 0;
}

.ape-search[hidden] {
	display: none;
}

.ape-search .ape-icon {
	position: absolute;
	left: 11px;
	top: 50%;
	width: 16px;
	height: 16px;
	transform: translateY(-50%);
	color: var(--ape-muted);
	pointer-events: none;
}

.ap-estadistica .ape-search input {
	width: 100%;
	height: 38px;
	margin: 0;
	padding: 0 12px 0 36px;
	border: 1px solid var(--ape-border);
	border-radius: 0;
	background: #fff;
	color: var(--ape-primary);
	font: inherit;
	font-size: 14px;
	box-shadow: none;
	-webkit-appearance: none;
	appearance: none;
}

.ap-estadistica .ape-search input::placeholder {
	color: var(--ape-muted);
	opacity: 1;
}

.ap-estadistica .ape-search input:focus {
	border-color: var(--ape-primary);
}

.ape-views {
	display: inline-flex;
	border: 1px solid var(--ape-border);
}

.ap-estadistica .ape-view {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 36px;
	color: var(--ape-primary);
	transition: background-color 0.15s ease, color 0.15s ease;
}

.ape-view + .ape-view {
	border-left: 1px solid var(--ape-border);
}

.ape-view .ape-icon {
	width: 18px;
	height: 18px;
}

.ap-estadistica .ape-view:hover {
	background: var(--ape-soft);
}

.ap-estadistica .ape-view[aria-pressed="true"] {
	background: var(--ape-primary);
	color: #fff;
}

.ape-view:focus-visible {
	outline-offset: 1px;
}

/* ---------- Encabezado de la carpeta ---------- */

.ape-heading {
	margin: 22px 0 18px;
}

.ap-estadistica .ape-title {
	margin: 0 0 4px;
	padding: 0;
	color: var(--ape-primary);
	font-size: 22px;
	font-weight: 700;
	line-height: 1.3;
}

.ap-estadistica .ape-summary {
	margin: 0;
	padding: 0;
	color: var(--ape-muted);
	font-size: 13px;
}

/* ---------- Contenido ---------- */

.ape-body {
	transition: opacity 0.2s ease;
}

.ap-estadistica.is-loading .ape-body {
	opacity: 0.45;
	pointer-events: none;
}

.ape-message {
	margin: 0;
	padding: 36px 0;
	color: var(--ape-muted);
	text-align: center;
}

.ape-message--error {
	padding: 16px 20px;
	border-left: 3px solid #b42318;
	background: #fef3f2;
	color: #7a271a;
	text-align: left;
}

.ape-message--error p {
	margin: 0 0 12px;
	padding: 0;
}

.ap-estadistica .ape-retry {
	padding: 8px 18px;
	background: var(--ape-primary);
	color: #fff;
	font-size: 14px;
	font-weight: 700;
}

.ap-estadistica .ape-retry:hover {
	opacity: 0.9;
}

.ape-item {
	color: inherit;
	text-decoration: none !important;
	transition: background-color 0.15s ease;
}

.ape-name {
	color: var(--ape-primary);
	font-weight: 700;
	line-height: 1.35;
	overflow-wrap: anywhere;
}

.ape-meta {
	color: var(--ape-muted);
	font-size: 13px;
	line-height: 1.4;
}

.ape-visual {
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--ape-primary);
}

/* Miniaturas: mismo patrón que los bloques de descarga de la web (icono grande + título). */
.ape-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
	gap: 8px 16px;
}

.ape-grid .ape-item {
	display: flex;
	flex-direction: column;
	align-items: center;
	width: 100%;
	height: 100%;
	padding: 20px 12px 18px;
	text-align: center;
}

.ape-grid .ape-visual {
	width: 88px;
	height: 88px;
	margin-bottom: 12px;
	transition: transform 0.2s ease;
}

.ape-grid .ape-visual .ape-icon {
	width: 72px;
	height: 72px;
	stroke-width: 1.6;
}

.ape-grid .ape-visual--image {
	width: 120px;
	border: 1px solid var(--ape-border);
	background: var(--ape-soft);
	overflow: hidden;
}

.ape-grid .ape-visual--image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.ape-grid .ape-name {
	font-size: 15px;
}

.ape-grid .ape-meta {
	margin-top: 4px;
}

.ape-grid .ape-item:hover {
	background: var(--ape-soft);
}

.ape-grid .ape-item:hover .ape-visual {
	transform: translateY(-3px);
}

.ape-grid .ape-item:hover .ape-name {
	text-decoration: underline;
	text-underline-offset: 3px;
}

.ape-grid .ape-item:focus-visible {
	outline-offset: -2px;
}

/* Lista */
.ape-list li {
	border-bottom: 1px solid var(--ape-border);
}

.ape-list .ape-item {
	display: flex;
	align-items: center;
	gap: 16px;
	width: 100%;
	padding: 14px 12px;
	text-align: left;
}

.ape-list .ape-visual .ape-icon {
	width: 30px;
	height: 30px;
}

.ape-list .ape-text {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	min-width: 0;
}

.ape-list .ape-name {
	font-size: 15px;
}

.ape-list .ape-meta {
	margin-top: 2px;
}

.ape-date::before {
	content: "·";
	margin: 0 6px;
}

.ape-action {
	display: inline-flex;
	flex: none;
	align-items: center;
	gap: 6px;
	color: var(--ape-primary);
	font-size: 13px;
	font-weight: 700;
}

.ape-action .ape-icon {
	width: 20px;
	height: 20px;
}

.ape-list .ape-item:hover {
	background: var(--ape-soft);
}

.ape-list .ape-item:hover .ape-name {
	text-decoration: underline;
	text-underline-offset: 3px;
}

.ape-list .ape-item--folder:hover .ape-action {
	transform: translateX(3px);
}

.ape-list .ape-action {
	transition: transform 0.15s ease;
}

.ape-list .ape-item:focus-visible {
	outline-offset: -2px;
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
	/* Con buscador, las herramientas pasan a su propia fila. */
	.ape-tools:has(.ape-search:not([hidden])) {
		flex-basis: 100%;
	}

	.ape-search {
		flex: 1 1 auto;
		width: auto;
	}

	.ape-views {
		margin-left: auto;
	}

	.ape-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 4px 8px;
	}

	.ape-grid .ape-visual {
		width: 64px;
		height: 64px;
	}

	.ape-grid .ape-visual .ape-icon {
		width: 56px;
		height: 56px;
	}

	.ape-grid .ape-visual--image {
		width: 96px;
	}

	.ape-list .ape-item {
		gap: 12px;
		padding: 12px 4px;
	}

	.ape-action__label {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip: rect(0 0 0 0);
		white-space: nowrap;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ap-estadistica * {
		transition: none !important;
	}
}
