/**
 * Estilos para NRedes Galeria - Frontend
 */

/* Contenedor principal */
.nredes-gallery-wrapper {
    max-width: 100%;
    margin: 0 auto;
    padding: 20px 0;
}

/* Filtros */
.nredes-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-bottom: 30px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.nredes-filter-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: 2px solid transparent;
    border-radius: 25px;
    background: white;
    color: #333;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.nredes-filter-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.nredes-filter-btn.active {
    background: var(--category-color, #0073aa);
    color: white;
    border-color: var(--category-color, #0073aa);
}

.nredes-filter-btn .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.nredes-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 11px;
    font-size: 11px;
    font-weight: 600;
}

.nredes-filter-btn.active .nredes-count {
    background: rgba(255, 255, 255, 0.3);
}

/* Grid de galería */
.nredes-gallery-grid {
    display: grid;
    gap: 20px;
}

/* Layout: Grid (default) */
.nredes-gallery-grid.grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* Layout: Masonry */
.nredes-gallery-grid.masonry {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    grid-auto-rows: 10px;
}

.nredes-gallery-grid.masonry .nredes-gallery-item {
    grid-row: span 20;
}

.nredes-gallery-grid.masonry .nredes-gallery-item:nth-child(2n) {
    grid-row: span 25;
}

.nredes-gallery-grid.masonry .nredes-gallery-item:nth-child(3n) {
    grid-row: span 18;
}

/* Layout: Columns */
.nredes-gallery-grid.columns {
    column-count: 4;
    column-gap: 20px;
}

@media (max-width: 1200px) {
    .nredes-gallery-grid.columns {
        column-count: 3;
    }
}

