.vmg-gallery-container {
    --vmg-cols: 4;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    margin: 20px 0;
}

.vmg-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.vmg-search-box {
    position: relative;
    flex: 1;
    min-width: 260px;
}

.vmg-search-input {
    width: 100%;
    padding: 10px 38px 10px 14px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
}

.vmg-search-input:focus {
    border-color: #0073aa;
    box-shadow: 0 0 0 1px #0073aa;
}

.vmg-clear-search {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 18px;
    color: #888;
    cursor: pointer;
    display: none;
}

.vmg-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #0073aa;
    color: #fff !important;
    padding: 10px 16px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none !important;
    transition: background 0.2s;
}

.vmg-btn:hover {
    background: #005177;
}

.vmg-grid {
    display: grid;
    grid-template-columns: repeat(var(--vmg-cols), 1fr);
    gap: 16px;
    min-height: 200px;
}

@media (max-width: 1024px) {
    .vmg-gallery-container { --vmg-cols: 3 !important; }
}
@media (max-width: 768px) {
    .vmg-gallery-container { --vmg-cols: 2 !important; }
}
@media (max-width: 480px) {
    .vmg-gallery-container { --vmg-cols: 1 !important; }
}

.vmg-item {
    position: relative;
    aspect-ratio: 4/3;
    overflow: hidden;
    border-radius: 8px;
    background: #f0f0f0;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: transform 0.2s, box-shadow 0.2s;
}

.vmg-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.12);
}

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

.vmg-item-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px 12px;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    color: #fff;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    transition: opacity 0.2s;
}

.vmg-item:hover .vmg-item-overlay {
    opacity: 1;
}

/* Selezione multipla */
.vmg-item-check {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 3;
    width: 24px;
    height: 24px;
    margin: 0;
    cursor: pointer;
    accent-color: #0073aa;
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.15s;
}

.vmg-item:hover .vmg-item-check,
.vmg-item.vmg-selected .vmg-item-check,
.vmg-gallery-container.vmg-has-selection .vmg-item-check {
    opacity: 1;
}

@media (hover: none) {
    .vmg-item-check {
        opacity: 1;
    }
}

.vmg-item.vmg-selected {
    outline: 3px solid #0073aa;
    outline-offset: -3px;
}

.vmg-btn-selection {
    background: #1d8a4c;
}

.vmg-btn-selection:hover {
    background: #146637;
}

.vmg-btn-clear-selection {
    background: none !important;
    color: #0073aa !important;
    padding: 10px 6px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    font-size: 13px;
    text-decoration: underline !important;
}

.vmg-loader {
    display: flex;
    justify-content: center;
    padding: 30px;
}

.vmg-spinner {
    width: 36px;
    height: 36px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0073aa;
    border-radius: 50%;
    animation: vmg-spin 1s linear infinite;
}

@keyframes vmg-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.vmg-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 25px;
    flex-wrap: wrap;
}

.vmg-page-btn {
    padding: 8px 14px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.vmg-page-btn.active, .vmg-page-btn:hover:not(:disabled) {
    background: #0073aa;
    color: #fff;
    border-color: #0073aa;
}

.vmg-page-btn.vmg-page-nav {
    font-weight: 600;
}

.vmg-page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #fff;
    color: #333;
}

/* Lightbox Modal */
.vmg-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vmg-lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
}

.vmg-lightbox-content {
    position: relative;
    z-index: 2;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.vmg-lightbox-media img {
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 4px;
    user-select: none;
}

.vmg-lightbox-close {
    position: fixed;
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    z-index: 100000;
    transition: background 0.2s;
}

.vmg-lightbox-close:hover {
    background: rgba(0, 0, 0, 0.8);
}

@media (max-width: 768px) {
    .vmg-lightbox-close {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
        font-size: 22px;
    }
}

.vmg-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    font-size: 48px;
    padding: 10px 18px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
}

.vmg-lightbox-nav:hover {
    background: rgba(255,255,255,0.3);
}

.vmg-prev { left: -60px; }
.vmg-next { right: -60px; }

@media (max-width: 768px) {
    .vmg-prev { left: 10px; }
    .vmg-next { right: 10px; }
}

@media (max-width: 768px) {
    /* Su mobile ho spesso i pulsanti di cookie/accessibilità ancorati in basso allo
       schermo: allineo il contenuto del lightbox più in alto invece di centrarlo
       verticalmente, per evitare che la foto o la barra inferiore ci finiscano sotto. */
    .vmg-lightbox {
        align-items: flex-start;
        padding-top: 20px;
        padding-bottom: 110px;
        box-sizing: border-box;
        overflow-y: auto;
    }

    .vmg-lightbox-content {
        max-height: none;
    }

    .vmg-lightbox-media img {
        max-height: calc(100vh - 230px);
    }
}

.vmg-lightbox-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-top: 12px;
    color: #fff;
}
