/**
 * Gallery Pro Layouts CSS
 * CSS cho các layout template của gallery
 */

/* ===== COMMON STYLES ===== */
.gallery-pro-container {
    margin: 20px 0;
    position: relative;
}

.gallery-title {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 20px;
    text-align: center;
    color: #333;
}

.gallery-images {
    position: relative;
}

.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    transition: all 0.3s ease;
    background: #f8f9fa;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    transition: transform 0.3s ease;
    border-radius: 8px;
}

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

.gallery-link {
    display: block;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.gallery-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
    color: white;
    padding: 15px 10px 10px;
    font-size: 14px;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.gallery-item:hover .gallery-caption {
    transform: translateY(0);
}

/* ===== GRID LAYOUT ===== */
.gallery-grid-layout .gallery-images {
    display: grid;
    gap: 15px;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.gallery-grid-layout .gallery-item {
    /* Height will be set dynamically via inline CSS */
    overflow: hidden;
}

/* Grid images inherit from global .gallery-item img styles */

/* Grid responsive */
@media (min-width: 768px) {
    .gallery-grid-layout .gallery-images {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 992px) {
    .gallery-grid-layout .gallery-images {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1200px) {
    .gallery-grid-layout .gallery-images {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ===== MASONRY LAYOUT ===== */
.gallery-masonry-layout .gallery-images {
    /* Masonry sẽ được khởi tạo bằng JavaScript */
}

.gallery-masonry-layout .gallery-item {
    width: calc(33.333% - 10px);
    margin-bottom: 15px;
    break-inside: avoid;
}

.gallery-masonry-layout .gallery-item img {
    height: auto;
    /* object-fit: cover inherited from global styles */
}

/* Masonry responsive */
@media (max-width: 768px) {
    .gallery-masonry-layout .gallery-item {
        width: calc(50% - 10px);
    }
}

@media (max-width: 480px) {
    .gallery-masonry-layout .gallery-item {
        width: 100%;
    }
}

@media (min-width: 1200px) {
    .gallery-masonry-layout .gallery-item {
        width: calc(25% - 12px);
    }
}

/* ===== JUSTIFIED GALLERY LAYOUT ===== */
.gallery-justified-layout .gallery-images {
    /* Để Justified Gallery hoàn toàn control */
}

/* Minimal reset - chỉ những gì cần thiết */
.gallery-justified-layout .gallery-item {
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    visibility: visible !important;
    opacity: 1 !important;
}

.gallery-justified-layout .gallery-item img {
    border-radius: 0; /* Justified Gallery sẽ handle border radius cho container */
    transition: none; /* Để Justified Gallery control */
    visibility: visible !important;
    opacity: 1 !important;
    display: block !important;
}

/* Ensure Justified Gallery entries are visible */
.gallery-justified-layout .gallery-item.jg-entry {
    visibility: visible !important;
    opacity: 1 !important;
    display: block !important;
}

.gallery-justified-layout .gallery-item.jg-entry-visible {
    visibility: visible !important;
    opacity: 1 !important;
}

/* Hover effects - simple và không conflict */
.gallery-justified-layout .gallery-item:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    z-index: 10;
}

/* ===== LIGHTBOX ENHANCEMENTS ===== */
.gallery-lightbox-enabled .gallery-item {
    cursor: pointer;
}

/* Standard lightbox overlay cho grid và masonry */
.gallery-lightbox-enabled:not(.gallery-justified-layout) .gallery-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0);
    transition: background 0.3s ease;
    z-index: 1;
}

.gallery-lightbox-enabled:not(.gallery-justified-layout) .gallery-item:hover::before {
    background: rgba(0,0,0,0.3);
}

.gallery-lightbox-enabled:not(.gallery-justified-layout) .gallery-item::after {
    content: '\f065';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 2;
}

.gallery-lightbox-enabled:not(.gallery-justified-layout) .gallery-item:hover::after {
    opacity: 1;
}

/* Lightbox overlay cho Justified Gallery */
.gallery-lightbox-enabled.gallery-justified-layout .gallery-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0);
    transition: background 0.3s ease;
    z-index: 1;
    pointer-events: none;
}

.gallery-lightbox-enabled.gallery-justified-layout .gallery-item:hover::before {
    background: rgba(0,0,0,0.3);
}

.gallery-lightbox-enabled.gallery-justified-layout .gallery-item::after {
    content: '\f065';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 2;
    pointer-events: none;
}

.gallery-lightbox-enabled.gallery-justified-layout .gallery-item:hover::after {
    opacity: 1;
}

/* ===== LOADING STATES ===== */
.gallery-loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.gallery-loading::before {
    content: '';
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #333;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
    vertical-align: middle;
}

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

/* ===== ANIMATIONS ===== */
/* Chỉ apply animation cho grid và masonry, không cho justified */
.gallery-grid-layout .gallery-item,
.gallery-masonry-layout .gallery-item {
    animation: fadeInUp 0.6s ease-out;
}

.gallery-grid-layout .gallery-item:nth-child(2),
.gallery-masonry-layout .gallery-item:nth-child(2) { animation-delay: 0.1s; }

.gallery-grid-layout .gallery-item:nth-child(3),
.gallery-masonry-layout .gallery-item:nth-child(3) { animation-delay: 0.2s; }

.gallery-grid-layout .gallery-item:nth-child(4),
.gallery-masonry-layout .gallery-item:nth-child(4) { animation-delay: 0.3s; }

.gallery-grid-layout .gallery-item:nth-child(5),
.gallery-masonry-layout .gallery-item:nth-child(5) { animation-delay: 0.4s; }

.gallery-grid-layout .gallery-item:nth-child(6),
.gallery-masonry-layout .gallery-item:nth-child(6) { animation-delay: 0.5s; }

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== ERROR STATES ===== */
.gallery-error {
    text-align: center;
    padding: 40px;
    color: #e74c3c;
    background: #fdf2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    margin: 20px 0;
}

.gallery-error::before {
    content: '\f071';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    font-size: 24px;
    display: block;
    margin-bottom: 10px;
}

/* ===== MOBILE OPTIMIZATIONS ===== */
@media (max-width: 768px) {
    .gallery-pro-container {
        margin: 15px 0;
    }
    
    .gallery-title {
        font-size: 20px;
        margin-bottom: 15px;
    }
    
    .gallery-item {
        border-radius: 6px;
    }
    
    .gallery-caption {
        font-size: 12px;
        padding: 10px 8px 6px;
    }
    
    .gallery-lightbox-enabled .gallery-item::after {
        font-size: 16px;
    }
}

/* ===== ACCESSIBILITY ===== */
.gallery-item:focus-within {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

.gallery-link:focus {
    outline: none;
}

@media (prefers-reduced-motion: reduce) {
    .gallery-item,
    .gallery-item img,
    .gallery-caption {
        transition: none;
        animation: none;
    }
    
    .gallery-item:hover img {
        transform: none;
    }
}

/* ===== PAGINATION STYLES ===== */
.gallery-pagination {
    margin-top: 30px;
    text-align: center;
}

/* Numbers Pagination */
.gallery-pagination-numbers {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.gallery-page-prev,
.gallery-page-next,
.gallery-page-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    color: #333;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
    background: white;
}

.gallery-page-prev:hover,
.gallery-page-next:hover,
.gallery-page-number:hover {
    border-color: #007cba;
    color: #007cba;
    background: #f0f7ff;
}

.gallery-page-number.current {
    background: #007cba;
    border-color: #007cba;
    color: white;
    cursor: default;
}

.gallery-page-dots {
    padding: 8px 4px;
    color: #666;
}

.gallery-page-prev i,
.gallery-page-next i {
    font-size: 12px;
}

/* Load More Button */
.gallery-pagination-load-more {
    margin-top: 20px;
}

.gallery-load-more-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 15px 30px;
    background: #007cba;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.gallery-load-more-btn:hover {
    background: #005a87;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.gallery-load-more-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.gallery-load-more-btn.loading {
    opacity: 0.7;
    pointer-events: none;
}

/* Infinite Scroll */
.gallery-pagination-infinite {
    margin-top: 20px;
    display: none; /* Hidden by default, shown by JS when near end */
}

.gallery-infinite-trigger {
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-loading-spinner {
    color: #007cba;
    font-size: 16px;
}

.gallery-loading-spinner i {
    margin-right: 8px;
}

/* ===== RESPONSIVE PAGINATION ===== */
@media (max-width: 768px) {
    .gallery-pagination {
        margin-top: 20px;
    }
    
    .gallery-page-prev,
    .gallery-page-next,
    .gallery-page-number {
        min-width: 35px;
        height: 35px;
        padding: 6px 10px;
        font-size: 14px;
    }
    
    .gallery-pagination-numbers {
        gap: 5px;
    }
    
    .gallery-load-more-btn {
        padding: 12px 24px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .gallery-page-prev span,
    .gallery-page-next span {
        display: none; /* Hide text on mobile, show only icons */
    }
    
    .gallery-pagination-numbers {
        justify-content: center;
        overflow-x: auto;
        padding: 0 10px;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .gallery-pro-container {
        break-inside: avoid;
    }
    
    .gallery-item {
        break-inside: avoid;
        margin-bottom: 10px;
    }
    
    .gallery-caption {
        position: static;
        background: none;
        color: #333;
        padding: 5px 0;
        transform: none;
    }
    
    .gallery-pagination {
        display: none;
    }
}

/* ===== SLIDER LAYOUT ===== */
.gallery-slider-layout .swiper {
    width: 100%;
    height: 500px; /* Default height, will be overridden by dynamic CSS */
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.gallery-slider-layout .swiper-slide {
    width: auto;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border-radius: 8px;
    overflow: hidden;
}

.gallery-slider-layout .swiper-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    border-radius: 8px;
}

/* Slider Navigation */
.gallery-slider-layout .swiper-button-next,
.gallery-slider-layout .swiper-button-prev {
    width: 44px;
    height: 44px;
    margin-top: 0;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    color: #333 !important;
    transition: all 0.3s ease;
}

.gallery-slider-layout .swiper-button-next:hover,
.gallery-slider-layout .swiper-button-prev:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.gallery-slider-layout .swiper-button-next:after,
.gallery-slider-layout .swiper-button-prev:after {
    font-size: 16px;
    font-weight: bold;
}

/* Slider Pagination */
.gallery-slider-layout .swiper-pagination {
    bottom: 20px;
}

.gallery-slider-layout .swiper-pagination-bullet {
    width: 10px;
    height: 10px;
    background: rgba(255, 255, 255, 0.7);
    opacity: 1;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.gallery-slider-layout .swiper-pagination-bullet-active {
    background: #007cba;
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.2);
}

/* Slider Responsive */
@media (max-width: 768px) {
    .gallery-slider-layout .swiper {
        border-radius: 8px;
    }
    
    .gallery-slider-layout .swiper-button-next,
    .gallery-slider-layout .swiper-button-prev {
        width: 36px;
        height: 36px;
    }
    
    .gallery-slider-layout .swiper-button-next:after,
    .gallery-slider-layout .swiper-button-prev:after {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .gallery-slider-layout .swiper-button-next,
    .gallery-slider-layout .swiper-button-prev {
        width: 30px;
        height: 30px;
    }
    
    .gallery-slider-layout .swiper-button-next:after,
    .gallery-slider-layout .swiper-button-prev:after {
        font-size: 12px;
    }
    
    .gallery-slider-layout .swiper-pagination {
        bottom: 15px;
    }
} 