/* =========================================================
   Smart Gallery Pro — Frontend Styles
   Modern, slick design inspired by mobile-first UI
   ========================================================= */

/* --- Variables (overridden by PHP inline styles) --- */
:root {
    --sgp-primary:    #F60758;
    --sgp-secondary:  #000000;
    --sgp-accent:     #ffffff;
    --sgp-font:       inherit;
    --sgp-size-base:  16px;
    --sgp-size-title: 24px;
    --sgp-size-meta:  13px;

    /* Internal design tokens */
    --sgp-primary-rgb: 37, 99, 235;
    --sgp-radius-sm:  10px;
    --sgp-radius-md:  18px;
    --sgp-radius-lg:  26px;
    --sgp-shadow-sm:  0 2px 8px rgba(0,0,0,.08);
    --sgp-shadow-md:  0 8px 32px rgba(0,0,0,.12);
    --sgp-shadow-lg:  0 20px 60px rgba(0,0,0,.18);
    --sgp-trans:      all .22s cubic-bezier(.4,0,.2,1);
    --sgp-surface:    #fff;
    --sgp-border:     rgba(0,0,0,.08);
    --sgp-text:       #1e293b;
    --sgp-text-muted: #64748b;
}

/* ---- Base ---- */
.sgp-gallery-wrap *,
.sgp-dashboard-wrap * {
    box-sizing: border-box;
    font-family: var(--sgp-font);
    font-size: var(--sgp-size-base);
}

/* =========================================================
   GALLERY GRID
   ========================================================= */
.sgp-gallery-wrap {
    width: 100%;
    /* Use display:flow-root instead of overflow:hidden so content
       expands naturally without clipping and footer stays below */
    display: flow-root;
    box-sizing: border-box;
    position: relative;
    margin-bottom: 32px; /* push footer down */
}

.sgp-grid {
    display: grid;
    grid-template-columns: repeat(var(--sgp-cols-desktop, 4), 1fr);
    gap: 10px;
    width: 100%;
    align-items: start;
    /* No grid-auto-rows — let each row size to its content naturally */
}

@media (max-width: 1024px) {
    .sgp-grid { grid-template-columns: repeat(var(--sgp-cols-tablet, 2), 1fr); }
}
@media (max-width: 640px) {
    .sgp-grid { grid-template-columns: repeat(var(--sgp-cols-mobile, 1), 1fr); gap: 8px; }
}
.sgp-grid-item {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    background: #e2e8f0;
    /* No fixed height — let aspect-ratio drive the size */
}

.sgp-grid-thumb {
    position: relative;
    width: 100%;
    /* aspect-ratio gives the thumb real height that the grid can measure,
       so rows grow and the page expands naturally with more images */
    aspect-ratio: 1 / 1;
    overflow: hidden;
}

.sgp-grid-thumb img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .4s cubic-bezier(.4,0,.2,1);
    display: block;
}

.sgp-grid-item:hover .sgp-grid-thumb img {
    transform: scale(1.07);
}

/* ---- Overlay ---- */
.sgp-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to top,
        rgba(0,0,0,.5) 0%,
        transparent 60%
    );
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--sgp-trans);
}

.sgp-overlay i {
    color: #fff;
    font-size: 28px;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,.4));
    transform: scale(.8);
    transition: transform .22s ease;
}

.sgp-grid-item:hover .sgp-overlay {
    opacity: 1;
}

.sgp-grid-item:hover .sgp-overlay i {
    transform: scale(1);
}

/* ---- BA Badge ---- */
.sgp-ba-badge {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: var(--sgp-primary);
    color: #fff;
    font-size: var(--sgp-size-meta);
    padding: 4px 10px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 600;
    letter-spacing: .02em;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

.sgp-ba-badge i {
    font-size: 11px;
    color: var(--sgp-accent);
}

/* ---- Empty Gallery ---- */
.sgp-empty-gallery {
    grid-column: 1/-1;
    text-align: center;
    padding: 60px 20px;
    color: var(--sgp-text-muted);
}
.sgp-empty-gallery i {
    font-size: 56px;
    opacity: .25;
    display: block;
    margin-bottom: 16px;
}
.sgp-empty-gallery p {
    font-size: 1.05rem;
    margin: 0;
}

.sgp-error {
    color: #ef4444;
    font-size: var(--sgp-size-base);
    padding: 12px 16px;
    border-radius: var(--sgp-radius-sm);
    background: #fef2f2;
    border: 1px solid #fecaca;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* =========================================================
   LIGHTBOX
   ========================================================= */
.sgp-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999999;
    align-items: center;
    justify-content: center;
}

.sgp-lightbox.is-open {
    display: flex;
}

.sgp-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .92);
    backdrop-filter: blur(12px);
    cursor: pointer;
}

.sgp-lightbox-container {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 0; /* zero padding — image fills full screen, nav bar at bottom */
    box-sizing: border-box;
}

.sgp-lb-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    /* No max-width cap — use full available space */
}

.sgp-lb-media {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.sgp-lb-media img {
    /* Full image always visible — never cropped */
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: center;
    border-radius: var(--sgp-radius-md);
    box-shadow: var(--sgp-shadow-lg);
    display: block;
    animation: sgpFadeIn .25s ease;
    /* Zoom support */
    transform-origin: center center;
    transition: transform 0.2s ease;
    cursor: zoom-in;
    touch-action: pinch-zoom;
    -webkit-user-drag: none;
    user-select: none;
}

@keyframes sgpFadeIn {
    from { opacity: 0; transform: scale(.97); }
    to   { opacity: 1; transform: scale(1); }
}

/* Lightbox buttons — all live in the bottom nav bar, none are absolute */
.sgp-lb-close,
.sgp-lb-prev,
.sgp-lb-next {
    position: static;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    background: var(--sgp-primary);
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: var(--sgp-size-meta);
    font-weight: 700;
    transition: background .15s ease;
    white-space: nowrap;
    width: auto;
    height: auto;
    border-radius: 0;
    backdrop-filter: none;
}
.sgp-lb-close {
    background: rgba(255,255,255,.15);
}
.sgp-lb-prev:hover,
.sgp-lb-next:hover { background: #c0003f; }
.sgp-lb-close:hover { background: rgba(255,255,255,.3); }

.sgp-lb-counter {
    flex: 1;
    text-align: center;
    color: rgba(255,255,255,.8);
    font-size: var(--sgp-size-meta);
    font-weight: 600;
    letter-spacing: .04em;
    /* Not absolute — lives inside the flex nav bar */
    position: static;
    background: none;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    transform: none;
}

/* Loading spinner */
.sgp-lb-loading {
    display: none;
    position: absolute;
    inset: 0;
    align-items: center;
    justify-content: center;
}

.sgp-lb-loading.is-loading {
    display: flex;
}

.sgp-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,.2);
    border-top-color: var(--sgp-primary);
    border-radius: 50%;
    animation: sgpSpin .7s linear infinite;
}

