/* --- Mosaic Grid --- */
#boxy-mosaic .boxy-grid-container,
.boxy-mosaic-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    grid-auto-rows: 120px;
    gap: 4px;
    padding: 10px 0;
}
.mosaic-span-2x2 { grid-column: span 2; grid-row: span 2; }
.mosaic-span-2x1 { grid-column: span 2; grid-row: span 1; }
.mosaic-span-1x2 { grid-column: span 1; grid-row: span 2; }
.mosaic-span-1x1 { grid-column: span 1; grid-row: span 1; }

/* --- Justified Grid --- */
#boxy-justified .boxy-grid-container,
.boxy-justified-grid {
    display: flex !important;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 4px;
    padding: 10px 0;
}
#boxy-justified .boxy-grid-container img,
#boxy-justified .boxy-grid-container video,
#boxy-justified .boxy-grid-container iframe,
.boxy-justified-grid img,
.boxy-justified-grid video,
.boxy-justified-grid iframe {
    height: 120px;
    width: auto;
    object-fit: cover;
    flex-grow: 1;
    flex-shrink: 1;
    margin: 0;
    border-radius: 6px;
}

/* --- Masonry Grid --- */
#boxy-masonry .boxy-grid-container,
.boxy-masonry-grid {
    column-count: 3;
    column-gap: 12px;
    display: block !important;
    padding: 10px 0;
}
#boxy-masonry .boxy-grid-container img,
#boxy-masonry .boxy-grid-container video,
#boxy-masonry .boxy-grid-container iframe,
.boxy-masonry-grid img,
.boxy-masonry-grid video,
.boxy-masonry-grid iframe {
    width: 100%;
    height: auto;
    object-fit: cover;
    margin-bottom: 12px;
    break-inside: avoid;
    border-radius: 6px;
}

/* --- Classic Grid --- */
#boxy-grid .boxy-grid-container,
.boxy-classic-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    grid-auto-rows: 140px;
    gap: 8px;
    padding: 10px 0;
}
#boxy-grid .boxy-grid-container img,
#boxy-grid .boxy-grid-container video,
#boxy-grid .boxy-grid-container iframe,
.boxy-classic-grid img,
.boxy-classic-grid video,
.boxy-classic-grid iframe {
    width: 100%;
    height: 100%;
    object-fit: cover;
    margin: 0;
    border-radius: 6px;
}
#boxy {
    position: relative;
    padding: 20px 40px;
    width: 100%;
    overflow: hidden;
}
#boxy .boxy-grid-container {
    display: flex;
    gap: 20px;
    overflow-x: scroll;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 10px 0;
}
#boxy .boxy-grid-container::-webkit-scrollbar {
    display: none;
}
#boxy .boxy-grid-container img, #boxy .boxy-grid-container video, #boxy .boxy-grid-container iframe, #boxy .boxy-grid-container div {
    flex: 0 0 200px;
    width: 200px;
    max-width: 200px;
    height: 200px;
    max-height: 200px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
