.dynamic-gallery {
    padding: 85px 0 100px;
    background: #f5f9fc;
}

.gallery-container {
    width: min(calc(100% - 48px), 1380px);
    margin-inline: auto;
}

.gallery-heading {
    max-width: 750px;
    margin: 0 auto 35px;
    text-align: center;
}

.gallery-heading > span {
    color: #1687a7;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: capitalize;
}

.gallery-heading h2 {
    margin: 9px 0 12px;
    color: #0d4f80;
    font-size: clamp(2rem, 3.2vw, 2.8rem);
}

.gallery-heading p {
    margin: 0;
    color: #627684;
    line-height: 1.7;
}

.gallery-filters {
    margin-bottom: 38px;
    display: flex;
    gap: 9px;
    overflow-x: auto;
    padding: 4px 2px 12px;
    scrollbar-width: thin;
}

.gallery-filter {
    display: inline-flex;
    flex: 0 0 180px;
    min-height: 48px;
    padding: 9px 14px;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.2;
    color: #31566e;
    background: #ffffff;
    border: 1px solid #d5e3eb;
    border-radius: 30px;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 180ms ease;
}

.gallery-filter:hover,
.gallery-filter.active {
    color: #ffffff;
    background: #1a5fbd;
    border-color: #1a5fbd;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
}

.gallery-item {
    min-width: 0;
    height: 315px;
    display: grid;
    grid-template-rows: 235px minmax(0, 1fr);
    overflow: hidden;
    background: #ffffff;
    border: 1px solid rgba(13, 79, 128, 0.11);
    border-radius: 0;
    box-shadow: 0 9px 26px rgba(18, 65, 96, 0.07);
    transition: transform 220ms ease, box-shadow 220ms ease;
}

.gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 14px 32px rgba(18, 65, 96, 0.12);
}

.gallery-image-button {
    position: relative;
    width: 100%;
    height: 235px;
    padding: 0;
    overflow: hidden;
    background: #dfe9ef;
    border: 0;
    cursor: zoom-in;
}

.gallery-image-button img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    transition: transform 350ms ease;
}

.gallery-image-button:hover img {
    transform: scale(1.045);
}

.gallery-category-flag {
    position: absolute;
    z-index: 2;
    top: 14px;
    left: 0;
    max-width: calc(100% - 62px);
    padding: 7px 13px 7px 16px;
    overflow: hidden;
    color: #ffffff;
    background: rgba(7, 75, 118, 0.94);
    border-radius: 0 30px 30px 0;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-overflow: ellipsis;
    text-transform: capitalize;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(4, 46, 73, 0.2);
}

