/**
 * Smart Gallery Pro - Clean CSS based on Magic Grid article
 * Version: 1.0.1
 * Based on official Magic Grid documentation
 */

/* =================================
   ZÁKLADNÍ KONTEJNER - FLEXIBILNÍ 100%
   ================================= */
.sgp-gallery-container,
.sgp-gallery-grid {
    position: relative;
    width: 100% !important; /* Fluidní kontejner */
    max-width: 100%;
    margin: 0 auto;
}

/* =================================
   GALLERY ITEMS - Pro Magic Grid Masonry
   ================================= */
.sgp-gallery-item {
    /* Pro správný masonry efekt */
    position: relative;
    display: inline-block;
    vertical-align: top;
    box-sizing: border-box;
    /* KRITICKÉ - žádné mezery! */
    margin: 0 !important;
    padding: 0 !important;
    /* Obrázky musí vyplnit celý prostor */
    line-height: 0;
}

/* Když Magic Grid nastaví transform */
.sgp-gallery-item[style*="transform"] {
    position: absolute !important;
}

/* Gap (mezery) řídí Magic Grid přes gutter parametr */
.sgp-gallery-container[data-gap] .sgp-gallery-item {
    /* Magic Grid nastaví správné pozice s mezerami */
    margin: 0 !important;
}

/* Když gap = 0 */
[data-gap="0"] .sgp-gallery-item {
    margin: 0 !important;
    padding: 0 !important;
}

[data-gap="0"][data-columns="2"] .sgp-gallery-item {
    width: 50%;
}

[data-gap="0"][data-columns="3"] .sgp-gallery-item {
    width: 33.333%;
}

[data-gap="0"][data-columns="4"] .sgp-gallery-item {
    width: 25%;
}

/* =================================
   OBRÁZKY - Masonry efekt s orientací
   ================================= */
.sgp-gallery-item img {
    width: 100%;
    height: auto;
    display: block;
    /* Odstranit mezery pod obrázky */
    vertical-align: top;
    line-height: 0;
}

/* UNIFORMNÍ VÝŠKA - nejlepší řešení pro masonry */
.sgp-gallery-item {
    height: 280px !important;  /* Všechny položky stejná výška */
    overflow: hidden;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sgp-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;  /* Vyplní celý prostor */
    object-position: center;  /* Centrovat ořez */
}

/* Alternativa - zachovat poměry s max výškou */
/*
.sgp-gallery-item.sgp-portrait img {
    max-height: 350px;
    width: auto;
    object-fit: contain;
}
*/

/* Landscape obrázky */
.sgp-gallery-item.sgp-landscape img {
    width: 100%;
    height: auto;
}

/* Square obrázky */
.sgp-gallery-item.sgp-square img {
    width: 100%;
    height: auto;
}

/* Odkazy bez mezer */
.sgp-gallery-item a,
.sgp-gallery-link {
    display: block;
    line-height: 0;
    text-decoration: none;
    /* Žádné mezery */
    margin: 0;
    padding: 0;
}

.sgp-gallery-item a {
    display: block;
    text-decoration: none;
}

/* =================================
   PŘED INICIALIZACÍ - SKRÝT
   ================================= */
.sgp-gallery-container:not([data-sgp-initialized]) {
    opacity: 0;
    min-height: 200px;
}

/* =================================
   PO INICIALIZACI - ZOBRAZIT
   ================================= */
.sgp-gallery-container[data-sgp-initialized] {
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* =================================
   POPISKY
   ================================= */
.sgp-caption {
    padding: 10px;
    font-size: 14px;
    line-height: 1.4;
}

.sgp-caption-bottom {
    /* Pod obrázkem */
}

.sgp-caption-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px;
}

.sgp-caption-hover {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px;
    opacity: 0;
    transition: opacity 0.3s;
}

.sgp-gallery-item:hover .sgp-caption-hover {
    opacity: 1;
}

/* =================================
   RESPONZIVNÍ DESIGN
   ================================= */
@media (max-width: 768px) {
    .sgp-gallery-item {
        width: calc(50% - 10px);
    }

    [data-columns="3"] .sgp-gallery-item,
    [data-columns="4"] .sgp-gallery-item,
    [data-columns="5"] .sgp-gallery-item {
        width: calc(50% - 10px);
    }
}

@media (max-width: 480px) {
    .sgp-gallery-item {
        width: 100%;
    }

    [data-columns="2"] .sgp-gallery-item,
    [data-columns="3"] .sgp-gallery-item,
    [data-columns="4"] .sgp-gallery-item,
    [data-columns="5"] .sgp-gallery-item {
        width: 100%;
    }
}

/* =================================
   ANIMACE
   ================================= */
.sgp-fade-in {
    animation: sgpFadeIn 0.5s ease;
}

@keyframes sgpFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =================================
   LOADING STATE
   ================================= */
.sgp-loading {
    text-align: center;
    padding: 20px;
}

.sgp-loading:after {
    content: "Načítám...";
    display: inline-block;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}