/* Reuse FooGallery PRO native search classes so existing theme and custom CSS
   for gallery searches automatically styles the album search as well. */
.foogallery-album-search.fg-search-wrap {
	width: 100%;
	margin: 0 0 30px;
}

.foogallery-album-search .fg-search-inner {
	max-width: 760px;
}

.foogallery-album-search .fg-search-icon {
	display: block;
	width: 18px;
	height: 18px;
}

.foogallery-album-search-media {
	clear: both;
	width: 100%;
	margin: -4px 0 30px;
	padding: 16px 18px 18px;
	box-sizing: border-box;
	border: 1px solid #e1e4e8;
	border-radius: 8px;
	background: #f8f9fa;
}

.foogallery-album-search-media-title {
	margin: 0 0 14px;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.4;
}

/* The matching media are rendered by FooGallery itself. This keeps the
 * configured lightbox, watermarking, ecommerce/cart and other extensions. */
.foogallery-album-search-media-gallery {
	width: 100%;
}

.foogallery-album-search-media-gallery .foogallery {
	margin: 0 !important;
}

.foogallery-album-search-media-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(150px, 180px));
	gap: 14px;
}

.foogallery-album-search-media-item {
	display: block;
	min-width: 0;
	overflow: hidden;
	border: 1px solid #ddd;
	border-radius: 6px;
	background: #fff;
	color: inherit;
	text-decoration: none !important;
	box-shadow: 0 1px 2px rgba(0,0,0,.06);
}

.foogallery-album-search-media-item img {
	display: block;
	width: 100%;
	height: 120px;
	object-fit: cover;
	margin: 0;
}

.foogallery-album-search-media-caption {
	display: block;
	padding: 8px 9px;
	overflow: hidden;
	font-size: 13px;
	line-height: 1.35;
	text-overflow: ellipsis;
	white-space: nowrap;
}

@media (max-width: 600px) {
	.foogallery-album-search-media {
		padding: 13px;
	}

	.foogallery-album-search-media-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 10px;
	}

	.foogallery-album-search-media-item img {
		height: 110px;
	}
}

/* When searching, each gallery and its matching media form one readable result block. */
.foogallery-album-gallery-list.foogallery-album-search-active > li {
	float: none !important;
	width: 100% !important;
	max-width: 100% !important;
	margin-left: 0 !important;
	margin-right: 0 !important;
	margin-bottom: 28px !important;
}

.foogallery-album-gallery-list.foogallery-album-search-active > li > .foogallery-pile {
	width: 100%;
	max-width: 100%;
}

.foogallery-album-gallery-list.foogallery-album-search-active .foogallery-album-search-media {
	margin-top: 14px;
}

/* Keep the All-In-One Stack search results below the corresponding pile. */
.foogallery-stack-album .fg-piles > .foogallery-album-search-media {
	width: 100%;
	position: relative;
	clear: both;
}

/* During album searches, each matching gallery and its media form one separate result block. */
.foogallery-album-gallery-list.foogallery-album-search-active > li {
    float: none !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    margin-bottom: 28px !important;
}
.foogallery-album-gallery-list.foogallery-album-search-active > li > .foogallery-pile {
    width: 100%;
    max-width: 100%;
}
.foogallery-album-gallery-list.foogallery-album-search-active .foogallery-album-search-media {
    margin-top: 14px;
}
.foogallery-stack-album .fg-piles > .foogallery-album-search-media {
    width: 100%;
    position: relative;
    clear: both;
}


/* Center the album gallery tile inside its matching-media result block.
 * The native FooGallery renderer remains untouched for the matching images. */
.foogallery-album-gallery-list.foogallery-album-search-active > li {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    text-align: center;
}
.foogallery-album-gallery-list.foogallery-album-search-active > li > .foogallery-pile,
.foogallery-album-gallery-list.foogallery-album-search-active > li > a.foogallery-pile-thumbnail,
.foogallery-album-gallery-list.foogallery-album-search-active > li > .foogallery-pile-thumbnail {
    align-self: center !important;
    margin-left: auto !important;
    margin-right: auto !important;
}
.foogallery-album-gallery-list.foogallery-album-search-active .foogallery-album-search-media {
    align-self: stretch;
    text-align: left;
}
.foogallery-stack-album .fg-piles > ul.fg-pile {
    margin-left: auto !important;
    margin-right: auto !important;
}
.foogallery-stack-album .fg-piles > .foogallery-album-search-media {
    margin-left: auto;
    margin-right: auto;
}