@keyframes sgpSpin {
    to { transform: rotate(360deg); }
}

/* =========================================================
   BEFORE / AFTER — WRAPPER (header + slider stacked)
   ========================================================= */
.sgp-ba-wrap {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    animation: sgpFadeIn .25s ease;
}

/* Label header bar — sits ABOVE the image */
.sgp-ba-header {
    display: flex;
    width: 100%;
    border-radius: var(--sgp-radius-md) var(--sgp-radius-md) 0 0;
    overflow: hidden;
    flex-shrink: 0;
}

.sgp-ba-header-before,
.sgp-ba-header-after {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    font-size: var(--sgp-size-meta);
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #fff;
    gap: 7px;
}

.sgp-ba-header-before {
    background: var(--sgp-secondary);
    justify-content: flex-start;
    padding-left: 20px;
}

.sgp-ba-header-after {
    background: var(--sgp-primary);
    justify-content: flex-end;
    padding-right: 20px;
}

.sgp-ba-header-before i,
.sgp-ba-header-after i {
    color: var(--sgp-accent);
    font-size: 12px;
}

/* =========================================================
   BEFORE / AFTER SLIDER (in lightbox) — below header
   ========================================================= */
.sgp-ba-slider {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 0 0 var(--sgp-radius-md) var(--sgp-radius-md);
    user-select: none;
    touch-action: pinch-zoom; /* allow pinch zoom, handle horizontal drag ourselves */
    box-shadow: var(--sgp-shadow-lg);
    cursor: ew-resize;
    flex-shrink: 0;
}

.sgp-ba-slider img {
    display: block;
    width: 100%;
    height: auto;
    max-height: calc(100vh - 160px); /* leave room for header bar + lightbox controls */
    object-fit: contain;
    pointer-events: none;
}

.sgp-ba-after-wrap {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.sgp-ba-after-wrap img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.sgp-ba-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #fff;
    cursor: ew-resize;
    z-index: 5;
    box-shadow: 0 0 10px rgba(0,0,0,.4);
}

.sgp-ba-handle-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 46px;
    height: 46px;
    background: var(--sgp-accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0,0,0,.35);
    transition: transform .15s ease;
}

.sgp-ba-handle:active .sgp-ba-handle-btn {
    transform: translate(-50%, -50%) scale(1.12);
}

.sgp-ba-handle-btn i {
    color: var(--sgp-secondary);
    font-size: 16px;
}

/* Remove old overlay labels — now in header bar */
.sgp-ba-label-before,
.sgp-ba-label-after {
    display: none !important;
}

/* Mobile BA: tap to toggle */
@media (max-width: 640px) {
    .sgp-ba-slider {
        cursor: pointer;
    }
    .sgp-ba-handle { display: none; }
    .sgp-ba-tap-hint {
        position: absolute;
        bottom: 16px;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(0,0,0,.6);
        color: #fff;
        font-size: 12px;
        padding: 5px 14px;
        border-radius: 999px;
        backdrop-filter: blur(8px);
        white-space: nowrap;
        pointer-events: none;
    }
}

/* =========================================================
   DASHBOARD
   ========================================================= */
.sgp-dashboard-wrap {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 0 16px 60px;
}

/* ---- Login Notice ---- */
.sgp-login-notice {
    text-align: center;
    padding: 60px 24px;
    background: var(--sgp-surface);
    border-radius: var(--sgp-radius-lg);
    box-shadow: var(--sgp-shadow-md);
    margin-top: 32px;
}

.sgp-login-icon {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, var(--sgp-primary), color-mix(in srgb, var(--sgp-primary) 60%, #000));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    box-shadow: 0 8px 24px rgba(var(--sgp-primary-rgb), .3);
}

.sgp-login-icon i {
    font-size: 28px;
    color: #fff;
}

.sgp-login-notice h3 {
    font-size: var(--sgp-size-title);
    font-weight: 700;
    margin: 0 0 10px;
    color: var(--sgp-text);
}

.sgp-login-notice p {
    color: var(--sgp-text-muted);
    margin: 0 0 28px;
}

/* ---- Section Header ---- */
.sgp-section-header {
    margin-bottom: 20px;
    margin-top: 36px;
}

.sgp-section-header h2 {
    font-size: var(--sgp-size-title);
    font-weight: 700;
    color: var(--sgp-text);
    margin: 0 0 4px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sgp-section-header h2 i {
    color: var(--sgp-primary);
    font-size: .85em;
}

.sgp-section-sub {
    color: var(--sgp-text-muted);
    margin: 0;
    font-size: var(--sgp-size-meta);
}

/* ---- Upload Card ---- */
.sgp-upload-card {
    background: var(--sgp-surface);
    border-radius: var(--sgp-radius-lg);
    box-shadow: var(--sgp-shadow-md);
    padding: 28px;
    border: 1px solid var(--sgp-border);
}

@media (max-width: 640px) {
    .sgp-upload-card {
        padding: 20px 16px;
        border-radius: var(--sgp-radius-md);
    }
}

/* ---- Type Tabs ---- */
.sgp-type-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    background: #f1f5f9;
    padding: 4px;
    border-radius: var(--sgp-radius-md);
}

.sgp-type-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border: none;
    background: transparent;
    color: var(--sgp-text-muted);
    font-size: var(--sgp-size-base);
    font-weight: 500;
    cursor: pointer;
    border-radius: calc(var(--sgp-radius-md) - 4px);
    transition: var(--sgp-trans);
}

.sgp-type-tab i {
    font-size: 15px;
}

.sgp-type-tab.active {
    background: var(--sgp-primary);
    color: #fff;
    box-shadow: 0 4px 14px rgba(var(--sgp-primary-rgb), .35);
}

.sgp-type-tab:not(.active):hover {
    background: rgba(0,0,0,.05);
    color: var(--sgp-text);
}

