/* Masonry Gallery Styles */
.reformas-gallery-masonry {
    margin: 40px auto;
    max-width: 1400px;
    padding: 0 20px;
}

/* Before masonry initializes - use flexbox as fallback */
.reformas-gallery-masonry:not(.masonry-initialized) {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.reformas-gallery-masonry:not(.masonry-initialized) .gallery-item {
    flex: 0 0 calc(33.333% - 14px);
}

/* After masonry initializes */
.reformas-gallery-masonry.masonry-initialized {
    margin-left: auto;
    margin-right: auto;
}

/* Masonry sizer for 3 columns */
.gallery-item-sizer {
    width: calc(33.333% - 14px);
    height: 0;
    padding: 0;
    margin: 0;
    border: 0;
}

.reformas-gallery-masonry .gallery-item {
    width: calc(33.333% - 14px);
}

.reformas-gallery-masonry .gallery-item {
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.12);
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    background: #fff;
}

/* Add subtle border */
.reformas-gallery-masonry .gallery-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    pointer-events: none;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.reformas-gallery-masonry .gallery-item:hover::before {
    opacity: 1;
}

.reformas-gallery-masonry .gallery-item:hover {
    transform: translateY(-10px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
}

.reformas-gallery-masonry .gallery-item a {
    display: block;
    position: relative;
    overflow: hidden;
    line-height: 0;
    cursor: pointer;
}

.reformas-gallery-masonry .gallery-item img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    vertical-align: middle;
    object-fit: cover;
}

.reformas-gallery-masonry .gallery-item:hover img {
    transform: scale(1.08);
}

.reformas-gallery-masonry .gallery-item a::before {
    content: '🔍';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    font-size: 48px;
    z-index: 10;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.6));
    opacity: 0;
}

.reformas-gallery-masonry .gallery-item:hover a::before {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.reformas-gallery-masonry .gallery-item a:active::before {
    transform: translate(-50%, -50%) scale(1.2);
}

.reformas-gallery-masonry .gallery-item a::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.1));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.reformas-gallery-masonry .gallery-item:hover a::after {
    opacity: 1;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .gallery-item-sizer,
    .reformas-gallery-masonry .gallery-item {
        width: calc(33.333% - 14px);
    }
    
    .reformas-gallery-masonry:not(.masonry-initialized) .gallery-item {
        flex: 0 0 calc(33.333% - 14px);
    }
}

@media (max-width: 768px) {
    .reformas-gallery-masonry {
        padding: 0 15px;
    }
    
    .gallery-item-sizer,
    .reformas-gallery-masonry .gallery-item {
        width: calc(50% - 10px);
    }
    
    .reformas-gallery-masonry:not(.masonry-initialized) .gallery-item {
        flex: 0 0 calc(50% - 10px);
    }
    
    .reformas-gallery-masonry:not(.masonry-initialized) {
        gap: 15px;
    }
}

@media (max-width: 576px) {
    .reformas-gallery-masonry {
        padding: 0 10px;
    }
    
    .gallery-item-sizer,
    .reformas-gallery-masonry .gallery-item {
        width: 100%;
    }
    
    .reformas-gallery-masonry:not(.masonry-initialized) .gallery-item {
        flex: 0 0 100%;
    }
    
    .reformas-gallery-masonry:not(.masonry-initialized) {
        gap: 15px;
    }
}

/* Lightbox Styles */
.reformas-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    padding: 20px;
    visibility: hidden;
}

.reformas-lightbox.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-content {
    position: relative;
    max-width: 95%;
    max-height: 95%;
    animation: zoomIn 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
}

@keyframes zoomIn {
    from {
        transform: scale(0.85);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.lightbox-content img {
    max-width: 100%;
    max-height: 90vh;
    display: block;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

.lightbox-close {
    position: absolute;
    top: -50px;
    right: -10px;
    font-size: 50px;
    color: #fff;
    cursor: pointer;
    line-height: 1;
    transition: all 0.2s ease;
    z-index: 10;
    font-weight: 300;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.lightbox-close:hover {
    color: #ff4444;
    transform: rotate(90deg);
}

/* Lightbox Navigation Arrows */
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 60px;
    color: #fff;
    cursor: pointer;
    user-select: none;
    padding: 20px;
    transition: all 0.3s ease;
    z-index: 10;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    line-height: 1;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

.lightbox-nav:hover {
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    transform: translateY(-50%) scale(1.1);
}

.lightbox-nav:active {
    transform: translateY(-50%) scale(0.95);
}

/* Lightbox Counter */
.lightbox-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 16px;
    background: rgba(0, 0, 0, 0.6);
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: 600;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    z-index: 10;
}

@media (max-width: 768px) {
    .lightbox-close {
        top: -40px;
        right: 0;
        font-size: 40px;
    }
    
    .lightbox-content {
        max-width: 100%;
        max-height: 100%;
    }
    
    .lightbox-nav {
        font-size: 40px;
        width: 50px;
        height: 50px;
        padding: 10px;
    }
    
    .lightbox-prev {
        left: 10px;
    }
    
    .lightbox-next {
        right: 10px;
    }
    
    .lightbox-counter {
        bottom: 10px;
        font-size: 14px;
        padding: 6px 16px;
    }
}

/* Admin Button on Home */
.reformas-admin-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    animation: slideInRight 0.5s ease;
}

@keyframes slideInRight {
    from {
        transform: translateX(100px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.button-carga-imagenes {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #2271b1, #135e96);
    color: #fff;
    padding: 14px 28px;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
    box-shadow: 0 6px 20px rgba(34, 113, 177, 0.4);
    transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.button-carga-imagenes:hover {
    background: linear-gradient(135deg, #135e96, #0a4a75);
    color: #fff;
    box-shadow: 0 8px 30px rgba(34, 113, 177, 0.6);
    transform: translateY(-3px);
    border-color: rgba(255, 255, 255, 0.2);
}

.button-carga-imagenes:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(34, 113, 177, 0.5);
}

.button-carga-imagenes .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

@media (max-width: 768px) {
    .reformas-admin-button {
        bottom: 20px;
        right: 20px;
    }
    
    .button-carga-imagenes {
        padding: 12px 20px;
        font-size: 14px;
    }
    
    .button-carga-imagenes .dashicons {
        font-size: 18px;
        width: 18px;
        height: 18px;
    }
}

/* Section Container Styles */
.recent-projects {
    padding: 60px 0;
    margin: 40px 0;
}

.recent-projects .section-title {
    text-align: center;
    margin-bottom: 50px;
}

.recent-projects .section-title h3 {
    font-size: 2.5rem;
    color: #ffffff;
    margin-bottom: 15px;
    font-weight: 700;
}

.recent-projects .section-title p {
    font-size: 1.1rem;
    color: #ffffff;
    max-width: 600px;
    margin: 0 auto;
}

/* No images message */
.reformas-gallery-masonry p {
    text-align: center;
    color: #6c757d;
    font-size: 1.1rem;
    padding: 60px 20px;
    background: #fff;
    border-radius: 8px;
    border: 2px dashed #dee2e6;
}

@media (max-width: 768px) {
    .recent-projects {
        padding: 40px 0;
        margin: 20px 0;
    }
    
    .recent-projects .section-title h3 {
        font-size: 2rem;
    }
    
    .recent-projects .section-title p {
        font-size: 1rem;
    }
}
