/* ===========================
   MOZAIKA NÁHLEDŮ V ČLÁNKU
   =========================== */

.smart-gallery-wrapper {
    width: 100%;
}

/* základní grid – počet sloupců se řídí třídou smart-gallery-cols-X */
.smart-gallery-grid {
    display: grid;
    grid-auto-rows: 110px;
    gap: 6px;
}

/* 1–9 sloupců podle columns / default 3 (nastavuje PHP) */
.smart-gallery-cols-1 .smart-gallery-grid { grid-template-columns: repeat(1, 1fr); }
.smart-gallery-cols-2 .smart-gallery-grid { grid-template-columns: repeat(2, 1fr); }
.smart-gallery-cols-3 .smart-gallery-grid { grid-template-columns: repeat(3, 1fr); }
.smart-gallery-cols-4 .smart-gallery-grid { grid-template-columns: repeat(4, 1fr); }
.smart-gallery-cols-5 .smart-gallery-grid { grid-template-columns: repeat(5, 1fr); }
.smart-gallery-cols-6 .smart-gallery-grid { grid-template-columns: repeat(6, 1fr); }
.smart-gallery-cols-7 .smart-gallery-grid { grid-template-columns: repeat(7, 1fr); }
.smart-gallery-cols-8 .smart-gallery-grid { grid-template-columns: repeat(8, 1fr); }
.smart-gallery-cols-9 .smart-gallery-grid { grid-template-columns: repeat(9, 1fr); }

/* dlaždice náhledů v článku */
.smart-gallery-thumb {
    position: relative;
    overflow: hidden;
    border-radius: 6px;
    cursor: pointer;
}

.smart-gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.2s, box-shadow 0.2s;
}

.smart-gallery-thumb:hover img {
    transform: scale(1.03);
    box-shadow: 0 4px 10px rgba(0,0,0,0.25);
}

/* Responzivita mozaiky – měníme jen výšku řádků,
   POČET sloupců zůstává vždy podle columns */
@media (max-width: 900px) {
    .smart-gallery-grid { grid-auto-rows: 100px; }
}
@media (max-width: 600px) {
    .smart-gallery-grid { grid-auto-rows: 90px; }
}

/* ===========================
   STRÁNKA S JEDNOU FOTKOU
   =========================== */

.smart-gallery-page-wrapper {
    max-width: 1000px;
    margin: 20px auto;
    padding: 0 10px;
    box-sizing: border-box;
}

.smart-gallery-page-back {
    margin-bottom: 10px;
    font-size: 14px;
}

.smart-gallery-page-back a {
    text-decoration: none;
    color: #0073aa;
}

.smart-gallery-page-back a:hover {
    text-decoration: underline;
}

/* velká fotka + šipky */
.smart-gallery-page-main {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    margin-bottom: 8px;
    height: 70vh;
    max-height: 70vh;
}

.smart-gallery-page-main-inner {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    max-height: 100%;
}

.smart-gallery-page-main-img {
    max-width: 100%;
    max-height: 100%;
    height: auto;
    border-radius: 4px;
    cursor: zoom-in;
}

/* ===========================
   LOADING SPINNER (DETAIL)
   =========================== */

.smart-gallery-page-main-inner.is-loading::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.18);
    border-radius: 4px;
    z-index: 4;
}

.smart-gallery-page-main-inner.is-loading::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 38px;
    height: 38px;
    margin-left: -19px;
    margin-top: -19px;
    border-radius: 50%;
    border: 3px solid rgba(255,255,255,0.35);
    border-top-color: rgba(255,255,255,0.95);
    animation: smartGallerySpin 0.8s linear infinite;
    z-index: 5;
}

@keyframes smartGallerySpin {
    to { transform: rotate(360deg); }
}

/* šipky – odkazy */
.smart-gallery-page-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    text-decoration: none;
    background: rgba(0,0,0,0.4);
    color: #fff;
    font-size: 28px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2;
}

.smart-gallery-page-prev { left: 8px; }
.smart-gallery-page-next { right: 8px; }

.smart-gallery-page-arrow:hover {
    background: rgba(0,0,0,0.6);
}