/* ---- Fields ---- */
.sgp-field {
    margin-bottom: 18px;
}

.sgp-field label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-weight: 600;
    color: var(--sgp-text);
    margin-bottom: 8px;
    font-size: var(--sgp-size-base);
}

.sgp-field label i {
    color: var(--sgp-primary);
    font-size: 14px;
}

.sgp-select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--sgp-border);
    border-radius: var(--sgp-radius-sm);
    background: #f8fafc;
    color: var(--sgp-text);
    font-size: var(--sgp-size-base);
    cursor: pointer;
    transition: var(--sgp-trans);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
}

.sgp-select:focus {
    outline: none;
    border-color: var(--sgp-primary);
    background-color: #fff;
    box-shadow: 0 0 0 4px rgba(var(--sgp-primary-rgb), .1);
}

/* ---- Dropzone ---- */
.sgp-dropzone {
    position: relative;
    border: 2px dashed var(--sgp-border);
    border-radius: var(--sgp-radius-md);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: var(--sgp-trans);
    background: #f8fafc;
    overflow: hidden;
}

.sgp-dropzone:hover,
.sgp-dropzone.is-dragover {
    border-color: var(--sgp-primary);
    background: rgba(var(--sgp-primary-rgb), .04);
}

.sgp-file-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.sgp-dropzone-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--sgp-primary), color-mix(in srgb, var(--sgp-primary) 70%, #6366f1));
    border-radius: var(--sgp-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    box-shadow: 0 6px 20px rgba(var(--sgp-primary-rgb), .25);
}

.sgp-dropzone-icon i {
    font-size: 26px;
    color: #fff;
}

.sgp-dropzone-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--sgp-text);
    margin: 0 0 6px;
}

.sgp-dropzone-sub {
    color: var(--sgp-text-muted);
    margin: 0 0 10px;
    font-size: .9em;
}

.sgp-dropzone-limits {
    font-size: var(--sgp-size-meta);
    color: var(--sgp-text-muted);
    background: rgba(0,0,0,.05);
    padding: 5px 14px;
    border-radius: 999px;
    display: inline-block;
}

.sgp-dropzone-active-overlay {
    position: absolute;
    inset: 0;
    background: rgba(var(--sgp-primary-rgb), .08);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--sgp-primary);
    font-size: 1.1rem;
    font-weight: 600;
    z-index: 3;
    pointer-events: none;
}

.sgp-dropzone-active-overlay i {
    font-size: 48px;
}

.sgp-dropzone.is-dragover .sgp-dropzone-active-overlay {
    display: flex;
}

/* ---- File Queue ---- */
.sgp-file-queue {
    margin: 16px 0 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sgp-file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: #f8fafc;
    border-radius: var(--sgp-radius-sm);
    border: 1px solid var(--sgp-border);
    position: relative;
    overflow: hidden;
}

.sgp-file-item-thumb {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    background: #e2e8f0;
}

.sgp-file-item-info {
    flex: 1;
    min-width: 0;
}

.sgp-file-item-name {
    font-weight: 500;
    color: var(--sgp-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: .9em;
    margin-bottom: 6px;
}

.sgp-file-item-bar {
    height: 4px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
}

.sgp-file-item-fill {
    height: 100%;
    background: var(--sgp-primary);
    border-radius: 999px;
    transition: width .15s linear;
    width: 0%;
}

.sgp-file-item-fill.is-done   { background: #22c55e; }
.sgp-file-item-fill.is-error  { background: #ef4444; }

.sgp-file-item-status {
    font-size: 11px;
    color: var(--sgp-text-muted);
    margin-top: 2px;
}

.sgp-file-item-remove {
    background: none;
    border: none;
    color: var(--sgp-text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    font-size: 13px;
    transition: var(--sgp-trans);
    flex-shrink: 0;
}
.sgp-file-item-remove:hover { color: #ef4444; background: #fef2f2; }

/* ---- Global Progress ---- */
.sgp-global-progress {
    margin: 16px 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.sgp-global-progress-bar {
    flex: 1;
    height: 6px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
}

.sgp-global-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--sgp-primary), var(--sgp-accent));
    border-radius: 999px;
    transition: width .2s ease;
    width: 0%;
}

#sgp-global-text, #sgp-ba-text {
    font-size: var(--sgp-size-meta);
    color: var(--sgp-text-muted);
    white-space: nowrap;
    font-weight: 500;
}

/* ---- Buttons ---- */
.sgp-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 22px;
    border-radius: var(--sgp-radius-sm);
    font-size: var(--sgp-size-base);
    font-weight: 600;
    border: 2px solid transparent;
    cursor: pointer;
    transition: var(--sgp-trans);
    text-decoration: none;
    letter-spacing: .01em;
}

.sgp-btn-primary {
    background: var(--sgp-primary);
    color: #fff;
    border-color: var(--sgp-primary);
    box-shadow: 0 4px 14px rgba(var(--sgp-primary-rgb), .3);
}

.sgp-btn-primary:hover:not(:disabled) {
    background: color-mix(in srgb, var(--sgp-primary) 85%, #000);
    border-color: color-mix(in srgb, var(--sgp-primary) 85%, #000);
    box-shadow: 0 6px 20px rgba(var(--sgp-primary-rgb), .4);
    transform: translateY(-1px);
    color: #fff;
    text-decoration: none;
}

.sgp-btn-primary:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.sgp-btn-outline {
    background: transparent;
    color: var(--sgp-text);
    border-color: var(--sgp-border);
}
.sgp-btn-outline:hover {
    border-color: var(--sgp-primary);
    color: var(--sgp-primary);
    text-decoration: none;
}

.sgp-btn-danger {
    background: #ef4444;
    color: #fff;
    border-color: #ef4444;
}
.sgp-btn-danger:hover {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff;
    text-decoration: none;
}

.sgp-upload-btn {
    width: 100%;
    justify-content: center;
    padding: 14px 22px;
    font-size: 1rem;
    border-radius: var(--sgp-radius-sm);
    margin-top: 16px;
}

/* ---- Upload Feedback ---- */
.sgp-upload-feedback {
    margin-top: 16px;
    padding: 14px 18px;
    border-radius: var(--sgp-radius-sm);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sgp-upload-feedback.is-success {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.sgp-upload-feedback.is-error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

/* ---- Before/After Upload Grid ---- */
.sgp-ba-upload-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

@media (max-width: 600px) {
    .sgp-ba-upload-grid {
        grid-template-columns: 1fr;
    }
    .sgp-ba-divider {
        text-align: center;
    }
}

.sgp-ba-slot {}

.sgp-ba-label {
    font-weight: 700;
    font-size: var(--sgp-size-base);
    color: var(--sgp-text);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 7px;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-size: .8em;
}

.sgp-ba-label i { color: var(--sgp-primary); }

.sgp-ba-divider {
    color: var(--sgp-text-muted);
    font-size: 20px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 28px;
}

.sgp-ba-dropzone {
    border: 2px dashed var(--sgp-border);
    border-radius: var(--sgp-radius-md);
    overflow: hidden;
    cursor: pointer;
    transition: var(--sgp-trans);
    background: #f8fafc;
    aspect-ratio: 4/3;
    position: relative;
}

.sgp-ba-dropzone:hover {
    border-color: var(--sgp-primary);
    background: rgba(var(--sgp-primary-rgb), .03);
}

/* The actual file input — covers the entire dropzone, fully transparent, always on top */
.sgp-ba-file-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 10;  /* above preview and empty state */
    font-size: 0; /* prevent iOS showing extra text */
}

/* When a preview is shown, hide the file input so the remove button is clickable */
.sgp-ba-dropzone.has-image .sgp-ba-file-input {
    display: none;
}

.sgp-ba-empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--sgp-text-muted);
    pointer-events: none; /* visual only — file input above handles clicks */
    z-index: 1;
}

.sgp-ba-empty i {
    font-size: 36px;
    opacity: .35;
}

.sgp-ba-empty span {
    font-size: .875rem;
    font-weight: 500;
    text-align: center;
    padding: 0 12px;
    line-height: 1.4;
}

.sgp-ba-slot-label {
    font-size: .75rem !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    letter-spacing: .06em;
    opacity: .6;
}

.sgp-ba-preview {
    position: absolute;
    inset: 0;
}

.sgp-ba-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.sgp-ba-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0,0,0,.6);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    z-index: 5;
    transition: var(--sgp-trans);
}

