/* Smart Gallery – Frontend CSS */

.sg-gallery-wrap {
    --sg-gap: 12px;
    width: 100%;
    margin: 0 auto;
}

/* =====================================================
   MASONRY  (CSS columns approach – zero JS needed)
   Works with images of any aspect ratio.
   ===================================================== */
.sg-masonry {
    column-gap: var(--sg-gap);
    orphans: 1;
    widows: 1;
}

/* Default: responsive columns (auto) */
.sg-gallery-wrap[data-columns="auto"] .sg-masonry {
    columns: 4 220px;     /* at least 220px wide, up to 4 cols */
}
.sg-gallery-wrap[data-columns="2"] .sg-masonry { columns: 2; }
.sg-gallery-wrap[data-columns="3"] .sg-masonry { columns: 3; }
.sg-gallery-wrap[data-columns="4"] .sg-masonry { columns: 4; }

@media (max-width: 900px) {
    .sg-gallery-wrap[data-columns="auto"] .sg-masonry { columns: 3 180px; }
    .sg-gallery-wrap[data-columns="4"] .sg-masonry    { columns: 3; }
}
@media (max-width: 600px) {
    .sg-gallery-wrap[data-columns="auto"] .sg-masonry,
    .sg-gallery-wrap[data-columns="3"] .sg-masonry,
    .sg-gallery-wrap[data-columns="4"] .sg-masonry { columns: 2; }
}
@media (max-width: 380px) {
    .sg-gallery-wrap .sg-masonry { columns: 1; }
}

/* Individual item */
.sg-item {
    break-inside: avoid;
    margin-bottom: var(--sg-gap);
    overflow: hidden;
    border-radius: 6px;
    position: relative;
    display: block;
    line-height: 0;
    cursor: pointer;
}

.sg-item img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform .35s ease;
    border-radius: 6px;
}
.sg-item:hover img { transform: scale(1.04); }

/* Overlay */
.sg-item-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.28);
    display: flex; align-items: center; justify-content: center;
    opacity: 0;
    transition: opacity .25s ease;
    border-radius: 6px;
}
.sg-item:hover .sg-item-overlay { opacity: 1; }

.sg-zoom-icon {
    width: 42px; height: 42px;
    background: rgba(255,255,255,.9);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 28px; color: #111; line-height: 1;
    font-family: sans-serif;
    box-shadow: 0 2px 12px rgba(0,0,0,.2);
}

/* Remove link default styling */
.sg-lightbox-trigger {
    display: block;
    position: relative;
    text-decoration: none;
    line-height: 0;
}

/* =====================================================
   LIGHTBOX
   ===================================================== */
