/* =========================================================
   BestBay — Global sidebar layout
   Desktop: sidebar aligned to BestBay editorial grid
   ========================================================= */

@media screen and (min-width: 60em) {

	/*
	 * One sidebar:
	 * 1250px container => 320px sidebar
	 * Gap => 20px
	 */
	.has-sidebar-right:not(.buddypress):not(.bbpress):not(.woocommerce):not(.woocommerce-page):not(.page-template-full-width-container):not(.post-template-post-full-large):not(.post-template-post-full-small):not(.mediapress):not(.single-fluent-products) .site-wrapper,
	.has-sidebar-right.buddyx-dokan.woocommerce:not(.buddypress):not(.bbpress):not(.woocommerce-page):not(.page-template-full-width-container) .site-wrapper,
	.has-sidebar-right.bpsh-buddypress .site-wrapper,
	.has-buddypress-sidebar-right:not(.bp-user):not(.single-item):not(.group-create):not(.page-template-full-width-container) .site-wrapper,
	.has-bbpress-sidebar-right.bbpress:not(.buddypress) .site-wrapper,
	.has-woocommerce-sidebar-right .site-wrapper,
	.has-fluentcart-sidebar-right.single-fluent-products .site-wrapper,
	.has-sidebar-right.buddypress.search-results .site-wrapper {
		grid-template-columns:
			minmax(0, 1fr)
			320px;
		gap: 20px;
	}

	.has-sidebar-left:not(.buddypress):not(.bbpress):not(.woocommerce):not(.woocommerce-page):not(.page-template-full-width-container):not(.post-template-post-full-large):not(.post-template-post-full-small):not(.mediapress):not(.single-fluent-products) .site-wrapper,
	.has-sidebar-left.buddyx-dokan.woocommerce:not(.buddypress):not(.bbpress):not(.woocommerce-page):not(.page-template-full-width-container) .site-wrapper,
	.has-sidebar-left.bpsh-buddypress .site-wrapper,
	.has-buddypress-sidebar-left:not(.bp-user):not(.single-item):not(.group-create):not(.page-template-full-width-container) .site-wrapper,
	.has-bbpress-sidebar-left.bbpress:not(.buddypress) .site-wrapper,
	.has-woocommerce-sidebar-left .site-wrapper,
	.has-fluentcart-sidebar-left.single-fluent-products .site-wrapper,
	.has-sidebar-left.buddypress.search-results .site-wrapper {
		grid-template-columns:
			320px
			minmax(0, 1fr);
		gap: 20px;
	}

	/*
	 * Two sidebars.
	 *
	 * At 1250px:
	 * 320 + 20 + 570 + 20 + 320 = 1250
	 *
	 * Nice side-effect: the centre column becomes exactly the
	 * same 570px width as the BestBay Hero main column.
	 */
	.has-sidebar-both:not(.buddypress):not(.bbpress):not(.woocommerce):not(.woocommerce-page):not(.page-template-full-width-container):not(.post-template-post-full-large):not(.post-template-post-full-small):not(.mediapress):not(.single-fluent-products) .site-wrapper,
	.has-sidebar-both.buddyx-dokan.woocommerce:not(.buddypress):not(.bbpress):not(.woocommerce):not(.woocommerce-page):not(.page-template-full-width-container) .site-wrapper,
	.has-sidebar-both.bpsh-buddypress .site-wrapper,
	.has-buddypress-sidebar-both:not(.bp-user):not(.single-item):not(.group-create):not(.page-template-full-width-container) .site-wrapper,
	.has-bbpress-sidebar-both.bbpress:not(.buddypress) .site-wrapper,
	.has-woocommerce-sidebar-both .site-wrapper,
	.has-fluentcart-sidebar-both.single-fluent-products .site-wrapper,
	.has-sidebar-both.buddypress.search-results .site-wrapper {
		grid-template-columns:
			320px
			minmax(0, 1fr)
			320px;
		gap: 20px;
	}


	/* BuddyPress: "both" selected but one sidebar is absent. */

	.has-buddypress-sidebar-both.has-no-buddypress-sidebar-left .site-wrapper {
		grid-template-columns:
			minmax(0, 1fr)
			320px !important;
		gap: 20px;
	}

	.has-buddypress-sidebar-both.has-no-buddypress-sidebar-right .site-wrapper {
		grid-template-columns:
			320px
			minmax(0, 1fr) !important;
		gap: 20px;
	}


	/* Page templates */

	.page-template-page-left-sidebar:not(.buddypress):not(.bbpress) #page > .container > .site-wrapper {
		grid-template-columns:
			320px
			minmax(0, 1fr) !important;
		gap: 20px;
	}

	.page-template-page-right-sidebar:not(.buddypress):not(.bbpress) #page > .container > .site-wrapper {
		grid-template-columns:
			minmax(0, 1fr)
			320px !important;
		gap: 20px;
	}

	.page-template-page-both-sidebar:not(.buddypress):not(.bbpress) #page > .container > .site-wrapper {
		grid-template-columns:
			320px
			minmax(0, 1fr)
			320px !important;
		gap: 20px;
	}


	/* Post templates */

	.post-template-post-left-sidebar .site-wrapper {
		grid-template-columns:
			320px
			minmax(0, 1fr) !important;
		gap: 20px;
	}

	.post-template-post-right-sidebar .site-wrapper {
		grid-template-columns:
			minmax(0, 1fr)
			320px !important;
		gap: 20px;
	}

	.post-template-post-both-sidebar .site-wrapper {
		grid-template-columns:
			320px
			minmax(0, 1fr)
			320px !important;
		gap: 20px;
	}


	/* Single post layouts */

	.has-single-post-left-sidebar .site-wrapper {
		grid-template-columns:
			320px
			minmax(0, 1fr) !important;
		gap: 20px;
	}

	.has-single-post-right-sidebar .site-wrapper {
		grid-template-columns:
			minmax(0, 1fr)
			320px !important;
		gap: 20px;
	}

	.has-single-post-both-sidebar .site-wrapper {
		grid-template-columns:
			320px
			minmax(0, 1fr)
			320px !important;
		gap: 20px;
	}


	/* BuddyPress Docs — only where BuddyX actually enables its sidebar grid. */

	.has-sidebar-left.has-docs-sidebar-right .site-wrapper,
	.has-sidebar-right.has-docs-sidebar-right .site-wrapper,
	.has-sidebar-both.has-docs-sidebar-right .site-wrapper {
		grid-template-columns:
			minmax(0, 1fr)
			320px !important;
		gap: 20px;
	}

	/* BuddyPress single objects follow BuddyBoss' two modes. The template
	 * supplies the mode class; the existing 1250px site grid supplies the
	 * actual 910px + 20px + 320px measurements. */
	.bbx-single-object-layout {
		display: grid;
		min-width: 0;
	}

	.bbx-single-object-layout-default {
		grid-template-columns: minmax(0, 1fr) 320px;
		gap: 20px;
		align-items: start;
	}

	/* Account screens without the profile sidebar (notifications, messages,
	 * settings, etc.) must use the complete content width. The PHP template
	 * intentionally omits the sidebar on these screens, so do not reserve an
	 * empty 320px grid track for it. */
	.bbx-single-object-layout-default:not(.bbx-has-profile-sidebar) {
		grid-template-columns: minmax(0, 1fr);
	}

	.bbx-single-object-layout-full {
		display: block;
	}

	.bbx-single-object-main,
	.bbx-single-object-main .member-home,
	.bbx-single-object-main .group-home,
	.bbx-single-object-main .bp-wrap {
		min-width: 0;
	}

	.bbx-single-object-layout-default .bbx-single-object-main {
		width: 100%;
	}

	.bbx-single-object-layout-default .member-home,
	.bbx-single-object-layout-default .group-home {
		display: grid;
		grid-template-columns: minmax(0, 1fr);
		gap: 20px;
		align-items: start;
	}

	.bbx-single-object-layout-default:not(.bbx-has-activity-sidebar) .member-home,
	.bbx-single-object-layout-default:not(.bbx-has-activity-sidebar) .group-home {
		display: block;
	}

	.bbx-single-object-layout-default.bbx-has-activity-sidebar .member-home,
	.bbx-single-object-layout-default.bbx-has-activity-sidebar .group-home {
		grid-template-columns: 320px minmax(0, 1fr);
	}

	.bbx-single-object-layout-default .bbx-single-object-main > #item-header {
		width: 100%;
	}

	.bbx-single-object-layout-full .member-home,
	.bbx-single-object-layout-full .group-home {
		display: grid;
		grid-template-columns: minmax(0, 1fr);
		gap: 20px;
		align-items: start;
	}

	.bbx-single-object-layout-full.bbx-has-profile-sidebar .member-home,
	.bbx-single-object-layout-full.bbx-has-profile-sidebar .group-home {
		grid-template-columns: minmax(0, 1fr) 320px;
	}

	.bbx-single-object-layout-full.bbx-has-activity-sidebar.bbx-has-profile-sidebar .member-home,
	.bbx-single-object-layout-full.bbx-has-activity-sidebar.bbx-has-profile-sidebar .group-home {
		grid-template-columns: 320px minmax(0, 1fr) 320px;
	}

	.bbx-single-object-layout-full.bbx-has-activity-sidebar:not(.bbx-has-profile-sidebar) .member-home,
	.bbx-single-object-layout-full.bbx-has-activity-sidebar:not(.bbx-has-profile-sidebar) .group-home {
		grid-template-columns: 320px minmax(0, 1fr);
	}

	.bbx-single-object-layout .primary-sidebar {
		min-width: 0;
		width: auto;
		align-self: stretch;
	}

	/* BuddyX's parent stylesheet makes every cover 100vw. The option is the
	 * source of truth: default is constrained by the main column, full spans
	 * the existing 1250px BuddyX content container. */
	.bbx-single-object-layout .users-header #cover-image-container,
	.bbx-single-object-layout .groups-header #cover-image-container,
	.bbx-single-object-layout .users-header #header-cover-image,
	.bbx-single-object-layout .groups-header #header-cover-image {
		width: 100%;
		left: auto;
		right: auto;
		margin-left: 0;
		margin-right: 0;
	}

	.bbx-single-object-layout-full .users-header #cover-image-container,
	.bbx-single-object-layout-full .groups-header #cover-image-container,
	.bbx-single-object-layout-full .users-header #header-cover-image,
	.bbx-single-object-layout-full .groups-header #header-cover-image {
		width: 100%;
		left: auto;
		right: auto;
		margin-left: 0;
		margin-right: 0;
	}
}

/* =========================================================
   Sidebar
   ========================================================= */

.bestbay-sidebar {
	margin-left: auto;
	margin-top: 0;
	float: none;
	clear: both;
}

@media screen and (min-width: 60em) {
	body.buddypress.has-single-member-sidebar #page,
	body.buddypress.has-single-member-activity-sidebar #page,
	body.buddypress.has-single-group-sidebar #page,
	body.buddypress.has-single-group-activity-sidebar #page {
		overflow: visible;
	}

	.bbx-single-object-layout .bbx-sticky-sidebar {
		position: sticky;
		top: 132px;
		width: 100%;
	}
}



/* =========================================================
   BuddyX compatibility
   ========================================================= */

.bestbay-content-layout #primary.site-main {
	float: none;
}




/* =========================================================
   Tablet
   ========================================================= */

@media (max-width: 900px) {

	.bestbay-sidebar {
		width: 100%;
		margin-left: 0;
	}

}