.sgp-ba-remove:hover {
    background: #ef4444;
}

.sgp-ba-error {
    color: #ef4444;
    font-size: var(--sgp-size-meta);
    margin-top: 6px;
}

/* =========================================================
   MY UPLOADS GRID
   ========================================================= */
.sgp-my-uploads-section {
    margin-top: 12px;
}

.sgp-my-uploads-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

@media (max-width: 900px) {
    .sgp-my-uploads-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 600px) {
    .sgp-my-uploads-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
}

.sgp-my-item {
    position: relative;
    border-radius: var(--sgp-radius-md);
    overflow: hidden;
    background: #e2e8f0;
    box-shadow: var(--sgp-shadow-sm);
    cursor: default;
}

.sgp-my-thumb {
    position: relative;
    width: 100%;
    padding-bottom: 100%;
    overflow: hidden;
}

.sgp-my-thumb img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .3s ease;
}

.sgp-my-item:hover .sgp-my-thumb img {
    transform: scale(1.05);
}

.sgp-my-actions {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.55);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    opacity: 0;
    transition: var(--sgp-trans);
}

.sgp-my-item:hover .sgp-my-actions {
    opacity: 1;
}

/* Touch devices: always show actions */
@media (hover: none) {
    .sgp-my-actions {
        opacity: 1;
        background: linear-gradient(to top, rgba(0,0,0,.6) 0%, transparent 60%);
        align-items: flex-end;
        padding-bottom: 12px;
    }
}

.sgp-my-edit,
.sgp-my-delete {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 15px;
    transition: var(--sgp-trans);
}

.sgp-my-edit {
    background: rgba(255,255,255,.9);
    color: var(--sgp-primary);
}
.sgp-my-edit:hover {
    background: var(--sgp-primary);
    color: #fff;
    transform: scale(1.1);
}

.sgp-my-delete {
    background: rgba(255,255,255,.9);
    color: #ef4444;
}
.sgp-my-delete:hover {
    background: #ef4444;
    color: #fff;
    transform: scale(1.1);
}

.sgp-my-meta {
    padding: 6px 10px;
    font-size: var(--sgp-size-meta);
    color: var(--sgp-primary);
    display: flex;
    align-items: center;
    gap: 5px;
    background: color-mix(in srgb, var(--sgp-primary) 12%, #fff);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
    letter-spacing: .01em;
}

.sgp-my-meta i { color: var(--sgp-accent); font-size: 11px; }

/* ---- Empty State ---- */
.sgp-empty-state {
    grid-column: 1/-1;
    text-align: center;
    padding: 48px 20px;
    color: var(--sgp-text-muted);
}

.sgp-my-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.sgp-my-empty i {
    font-size: 52px;
    opacity: .2;
}

.sgp-my-empty p {
    margin: 0;
    font-size: .95rem;
}

/* ---- Notice ---- */
.sgp-notice {
    padding: 14px 18px;
    border-radius: var(--sgp-radius-sm);
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 20px;
}

.sgp-notice-info {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

/* =========================================================
   MODALS
   ========================================================= */
.sgp-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999998;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.sgp-modal.is-open {
    display: flex;
}

.sgp-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.6);
    backdrop-filter: blur(6px);
    cursor: pointer;
}

.sgp-modal-box {
    position: relative;
    z-index: 1;
    background: var(--sgp-surface);
    border-radius: var(--sgp-radius-lg);
    box-shadow: var(--sgp-shadow-lg);
    width: 100%;
    max-width: 580px;
    max-height: 90vh;
    overflow-y: auto;
    animation: sgpSlideUp .25s cubic-bezier(.4,0,.2,1);
}

.sgp-modal-box-sm {
    max-width: 400px;
    text-align: center;
}