.gallery-zoom-icon {
    position: absolute;
    z-index: 2;
    top: 13px;
    right: 13px;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    color: #0b5686;
    background: rgba(255, 255, 255, 0.92);
    border-radius: 50%;
    opacity: 0;
    transform: translateY(-4px);
    transition:
        opacity 200ms ease,
        transform 200ms ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.gallery-image-button:hover .gallery-zoom-icon,
.gallery-image-button:focus-visible .gallery-zoom-icon {
    opacity: 1;
    transform: translateY(0);
}

.gallery-item-information {
    min-height: 0;
    padding: 16px 17px;
    display: flex;
    align-items: center;
}

.gallery-item-information h3 {
    margin: 0;
    display: -webkit-box;
    overflow: hidden;
    color: #123f60;
    font-size: 0.91rem;
    font-weight: 650;
    line-height: 1.45;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.gallery-empty {
    padding: 35px;
    color: #627582;
    text-align: center;
}

/* Popup */
.gallery-lightbox[hidden] {
    display: none;
}

.gallery-lightbox {
    position: fixed;
    z-index: 99999;
    inset: 0;
    padding: 24px;
    display: grid;
    place-items: center;
    background: rgba(5, 23, 36, 0.9);
    backdrop-filter: blur(5px);
}

.gallery-lightbox-dialog {
    width: min(100%, 1180px);
    max-height: calc(100vh - 48px);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.gallery-lightbox-header {
    padding: 17px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    border-bottom: 1px solid #e3ebef;
    background: #ffffff;
}

.gallery-lightbox-category {
    color: #1684a6;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: capitalize;
}

.gallery-lightbox-heading h2 {
    margin: 4px 0 0;
    color: #123f60;
    font-size: 1.08rem;
    line-height: 1.4;
    font-weight: 700;
}

.gallery-lightbox-close {
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    padding: 0;
    color: #244e68;
    background: #edf4f7;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    transition: background 180ms ease, color 180ms ease;
}

.gallery-lightbox-close:hover {
    background: #e2eaf0;
    color: #0c5e91;
}

.gallery-lightbox-stage {
    position: relative;
    min-height: 300px;
    overflow: hidden;
    background: #101c24;
}

.gallery-lightbox-image-viewport {
    width: 100%;
    height: min(68vh, 680px);
    overflow: auto;
    display: grid;
    place-items: center;
    cursor: grab;
}

.gallery-lightbox-image-viewport:active {
    cursor: grabbing;
}

.gallery-lightbox-image-viewport img {
    max-width: 100%;
    max-height: 100%;
    display: block;
    object-fit: contain;
    transform: scale(1);
    transform-origin: center;
    transition: transform 180ms ease;
    user-select: none;
}

.gallery-lightbox-arrow {
    position: absolute;
    z-index: 4;
    top: 50%;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    padding: 0;
    transform: translateY(-50%);
    color: #ffffff;
    background: rgba(10, 49, 84, 0.38);
    border: 1px solid rgba(255, 255, 255, 0.42);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    transition: background 180ms ease, transform 180ms ease;
}

.gallery-lightbox-arrow:hover {
    background: rgba(10, 49, 84, 0.68);
    transform: translateY(-50%) scale(1.08);
}

.gallery-lightbox-arrow.previous {
    left: 17px;
}

.gallery-lightbox-arrow.next {
    right: 17px;
}

.gallery-lightbox-footer {
    min-height: 62px;
    padding: 12px 20px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 20px;
    border-top: 1px solid #e3ebef;
    background: #ffffff;
}

.gallery-lightbox-category-detail {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #406075;
    font-size: 0.82rem;
    font-weight: 600;
}

.gallery-lightbox-category-detail span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gallery-zoom-controls {
    display: flex;
    align-items: center;
    gap: 7px;
}

.gallery-zoom-controls button {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    padding: 0;
    color: #0d527f;
    background: #edf4f7;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    transition: background 180ms ease;
}

.gallery-zoom-controls button:hover {
    background: #dbe7ee;
}

#lightboxZoomValue,
.gallery-image-counter {
    color: #607582;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

body.gallery-popup-open {
    overflow: hidden;
}

@media (max-width: 1199px) {
    .gallery-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 899px) {
    .gallery-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 575px) {
    .dynamic-gallery {
        padding: 55px 0 65px;
    }

    .gallery-container {
        width: min(calc(100% - 28px), 1380px);
    }

    .gallery-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .gallery-item {
        height: 300px;
        grid-template-rows: 225px minmax(0, 1fr);
    }

    .gallery-image-button {
        height: 225px;
    }

    .gallery-zoom-icon {
        opacity: 1;
        transform: none;
    }

    .gallery-lightbox {
        padding: 10px;
    }

    .gallery-lightbox-dialog {
        max-height: calc(100vh - 20px);
        border-radius: 12px;
    }

    .gallery-lightbox-image-viewport {
        height: 56vh;
    }

    .gallery-lightbox-arrow {
        width: 38px;
        height: 38px;
    }

    .gallery-lightbox-arrow.previous {
        left: 8px;
    }

    .gallery-lightbox-arrow.next {
        right: 8px;
    }

    .gallery-lightbox-footer {
        grid-template-columns: 1fr auto;
        gap: 10px;
    }

    .gallery-zoom-controls {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-content: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    .gallery-image-button img,
    .gallery-zoom-icon,
    .gallery-lightbox-image-viewport img {
        transition: none;
    }
}

/* Admin Gallery Summary Styles */
.gallery-admin-information {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 20px;
    background: #f0f7fc;
    border: 1px solid #cbe3f3;
    border-radius: 10px;
    color: #124d78;
    margin-bottom: 24px;
}

.gallery-admin-information i {
    font-size: 1.6rem;
    color: #0c5e91;
    margin-top: 2px;
}

.gallery-admin-information h3 {
    margin: 0 0 6px;
    font-size: 1.05rem;
    color: #0d4f80;
}

.gallery-admin-information p {
    margin: 0;
    color: #43657d;
    line-height: 1.5;
    font-size: 0.92rem;
}

.gallery-admin-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.gallery-admin-summary > div {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 24px 20px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}

.gallery-admin-summary span {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
    color: #0d4f80;
    line-height: 1.2;
}

.gallery-admin-summary small {
    display: block;
    margin-top: 6px;
    color: #64748b;
    font-size: 0.82rem;
    text-transform: capitalize;
    letter-spacing: 0.05em;
    font-weight: 600;
}

@media (max-width: 768px) {
    .gallery-admin-summary {
        grid-template-columns: 1fr;
    }
}
