/* Common Styles */
.wdg-top-bar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 20px;
    align-items: center;
}

.wdg-sort-select {
    padding: 8px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%234a5568'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E") no-repeat right 10px center;
    background-size: 16px;
    font-size: 14px;
    color: #4a5568;
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    padding-right: 35px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
    font-family: inherit;
    font-weight: 500;
}

.wdg-sort-select:hover {
    border-color: #cbd5e0;
}

.wdg-sort-select:focus {
    border-color: #3182ce;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.15);
}

.wdg-wrapper {
    position: relative;
    min-height: 300px;
}

.wdg-grid {
    gap: 24px;
    display: grid;
    grid-template-columns: repeat(var(--cols), 1fr);
    transition: opacity 0.4s ease;
}

.wdg-item {
    position: relative;
    cursor: pointer;
    overflow: hidden;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    aspect-ratio: 4/3;
}

.wdg-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.wdg-item img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block;
    opacity: 0;
    transition: opacity 0.5s ease, transform 0.3s ease;
}

.wdg-item img.loaded {
    opacity: 1;
}

.wdg-item:hover img {
    transform: scale(1.05);
}

.wdg-download {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.3s
}

.wdg-item:hover .wdg-download {
    opacity: 1
}

.wdg-skeleton-grid {
    display: grid;
    grid-template-columns: repeat(var(--cols), 1fr);
    gap: 24px;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 0;
}

.wdg-skeleton-card {
    background: #fff;
    border-radius: 12px;
    aspect-ratio: 4/3;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

.wdg-sk-anim {
    width: 100%;
    height: 100%;
    background: #e2e8f0;
    animation: wdg-shimmer 1.5s infinite linear;
    background-image: linear-gradient(to right, #e2e8f0 0%, #edf2f7 20%, #e2e8f0 40%, #e2e8f0 100%);
    background-size: 1000px 100%;
}

@keyframes wdg-shimmer {
    0% {
        background-position: -1000px 0;
    }

    100% {
        background-position: 1000px 0;
    }
}

.wdg-pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin: 30px 0;
    flex-wrap: wrap;
    transition: opacity 0.4s;
}

.wdg-pagination a,
.wdg-pagination span {
    min-width: 38px;
    height: 38px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    border: 1px solid #e0e0e0;
    background: #fff;
    color: #333;
    cursor: pointer;
    transition: all .2s ease;
}

.wdg-pagination a:hover {
    background: #f5f5f5;
    border-color: #ccc;
}

.wdg-pagination .current {
    background: #000;
    color: #fff;
    border-color: #000;
    cursor: default;
}

.wdg-pagination span {
    cursor: default;
    background: transparent;
    border: none;
    color: #999;
}

.wdg-lightbox {
    position: fixed !important;
    inset: 0 !important;
    background: #1a1a1a;
    z-index: 99999 !important;
    display: none;
    flex-direction: column;
}

.wdg-lightbox.active {
    display: flex !important
}

.wdg-lightbox-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.wdg-lightbox img.main-img {
    max-width: 90vw;
    max-height: calc(100vh - 140px);
    object-fit: contain;
    cursor: grab;
    user-select: none;
    will-change: transform;
    transition: opacity 0.3s ease;
}

.wdg-lightbox img.main-img:active {
    cursor: grabbing
}

.wdg-lb-loader {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .35);
    font-size: 0;
}

.wdg-lb-loader:after {
    content: "";
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, .3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

@keyframes shimmer {
    0% {
        background-position: -468px 0;
    }

    100% {
        background-position: 468px 0;
    }
}

.wdg-lb-counter {
    position: absolute;
    top: 20px;
    left: 20px;
    color: #fff;
    font-size: 15px;
    background: rgba(0, 0, 0, 0.6);
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 500;
}

.wdg-lb-zoom-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 4px;
    background: rgba(0, 0, 0, 0.8);
    padding: 8px;
    border-radius: 8px;
    align-items: center;
}