@keyframes sgpSlideUp {
    from { opacity: 0; transform: translateY(24px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.sgp-modal-box h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--sgp-text);
    margin: 0 0 4px;
    padding: 24px 24px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sgp-modal-box h3 i { color: var(--sgp-primary); }

.sgp-modal-body {
    padding: 20px 24px;
}

.sgp-modal-footer {
    padding: 16px 24px 24px;
    display: flex;
    gap: 10px;
    justify-content: flex-start;
}

.sgp-modal-box-sm .sgp-modal-footer {
    justify-content: center;
}

.sgp-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: #f1f5f9;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--sgp-text-muted);
    font-size: 14px;
    transition: var(--sgp-trans);
}

.sgp-modal-close:hover {
    background: #e2e8f0;
    color: var(--sgp-text);
}

.sgp-confirm-icon {
    padding: 32px 24px 0;
}

.sgp-confirm-icon i {
    font-size: 48px;
    color: #f59e0b;
}

.sgp-confirm-modal h3 {
    justify-content: center;
    padding-top: 12px;
}

.sgp-confirm-modal p {
    color: var(--sgp-text-muted);
    padding: 0 24px;
    margin: 0 0 4px;
}

.sgp-edit-current-images {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 12px;
}

.sgp-edit-img-thumb {
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

.sgp-edit-img-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sgp-edit-hint {
    color: var(--sgp-text-muted);
    font-size: var(--sgp-size-meta);
    display: flex;
    align-items: flex-start;
    gap: 7px;
    margin: 0 0 8px;
}

.sgp-edit-hint i { flex-shrink: 0; margin-top: 2px; }

/* Responsive modals on mobile */
@media (max-width: 640px) {
    .sgp-modal {
        align-items: flex-end;
        padding: 0;
    }
    .sgp-modal-box {
        border-radius: var(--sgp-radius-lg) var(--sgp-radius-lg) 0 0;
        max-width: 100%;
        animation: sgpSlideUpMobile .3s cubic-bezier(.4,0,.2,1);
    }
    @keyframes sgpSlideUpMobile {
        from { transform: translateY(100%); }
        to   { transform: translateY(0); }
    }
}

/* =========================================================
   ADDITIONAL / MISSING STYLES
   ========================================================= */

/* ---- Lightbox — disable prev/next when only 1 item ---- */
.sgp-lb-prev.is-hidden,
.sgp-lb-next.is-hidden {
    display: none;
}

/* ---- Upload panel transition ---- */
.sgp-upload-panel {
    animation: sgpFadeIn .2s ease;
}

/* ---- My uploads BA badge (icon only in grid) ---- */
.sgp-my-thumb .sgp-ba-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    bottom: auto;
    background: var(--sgp-accent);
    color: var(--sgp-secondary);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 11px;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(0,0,0,.25);
}

/* ---- Edit modal BA grid ---- */
.sgp-edit-ba-grid {
    margin-bottom: 0;
}

.sgp-edit-ba-grid .sgp-ba-slot img {
    width: 100%;
    border-radius: 10px;
    aspect-ratio: 4/3;
    object-fit: cover;
}

/* ---- Form field inside modal ---- */
.sgp-modal-body .sgp-field {
    margin-bottom: 14px;
}
.sgp-modal-body .sgp-select {
    font-size: .95rem;
}

/* ---- Nonce / auth error state ---- */
.sgp-auth-error {
    padding: 40px 24px;
    text-align: center;
    color: var(--sgp-text-muted);
}
.sgp-auth-error i {
    font-size: 40px;
    color: #ef4444;
    margin-bottom: 14px;
    display: block;
}

/* ---- Accessibility: focus-visible rings ---- */
.sgp-btn:focus-visible,
.sgp-select:focus-visible,
.sgp-type-tab:focus-visible {
    outline: 3px solid var(--sgp-primary);
    outline-offset: 2px;
}

/* ---- Loading skeleton for my-uploads on refresh ---- */
.sgp-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: sgpSkeleton 1.4s infinite;
    border-radius: var(--sgp-radius-md);
    aspect-ratio: 1;
}
@keyframes sgpSkeleton {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ---- Scrollbar styling for modal ---- */
.sgp-modal-box::-webkit-scrollbar { width: 6px; }
.sgp-modal-box::-webkit-scrollbar-track { background: #f8fafc; }
.sgp-modal-box::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
}

/* ---- Mobile: larger tap targets ---- */
@media (max-width: 640px) {
    .sgp-my-edit,
    .sgp-my-delete {
        width: 44px;
        height: 44px;
        font-size: 16px;
    }

    .sgp-type-tab {
        padding: 10px 12px;
        font-size: .875rem;
    }

    .sgp-type-tab span {
        display: none; /* icon only on very small screens */
    }

    .sgp-type-tab i {
        font-size: 18px;
    }

    .sgp-lb-prev,
    .sgp-lb-next {
        width: 42px;
        height: 42px;
        font-size: 14px;
    }

    .sgp-ba-handle-btn {
        width: 38px;
        height: 38px;
    }

    .sgp-dropzone {
        padding: 36px 16px;
    }

    .sgp-dropzone-icon {
        width: 52px;
        height: 52px;
    }

    .sgp-dropzone-icon i {
        font-size: 22px;
    }
}

/* ---- Print: hide UI chrome ---- */
@media print {
    .sgp-lightbox,
    .sgp-modal,
    .sgp-upload-section,
    .sgp-my-actions { display: none !important; }
}

/* =========================================================
   SELECT MODE & BULK DELETE
   ========================================================= */
.sgp-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
    margin-top: 36px;
}

.sgp-section-header h2 { margin: 0; }

.sgp-uploads-toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
}

.sgp-bulk-delete-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border: 1px solid var(--sgp-border);
    border-radius: var(--sgp-radius-sm);
    padding: 10px 16px;
    margin-bottom: 12px;
    font-size: var(--sgp-size-meta);
    color: var(--sgp-text);
    font-weight: 500;
    box-shadow: var(--sgp-shadow-sm);
    flex-wrap: wrap;
}

#sgp-bulk-delete-count {
    font-weight: 700;
    color: var(--sgp-primary);
    font-size: 1.1em;
}

/* Checkboxes — hidden until select mode */
.sgp-my-checkbox {
    display: none;
    position: absolute;
    top: 8px;
    right: 8px;
    width: 22px;
    height: 22px;
    cursor: pointer;
    z-index: 20;
    accent-color: var(--sgp-primary);
}

/* Show checkboxes + visual cues in select mode */
.sgp-select-mode .sgp-my-checkbox {
    display: block;
}

.sgp-select-mode .sgp-my-item {
    cursor: pointer;
}

.sgp-select-mode .sgp-my-item:hover {
    outline: 3px solid var(--sgp-primary);
    outline-offset: 2px;
}

