/* =============================================
   SGG PUBLIC GALLERY STYLES
============================================= */
.sgg-wrapper {
    --sgg-primary:            #C0392B;
    --sgg-active-tab-bg:      #C0392B;
    --sgg-active-tab-text:    #ffffff;
    --sgg-tab-bg:             #2C2C2C;
    --sgg-tab-text:           #B8AFA6;
    --sgg-bg:                 #1A1A1A;
    --sgg-text:               #F5F0EB;
    --sgg-overlay:            #C0392B;
    --sgg-tag-bg:             #C0392B;
    --sgg-tag-text:           #ffffff;
    --sgg-card-bg:            #2C2C2C;
    --sgg-radius:             8px;
    --sgg-gap:                12px;
    --sgg-transition:         0.3s ease;

    background:    var(--sgg-bg);
    border-radius: var(--sgg-radius);
    padding:       24px;
    font-family:   -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    box-sizing:    border-box;
}

.sgg-wrapper *, .sgg-wrapper *::before, .sgg-wrapper *::after {
    box-sizing: border-box;
}

/* =============================================
   ERROR / EMPTY
============================================= */
.sgg-error {
    color: #E74C3C;
    padding: 12px 16px;
    background: rgba(231,76,60,0.1);
    border: 1px solid rgba(231,76,60,0.3);
    border-radius: var(--sgg-radius);
    font-size: 14px;
}

.sgg-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--sgg-text);
    opacity: 0.5;
}

.sgg-empty-icon { font-size: 50px; display: block; margin-bottom: 12px; }

/* =============================================
   FILTER BAR
============================================= */
.sgg-filter-bar {
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    gap:             12px;
    flex-wrap:       wrap;
    margin-bottom:   24px;
    padding-bottom:  20px;
    border-bottom:   1px solid rgba(255,255,255,0.06);
}

.sgg-filter-tabs {
    display:     flex;
    gap:         6px;
    flex-wrap:   wrap;
    align-items: center;
}

.sgg-filter-btn {
    display:         inline-flex;
    align-items:     center;
    gap:             6px;
    padding:         9px 18px;
    border-radius:   50px;
    border:          1px solid rgba(255,255,255,0.1);
    background:      var(--sgg-tab-bg);
    color:           var(--sgg-tab-text);
    font-family:     inherit;
    font-size:       13px;
    font-weight:     500;
    cursor:          pointer;
    transition:      all var(--sgg-transition);
    white-space:     nowrap;
}

.sgg-filter-btn:hover {
    border-color: var(--sgg-active-tab-bg);
    color:        var(--sgg-active-tab-text);
    background:   rgba(192,57,43,0.15);
}

.sgg-filter-btn.sgg-active {
    background:   var(--sgg-active-tab-bg);
    color:        var(--sgg-active-tab-text);
    border-color: var(--sgg-active-tab-bg);
    font-weight:  600;
}

.sgg-filter-count {
    background:    rgba(255,255,255,0.15);
    border-radius: 50px;
    padding:       1px 8px;
    font-size:     11px;
    font-weight:   700;
    min-width:     20px;
    text-align:    center;
}

.sgg-filter-btn.sgg-active .sgg-filter-count {
    background: rgba(255,255,255,0.25);
}

/* Filter Right */
.sgg-filter-right {
    display:     flex;
    align-items: center;
    gap:         12px;
    flex-wrap:   wrap;
}

.sgg-results-count {
    font-size:  12px;
    color:      var(--sgg-tab-text);
    white-space: nowrap;
}

.sgg-count-num {
    color:       var(--sgg-primary);
    font-weight: 700;
}

/* View Switcher */
.sgg-view-switcher {
    display: flex;
    gap:     4px;
}

.sgg-view-btn {
    width:         34px;
    height:        34px;
    border-radius: 6px;
    border:        1px solid rgba(255,255,255,0.1);
    background:    var(--sgg-tab-bg);
    color:         var(--sgg-tab-text);
    cursor:        pointer;
    display:       flex;
    align-items:   center;
    justify-content: center;
    transition:    all var(--sgg-transition);
    padding:       0;
}

