/* Grid de Apps do Associado - Estilo Apple */

/* Centralizar título da página quando o shortcode estiver presente */
body:has(.tec-associate-apps-grid) .entry-title,
body:has(.tec-associate-apps-grid) h1.entry-title,
body:has(.tec-associate-apps-grid) h2.entry-title,
body:has(.tec-associate-apps-grid) .page-title,
body:has(.tec-associate-apps-grid) h1.page-title,
body:has(.tec-associate-apps-grid) .post-title,
body:has(.tec-associate-apps-grid) h1.post-title,
body:has(.tec-associate-apps-grid) .entry-header .entry-title {
	text-align: center !important;
}

/* Fallback para navegadores que não suportam :has() - usar JavaScript ou classe no body */
body.tec-has-associate-apps .entry-title,
body.tec-has-associate-apps h1.entry-title,
body.tec-has-associate-apps h2.entry-title,
body.tec-has-associate-apps .entry-header .entry-title {
	text-align: center !important;
}

.tec-associate-apps-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
	gap: 30px;
	padding: 40px 20px;
	max-width: 1200px;
	margin: 0 auto;
	justify-items: center;
	justify-content: center; /* Centraliza o grid quando há menos apps do que colunas */
	width: 100%;
}

/* Desktop: número específico de colunas se definido */
@media (min-width: 768px) {
	.tec-associate-apps-grid[data-columns="2"] {
		grid-template-columns: repeat(2, 1fr);
		justify-content: center;
	}
	.tec-associate-apps-grid[data-columns="3"] {
		grid-template-columns: repeat(3, 1fr);
		justify-content: center;
	}
	.tec-associate-apps-grid[data-columns="4"] {
		grid-template-columns: repeat(4, 1fr);
		justify-content: center;
	}
	.tec-associate-apps-grid[data-columns="5"] {
		grid-template-columns: repeat(5, 1fr);
		justify-content: center;
	}
	.tec-associate-apps-grid[data-columns="6"] {
		grid-template-columns: repeat(6, 1fr);
		justify-content: center;
	}
	
	/* Centralizar grupo de apps quando há menos itens do que colunas */
	/* Usar auto-fit para criar apenas as colunas necessárias, permitindo centralização */
	.tec-associate-apps-grid[data-columns="2"] {
		grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
		max-width: calc(2 * 120px + 1 * 30px + 80px); /* 2 colunas + gap + padding */
	}
	.tec-associate-apps-grid[data-columns="3"] {
		grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
		max-width: calc(3 * 120px + 2 * 30px + 80px);
	}
	.tec-associate-apps-grid[data-columns="4"] {
		grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
		max-width: calc(4 * 120px + 3 * 30px + 80px);
	}
	.tec-associate-apps-grid[data-columns="5"] {
		grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
		max-width: calc(5 * 120px + 4 * 30px + 80px);
	}
	.tec-associate-apps-grid[data-columns="6"] {
		grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
		max-width: calc(6 * 120px + 5 * 30px + 80px);
	}
}

/* Mobile: 2 colunas */
@media (max-width: 767px) {
	.tec-associate-apps-grid {
		grid-template-columns: repeat(2, 1fr);
		gap: 25px;
		padding: 30px 15px;
	}
}

.tec-associate-app-item {
	width: 100%;
	max-width: 120px;
	text-align: center;
}

.tec-associate-app-link {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-decoration: none !important;
	color: inherit;
	transition: transform 0.2s ease, opacity 0.2s ease;
	border: none !important;
	border-bottom: none !important;
	outline: none !important;
	box-shadow: none !important;
}

.tec-associate-app-link:focus,
.tec-associate-app-link:active,
.tec-associate-app-link:hover,
.tec-associate-app-link:visited {
	text-decoration: none !important;
	border-bottom: none !important;
	box-shadow: none !important;
}

.tec-associate-app-link:hover,
.tec-associate-app-link:focus {
	transform: translateY(-5px);
	opacity: 0.8;
	outline: none;
}

.tec-associate-app-icon {
	width: 100%;
	aspect-ratio: 1;
	border-radius: 22px; /* Bordas arredondadas estilo Apple */
	overflow: hidden;
	background: #fff;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
	margin-bottom: 10px;
	transition: box-shadow 0.2s ease;
	display: flex;
	align-items: center;
	justify-content: center;
}

.tec-associate-app-link:hover .tec-associate-app-icon,
.tec-associate-app-link:focus .tec-associate-app-icon {
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.tec-associate-app-icon img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.tec-associate-app-icon i {
	font-size: 48px;
	display: block;
}

@media (max-width: 767px) {
	.tec-associate-app-icon i {
		font-size: 40px;
	}
}

.tec-associate-app-title {
	font-size: 13px;
	line-height: 1.3;
	color: #333;
	font-weight: 400;
	margin-top: 4px;
	word-wrap: break-word;
	max-width: 100%;
	text-decoration: none !important;
	border-bottom: none !important;
	box-shadow: none !important;
}

/* Garantir que não há underline em nenhum elemento dentro do link */
.tec-associate-app-link * {
	text-decoration: none !important;
	border-bottom: none !important;
}

/* Sobrescrever estilos globais do tema que podem adicionar underline */
.entry-content .tec-associate-app-link,
.entry-content .tec-associate-app-link:hover,
.entry-content .tec-associate-app-link:focus,
.entry-content .tec-associate-app-link:visited {
	text-decoration: none !important;
	border-bottom: none !important;
	box-shadow: none !important;
}

.entry-content .tec-associate-app-link .tec-associate-app-title {
	text-decoration: none !important;
	border-bottom: none !important;
}

@media (max-width: 767px) {
	.tec-associate-app-title {
		font-size: 12px;
	}
}

/* Acessibilidade */
.tec-associate-app-link:focus-visible {
	outline: 2px solid #007AFF;
	outline-offset: 4px;
	border-radius: 8px;
}
