/**
 * Custom styles for Shared Albums for Google Photos (by JanZeman) plugin
 */

.jzsa-album {
    width: 100%;
    height: 100%;
    /* Use configurable background; fallback to white if not set */
    background-color: var(--gallery-bg-color, #FFFFFF);
    position: relative; /* For loader and overlay positioning */
}

/* Make sure all structural layers share the same background color */
.jzsa-album,
.jzsa-album .swiper,
.jzsa-album .swiper-wrapper,
.jzsa-album .swiper-slide,
.jzsa-album .swiper-zoom-container {
    background-color: var(--gallery-bg-color, #FFFFFF);
}

.jzsa-album .swiper-slide img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    width: auto;
    height: auto;
}

/* image-fit options */
.jzsa-album[data-image-fit="cover"] .swiper-slide img { object-fit: cover; width: 100%; height: 100%; }
.jzsa-album[data-image-fit="stretch"] .swiper-slide img { width: 100%; height: 100%; object-fit: fill; }

/* Navigation buttons */
.jzsa-album .swiper-button-next,
.jzsa-album .swiper-button-prev {
    color: #fff;
    background: rgba(0, 0, 0, 0.5);
    width: 44px;
    height: 44px;
    border-radius: 50%;
}

.jzsa-album .swiper-button-next:after,
.jzsa-album .swiper-button-prev:after { font-size: 20px; }

/* Persistent Overlays (Stick to Viewport) */
.jzsa-persistent-filename {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 30;
    pointer-events: none;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    max-width: 80%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s ease;
    will-change: opacity;
}

.jzsa-persistent-info {
    position: absolute;
    bottom: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.5;
    z-index: 30;
    pointer-events: none;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    max-width: 300px;
    text-align: right;
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.2s ease;
    will-change: opacity;
}

/* Fullscreen adjustments for persistent overlays */
.jzsa-album.jzsa-is-fullscreen .jzsa-persistent-filename { bottom: 80px; }
.jzsa-album.jzsa-is-fullscreen .jzsa-persistent-info { bottom: 60px; right: 25px; }

/* Control Buttons & Progress */
.jzsa-album .swiper-button-external-link,
.jzsa-album .swiper-button-download,
.jzsa-album .swiper-button-fullscreen {
    position: absolute;
    top: 10px;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    cursor: pointer;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
}

.jzsa-album .swiper-button-external-link { left: 10px; }
.jzsa-album .swiper-button-download { left: 10px; }
.jzsa-album[data-show-link-button="true"][data-show-download-button="true"] .swiper-button-download { left: 60px; }
.jzsa-album .swiper-button-fullscreen { right: 10px; }

/* Icons */
.jzsa-album .swiper-button-external-link:after {
    content: ''; display: block; width: 20px; height: 20px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z"/></svg>');
    background-size: contain; background-repeat: no-repeat;
}

.jzsa-album .swiper-button-download:after {
    content: ''; display: block; width: 20px; height: 20px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"/></svg>');
    background-size: contain; background-repeat: no-repeat;
}

/* Autoplay Progress */
.jzsa-album .swiper-autoplay-progress {
    position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%);
    width: 39px; height: 2px; background: rgba(255, 255, 255, 0.2);
    border-radius: 1px; z-index: 40; overflow: hidden;
}
.jzsa-album.jzsa-is-fullscreen .swiper-autoplay-progress { bottom: 12px; }
.jzsa-album .swiper-autoplay-progress-bar { height: 100%; width: 100%; background: rgba(255, 255, 255, 0.8); transform-origin: left; transition: transform linear; }

/* Fullscreen Button Icon Toggle */
.jzsa-album .swiper-button-fullscreen:after {
    content: ''; display: block; width: 20px; height: 20px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"/></svg>');
    background-size: contain; background-repeat: no-repeat;
}
.jzsa-album:fullscreen .swiper-button-fullscreen:after,
.jzsa-album.jzsa-pseudo-fullscreen .swiper-button-fullscreen:after {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"/></svg>');
}