/* The gallery preview is part of its result card and sits above the media count. */
.foogallery-album-search-media > .foogallery-pile,
.foogallery-album-search-media > ul.fg-pile {
    display: block !important;
    float: none !important;
    width: auto !important;
    max-width: 360px !important;
    margin: 0 auto 14px !important;
    text-align: center !important;
}
.foogallery-album-search-media > .foogallery-pile .foogallery-pile-inner,
.foogallery-album-search-media > ul.fg-pile .fg-pile-inner {
    margin-left: auto !important;
    margin-right: auto !important;
}
.foogallery-album-search-media > .foogallery-album-search-media-title {
    clear: both;
    text-align: center;
    margin-top: 0;
}
.foogallery-album-search-media-gallery {
    clear: both;
}


/* All album search result cards use the same full available width, regardless
 * of how many matching media items are returned for an individual gallery. */
.foogallery-album-gallery-list.foogallery-album-search-active > li.fgt-album-search-result-tile {
    box-sizing: border-box !important;
    display: flex !important;
    flex: 0 0 100% !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    grid-column: 1 / -1 !important;
}
.foogallery-album-search-media {
    display: block !important;
    box-sizing: border-box !important;
    flex: 0 0 100% !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    grid-column: 1 / -1 !important;
}
.foogallery-stack-album .fg-piles > .foogallery-album-search-media {
    flex: 0 0 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
}
.foogallery-album-search-media-gallery,
.foogallery-album-search-media-gallery > .foogallery {
    box-sizing: border-box;
    width: 100% !important;
    max-width: 100% !important;
}


/* Uniform album search result cards, independent of the number of matches.
 * Apply the layout to the real list container, including theme-provided album
 * templates, rather than relying on FooGallery's default template classes. */
.fgt-album-search-results-list,
.foogallery-album-search-active.fgt-album-search-results-list {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}
.fgt-album-search-results-list > li.fgt-album-search-result-tile {
    display: flex !important;
    flex: 0 0 100% !important;
    align-self: stretch !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}
.fgt-album-search-results-list > li.fgt-album-search-result-tile > .foogallery-album-search-media {
    flex: 0 0 100% !important;
    align-self: stretch !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
}
.fgt-album-search-results-list > .foogallery-album-search-media,
.foogallery-stack-album .fg-piles > .foogallery-album-search-media {
    flex: 0 0 100% !important;
    align-self: stretch !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.fgt-album-search-results-list > ul.fg-pile {
    flex: 0 0 100% !important;
    align-self: center !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}


/* Center the empty-state message shown inside album-search results. */
.foogallery-album-search-media.fgt-album-search-empty .fgt-no-results {
    display: block;
    width: 100%;
    margin: 0;
    padding: 1em 0;
    text-align: center !important;
    box-sizing: border-box;
}


/* Album-wide empty state: use the exact class emitted by the album search. */
.fgt-album-no-results {
    display: block !important;
    position: relative !important;
    clear: both !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    margin: 1.5rem 0 !important;
    padding: 1rem 0 !important;
    text-align: center !important;
    box-sizing: border-box !important;
}

/* Empty gallery result inside an album search and server-side gallery search. */
.foogallery-album-search-media.fgt-album-search-empty .fgt-no-results,
.fgt-gallery-no-results {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 1rem 0 !important;
    text-align: center !important;
    box-sizing: border-box;
}


/* Ensure empty-state messages remain readable even when the active theme or
 * FooGallery styling collapses paragraph typography to zero. */
.fgt-gallery-no-results,
.fgt-album-no-results {
    display: block !important;
    font-size: 1rem !important;
    line-height: 1.5 !important;
    font-weight: 400 !important;
    text-indent: 0 !important;
    -webkit-text-fill-color: currentColor;
}
