/* ============================================
   PHOTO GALLERY - FRONTEND STYLES
   ============================================ */

/* Gallery Page Wrapper */
.gallery-page-wrapper {
    background: #f5f5f5;
    padding: 60px 0;
    min-height: 60vh;
}

.gallery-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ============================================
   CATEGORY TABS
   ============================================ */
.gallery-tabs {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 40px;
    padding: 0 20px;
}

.gallery-tab {
    background: white;
    border: 2px solid #e0e0e0;
    padding: 12px 28px;
    border-radius: 50px;
    font-family: 'Poppins', sans-serif;
    font-size: 15px;
    font-weight: 500;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.gallery-tab i {
    font-size: 18px;
}

.gallery-tab:hover {
    border-color: #8B4513;
    color: #8B4513;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 69, 19, 0.15);
}

.gallery-tab.active {
    background: linear-gradient(135deg, #8B4513 0%, #A0522D 100%);
    border-color: #8B4513;
    color: white;
    box-shadow: 0 4px 16px rgba(139, 69, 19, 0.3);
}

/* Counter */
.gallery-counter {
    text-align: center;
    margin-bottom: 30px;
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    color: #666;
}

.gallery-counter #image-count {
    font-weight: 600;
    color: #8B4513;
    font-size: 18px;
}

/* ============================================
   MASONRY GRID LAYOUT (Pinterest Style)
   ============================================ */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    auto-rows: auto;
    gap: 20px;
    margin-bottom: 40px;
}

/* Gallery Item */
.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    animation: fadeInUp 0.6s ease forwards;
    break-inside: avoid;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stagger animation delay */
.gallery-item:nth-child(1) { animation-delay: 0.05s; }
.gallery-item:nth-child(2) { animation-delay: 0.1s; }
.gallery-item:nth-child(3) { animation-delay: 0.15s; }
.gallery-item:nth-child(4) { animation-delay: 0.2s; }
.gallery-item:nth-child(5) { animation-delay: 0.25s; }
.gallery-item:nth-child(6) { animation-delay: 0.3s; }
.gallery-item:nth-child(n+7) { animation-delay: 0.35s; }

.gallery-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.2);
}

.gallery-item-image {
    width: 100%;
    height: 100%;
    display: block;
    transition: transform 0.4s ease;
    object-fit: cover;
    object-position: center;
}

.gallery-item:hover .gallery-item-image {
    transform: scale(1.1);
}

/* Hacer algunas imágenes más grandes para efecto masonry */
.gallery-item:nth-child(3n+1) {
    grid-column: span 1;
    min-height: 300px;
}

.gallery-item:nth-child(5n+2) {
    grid-column: span 2;
    min-height: 400px;
}

.gallery-item:nth-child(7n+4) {
    grid-column: span 1;
    min-height: 350px;
}

@media (max-width: 768px) {
    .gallery-item:nth-child(5n+2) {
        grid-column: span 1;
        min-height: 300px;
    }
    
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

/* Error state for images */
.gallery-item.image-error .gallery-item-image {
    background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
}

.gallery-item.image-error .gallery-item-image::after {
    content: '\1F5BC\FE0F Image not found';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #999;
    font-size: 16px;
    text-align: center;
    z-index: 1;
}

/* Overlay */
.gallery-item-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, rgba(0,0,0,0) 0%, rgba(0,0,0,0.8) 100%);
    opacity: 0;
    transition: opacity 0.4s ease;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 20px;
}

.gallery-item:hover .gallery-item-overlay {
    opacity: 1;
}

.gallery-item-title {
    color: white;
    font-family: 'Poppins', sans-serif;
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 8px 0;
    transform: translateY(20px);
    transition: transform 0.4s ease 0.1s;
}

.gallery-item:hover .gallery-item-title {
    transform: translateY(0);
}

.gallery-item-category {
    display: inline-block;
    background: rgba(139, 69, 19, 0.9);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    font-family: 'Poppins', sans-serif;
    transform: translateY(20px);
    transition: transform 0.4s ease 0.2s;
}

.gallery-item:hover .gallery-item-category {
    transform: translateY(0);
}

/* Loading & Empty States */
.gallery-loading,
.gallery-empty {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.gallery-loading .spinner,
.lightbox-loader .spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #8B4513;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.gallery-empty i {
    font-size: 64px;
    color: #ddd;
    margin-bottom: 16px;
    display: block;
}

/* ============================================
   LIGHTBOX
   ============================================ */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lightbox.active {
    display: block;
    opacity: 1;
}

.lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    cursor: pointer;
}

.lightbox-content {
    position: fixed;
    top: 80px;
    left: 0;
    right: 0;
    bottom: 140px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 10000;
    box-sizing: border-box;
    pointer-events: none;
    gap: 15px;
    margin: 0 auto;
}

.lightbox-content > * {
    pointer-events: auto;
}

/* Close Button */
.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid white;
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10003;
}

.lightbox-close:hover {
    background: white;
    color: #333;
    transform: rotate(90deg);
}

/* Navigation Arrows */
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid white;
    color: white;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10001;
}

.lightbox-nav:hover {
    background: white;
    color: #333;
}

.lightbox-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