.sgp-my-item.sgp-selected .sgp-my-thumb::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(var(--sgp-primary-rgb), .25);
    border: 3px solid var(--sgp-primary);
    border-radius: var(--sgp-radius-md);
    pointer-events: none;
    z-index: 5;
}

.sgp-my-item.sgp-selected .sgp-my-checkbox {
    /* Show a checkmark overlay */
    outline: 2px solid var(--sgp-primary);
    border-radius: 4px;
}

/* In select mode, hide the individual action buttons (we use checkboxes instead)
   but still show delete for quick single-delete convenience */
.sgp-select-mode .sgp-my-edit {
    display: none !important;
}

/* =========================================================
   CRISP IMAGE RENDERING
   ========================================================= */

/* Grid thumbnails — use medium_large (768px) which is sharp at all grid sizes */
.sgp-grid-thumb img,
.sgp-my-thumb img {
    image-rendering: -webkit-optimize-contrast; /* Safari */
    image-rendering: crisp-edges;               /* Firefox fallback */
    image-rendering: auto;                      /* Chrome/default — let browser decide */
    -webkit-backface-visibility: hidden;        /* Prevent blurring on GPU compositing */
    backface-visibility: hidden;
    transform: translateZ(0);                   /* Force GPU layer — eliminates subpixel blur */
    will-change: transform;
}

/* During hover zoom, prevent blur by keeping will-change active */
.sgp-grid-item:hover .sgp-grid-thumb img {
    transform: scale(1.07) translateZ(0);
}

/* =========================================================
   ADMIN MEDIA PICKER PREVIEW
   ========================================================= */
.sgp-admin-preview-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.sgp-admin-mini-thumb {
    width: 52px;
    height: 52px;
    object-fit: cover;
    border-radius: 6px;
    border: 2px solid #e2e8f0;
}

.sgp-admin-count-label {
    font-size: 12px;
    color: #64748b;
    font-weight: 500;
    margin-top: 4px;
    display: block;
}

.sgp-admin-added-notice {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-left: 8px;
    font-size: 13px;
    color: #15803d;
    font-weight: 600;
    animation: sgpFadeIn .2s ease;
}

.sgp-admin-added-notice i {
    color: #22c55e;
}

/* =========================================================
   ADMIN CATEGORIES TABLE — Add Images column
   ========================================================= */
.sgp-admin-preview-row td {
    padding: 4px 14px 12px;
    background: #fafbff;
}

/* =========================================================
   MOBILE BEFORE/AFTER — CUT PANEL EFFECT
   ========================================================= */
.sgp-ba-cut-wrap {
    display: flex;
    width: 100%;
    max-height: calc(100vh - 160px);
    border-radius: 0 0 var(--sgp-radius-md) var(--sgp-radius-md); /* flat top — header bar sits above */
    overflow: hidden;
    box-shadow: var(--sgp-shadow-lg);
    position: relative;
}

.sgp-ba-cut-panel {
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    /* Width set by JS, transitions handled via inline style */
    cursor: pointer;
}

/* The image fills the panel fully — no black bars */
.sgp-ba-cut-panel img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
    /* Keep image anchored to the inside edge so the crop always shows the subject */
}

.sgp-cut-before img { object-position: right center; }
.sgp-cut-after  img { object-position: left  center; }

/* Aspect ratio placeholder — ensures the wrap has height */
.sgp-ba-cut-wrap::before {
    content: '';
    display: block;
    padding-bottom: 60%; /* landscape ratio */
    float: left;
}
.sgp-ba-cut-wrap::after { content: ''; display: table; clear: both; }

/* Labels — now in .sgp-ba-header above cut panels, not inside panels */
.sgp-cut-label {
    display: none; /* removed from inside panels — header bar used instead */
}

.sgp-cut-label-big { display: none; }

/* Tap hint arrow — stays inside panel, accent colour */
.sgp-cut-hint {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--sgp-accent);
    font-size: 22px;
    pointer-events: none;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,.5));
    transition: opacity var(--sgp-ba-speed, 350ms) ease;
}

/* Divider line between panels */
.sgp-ba-cut-panel::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 3px;
    background: rgba(255,255,255,.7);
    box-shadow: 0 0 8px rgba(0,0,0,.4);
    pointer-events: none;
}
.sgp-cut-after::after { display: none; }

/* Active panel — slightly brighter */
.sgp-ba-cut-panel.sgp-cut-active::before {
    content: '';
    position: absolute;
    inset: 0;
    box-shadow: inset 0 0 0 3px var(--sgp-accent);
    border-radius: inherit;
    pointer-events: none;
    z-index: 5;
}

/* Mobile tap hint */
.sgp-ba-tap-hint {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,.6);
    color: #fff;
    font-size: 12px;
    padding: 5px 14px;
    border-radius: 999px;
    backdrop-filter: blur(8px);
    white-space: nowrap;
    pointer-events: none;
}

/* =========================================================
   DESKTOP BA HANDLE STYLE VARIANTS
   ========================================================= */
.sgp-handle-line .sgp-ba-handle-btn {
    width: 4px;
    height: 60px;
    border-radius: 2px;
    background: #fff;
    box-shadow: 0 0 8px rgba(0,0,0,.4);
}
.sgp-handle-line .sgp-ba-handle-btn i { display: none; }

.sgp-handle-arrow .sgp-ba-handle-btn {
    background: #fff;
    color: var(--sgp-secondary);
}

/* =========================================================
   EDIT MODAL — BA slot background preview of current image
   ========================================================= */
.sgp-ba-dropzone .sgp-ba-empty.has-bg {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Dim the bg image so the label text is readable */
.sgp-ba-dropzone .sgp-ba-empty.has-bg::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 0;
}

.sgp-ba-dropzone .sgp-ba-empty.has-bg > * {
    position: relative;
    z-index: 1;
    color: #fff;
}

.sgp-ba-dropzone .sgp-ba-empty.has-bg i {
    opacity: .9;
    color: #fff;
}

/* =========================================================
   ADMIN — BA Settings Grid
   ========================================================= */
.sgp-ba-settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

@media (max-width: 700px) {
    .sgp-ba-settings-grid { grid-template-columns: 1fr; }
}


/* =========================================================
   ELEMENTOR FOOTER / OVERLAP FIX
   ========================================================= */