.sg-lb-overlay {
    position: fixed; inset: 0; z-index: 99999;
    background: rgba(0,0,0,.88);
    display: flex; align-items: center; justify-content: center;
    animation: sg-lb-in .22s ease;
    touch-action: pan-y;
}
@keyframes sg-lb-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.sg-lb-inner {
    position: relative;
    max-width: 94vw;
    max-height: 94vh;
    display: flex; flex-direction: column; align-items: center;
    animation: sg-lb-pop .25s cubic-bezier(.34,1.56,.64,1);
}
@keyframes sg-lb-pop {
    from { transform: scale(.88); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}

.sg-lb-img {
    max-width: 90vw;
    max-height: 88vh;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 24px 60px rgba(0,0,0,.6);
    display: block;
    transition: opacity .2s;
}

.sg-lb-caption {
    color: rgba(255,255,255,.75);
    margin-top: 12px;
    font-size: 14px;
    text-align: center;
    max-width: 600px;
}

/* Nav arrows */
.sg-lb-prev,
.sg-lb-next {
    position: fixed; top: 50%; transform: translateY(-50%);
    background: rgba(255,255,255,.12); border: none; color: #fff;
    width: 52px; height: 52px; border-radius: 50%;
    font-size: 26px; cursor: pointer; z-index: 100000;
    transition: background .2s;
    display: flex; align-items: center; justify-content: center;
}
.sg-lb-prev { left: 16px; }
.sg-lb-next { right: 16px; }
.sg-lb-prev:hover, .sg-lb-next:hover { background: rgba(255,255,255,.28); }

/* Close button */
.sg-lb-close {
    position: fixed; top: 16px; right: 20px;
    background: rgba(255,255,255,.12); border: none; color: #fff;
    width: 44px; height: 44px; border-radius: 50%;
    font-size: 22px; cursor: pointer; z-index: 100001;
    transition: background .2s;
    display: flex; align-items: center; justify-content: center;
}
.sg-lb-close:hover { background: rgba(255,255,255,.28); }

/* Counter */
.sg-lb-counter {
    position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
    color: rgba(255,255,255,.6); font-size: 13px; z-index: 100001;
    pointer-events: none;
}

/* Misc */
.sg-error, .sg-empty { color: #888; font-style: italic; }

/* =====================================================
   LIGHTBOX – Thumbnail strip
   ===================================================== */
.sg-lb-thumbs {
    position: fixed;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    max-width: 90vw;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 6px 8px;
    background: rgba(0, 0, 0, .55);
    border-radius: 10px;
    z-index: 100001;
    scroll-behavior: smooth;
    /* Hide scrollbar but keep scroll */
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.sg-lb-thumbs::-webkit-scrollbar { display: none; }

.sg-lb-thumb {
    flex: 0 0 auto;
    width: 80px;
    height: 80px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    background: none;
    overflow: hidden;
    opacity: .55;
    transition: opacity .2s, border-color .2s, transform .15s;
}
.sg-lb-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 4px;
    pointer-events: none;
}
.sg-lb-thumb:hover {
    opacity: .85;
    transform: scale(1.08);
}
.sg-lb-thumb--active {
    border-color: #fff;
    opacity: 1;
    transform: scale(1.08);
}

/* Push counter up a bit so it doesn't overlap thumbs */
.sg-lb-counter {
    bottom: 90px;
    top: auto !important;
}

@media (max-width: 600px) {
    .sg-lb-thumbs {
        bottom: auto;
        top: 18px;
        max-width: 96vw;
    }
    .sg-lb-counter {
        bottom: 12px;
        top: auto !important;
    }
}

/* Smart Gallery – external opener + cleaner lightbox style */
.sg-open-gallery-hidden {
    display: none !important;
}
.sg-open-gallery-button {
    cursor: pointer;
}
.sg-lb-prev,
.sg-lb-next,
.sg-lb-close {
    background: transparent !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}
.sg-lb-prev:hover,
.sg-lb-next:hover,
.sg-lb-close:hover {
    background: transparent !important;
    transform: translateY(-50%) scale(1.08);
}
.sg-lb-close:hover {
    transform: scale(1.08);
}

/* ============================================================
   GALLERY LIST — Frontend prikaz (v1.2.0)
   ============================================================ */

.sg-list-wrap {
    --sg-list-cols: 5;
    --sg-list-gap: 4px;
    display: grid;
    grid-template-columns: repeat(var(--sg-list-cols), 1fr);
    gap: var(--sg-list-gap);
    width: 100%;
}

/* Hidden lightbox divovi — nikad vidljivi */
.sg-list-hidden { display: none !important; }

.sg-list-item { display: flex; flex-direction: column; }

/* Thumb */
.sg-list-thumb {
    display: block;
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    background: #1e1e1e;
    text-decoration: none;
}

.sg-list-thumb img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.45s ease, filter 0.45s ease;
    filter: brightness(0.75);
}
.sg-list-thumb:hover img {
    transform: scale(1.07);
    filter: brightness(0.3);
}

/* Placeholder kad nema slike */
.sg-list-thumb-placeholder {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    background: #2a2a2a;
}
.sg-list-thumb-placeholder .dashicons { font-size: 40px; color: rgba(255,255,255,0.2); }

/* Overlay na hover */
.sg-list-overlay {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    padding: 16px; text-align: center;
    opacity: 0;
    transition: opacity 0.4s ease;
}
.sg-list-thumb:hover .sg-list-overlay { opacity: 1; }

.sg-list-overlay-inner {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.sg-list-overlay-title {
    font-size: 13px; font-weight: 700; color: #fff;
    text-transform: uppercase; letter-spacing: 1.5px;
    border-top: 1px solid rgba(255,255,255,0.45);
    border-bottom: 1px solid rgba(255,255,255,0.45);
    padding: 8px 16px; line-height: 1.4;
}
.sg-list-overlay-sub {
    font-size: 11px; color: rgba(255,255,255,0.7);
    letter-spacing: 1px;
}

/* Naziv ispod thumba */
.sg-list-meta {
    padding: 8px 2px 0;
    display: flex; flex-direction: column; gap: 2px;
}
.sg-list-title {
    font-size: 11px; font-weight: 700;
    color: #222;
    text-transform: uppercase; letter-spacing: 0.8px;
    line-height: 1.3;
}
.sg-list-subtitle {
    font-size: 10px; color: #888;
    letter-spacing: 0.5px;
}

/* Responsive */
@media (max-width: 900px) {
    .sg-list-wrap { --sg-list-cols: 3; }
}
@media (max-width: 580px) {
    .sg-list-wrap { --sg-list-cols: 2; }
}