#boxy .boxy-grid-container img:hover, #boxy .boxy-grid-container video:hover, #boxy .boxy-grid-container iframe:hover, #boxy .boxy-grid-container div:hover {
    transform: scale(1.05);
}
#boxy .boxy-grid-container video {
    background-color: #2d2d2d;
}
#boxy .boxy-container-prev, #boxy .boxy-container-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: var(--boxy-theme-color,rgba(140, 75, 201, 0.8));
    color: #fff;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    z-index: 10;
    transition: all 0.3s ease;
}
#boxy .boxy-container-prev:hover, #boxy .boxy-container-next:hover {
    background: #2d2d2d;
    transform: translateY(-50%) scale(1.1);
}
#boxy .boxy-container-prev:disabled, #boxy .boxy-container-next:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
#boxy .boxy-container-prev {
    left: 0.5em;
}
#boxy .boxy-container-next {
    right: 0.5em;
}
.boxy-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.boxy-overlay.active {
    display: flex;
    opacity: 1;
}
.boxy-lightbox {
    position: relative;
    max-width: 90%;
    max-height: 90vh;
    margin: auto;
    background-color: #2d2d2d;
    border-radius: 8px;
    overflow: hidden;
}
.boxy-image {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    transition: opacity 0.2s ease;
}
.boxy-image-container {
    display: flex;
    align-items: center;
    justify-content: center;
}
.boxy-media-container {
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    overflow: hidden;
    z-index: 10001;
}
.boxy-media-container img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 10002;
}
.boxy-media-container video {
    background-color: #000;
    position: relative;
    max-width: 100%;
    max-height: 80vh;
    width: 100%;
    z-index: 10002;
    border-radius: 4px;
    display: block;
}
.boxy-media-container .boxy-video-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #000;
    z-index: 10002;
    position: relative;
}
.boxy-media-container .boxy-iframe-wrapper {
    width: 100%;
    height: 0;
    padding-bottom: 56.25%;
    position: relative;
    overflow: hidden;
    background-color: #000;
    z-index: 10002;
}
.boxy-media-container .boxy-iframe-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    z-index: 10002;
    border-radius: 4px;
}
.boxy-video-container {
    width: 80vw !important;
    max-width: 1200px !important;
    height: 70vh !important;
    min-height: 400px !important;
    position: relative;
    z-index: 10001;
}
.boxy-video-container iframe {
    position: absolute;
    width: 100% !important;
    height: 100% !important;
    top: 0;
    left: 0;
    border: none;
}
.boxy-video-container video {
    width: 100%;
    height: 100%;
    background-color: #000;
}
.boxy-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 10px;
    z-index: 10003;
}
.boxy-description {
    color: #fff;
    padding: 15px;
    text-align: center;
    font-size: 14px;
    background: rgba(0, 0, 0, 0.5);
    margin: 10px 0;
    border-radius: 4px;
    z-index: 10003;
}
.boxy-close, .boxy-share, .boxy-prev, .boxy-next {
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    border: none;
    padding: 10px;
    cursor: pointer;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    z-index: 10003;
}
.boxy-close:hover, .boxy-share:hover, .boxy-prev:hover, .boxy-next:hover {
    background: rgba(0, 0, 0, 0.8);
    color: #8c4bc9;
}
.boxy-prev, .boxy-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
}
.boxy-prev {
    left: 20px;
}
.boxy-next {
    right: 20px;
}
.boxy-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #2d2d2d;
    color: #fff;
    padding: 10px 20px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 20001;
    animation: boxyFadeInUp 0.3s ease;
}
.boxy-toast-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 0 5px;
}
.boxy-toast-close:hover {
    color: #8c4bc9;
}
.boxy-media-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 200px;
    height: 200px;
    background-color: rgba(0, 0, 0, 0);
    cursor: pointer;
    z-index: 1;
}
.boxy-container-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
}
.boxy-container-nav button {
    background: #2d2d2d;
    color: #fff;
    border: none;
    padding: 10px 15px;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s;
}
.boxy-container-nav button:hover {
    background: #474747;
}
.boxy-container-nav button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.boxy-pagination {
    color: #fff;
    padding: 10px;
    font-size: 14px;
    font-weight: 500;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 20px;
    min-width: 60px;
    text-align: center;
}
@keyframes boxyFadeInUp {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
   }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
   }
}
:root {
    --boxy-bg-color: #1a1a1a;
    --boxy-text-color: #fff;
    --boxy-overlay-bg: rgba(0, 0, 0, 0.9);
    --boxy-card-color: #2d2d2d;
    --boxy-button-bg: rgba(0, 0, 0, 0.5);
    --boxy-button-hover: rgba(0, 0, 0, 0.8);
    --boxy-theme-color: #2f7fc2;
}
@media (prefers-color-scheme: light) {
    :root {
        --boxy-bg-color: #f5f5f5;
        --boxy-text-color: #1f1f1f;
        --boxy-overlay-bg: rgba(0, 0, 0, 0.8);
        --boxy-card-color: #f0f0f0;
        --boxy-button-bg: rgba(0, 0, 0, 0.3);
        --boxy-button-hover: rgba(0, 0, 0, 0.6);
   }
    .boxy-description {
        background: rgba(0, 0, 0, 0.3);
        color: #FFF;
   }
}

@media (prefers-color-scheme: dark) {
    .boxy-description {
        background: rgba(0, 0, 0, 0.3);
        color: #fff;
   }
}