.sgg-view-btn svg { width: 14px; height: 14px; }

.sgg-view-btn:hover,
.sgg-view-btn.sgg-view-active {
    background:   var(--sgg-primary);
    border-color: var(--sgg-primary);
    color:        #fff;
}

/* =============================================
   MASONRY GRID
============================================= */
.sgg-grid {
    columns:    4;
    column-gap: var(--sgg-gap);
    transition: columns var(--sgg-transition);
}

.sgg-grid.sgg-cols-1 { columns: 1; }
.sgg-grid.sgg-cols-2 { columns: 2; }
.sgg-grid.sgg-cols-3 { columns: 3; }
.sgg-grid.sgg-cols-4 { columns: 4; }
.sgg-grid.sgg-cols-5 { columns: 5; }
.sgg-grid.sgg-cols-6 { columns: 6; }

/* =============================================
   GALLERY ITEM
============================================= */
.sgg-item {
    break-inside:  avoid;
    margin-bottom: var(--sgg-gap);
    border-radius: var(--sgg-radius);
    overflow:      hidden;
    position:      relative;
    opacity:       0;
    transform:     translateY(16px) scale(0.97);
    transition:    opacity 0.5s ease, transform 0.5s ease, box-shadow 0.3s ease;
    cursor:        pointer;
    display:       block;
    background:    var(--sgg-card-bg);
}

.sgg-item.sgg-visible {
    opacity:   1;
    transform: translateY(0) scale(1);
}

.sgg-item.sgg-item-hidden {
    display: none;
}

.sgg-item:hover {
    box-shadow: 0 12px 40px rgba(0,0,0,0.5), 0 0 0 1px var(--sgg-primary);
    z-index:    2;
}

.sgg-item-inner {
    position: relative;
    overflow: hidden;
    border-radius: var(--sgg-radius);
}

/* Image */
.sgg-img {
    display:    block;
    width:      100%;
    height:     auto;
    transition: transform 0.5s ease;
}

.sgg-item:hover .sgg-img {
    transform: scale(1.05);
}

/* Tag Badge */
.sgg-tag {
    position:      absolute;
    top:           12px;
    left:          12px;
    background:    var(--sgg-tag-bg);
    color:         var(--sgg-tag-text);
    font-size:     10px;
    font-weight:   700;
    padding:       4px 10px;
    border-radius: 50px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    display:       flex;
    align-items:   center;
    gap:           4px;
    z-index:       2;
    pointer-events: none;
    backdrop-filter: blur(4px);
}

.sgg-tag-icon { font-size: 12px; }

/* Overlay */
.sgg-overlay {
    position:   absolute;
    inset:      0;
    background: linear-gradient(
        to top,
        rgba(0,0,0,0.85) 0%,
        rgba(0,0,0,0.3)  40%,
        transparent      100%
    );
    opacity:    0;
    transition: opacity var(--sgg-transition);
    display:    flex;
    flex-direction: column;
    justify-content: flex-end;
    padding:    16px;
}

.sgg-item:hover .sgg-overlay { opacity: 1; }

.sgg-overlay-top {
    position: absolute;
    top:      12px;
    right:    12px;
    display:  flex;
    gap:      6px;
}

.sgg-zoom-btn {
    width:           34px;
    height:          34px;
    background:      rgba(255,255,255,0.15);
    backdrop-filter: blur(8px);
    border:          1px solid rgba(255,255,255,0.2);
    border-radius:   50%;
    color:           #fff;
    cursor:          pointer;
    display:         flex;
    align-items:     center;
    justify-content: center;
    transition:      all var(--sgg-transition);
    padding:         0;
}

.sgg-zoom-btn:hover {
    background:   var(--sgg-primary);
    border-color: var(--sgg-primary);
    transform:    scale(1.1);
}

.sgg-zoom-btn svg { width: 14px; height: 14px; }

/* Caption */
.sgg-caption {}

