/* Page Fade System */
body {
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
}

body.loaded {
    opacity: 1;
}

body.page-transitioning {
    opacity: 0;
}

/* Nasconde la gallery fino al caricamento completo */
.gallery-grid {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-grid.loaded {
    opacity: 1;
}

/* Assicura che l'overlay sia nascosto inizialmente */
.gallery-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    color: #ffffff;
    padding: 10px 15px 0px;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    visibility: hidden;
}

.gallery-item:hover .gallery-overlay {
    transform: translateY(0);
    visibility: visible;
}

/* Loading Overlay */
.page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.page-loader.active {
    opacity: 1;
    visibility: visible;
}

.page-loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    animation: page-spin 1s linear infinite;
}

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

/* Smooth scroll */
html {
    scroll-behavior: smooth;
}

/* Gallery Grid */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
    margin: 30px 0;
}

/* Gallery Filters */
.gallery-filters {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 30px;
    border: 1px solid #e9ecef;
    /* 🔧 FIX: Previeni overflow orizzontale nel container */
    overflow: hidden;
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #dee2e6;
}

.filter-header h3 {
    margin: 0;
    color: #333;
    font-size: 18px;
    font-weight: 600;
}

.filter-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.results-count {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

/* Container override per gallery */
.container {
    max-width: 1680px;
    margin: 0 auto;
    padding: 0 20px;
    /* 🔧 FIX: Previeni scroll orizzontale indesiderato */
    overflow-x: hidden;
}

.gallery-item {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    background: #fff;
    border: 1px solid #ccc;
    padding: 1px;
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.gallery-image {
    position: relative;
    aspect-ratio: 4/3;
    overflow: hidden;
    border-radius: 10px;
}

.gallery-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

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

.gallery-event {
    margin-bottom: 8px;
}

.event-name {
    font-weight: 600;
    font-size: 17px;
    display: block;
}

.event-date {
    font-size: 14px;
    opacity: 0.8;
}

.gallery-title {
    font-size: 13px;
    margin-bottom: 10px;
}

.gallery-action {
    text-align: right;
}

.view-icon {
    font-size: 18px;
}

/* No Content */
.no-content {
    text-align: center;
    padding: 60px 20px;
}

.no-content-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.no-content h2 {
    color: #333;
    margin-bottom: 10px;
}

.no-content p {
    color: #a3a3a3;
    font-size: 16px;
}

.sbiadio {
    color: #a3a3a3 !important;
}

.main-footer {
    margin-top: 10%;
}

/* EVENT BUTTONS - DESKTOP & MOBILE */
.event-buttons {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: center;
    /* 🔧 FIX: Assicura che non overflow */
    width: 100%;
}

.event-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 25px;
    text-decoration: none;
    color: #333;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.event-btn:hover {
    background: #f8f9fa;
    border-color: var(--primary-color, #007bff);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    color: var(--primary-color, #007bff);
}

.event-btn.active {
    background: var(--primary-color, #007bff);
    border-color: var(--primary-color, #007bff);
    color: white;
    box-shadow: 0 4px 12px rgba(0,123,255,0.3);
}

.event-btn.active:hover {
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,123,255,0.4);
}

.event-icon {
    font-size: 26px;
    flex-shrink: 0;
}

.event-info {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.event-name {
    font-weight: 600;
    line-height: 1.2;
}

.event-date {
    font-size: 12px;
    opacity: 0.8;
    margin-top: 2px;
}

.event-btn.active .event-date {
    opacity: 0.9;
}

/* 📱 MOBILE: Slider orizzontale swipeable */
@media (max-width: 768px) {
    /* 🔧 FIX: Container specifico per evitare scroll */
    .gallery-filters {
        padding: 20px 0 25px 0; /* Rimuovi padding laterale */
        overflow: visible; /* Permetti overflow solo per lo slider */
    }
    
    .filter-header {
        padding: 0 20px 15px 20px; /* Ripristina padding solo per header */
        margin-bottom: 15px;
        flex-direction: column;
        align-items: stretch;
        text-align: center;
        gap: 15px;
    }
    
    .filter-actions {
        justify-content: space-between;
    }
    
    /* 🚀 SLIDER EVENTS */
    .event-buttons {
        display: flex;
        flex-direction: row;
        gap: 15px;
        justify-content: flex-start;
        
        /* Scroll orizzontale smooth */
        overflow-x: auto;
        overflow-y: hidden;
        scroll-behavior: smooth;
        
        /* Nasconde scrollbar ma mantiene funzionalità */
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none; /* IE/Edge */
        
        /* Padding per vedere i bordi */
        padding: 0 20px 10px 20px;
        
        /* Snap agli elementi per swipe preciso */
        scroll-snap-type: x mandatory;
    }
    
    /* Nasconde scrollbar Webkit (Chrome, Safari) */
    .event-buttons::-webkit-scrollbar {
        display: none;
    }
    
    /* Ogni bottone evento */
    .event-btn {
        /* Dimensioni fisse per slider */
        min-width: 200px !important;
        max-width: 200px;
        flex-shrink: 0;
        
        /* Snap point per swipe */
        scroll-snap-align: start;
        
        /* Layout interno */
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 15px 18px;
        
        /* Styling */
        background: rgba(255, 255, 255, 0.95);
        border-radius: 25px;
        text-decoration: none;
        color: #333;
        border: 2px solid transparent;
        
        /* Transizioni smooth */
        transition: all 0.3s ease;
        
        /* Shadow per depth */
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
        
        /* Prevent text selection durante swipe */
        user-select: none;
        -webkit-user-select: none;
    }
    
    /* Stato attivo */
    .event-btn.active {
        background: linear-gradient(135deg, #c0af6e 0%, #8a7c4a 100%);
        color: white;
        border-color: #8a7c4a;
        transform: scale(1.05);
        box-shadow: 0 6px 20px rgba(192, 175, 110, 0.4);
    }
    
    /* Hover/Touch feedback */
    .event-btn:hover,
    .event-btn:active {
        transform: translateY(-2px) scale(1.02);
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    }
    
    .event-btn.active:hover,
    .event-btn.active:active {
        transform: scale(1.08) translateY(-2px);
        box-shadow: 0 8px 25px rgba(192, 175, 110, 0.5);
    }
    
    /* Icona evento */
    .event-icon {
        font-size: 1.5rem;
        flex-shrink: 0;
        opacity: 0.8;
    }
    
    .event-btn.active .event-icon {
        opacity: 1;
        filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.3));
    }
    
    /* Info evento */
    .event-info {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        min-width: 0;
    }
    
    /* Nome evento */
    .event-name {
        font-weight: 600;
        font-size: 0.95rem;
        line-height: 1.2;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 140px;
    }
    
    /* Data evento */
    .event-date {
        font-size: 0.8rem;
        opacity: 0.7;
        margin-top: 2px;
        font-weight: 400;
    }
    
    .event-btn.active .event-date {
        opacity: 0.9;
    }
    
    /* Gallery grid mobile */
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .container {
        padding: 0 15px;
    }
}

/* 📱 EXTRA SMALL DEVICES */
@media (max-width: 480px) {
    .event-btn {
        min-width: 180px !important;
        max-width: 180px;
        padding: 12px 15px;
    }
    
    .event-name {
        font-size: 0.9rem;
        max-width: 120px;
    }
    
    .event-date {
        font-size: 0.75rem;
    }
    
    .event-icon {
        font-size: 1.3rem;
    }
}

/* Responsive Desktop */
@media (max-width: 1400px) {
    .gallery-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 1024px) {
    .gallery-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Pagination Circular Buttons */
.pagination-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    margin: 40px 0;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pagination-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: white;
    border: 2px solid #e9ecef;
    text-decoration: none;
    color: #6c757d;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.pagination-btn:hover {
    background: #f8f9fa;
    border-color: var(--primary-color, #007bff);
    color: var(--primary-color, #007bff);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.pagination-btn.active {
    background: var(--primary-color, #007bff);
    border-color: var(--primary-color, #007bff);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,123,255,0.4);
}

.pagination-btn.active:hover {
    background: #0056b3;
    border-color: #0056b3;
    color: white;
}

.pagination-btn:first-child,
.pagination-btn:last-child {
    width: auto;
    min-width: 44px;
    padding: 0 16px;
    border-radius: 22px;
    font-size: 13px;
}

.pagination-info {
    font-size: 14px;
    color: #6c757d;
    text-align: center;
    font-weight: 500;
}

/* Responsive Pagination */
@media (max-width: 768px) {
    .pagination {
        gap: 6px;
    }
	    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .pagination-btn {
        width: 40px;
        height: 40px;
        font-size: 13px;
    }
    
    .pagination-btn:first-child,
    .pagination-btn:last-child {
        min-width: 40px;
        padding: 0 12px;
        border-radius: 20px;
        font-size: 12px;
    }
    
    .pagination-info {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .pagination-wrapper {
        margin: 30px 0;
        gap: 15px;
    }
    
    .pagination {
        gap: 4px;
    }
    
    .pagination-btn {
        width: 36px;
        height: 36px;
        font-size: 12px;
    }
    
    .pagination-btn:first-child,
    .pagination-btn:last-child {
        min-width: 36px;
        padding: 0 10px;
        border-radius: 18px;
        font-size: 11px;
    }
}