/* Image Container */
.lightbox-image-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    width: 100%;
    min-height: 0;
}

.lightbox-image {
    max-width: 90vw;
    max-height: 80vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 50px rgba(0,0,0,0.5);
    opacity: 1;
    transform: scale(1);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.lightbox-image.loading {
    opacity: 0.5;
    transform: scale(0.95);
}

.lightbox-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    z-index: 10;
}

.lightbox-loader.loading {
    display: block;
}

/* Image Info */
.lightbox-info {
    text-align: center;
    color: white;
    max-width: 800px;
    padding: 15px 25px;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 15px;
    backdrop-filter: blur(10px);
    z-index: 10002;
    position: relative;
}

.lightbox-title {
    font-family: 'Poppins', sans-serif;
    font-size: 24px;
    font-weight: 600;
    margin: 0 0 8px 0;
}

.lightbox-description {
    font-family: 'Poppins', sans-serif;
    font-size: 15px;
    color: #e0e0e0;
    margin: 0 0 12px 0;
    line-height: 1.6;
}

.lightbox-meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.lightbox-category {
    background: rgba(139, 69, 19, 0.9);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

.lightbox-counter {
    font-size: 14px;
    color: #999;
}

.lightbox-counter #lightbox-current {
    font-weight: 600;
    color: white;
    font-size: 16px;
}

/* Category Menu in Lightbox */
.lightbox-categories {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: calc(100% - 40px);
    z-index: 10002;
    padding: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 25px;
    backdrop-filter: blur(10px);
}

.lightbox-category-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Poppins', sans-serif;
}

.lightbox-category-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: white;
}

.lightbox-category-btn.active {
    background: white;
    color: #333;
}

/* Thumbnails */
.lightbox-thumbnails-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 1200px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 10004;
}

.lightbox-thumbnails {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding: 10px 0;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.3) transparent;
}

.lightbox-thumbnails::-webkit-scrollbar {
    height: 6px;
}

.lightbox-thumbnails::-webkit-scrollbar-track {
    background: transparent;
}

.lightbox-thumbnails::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3);
    border-radius: 3px;
}

.lightbox-thumbnail {
    min-width: 80px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    opacity: 0.6;
}

.lightbox-thumbnail:hover {
    opacity: 1;
    border-color: white;
}

.lightbox-thumbnail.active {
    opacity: 1;
    border-color: #8B4513;
    box-shadow: 0 0 12px rgba(139, 69, 19, 0.6);
}

.lightbox-thumb-nav {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.lightbox-thumb-nav:hover {
    background: rgba(255, 255, 255, 0.2);
}

.lightbox-thumb-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1200px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }
}

@media (max-width: 1024px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }
    
    .lightbox-nav {
        width: 50px;
        height: 50px;
        font-size: 24px;
    }
    
    .lightbox-categories {
        max-width: 90%;
    }
    
    .lightbox-info {
        max-width: 700px;
        padding: 12px 20px;
    }
}

@media (max-width: 768px) {
    .gallery-page-wrapper {
        padding: 40px 0;
    }
    
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 12px;
    }
    
    .gallery-tabs {
        gap: 8px;
        margin-bottom: 30px;
    }
    
    .gallery-tab {
        padding: 10px 20px;
        font-size: 14px;
    }
    
    .gallery-tab i {
        font-size: 16px;
    }
    
    .lightbox-content {
        top: 75px;
        bottom: 120px;
        padding: 15px;
    }
    
    .lightbox-nav {
        width: 45px;
        height: 45px;
        font-size: 20px;
    }
    
    .lightbox-prev {
        left: 10px;
    }
    
    .lightbox-next {
        right: 10px;
    }
    
    .lightbox-close {
        width: 45px;
        height: 45px;
        font-size: 20px;
        top: 15px;
        right: 15px;
    }
    
    .lightbox-title {
        font-size: 20px;
    }
    
    .lightbox-description {
        font-size: 14px;
    }
    
    .lightbox-info {
        max-width: 90%;
        padding: 12px 20px;
    }
    
    .lightbox-categories {
        top: 15px;
        max-width: calc(100% - 80px);
        gap: 6px;
        padding: 8px;
    }
    
    .lightbox-category-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .lightbox-thumbnails-container {
        width: 95%;
        bottom: 15px;
    }
    
    .lightbox-thumbnail {
        min-width: 60px;
        height: 45px;
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
    }
    
    .gallery-item-title {
        font-size: 14px;
    }
    
    .gallery-item-category {
        font-size: 10px;
        padding: 3px 10px;
    }
    
    .lightbox-content {
        top: 100px;
        bottom: 100px;
        padding: 10px;
        gap: 10px;
    }
    
    .lightbox-title {
        font-size: 18px;
    }
    
    .lightbox-info {
        max-width: 95%;
        padding: 10px 15px;
    }
    
    .lightbox-categories {
        flex-direction: row;
        flex-wrap: wrap;
        padding: 8px;
    }
    
    .lightbox-category-btn {
        font-size: 11px;
        padding: 6px 10px;
    }
    
    .lightbox-thumbnails-container {
        width: 95%;
        bottom: 10px;
    }
    
    .lightbox-thumbnail {
        min-width: 50px;
        height: 40px;
    }
}