.wdg-lb-zoom-controls button {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    cursor: pointer;
    border-radius: 6px;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.wdg-lb-zoom-controls button:hover {
    background: rgba(255, 255, 255, 0.2);
}

.wdg-lb-zoom-controls .zoom-level {
    color: #fff;
    padding: 0 12px;
    font-size: 13px;
    min-width: 50px;
    text-align: center;
}

.wdg-lb-download {
    position: absolute;
    top: 20px;
    right: 140px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    font-size: 18px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 30 !important;
    text-decoration: none;
}

.wdg-lb-download:hover {
    background: rgba(0, 0, 0, 0.8);
}

.wdg-lb-close,
.wdg-lb-prev,
.wdg-lb-next,
.wdg-lb-open,
.wdg-lb-share {
    position: absolute;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    font-size: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 30 !important;
}

.wdg-lb-close:hover,
.wdg-lb-prev:hover,
.wdg-lb-next:hover,
.wdg-lb-open:hover,
.wdg-lb-share:hover {
    background: rgba(0, 0, 0, 0.85);
}

.wdg-lb-prev:disabled,
.wdg-lb-next:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.wdg-lb-close {
    top: 20px;
    right: 20px;
    font-size: 28px
}

.wdg-lb-open {
    top: 20px;
    right: 80px;
    font-size: 18px
}

.wdg-lb-share {
    top: 20px;
    right: 200px;
    /* Next to Download (140px + 60px) */
    font-size: 16px;
}

.wdg-lb-prev {
    top: 50%;
    left: 20px;
    transform: translateY(-50%)
}

.wdg-lb-next {
    top: 50%;
    right: 20px;
    transform: translateY(-50%)
}

.wdg-lb-thumbs-wrapper {
    background: #0a0a0a;
    padding: 12px 0;
    border-top: 1px solid #333;
}

/* REVISED: Smooth Scroll Snap */
.wdg-lb-thumbs {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 20px;
    scroll-behavior: smooth;
}

.wdg-lb-thumb-item {
    position: relative;
    flex: 0 0 60px;
    height: 60px;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid transparent;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s, border-color 0.2s;
}

.wdg-lb-thumb-item:hover {
    opacity: 1;
}

.wdg-lb-thumb-item.active {
    border-color: #fff;
    opacity: 1;
}

.wdg-lb-thumb-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.wdg-lb-thumb-item.is-video::after {
    content: "▶";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 14px;
    background: rgba(0, 0, 0, 0.6);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    pointer-events: none;
    line-height: 1;
    padding-left: 2px;
    /* slight visual center adjust */
}

.wdg-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    transition: background 0.3s;
    z-index: 15;
}

.wdg-play-icon::after {
    content: '';
    display: block;
    width: 0;
    height: 0;
    border-left: 14px solid #fff;
    border-top: 9px solid transparent;
    border-bottom: 9px solid transparent;
    margin-left: 4px;
}

.wdg-item:hover .wdg-play-icon {
    background: rgba(204, 0, 0, 0.9);
}

.wdg-lb-video-wrap {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
}

.wdg-lb-video-frame {
    width: 85vw;
    height: 80vh;
    max-width: 1280px;
    aspect-ratio: 16/9;
    border: none;
    background: #000;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    border-radius: 8px;
}

.wdg-quota-warning {
    background: #fff8e5;
    border: 1px solid #f0c36d;
    color: #5f4b00;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
    font-size: 15px;
}

.wdg-quota-warning a {
    color: #0073aa;
    font-weight: 600;
    text-decoration: none;
}

.wdg-quota-warning a:hover {
    text-decoration: underline;
}

@media (max-width: 768px) {
    .wdg-lightbox img.main-img {
        max-width: 95vw;
        max-height: calc(100vh - 120px);
    }

    .wdg-lb-prev {
        left: 10px;
        width: 44px;
        height: 44px;
        font-size: 18px
    }

    .wdg-lb-next {
        right: 10px;
        width: 44px;
        height: 44px;
        font-size: 18px
    }

    .wdg-lb-close {
        right: 10px;
        top: 10px;
        width: 44px;
        height: 44px;
        font-size: 24px
    }

    .wdg-lb-open {
        right: 65px;
        top: 10px;
        width: 44px;
        height: 44px;
        font-size: 16px
    }

    .wdg-lb-share {
        right: 175px;
        /* Adjust for mobile */
        top: 10px;
        width: 44px;
        height: 44px;
        font-size: 16px
    }

    /* Adjusted counter to align with buttons */
    .wdg-lb-counter {
        top: 14px;
        left: 10px;
        font-size: 13px;
        padding: 6px 12px;
        height: 36px;
        display: flex;
        align-items: center;
    }

    .wdg-lb-thumbs {
        padding: 0 10px;
        gap: 6px
    }

    .wdg-lb-thumbs img {
        height: 70px
    }

    .wdg-lb-zoom-controls {
        bottom: 10px;
        padding: 6px;
        gap: 2px
    }

    .wdg-lb-zoom-controls button {
        width: 32px;
        height: 32px;
        font-size: 16px
    }

    .wdg-lb-zoom-controls .zoom-level {
        font-size: 12px;
        padding: 0 8px;
        min-width: 45px
    }

    .wdg-lb-download {
        right: 120px;
        top: 10px;
        width: 44px;
        height: 44px;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .wdg-lb-thumbs img {
        height: 70px !important;
        width: auto;
    }
}

/* Lightbox UI Visibility & Z-Index */
.wdg-lb-close,
.wdg-lb-prev,
.wdg-lb-next,
.wdg-lb-counter,
.wdg-lb-download,
.wdg-lb-open,
.wdg-lb-zoom-controls {
    z-index: 100 !important;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.wdg-lightbox.ui-hidden .wdg-lb-close,
.wdg-lightbox.ui-hidden .wdg-lb-prev,
.wdg-lightbox.ui-hidden .wdg-lb-next,
/* .wdg-lightbox.ui-hidden .wdg-lb-counter,  Excluded: Keep counter visible */
.wdg-lightbox.ui-hidden .wdg-lb-download,
.wdg-lightbox.ui-hidden .wdg-lb-open,
.wdg-lightbox.ui-hidden .wdg-lb-share,
.wdg-lightbox.ui-hidden .wdg-lb-zoom-controls {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}