@media (max-width: 768px) {
    .nredes-gallery-grid.columns {
        column-count: 2;
    }
    .nredes-gallery-grid.grid,
    .nredes-gallery-grid.masonry {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

@media (max-width: 480px) {
    .nredes-gallery-grid.columns {
        column-count: 1;
    }
    .nredes-gallery-grid.grid,
    .nredes-gallery-grid.masonry {
        grid-template-columns: 1fr;
    }
}

/* Items de la galería */
.nredes-gallery-item {
    break-inside: avoid;
    margin-bottom: 0;
}

.nredes-item-inner {
    position: relative;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.nredes-gallery-item:hover .nredes-item-inner {
    transform: translateY(-5px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
}

/* Wrapper de imagen */
.nredes-image-wrapper {
    position: relative;
    overflow: hidden;
    aspect-ratio: 4/3;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

.nredes-gallery-grid.masonry .nredes-image-wrapper {
    aspect-ratio: auto;
    height: 100%;
}

.nredes-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.nredes-gallery-item:hover .nredes-image-wrapper img {
    transform: scale(1.1);
}

/* Overlay */
.nredes-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0) 0%,
        rgba(0, 0, 0, 0.3) 50%,
        rgba(0, 0, 0, 0.8) 100%
    );
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 20px;
}

.nredes-gallery-item:hover .nredes-overlay {
    opacity: 1;
}

.nredes-overlay-content {
    color: white;
    margin-bottom: 15px;
}

.nredes-overlay-content h4 {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
}

.nredes-dims,
.nredes-size {
    display: inline-block;
    font-size: 11px;
    opacity: 0.9;
    margin-right: 10px;
    padding: 3px 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

/* Acciones */
.nredes-actions {
    display: flex;
    gap: 10px;
}

.nredes-actions a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 50%;
    color: #333;
    text-decoration: none;
    transition: all 0.3s ease;
}

.nredes-actions a:hover {
    background: var(--item-color, #0073aa);
    color: white;
    transform: scale(1.1);
}

.nredes-actions .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

/* Info del item */
.nredes-item-info {
    padding: 15px;
}

.nredes-item-info h5 {
    margin: 0 0 10px 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nredes-category-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.nredes-category-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 10px;
    font-weight: 500;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1.3;
}

/* Animaciones de filtro */
.nredes-gallery-item {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Fade animation */
[data-animation="fade"] .nredes-gallery-item.filtered-out {
    opacity: 0;
    transform: scale(0.8);
    position: absolute;
    pointer-events: none;
}

[data-animation="fade"] .nredes-gallery-item.filtered-in {
    animation: fadeIn 0.4s ease forwards;
}

/* Slide animation */
[data-animation="slide"] .nredes-gallery-item.filtered-out {
    opacity: 0;
    transform: translateX(-30px);
    position: absolute;
    pointer-events: none;
}

[data-animation="slide"] .nredes-gallery-item.filtered-in {
    animation: slideIn 0.4s ease forwards;
}

/* Scale animation */
[data-animation="scale"] .nredes-gallery-item.filtered-out {
    opacity: 0;
    transform: scale(0);
    position: absolute;
    pointer-events: none;
}

[data-animation="scale"] .nredes-gallery-item.filtered-in {
    animation: scaleIn 0.4s ease forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Mensaje sin imágenes */
.nredes-no-images {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.nredes-no-images p {
    font-size: 18px;
    margin: 0;
}

/* Loading spinner */
.nredes-gallery-loading {
    display: none;
    text-align: center;
    padding: 40px;
}

.nredes-gallery-loading.active {
    display: block;
}

.nredes-spinner {
    display: inline-block;
    width: 50px;
    height: 50px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: var(--category-color, #0073aa);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Lazy loading placeholder */
.nredes-image-wrapper img[loading="lazy"] {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .nredes-filters {
        gap: 8px;
    }

    .nredes-filter-btn {
        padding: 8px 15px;
        font-size: 13px;
    }

    .nredes-overlay {
        opacity: 1;
        background: linear-gradient(
            to bottom,
            rgba(0, 0, 0, 0) 0%,
            rgba(0, 0, 0, 0.7) 100%
        );
    }

    .nredes-actions {
        gap: 8px;
    }

    .nredes-actions a {
        width: 36px;
        height: 36px;
    }
}

/* Paginación */
.nredes-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-top: 30px;
    padding: 20px;
}

.nredes-page-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 24px;
    border: 2px solid #ddd;
    border-radius: 25px;
    background: white;
    color: #333;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.nredes-page-btn:hover:not(:disabled) {
    background: #0073aa;
    color: white;
    border-color: #0073aa;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.3);
}

.nredes-page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.nredes-page-info {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

.nredes-current-page {
    font-weight: 700;
    color: #0073aa;
}

/* Loading overlay */
.nredes-gallery-loading {
    display: none;
    text-align: center;
    padding: 40px;
}

.nredes-gallery-loading.active {
    display: block;
}

.nredes-gallery-grid {
    transition: opacity 0.3s ease;
}

/* View button en overlay */
.nredes-view-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 25px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.nredes-view-btn:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* ========== Slider/Lightbox de categoría ========== */
.nredes-slider-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.92);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nredes-slider-container {
    width: 95%;
    max-width: 1100px;
    max-height: 95vh;
    display: flex;
    flex-direction: column;
    color: white;
}

.nredes-slider-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    flex-shrink: 0;
}

.nredes-slider-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: white;
}

.nredes-slider-close {
    background: none;
    border: none;
    color: white;
    font-size: 36px;
    cursor: pointer;
    padding: 0 10px;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.nredes-slider-close:hover {
    opacity: 1;
}

.nredes-slider-body {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.nredes-slider-arrow {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 40px;
    width: 50px;
    height: 80px;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
    line-height: 1;
}

.nredes-slider-arrow:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.6);
}

.nredes-slider-arrow:disabled {
    opacity: 0.2;
    cursor: not-allowed;
}

.nredes-slider-image-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 0;
    overflow: hidden;
}

.nredes-slider-image {
    max-width: 100%;
    max-height: 65vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    transition: opacity 0.3s ease;
}

.nredes-slider-caption {
    margin-top: 12px;
    font-size: 15px;
    color: rgba(255, 255, 255, 0.8);
    text-align: center;
}

.nredes-slider-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 15px 0 5px;
    flex-shrink: 0;
}

.nredes-slider-counter {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
}

.nredes-slider-thumbnails {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    max-width: 100%;
    padding: 5px 0;
    scroll-behavior: smooth;
}

.nredes-slider-thumbnails::-webkit-scrollbar {
    height: 4px;
}

.nredes-slider-thumbnails::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
}

.nredes-slider-thumb {
    width: 60px;
    height: 45px;
    flex-shrink: 0;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    opacity: 0.5;
    transition: all 0.2s;
}

.nredes-slider-thumb:hover {
    opacity: 0.8;
}

.nredes-slider-thumb.active {
    border-color: white;
    opacity: 1;
}

.nredes-slider-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

@media (max-width: 768px) {
    .nredes-slider-arrow {
        width: 36px;
        height: 60px;
        font-size: 28px;
    }

    .nredes-slider-image {
        max-height: 50vh;
    }

    .nredes-slider-thumb {
        width: 45px;
        height: 34px;
    }
}

/* Accesibilidad - Respectar prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .nredes-gallery-item,
    .nredes-image-wrapper img,
    .nredes-item-inner,
    .nredes-filter-btn {
        transition: none !important;
        animation: none !important;
    }
}