/* index "Foto X / Y" */
.smart-gallery-page-index {
    font-size: 13px;
    margin-bottom: 6px;
    text-align: right;
    color: #666;
}

/* všechny náhledy pod obrázkem – mřížka */
.smart-gallery-page-bottom-thumbs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 6px;
    margin-top: 8px;
}

/* pevná výška náhledů v detailu */
.smart-gallery-page-bottom-thumb img {
    display: block;
    width: 100%;
    height: 70px;
    object-fit: cover;
    cursor: pointer;
    border-radius: 3px;
    opacity: 0.7;
    transition: opacity 0.2s, box-shadow 0.2s, transform 0.2s;
}

.smart-gallery-page-bottom-thumb img:hover {
    opacity: 1;
    transform: scale(1.03);
}

.smart-gallery-page-bottom-thumb.is-active img {
    opacity: 1;
    box-shadow: 0 0 0 2px #0073aa;
}

/* ===========================
   INFO PANEL PŘES FOTKU
   =========================== */

.smart-gallery-info-toggle {
    position: absolute;
    left: 10px;
    bottom: 10px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.65);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.smart-gallery-info-panel {
    position: absolute;
    left: 10px;
    bottom: 10px;
    max-width: 65%;
    background: rgba(0,0,0,0.8);
    color: #fff;
    padding: 10px 12px;
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.4;
    transform: translateY(110%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.smart-gallery-info-panel.is-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.smart-gallery-info-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.smart-gallery-info-text {
    font-weight: 400;
}

/* ===========================
   LIGHTBOX – originální velikost
   =========================== */

.smart-gallery-lightbox {
    position: fixed;
    inset: 0;
    display: none;
    z-index: 9999;
}

.smart-gallery-lightbox[data-active="true"] {
    display: block;
}

.smart-gallery-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.8);
}

/* box přes celé okno – vystředění obsahu */
.smart-gallery-lightbox-inner {
    position: fixed;
    inset: 0;
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1;
}

/* rámeček kolem fotky – na ten se váže křížek */
.smart-gallery-lightbox-frame {
    position: relative;
    max-width: 100%;
    max-height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* FIT DO OKNA */
.smart-gallery-lightbox-img {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
    border-radius: 4px;
}

/* ===========================
   LOADING SPINNER (LIGHTBOX)
   =========================== */

.smart-gallery-lightbox-frame.is-loading::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.22);
    border-radius: 4px;
    z-index: 4;
}

.smart-gallery-lightbox-frame.is-loading::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 44px;
    height: 44px;
    margin-left: -22px;
    margin-top: -22px;
    border-radius: 50%;
    border: 3px solid rgba(255,255,255,0.35);
    border-top-color: rgba(255,255,255,0.95);
    animation: smartGallerySpin 0.8s linear infinite;
    z-index: 5;
}

/* volitelně: ať je pod spinnerem vidět, že se "něco děje" */
.smart-gallery-lightbox-frame.is-loading .smart-gallery-lightbox-img {
    opacity: 0.65;
}

/* X je vždy vpravo nahoře PŘÍMO NA FOTCE */
.smart-gallery-lightbox-close {
    position: absolute;
    top: 8px;
    right: 8px;
    border: none;
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    font-size: 22px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 7; /* aby bylo vždy nad spinnerem */
    display: flex;
    align-items: center;
    justify-content: center;
}

.smart-gallery-lightbox-close::before {
    content: '×';
    font-size: 22px;
    line-height: 1;
}

/* ===========================
   LIGHTBOX – šipky pro listování
   =========================== */

.smart-gallery-lightbox-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 7; /* nad spinnerem */
}

.smart-gallery-lightbox-prev { left: 10px; }
.smart-gallery-lightbox-next { right: 10px; }

.smart-gallery-lightbox-arrow:hover {
    background: rgba(0,0,0,0.8);
}

/* responzivita detailu */
@media (max-width: 768px) {
    .smart-gallery-page-wrapper {
        margin: 15px auto;
        padding: 0 8px;
    }

    .smart-gallery-info-panel {
        max-width: 80%;
    }
}