/* Ensure gallery wrap sits in normal document flow above footer */
.sgp-gallery-wrap,
.sgp-dashboard-wrap {
    position: relative;
    z-index: 1;
    /* JS will set padding-bottom dynamically based on footer height */
}

/* Override any Elementor sticky footer that might overlap content */
.elementor-location-footer,
.elementor-sticky--effects {
    z-index: 99 !important; /* keep footer in footer */
}

/* Ensure page content section containing gallery expands fully */
.elementor-section.elementor-section-full_width .sgp-gallery-wrap,
.elementor-widget-container .sgp-gallery-wrap,
.elementor-widget-container .sgp-dashboard-wrap {
    width: 100%;
    display: block;
    clear: both;
}

/* =========================================================
   LIGHTBOX — ZOOMED STATE
   ========================================================= */
.sgp-lb-media img.is-zoomed {
    cursor: grab;
}
.sgp-lb-media img.is-zoomed:active {
    cursor: grabbing;
}

/* When zoomed, hide prev/next and counter so they don't interfere */
.sgp-lightbox.is-zoomed .sgp-lb-prev,
.sgp-lightbox.is-zoomed .sgp-lb-next,
.sgp-lightbox.is-zoomed .sgp-lb-counter {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

/* =========================================================
   BA HEADER — ACTIVE STATE (mobile cut panel)
   ========================================================= */
.sgp-ba-header-before,
.sgp-ba-header-after {
    transition: opacity var(--sgp-ba-speed, 350ms) ease,
                background var(--sgp-ba-speed, 350ms) ease;
    opacity: 0.65;
}

/* The active side glows full opacity */
.sgp-ba-header-before.sgp-header-active,
.sgp-ba-header-after.sgp-header-active {
    opacity: 1;
}

/* After starts active by default */
.sgp-ba-header-after {
    opacity: 1;
}

/* =========================================================
   LIGHTBOX IMAGE — transition for zoom
   ========================================================= */
.sgp-lb-media img {
    will-change: transform;
}

/* =========================================================
   BA WRAP — ensure it doesn't get wider than viewport
   ========================================================= */
.sgp-ba-wrap {
    max-width: 100%;
    width: 100%;
}

/* =============================================================
   SMART GALLERY PRO v1.2.0 — ADDITIONS & OVERRIDES
   ============================================================= */

/* ---- Force correct default colours ---- */
:root {
    --sgp-primary:    #F60758;
    --sgp-secondary:  #000000;
    --sgp-accent:     #ffffff;
    --sgp-grid-gap:   8px;
    --sgp-col-width:  200px;
    --sgp-row-height: 200px;
    --sgp-latest-gap:   8px;
    --sgp-latest-col-w: 200px;
    --sgp-latest-row-h: 200px;
    --sgp-latest-cols:  4;
}

/* ---- Grid — use admin-controlled gap & column width, natural row height ---- */
.sgp-grid {
    display: grid;
    grid-template-columns: repeat(var(--sgp-cols-desktop, 4), minmax(0, 1fr));
    gap: var(--sgp-grid-gap, 8px);
    width: 100%;
    align-items: start;
}
@media (max-width: 1024px) {
    .sgp-grid { grid-template-columns: repeat(var(--sgp-cols-tablet, 2), minmax(0, 1fr)); }
}
@media (max-width: 640px) {
    .sgp-grid { grid-template-columns: repeat(var(--sgp-cols-mobile, 1), 1fr); }
}

/* Grid items use aspect-ratio — no fixed heights imposed */
.sgp-grid-item { height: auto; }

/* ---- Latest grid ---- */
.sgp-latest-wrap .sgp-grid {
    grid-template-columns: repeat(var(--sgp-latest-cols, 4), minmax(0, 1fr));
    gap: var(--sgp-latest-gap, 8px);
}


/* ---- No border-radius anywhere ---- */
.sgp-grid-item,
.sgp-grid-thumb,
.sgp-btn,
.sgp-upload-card,
.sgp-upload-section,
.sgp-my-item,
.sgp-my-thumb,
.sgp-modal-box,
.sgp-dropzone,
.sgp-type-tab,
.sgp-select,
.sgp-file-item,
.sgp-ba-badge,
.sgp-my-meta,
.sgp-global-progress-bar,
.sgp-global-progress-fill,
.sgp-file-item-bar,
.sgp-file-item-fill,
.sgp-bulk-delete-bar,
.sgp-notice,
.sgp-lb-prev,
.sgp-lb-next,
.sgp-lb-close,
.sgp-login-icon,
.sgp-upload-feedback,
.sgp-lb-counter,
.sgp-lb-nav-bar { border-radius: 0 !important; }

/* ---- Lightbox — maximum z-index, full screen, zero padding ---- */
.sgp-lightbox {
    display: none;
    position: fixed !important;
    inset: 0 !important;
    z-index: 2147483647 !important;
    background: #000 !important;
    isolation: isolate;
}
.sgp-lightbox.is-open { display: flex !important; flex-direction: column !important; }
.sgp-lightbox-backdrop { position: absolute; inset: 0; background: #000; cursor: pointer; }
.sgp-lightbox-container {
    position: relative; z-index: 1;
    width: 100%; height: 100%;
    display: flex; flex-direction: column;
    padding: 0 !important;
}
.sgp-lb-content { flex: 1; position: relative; min-height: 0; display: flex; align-items: center; justify-content: center; }
.sgp-lb-media { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.sgp-lb-media img {
    max-width: 100%; max-height: 100%;
    width: auto; height: auto;
    object-fit: contain;
    display: block;
    border-radius: 0 !important;
    box-shadow: none !important;
    animation: sgpFadeIn .2s ease;
    transform-origin: center;
    transition: transform .2s ease;
    cursor: zoom-in;
    touch-action: pinch-zoom;
    -webkit-user-drag: none;
    user-select: none;
}
.sgp-lb-media img.is-zoomed { cursor: grab; }
.sgp-lb-media img.is-zoomed:active { cursor: grabbing; }

/* Bottom nav bar layout */
.sgp-lb-nav-bar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(0,0,0,.85);
    border-top: 1px solid rgba(255,255,255,.08);
    z-index: 10;
}
.sgp-lb-nav-bar.sgp-single .sgp-lb-prev,
.sgp-lb-nav-bar.sgp-single .sgp-lb-next { display: none; }


/* Zoom state */
.sgp-lightbox.is-zoomed .sgp-lb-nav-bar,
.sgp-lightbox.is-zoomed .sgp-lb-close { opacity: 0; pointer-events: none; }

/* Loading spinner */
.sgp-lb-loading { display: none; position: absolute; inset: 0; align-items: center; justify-content: center; z-index: 5; }
.sgp-lb-loading.is-loading { display: flex; }
.sgp-spinner { width: 36px; height: 36px; border: 3px solid rgba(255,255,255,.2); border-top-color: var(--sgp-primary); border-radius: 50%; animation: sgpSpin .7s linear infinite; }
@keyframes sgpSpin { to { transform: rotate(360deg); } }
@keyframes sgpFadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---- Badge colours ---- */
.sgp-ba-badge { background: var(--sgp-primary) !important; }
.sgp-my-meta { color: var(--sgp-primary) !important; background: color-mix(in srgb, var(--sgp-primary) 8%, #fff) !important; }
.sgp-my-meta i { color: var(--sgp-primary) !important; }
.sgp-lb-counter { background: none !important; padding: 0 !important; }

/* ---- Drag handle for My Uploads reordering ---- */
.sgp-drag-handle {
    position: absolute;
    top: 6px; left: 6px;
    z-index: 15;
    background: rgba(0,0,0,.55);
    color: #fff;
    width: 24px; height: 24px;
    display: flex; align-items: center; justify-content: center;
    cursor: grab; font-size: 11px;
    opacity: 0; transition: opacity .18s ease;
}
.sgp-my-item:hover .sgp-drag-handle,
.sgp-select-mode .sgp-drag-handle { opacity: 1; }
.sgp-drag-handle:active { cursor: grabbing; }

/* ---- Hidden-from-latest badge ---- */
.sgp-hidden-badge {
    position: absolute; top: 6px; right: 6px; z-index: 15;
    background: rgba(0,0,0,.7); color: #fff;
    width: 24px; height: 24px;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px;
}
.sgp-my-item.sgp-hidden-latest { opacity: .65; }
.sgp-my-item.sgp-hidden-latest .sgp-my-thumb::after {
    content: '';
    position: absolute; inset: 0;
    background: repeating-linear-gradient(
        45deg, transparent, transparent 4px,
        rgba(0,0,0,.15) 4px, rgba(0,0,0,.15) 8px
    );
    pointer-events: none; z-index: 2;
}

/* ---- Gallery & Dashboard wrapper z-index ---- */
.sgp-gallery-wrap, .sgp-dashboard-wrap { position: relative; z-index: 1; }

/* ---- Bulk delete bar ---- */
.sgp-bulk-delete-bar {
    display: flex; align-items: center; gap: 10px;
    background: var(--sgp-secondary); color: #fff;
    padding: 10px 16px; margin-bottom: 12px;
    font-size: var(--sgp-size-meta); font-weight: 500;
    flex-wrap: wrap;
}
#sgp-bulk-delete-count { font-weight: 700; color: var(--sgp-primary); font-size: 1.1em; }

/* ---- Uploads section header layout ---- */
.sgp-section-header {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 10px; margin-bottom: 14px; margin-top: 36px;
}
.sgp-section-header h2 { margin: 0; }
.sgp-uploads-toolbar { display: flex; gap: 8px; align-items: center; }

/* ---- Select mode ---- */
.sgp-my-checkbox {
    display: none; position: absolute;
    top: 8px; right: 8px; width: 20px; height: 20px;
    cursor: pointer; z-index: 20;
    accent-color: var(--sgp-primary);
}
.sgp-select-mode .sgp-my-checkbox { display: block; }
.sgp-my-item.sgp-selected .sgp-my-thumb::before {
    content: '';
    position: absolute; inset: 0;
    background: rgba(246,7,88,.22);
    border: 3px solid var(--sgp-primary);
    pointer-events: none; z-index: 5;
}
.sgp-select-mode .sgp-my-item { cursor: pointer; }

/* ---- Empty state ---- */
.sgp-my-empty { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 48px 20px; }
.sgp-my-empty i { font-size: 52px; opacity: .2; }
.sgp-my-empty p { margin: 0; }

/* ---- Buttons use primary colour ---- */
.sgp-btn-primary { background: var(--sgp-primary) !important; border-color: var(--sgp-primary) !important; }
.sgp-btn-primary:hover { background: #c0003f !important; border-color: #c0003f !important; }
.sgp-type-tab.active { background: var(--sgp-primary) !important; }

/* ---- Upload card desc label ---- */
.sgp-card-desc { color: #64748b; font-size: 13px; margin: -10px 0 16px; }

/* ---- Mobile ---- */
@media (max-width: 640px) {
    .sgp-lb-prev, .sgp-lb-next { min-width: 60px; padding: 8px 12px; font-size: 12px; }
    .sgp-lb-prev span, .sgp-lb-next span { display: none; }
    .sgp-bulk-delete-bar { gap: 6px; }
}

/* =========================================================
   ELEMENTOR / PAGE BUILDER CONTAINMENT FIX
   Ensures the gallery section grows with its content and
   the footer always sits below the last image row.
   ========================================================= */

/* The widget container must not clip or collapse */
.elementor-widget-container:has(.sgp-gallery-wrap),
.elementor-widget-container:has(.sgp-dashboard-wrap) {
    overflow: visible !important;
    height: auto !important;
    min-height: 0 !important;
}

/* The section/column holding the gallery must expand */
.elementor-section:has(.sgp-gallery-wrap),
.elementor-column:has(.sgp-gallery-wrap),
.elementor-section:has(.sgp-dashboard-wrap),
.elementor-column:has(.sgp-dashboard-wrap) {
    height: auto !important;
    overflow: visible !important;
}

/* Fallback for browsers without :has() support —
   use JS-added class .sgp-parent-fix on the widget container */
.sgp-parent-fix {
    overflow: visible !important;
    height: auto !important;
}

/* Gallery wrap itself must be in normal document flow */
.sgp-gallery-wrap,
.sgp-dashboard-wrap {
    position: relative !important;
    overflow: visible !important;
    /* aspect-ratio on children gives real height — no need for fixed height here */
    height: auto !important;
    width: 100% !important;
    display: block !important; /* plain block so it participates in normal flow */
    margin-bottom: 40px;
    z-index: 1;
    /* Isolate stacking context so lightbox (z-index: max) still covers everything */
    isolation: auto;
}
