/**
 * Allopro — Mobile-first responsive (breakpoints: 768px, 1024px)
 */

/* Mobile: < 768px */
@media (max-width: 768px) {
	.ap-nav {
		padding-left: 12px;
		padding-right: 12px;
	}
	.ap-hero-inner { padding: 44px 20px 28px; max-width: 100%; }
	/* Hero search: un peu plus étroit que le conteneur pour aérer les bords */
	.ap-hero-search {
		flex-direction: column;
		flex-wrap: nowrap;
		align-items: stretch;
		align-content: flex-start;
		padding: 4px;
		gap: 0;
		border-radius: 14px;
		width: calc(100% - 36px);
		max-width: 100%;
		margin-left: auto;
		margin-right: auto;
		box-sizing: border-box;
	}
	.ap-hero-search .ap-input-wrap,
	.ap-hero-search .ap-hero-search__field {
		flex: 0 0 auto !important;
		flex-grow: 0 !important;
		flex-shrink: 0 !important;
		min-height: 0 !important;
		width: 100%;
		max-width: 100%;
		min-width: 0;
		box-sizing: border-box;
		border-right: none !important;
		border-bottom: 1px solid var(--ap-border-light);
		padding: 2px 8px !important;
		gap: 6px;
	}
	.ap-hero-search .ap-input-wrap:last-of-type,
	.ap-hero-search .ap-hero-search__field:last-of-type { border-bottom: none; }
	.ap-hero-search .ap-input-wrap .ap-select {
		flex: 1 1 auto;
		min-width: 0;
		width: 100%;
		max-width: 100%;
		padding: 10px 2px 10px 0;
		font-size: 15px;
		line-height: 1.3;
		min-height: 44px;
	}
	.ap-hero-search-btn {
		width: auto;
		align-self: stretch;
		margin: 4px;
		box-sizing: border-box;
		justify-content: center;
		padding: 12px 16px;
		border-radius: 10px;
	}
	.ap-section { padding: 40px 20px 32px; }
	.ap-cats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
	.ap-cats-grid-wrap:not(.ap-cats-grid-wrap--expanded) .ap-cats-grid .ap-cat-card:nth-child(n + 7) {
		display: none;
	}
	.ap-cats-load-more {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 100%;
		margin-top: 14px;
		padding: 12px 16px;
		border-radius: var(--ap-radius-sm, 10px);
		border: 1px solid var(--ap-border, #e8e6e1);
		background: var(--ap-surface, #fff);
		font-family: var(--ap-font-heading, sans-serif);
		font-size: 13px;
		font-weight: 600;
		color: var(--ap-primary, #7c3aed);
		cursor: pointer;
		-webkit-tap-highlight-color: transparent;
	}
	.ap-cats-load-more:active {
		opacity: 0.88;
	}
	.ap-providers-grid { grid-template-columns: 1fr; }
	.ap-partners-logos-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
	.ap-cta-box { padding: 28px 20px; }
	.ap-container { padding-left: 20px; padding-right: 20px; }
	.ap-explore-bar .ap-container { padding: 10px 16px; }
	.ap-filter-pill { font-size: 10px; padding: 3px 8px; }
}

/* Single listing: stack sidebar below on small */
@media (max-width: 900px) {
	.ap-listing-layout { grid-template-columns: 1fr !important; }
	.ap-listing-layout aside > div { position: static !important; }
}

/* Single listing: mobile optimizations */
@media (max-width: 768px) {
	/* Tabs: scroll horizontal when > 3 tabs, avoid page overflow */
	.ap-tabs {
		min-width: 0;
		overflow-y: hidden;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: thin;
	}
	.ap-tabs::-webkit-scrollbar {
		width: 0;
		height: 4px;
	}
	/* Listing content: prevent horizontal page scroll */
	.ap-listing-content { overflow-x: hidden; }
	.ap-listing-layout > div:first-child { min-width: 0; }
	/* Gallery: show 2–3 photos on mobile instead of 1 */
	#ap-gallery-grid .ap-hide-mobile { display: flex !important; }
	#ap-gallery-grid {
		grid-template-columns: 1fr 1fr !important;
		grid-template-rows: 200px 120px !important;
	}
	#ap-gallery-grid > div:first-child { grid-column: 1 / -1; grid-row: 1; }
	#ap-gallery-grid > div:nth-child(2) { grid-column: 1; grid-row: 2; }
	#ap-gallery-grid > div:nth-child(3) { grid-column: 2; grid-row: 2; }
	#ap-gallery-grid > div:nth-child(n+4) { display: none !important; }
	/* Conditions grid: 1 column */
	.ap-conditions-grid { grid-template-columns: 1fr !important; }
	/* Info grid (Horaires, Langues, etc.): 1 column */
	.ap-listing-info-grid { grid-template-columns: 1fr !important; }
	/* Availability calendar: 4 columns on mobile (was 7) */
	.ap-avail-calendar { grid-template-columns: repeat(4, 1fr) !important; gap: 6px !important; }
	.ap-avail-calendar > div { min-height: 52px !important; }
	/* Devis form: 1 column */
	#ap-devis-form .ap-devis-fields { grid-template-columns: 1fr !important; }
	/* Points forts: 1 column */
	.ap-tab-panel .ap-strengths-grid { grid-template-columns: 1fr !important; }
	/* Lightbox: reduce margins on mobile */
	#ap-lightbox > div:nth-child(4) { inset: 16px 16px 50px !important; }
	#ap-client-photo-lightbox > div:nth-child(4) { inset: 16px 16px 70px !important; }
	/* Listing content & gallery padding */
	.ap-listing-content,
	.ap-listing-gallery-wrap { padding-left: 16px !important; padding-right: 16px !important; }
}
@media (max-width: 480px) {
	.ap-avail-calendar { grid-template-columns: repeat(2, 1fr) !important; gap: 8px !important; }
	.ap-avail-calendar > div { min-height: 56px !important; }
}

/* Explore: 1 col when no sidebar space, hide map on mobile */
@media (max-width: 1024px) {
	.ap-explore-with-map { grid-template-columns: 1fr !important; }
	.ap-explore-map-col { position: static !important; height: 280px !important; }
}
@media (max-width: 768px) {
	.ap-explore-map-col { display: none !important; }
}

/* Tablet: 769–1024 */
@media (min-width: 769px) and (max-width: 1024px) {
	.ap-providers-grid { grid-template-columns: repeat(2, 1fr); }
	.ap-cats-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
	.ap-partners-logos-grid {
		grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
	}
}

/* Desktop: > 1024 */
@media (min-width: 1025px) {
	.ap-providers-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
}
