/* Bricks Drive Embed Styles */

.brxe-drive-embed,
.bricks-drive-embed-root {
    width: 100%;
}

.bricks-drive-gallery {
    width: 100%;
    margin: 0 auto;
}

/* Grid Layout */
.bricks-drive-gallery.layout-grid {
    display: grid;
    grid-template-columns: repeat(var(--bde-cols, 3), 1fr);
    gap: 20px;
    /* Default override by element control */
}

/* Masonry Layout (CSS Columns) */
/* Masonry Layout */
.bricks-drive-gallery.is-masonry .bricks-drive-item {
    display: inline-block;
    width: 100%;
    break-inside: avoid;
}

/* Item Styling */
.bricks-drive-item {
    position: relative;
    border-radius: 4px;
    overflow: hidden;
    background: #f0f0f0;
}

.bricks-drive-item img {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
    object-fit: cover;
}

.bricks-drive-gallery.layout-grid .bricks-drive-item img {
    height: 100%;
    aspect-ratio: 1/1;
    /* Default square for grid, user can override via custom CSS if needed or we add ratio control */
}

/* Map Styles */
.bricks-drive-map-wrapper {
    position: relative;
    width: 100%;
    min-height: 50px;
    /* Ensure at least some height if map fails */
}

.bricks-drive-map {
    width: 100%;
    height: 100%;
    min-height: 200px;
    /* Fallback min-height */
}

/* Info Window */
.bricks-drive-map-infowindow {
    padding: 10px;
    font-family: inherit;
    color: #333;
}

.bricks-drive-map-infowindow strong {
    display: block;
    margin-bottom: 5px;
    font-size: 1.1em;
}

.bricks-drive-map-infowindow a {
    color: #0073aa;
    text-decoration: none;
    font-weight: 500;
}

.bricks-drive-map-infowindow a:hover {
    text-decoration: underline;
}

/* Video Overlay */
.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.2);
    transition: background 0.3s;
}

.bricks-drive-lightbox-link:hover .video-overlay {
    background: rgba(0, 0, 0, 0.4);
}

.play-icon {
    font-size: 3rem;
    color: #fff;
    opacity: 0.9;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Lightbox */
.bricks-drive-lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.9);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.bricks-drive-lightbox-overlay.active {
    opacity: 1;
    visibility: visible;
}

.bricks-drive-lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
}

.bricks-drive-lightbox-content img {
    max-height: 90vh;
    max-width: 90vw;
    display: block;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

.bricks-drive-lightbox-content iframe {
    width: 80vw;
    height: 45vw;
    /* 16:9 approx */
    max-width: 1200px;
    max-height: 80vh;
    border: none;
    background: #000;
}

.bricks-drive-lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #fff;
    font-size: 40px;
    cursor: pointer;
    z-index: 100;
}

/* Pagination */
.bricks-drive-pagination {
    grid-column: 1 / -1;
    text-align: center;
    margin-top: 20px;
    width: 100%;
}

.bricks-drive-load-more {
    display: inline-block;
    cursor: pointer;
    /* Visuals handled by .bricks-button class */
}

/* Download Button */
.bricks-drive-item {
    position: relative;
    /* Ensure existing styles are kept */
}

.bricks-drive-download {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.8);
    color: #333;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    text-decoration: none;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.bricks-drive-item:hover .bricks-drive-download {
    opacity: 1;
    visibility: visible;
    opacity: 1;
}

.bricks-drive-download:hover {
    background: #fff;
    color: #000;
}

/* Filter Bar */
.bricks-drive-filter {
    display: flex;
    justify-content: flex-end;
    /* Default Right */
    width: 100%;
    margin-bottom: 20px;
}

/* Filter (Button Group) */
.bricks-drive-filter-group {
    display: inline-flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: inherit;
}

.bricks-drive-filter-btn {
    padding: 8px 20px;
    border: 1px solid #e1e1e1;
    background: #fff;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.bricks-drive-filter-btn:hover {
    background: #f5f5f5;
    border-color: #ccc;
}

.bricks-drive-filter-btn.active {
    background: #333;
    color: #fff;
    border-color: #333;
}

/* Lightbox Navigation */
.bricks-drive-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: #fff;
    font-size: 40px;
    padding: 10px 20px;
    cursor: pointer;
    z-index: 1001;
    user-select: none;
    transition: background 0.3s;
    border-radius: 4px;
}

.bricks-drive-lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.1);
}

.bricks-drive-lightbox-nav.prev {
    left: 20px;
}

.bricks-drive-lightbox-nav.next {
    right: 20px;
}

/* Justified Layout (Flickr Style) */
.bricks-drive-gallery.is-justified {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
}

.bricks-drive-gallery.is-justified .bricks-drive-item {
    flex-grow: 1;
    width: auto;
    position: relative;
    overflow: hidden;
}

.bricks-drive-gallery.is-justified .bricks-drive-item img {
    width: auto;
    height: 100%;
    object-fit: cover;
    max-width: none;
    min-width: 100%;
    aspect-ratio: auto !important;
}

/* Video overlay fix for justified */
.bricks-drive-gallery.is-justified .video-overlay {
    z-index: 5;
}

/* Ensure last row doesn't stretch to fill entire width if empty */
.bricks-drive-gallery.is-justified::after {
    content: "";
    flex-grow: 1000000;
}

/* PhotoSwipe Overrides */
.pswp {
    z-index: 999999 !important;
    /* Ensure it's above everything including Bricks header */
}

.pswp__button {
    opacity: 1 !important;
    /* Force visibility */
}

/* Ensure icons are visible even if background is light */
.pswp__button--arrow {
    background-color: rgba(0, 0, 0, 0.3) !important;
    border-radius: 50%;
}

/* Fix Bricks Builder Conflict: Force SVG visibility */
.pswp.bricks-drive-pswp .pswp__button svg {
    display: block !important;
    width: 100%;
    height: 100%;
}

/* Lightbox Image Radius & Fit */
.pswp__img {
    border-radius: 8px !important;
    object-fit: contain !important;
}