/* Fullscreen Base */
.jzsa-album:fullscreen,
.jzsa-album.jzsa-pseudo-fullscreen {
    width: 100vw !important; height: 100vh !important;
    max-width: 100vw; max-height: 100vh;
    background-color: var(--gallery-bg-color, #FFFFFF);
    z-index: 9999;
}

/* Pagination & Title */
.jzsa-album .swiper-album-title {
    position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.5); color: #fff; padding: 6px 16px; border-radius: 20px;
    font-size: 14px; font-weight: 600; z-index: 40; max-width: 80%; text-align: center;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.jzsa-album .swiper-pagination {
    background: rgba(0, 0, 0, 0.5); color: #fff; padding: 4px 16px; border-radius: 20px;
    display: inline-block; bottom: 10px; left: 10px; right: 10px; margin: 0 auto;
    max-width: max-content; width: auto; font-size: 14px; z-index: 40;
}
.jzsa-album.jzsa-is-fullscreen .swiper-pagination { bottom: 25px; }

/* Loader Overlay */
.jzsa-album .jzsa-loader {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    background: radial-gradient(circle at top, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.85));
    color: #fff; z-index: 50; transition: opacity 0.35s ease-in-out;
}
.jzsa-album.jzsa-loaded .jzsa-loader { opacity: 0; visibility: hidden; }
.jzsa-loader-spinner { width: 30px; height: 30px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.35); border-top-color: #ffffff; animation: jzsa-spin 0.9s linear infinite; }
@keyframes jzsa-spin { to { transform: rotate(360deg); } }

/* Mosaic Styles */
.jzsa-gallery-wrapper { display: flex; gap: 15px; width: 100%; height: 100%; }
.jzsa-gallery-wrapper.jzsa-mosaic-left { flex-direction: row-reverse; }
.jzsa-gallery-wrapper.jzsa-mosaic-right { flex-direction: row; }
.jzsa-gallery-wrapper .jzsa-album { flex: 1; min-width: 0; }

.jzsa-mosaic {
    width: var(--mosaic-width, 250px); height: 100%; max-height: 100%;
    flex-shrink: 0; overflow: hidden; position: relative; background: rgba(0,0,0,0.05); border-radius: 8px;
}

.jzsa-mosaic .swiper-slide {
    cursor: pointer; opacity: 0.5; transition: all 0.3s ease;
    overflow: hidden; border-radius: 4px;
}

.jzsa-mosaic .swiper-slide img { width: 100%; height: 100%; object-fit: cover; }
.jzsa-mosaic .swiper-slide:hover { opacity: 0.8; transform: scale(1.02); }
.jzsa-mosaic .swiper-slide-thumb-active { opacity: 1; outline: 3px solid #0b57d0; outline-offset: -3px; }

/* Scroll indicators for mosaic */
.jzsa-mosaic::before, .jzsa-mosaic::after {
    content: ''; position: absolute; left: 0; right: 0; height: 40px; z-index: 10;
    pointer-events: none; display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 24px; text-shadow: 0 0 4px rgba(0,0,0,0.8); opacity: 0; transition: opacity 0.3s;
}
.jzsa-mosaic::before { top: 0; background: linear-gradient(to bottom, rgba(0,0,0,0.5), transparent); content: '▴'; align-items: flex-start; padding-top: 5px; }
.jzsa-mosaic::after { bottom: 0; background: linear-gradient(to top, rgba(0,0,0,0.5), transparent); content: '▾'; align-items: flex-end; padding-bottom: 5px; }
.jzsa-mosaic:hover::before, .jzsa-mosaic:hover::after { opacity: 1; }


/* Responsive Mobile */
@media (max-width: 480px) {
    .jzsa-gallery-wrapper { flex-direction: column !important; }
    .jzsa-mosaic { width: 100%; height: 80px; }
    .jzsa-mosaic::before, .jzsa-mosaic::after { display: none; }
}