.sgg-caption-title {
    font-size:   15px;
    font-weight: 700;
    color:       #fff;
    margin:      0 0 4px;
    line-height: 1.3;
}

.sgg-caption-text {
    font-size:   12px;
    color:       rgba(255,255,255,0.75);
    margin:      0 0 6px;
    line-height: 1.4;
    display:     -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow:    hidden;
}

.sgg-caption-cat {
    font-size:      10px;
    font-weight:    600;
    letter-spacing: 2px;
    text-transform: uppercase;
    color:          rgba(255,255,255,0.55);
}

/* =============================================
   NO RESULTS
============================================= */
.sgg-no-results {
    text-align:  center;
    padding:     60px 20px;
    color:       var(--sgg-text);
    opacity:     0.5;
}

.sgg-no-results span { font-size: 48px; display: block; margin-bottom: 12px; }

/* =============================================
   LOAD MORE
============================================= */
.sgg-load-more-wrap {
    text-align:  center;
    margin-top:  36px;
}

.sgg-load-more-btn {
    display:      inline-flex;
    align-items:  center;
    gap:          8px;
    padding:      13px 36px;
    background:   transparent;
    border:       2px solid rgba(255,255,255,0.15);
    border-radius: 50px;
    color:        var(--sgg-tab-text);
    font-family:  inherit;
    font-size:    13px;
    font-weight:  600;
    cursor:       pointer;
    transition:   all var(--sgg-transition);
}

.sgg-load-more-btn:hover {
    border-color: var(--sgg-primary);
    color:        var(--sgg-text);
    background:   rgba(192,57,43,0.08);
}

.sgg-load-more-spinner {
    display:     flex;
    align-items: center;
    gap:         8px;
}

.sgg-spin {
    animation: sgg-spin 0.8s linear infinite;
}

@keyframes sgg-spin { 100% { transform: rotate(360deg); } }

/* =============================================
   LIGHTBOX
============================================= */
.sgg-lightbox {
    position:        fixed;
    inset:           0;
    z-index:         9999999; /* Higher than any header/nav */
    display:         none;
    align-items:     center;
    justify-content: center;
    /* Reset any inherited stacking context */
    transform:       none !important;
    isolation:       isolate;
}

/* When appended to body, ensure no stacking issues */
body > .sgg-lightbox {
    position: fixed;
    inset:    0;
    z-index:  9999999;
}

.sgg-lightbox.sgg-lb-open { display: flex; }

.sgg-lightbox-overlay {
    position:   absolute;
    inset:      0;
    background: rgba(0,0,0,0.97);
    backdrop-filter: blur(20px);
}

/* Close */
.sgg-lightbox-close {
    position:        fixed;
    top:             20px;
    right:           20px;
    width:           46px;
    height:          46px;
    background:      rgba(255,255,255,0.08);
    border:          1px solid rgba(255,255,255,0.12);
    border-radius:   50%;
    color:           #fff;
    cursor:          pointer;
    display:         flex;
    align-items:     center;
    justify-content: center;
    transition:      all var(--sgg-transition);
    z-index:         3;
    padding:         0;
}

.sgg-lightbox-close:hover {
    background:   var(--sgg-primary);
    border-color: var(--sgg-primary);
    transform:    rotate(90deg);
}

.sgg-lightbox-close svg { width: 20px; height: 20px; }

/* Nav arrows */
.sgg-lightbox-prev,
.sgg-lightbox-next {
    position:        fixed;
    top:             50%;
    transform:       translateY(-50%);
    width:           50px;
    height:          50px;
    background:      rgba(255,255,255,0.08);
    border:          1px solid rgba(255,255,255,0.12);
    border-radius:   50%;
    color:           #fff;
    cursor:          pointer;
    display:         flex;
    align-items:     center;
    justify-content: center;
    transition:      all var(--sgg-transition);
    z-index:         3;
    padding:         0;
}

.sgg-lightbox-prev:hover,
.sgg-lightbox-next:hover {
    background:   var(--sgg-primary);
    border-color: var(--sgg-primary);
}

.sgg-lightbox-prev svg,
.sgg-lightbox-next svg { width: 20px; height: 20px; }

.sgg-lightbox-prev { left:  20px; }
.sgg-lightbox-next { right: 20px; }

/* Content */
.sgg-lightbox-content {
    position:   relative;
    z-index:    2;
    text-align: center;
    max-width:  90vw;
    max-height: 90vh;
    display:    flex;
    flex-direction: column;
    align-items: center;
}

.sgg-lightbox-img-wrap {
    position:   relative;
    max-width:  900px;
    width:      90vw;
}

.sgg-lightbox-img {
    max-height:   75vh;
    max-width:    100%;
    width:        auto;
    height:       auto;
    border-radius: var(--sgg-radius);
    object-fit:   contain;
    box-shadow:   0 20px 60px rgba(0,0,0,0.7);
    display:      block;
    margin:       0 auto;
    opacity:      0;
    transition:   opacity 0.3s ease, transform 0.3s ease;
    transform:    scale(0.97);
}

.sgg-lightbox-img.sgg-lb-loaded {
    opacity:   1;
    transform: scale(1);
}

/* Loader */
.sgg-lightbox-loader {
    position:        absolute;
    inset:           0;
    display:         flex;
    align-items:     center;
    justify-content: center;
    color:           var(--sgg-primary);
}

.sgg-lightbox-loader svg { width: 40px; height: 40px; }

/* Info */
.sgg-lightbox-info {
    margin-top: 16px;
    text-align: center;
}

.sgg-lightbox-title {
    font-size:   20px;
    font-weight: 700;
    color:       #fff;
    margin:      0 0 4px;
}

.sgg-lightbox-caption {
    font-size: 13px;
    color:     rgba(255,255,255,0.65);
    margin:    0 0 6px;
}

.sgg-lightbox-cat {
    font-size:      10px;
    font-weight:    600;
    letter-spacing: 3px;
    text-transform: uppercase;
    color:          var(--sgg-primary);
    display:        block;
}

/* Counter */
.sgg-lightbox-counter {
    position:        fixed;
    bottom:          24px;
    left:            50%;
    transform:       translateX(-50%);
    display:         flex;
    flex-direction:  column;
    align-items:     center;
    gap:             8px;
    z-index:         3;
}

.sgg-counter-text {
    font-size:  12px;
    color:      rgba(255,255,255,0.4);
    font-weight: 500;
}

.sgg-lightbox-dots {
    display: flex;
    gap:     5px;
}

.sgg-lb-dot {
    width:         6px;
    height:        6px;
    background:    rgba(255,255,255,0.25);
    border-radius: 50%;
    transition:    all var(--sgg-transition);
    cursor:        pointer;
}

.sgg-lb-dot:hover { background: rgba(255,255,255,0.5); }

.sgg-lb-dot.sgg-lb-dot-active {
    background:    var(--sgg-primary);
    width:         18px;
    border-radius: 3px;
}

/* =============================================
   RESPONSIVE
============================================= */
@media (max-width: 1024px) {
    .sgg-grid.sgg-cols-5,
    .sgg-grid.sgg-cols-6 { columns: 4; }
}

@media (max-width: 768px) {
    .sgg-wrapper { padding: 16px; }

    .sgg-grid.sgg-cols-4,
    .sgg-grid.sgg-cols-5,
    .sgg-grid.sgg-cols-6 { columns: 2; }

    .sgg-grid.sgg-cols-3 { columns: 2; }

    .sgg-filter-bar { flex-direction: column; align-items: flex-start; }

    .sgg-lightbox-prev,
    .sgg-lightbox-next { display: none; }

    .sgg-lightbox-img { max-height: 60vh; }
}

@media (max-width: 480px) {
    .sgg-grid.sgg-cols-2,
    .sgg-grid.sgg-cols-3,
    .sgg-grid.sgg-cols-4,
    .sgg-grid.sgg-cols-5,
    .sgg-grid.sgg-cols-6 { columns: 1; }

    .sgg-filter-btn { font-size: 11px; padding: 7px 12px; }
}