/* ============================================
   GALERÍA DE PORTADAS DE PERIÓDICOS - FRONTEND
   Versión con soporte WEBP
   ============================================ */

/* Contenedor principal */
.ncg-gallery-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background-color: #f5f5f5;
    border-radius: 8px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #333;
    line-height: 1.6;
}

/* Formato requerido banner */
.ncg-format-banner {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.ncg-format-banner strong {
    font-weight: 600;
}

.ncg-format-banner code {
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 8px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    margin: 0 5px;
}

/* --- ESTILOS DEL CARRUSEL --- */
.ncg-featured-carousel-section {
    background-color: #fff;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    text-align: center;
}

.ncg-featured-carousel-section h2 {
    margin-bottom: 20px;
    color: #2c3e50;
    font-size: 1.8rem;
    font-weight: 600;
}

.ncg-carousel-container {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 8px;
}

.ncg-carousel-track {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
    padding: 10px 0;
    min-height: 300px;
}

.ncg-carousel-track::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.ncg-carousel-item {
    flex: 0 0 auto;
    width: 200px;
    height: 280px;
    margin-right: 15px;
    scroll-snap-align: start;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    position: relative;
}

.ncg-carousel-item:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.ncg-carousel-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
    transition: transform 0.3s ease;
}

.ncg-carousel-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
    color: white;
    padding: 15px;
    opacity: 0;
    transition: opacity 0.3s ease;
    transform: translateY(10px);
}

.ncg-carousel-item:hover .ncg-carousel-overlay {
    opacity: 1;
    transform: translateY(0);
}

.ncg-carousel-info {
    text-align: left;
}

.ncg-carousel-name {
    font-weight: bold;
    margin-bottom: 3px;
    font-size: 0.9rem;
}

.ncg-carousel-country {
    font-size: 0.8rem;
    opacity: 0.9;
    margin-bottom: 3px;
}

.ncg-carousel-format {
    font-size: 0.7rem;
    opacity: 0.7;
    background: rgba(255,255,255,0.2);
    padding: 2px 6px;
    border-radius: 3px;
    display: inline-block;
}

.ncg-carousel-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 280px;
    color: #7f8c8d;
    font-style: italic;
}

/* --- ESTILOS DEL FILTRO POR PAÍSES --- */
.ncg-filter-section {
    margin-bottom: 30px;
    text-align: center;
    background-color: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.ncg-filter-section h2 {
    margin-bottom: 15px;
    color: #2c3e50;
    font-size: 1.5rem;
    font-weight: 600;
}

.ncg-filter-instructions {
    color: #555;
    font-size: 0.95rem;
    max-width: 600px;
    margin: 0 auto 20px auto;
    padding: 12px;
    background-color: #eaf2f8;
    border-left: 4px solid #3498db;
    border-radius: 4px;
    line-height: 1.5;
}

.ncg-country-filter {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

/* Botones de país */
.ncg-country-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    padding: 12px 8px;
    min-width: 100px;
    min-height: 100px;
    position: relative;
    overflow: hidden;
    text-align: center;
}

.ncg-country-btn:hover { 
    background-color: #3498db; 
    color: white; 
    transform: translateY(-3px); 
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
    border-color: #3498db;
}

.ncg-country-btn.active { 
    background-color: #3498db; 
    color: white; 
    border-color: #3498db;
    transform: translateY(-1px);
}

.ncg-btn-flag { 
    width: 40px; 
    height: 30px; 
    margin-bottom: 8px; 
    border-radius: 4px; 
    overflow: hidden;
    box-shadow: 0 0 4px rgba(0,0,0,0.1); 
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    background: #f8f9fa;
}

.ncg-btn-flag img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ncg-btn-name { 
    font-weight: bold; 
    margin-bottom: 5px;
    font-size: 0.85rem;
    line-height: 1.2;
    max-width: 90px;
    word-wrap: break-word;
}

.ncg-btn-count { 
    background-color: rgba(0,0,0,0.08); 
    color: #555; 
    font-size: 0.75rem; 
    font-weight: 600;
    padding: 3px 8px; 
    border-radius: 12px; 
    position: absolute;
    top: 8px;
    right: 8px;
    min-width: 24px;
    text-align: center;
}

.ncg-country-btn:hover .ncg-btn-count,
.ncg-country-btn.active .ncg-btn-count { 
    background-color: rgba(255,255,255,0.3); 
    color: white; 
}

/* Mensaje cuando no hay países */
.ncg-no-countries {
    padding: 20px;
    background: #fff8e5;
    border: 1px solid #ffb900;
    border-radius: 8px;
    color: #856404;
    text-align: center;
    width: 100%;
}

.ncg-no-countries code {
    background: #fff;
    padding: 3px 6px;
    border-radius: 3px;
    font-family: monospace;
    margin: 0 5px;
}

/* --- ESTILOS DE LA GALERÍA MASONRY --- */
.ncg-gallery-section {
    background-color: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.ncg-images-container {
    position: relative;
    min-height: 300px;
}

.ncg-loading {
    text-align: center;
    padding: 40px;
    font-size: 1.2rem;
    color: #7f8c8d;
    font-style: italic;
}

.ncg-no-results {
    text-align: center;
    padding: 40px;
    font-size: 1.1rem;
    color: #7f8c8d;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px dashed #dee2e6;
}

.ncg-no-results code {
    background: #e9ecef;
    padding: 3px 8px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.95rem;
    margin: 5px;
    display: inline-block;
}

.ncg-masonry-grid {
    column-count: 4;
    column-gap: 15px;
    transition: all 0.3s ease;
}

.ncg-masonry-item {
    break-inside: avoid;
    margin-bottom: 15px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    position: relative;
    background: #fff;
}

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

.ncg-masonry-item img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
}

.ncg-masonry-item:hover img {
    transform: scale(1.02);
}

.newspaper-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
    color: white;
    padding: 12px 15px;
    opacity: 0;
    transition: opacity 0.3s ease;
    transform: translateY(10px);
}

.ncg-masonry-item:hover .newspaper-info {
    opacity: 1;
    transform: translateY(0);
}

.newspaper-name {
    font-weight: bold;
    margin-bottom: 3px;
    font-size: 0.9rem;
    line-height: 1.2;
}

.newspaper-country {
    font-size: 0.8rem;
    opacity: 0.9;
    line-height: 1.2;
    margin-bottom: 3px;
}

.newspaper-format {
    font-size: 0.7rem;
    opacity: 0.7;
    background: rgba(255,255,255,0.2);
    padding: 2px 6px;
    border-radius: 3px;
    display: inline-block;
}

/* WEBP Badge */
.ncg-webp-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: linear-gradient(135deg, #00b09b, #96c93d);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: bold;
    z-index: 10;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* Format badges */
.ncg-format-badge-webp {
    background: linear-gradient(135deg, #00b09b, #96c93d);
}

.ncg-format-badge-jpg {
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
}

.ncg-format-badge-png {
    background: linear-gradient(135deg, #4ecdc4, #44a08d);
}

.ncg-format-badge-gif {
    background: linear-gradient(135deg, #ff9a9e, #fad0c4);
}

/* --- ESTILOS DEL LIGHTBOX --- */
.ncg-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.95);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
    opacity: 0;
    animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

.ncg-lightbox img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    animation: zoomIn 0.3s ease forwards;
}

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

.ncg-lightbox-info {
    position: absolute;
    bottom: 30px;
    left: 0;
    right: 0;
    color: white;
    text-align: center;
    padding: 0 20px;
}

.ncg-lightbox-title {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 5px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.ncg-lightbox-country {
    font-size: 1rem;
    opacity: 0.9;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    margin-bottom: 5px;
}

.ncg-lightbox-format {
    font-size: 0.9rem;
    opacity: 0.7;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* --- RESPONSIVE DESIGN --- */

/* Tablet (768px - 1024px) */
@media (max-width: 1024px) {
    .ncg-masonry-grid {
        column-count: 3;
    }
    
    .ncg-country-btn {
        min-width: 90px;
        min-height: 90px;
        padding: 10px 6px;
    }
    
    .ncg-btn-flag {
        width: 35px;
        height: 26px;
        font-size: 22px;
    }
    
    .ncg-btn-name {
        font-size: 0.8rem;
    }
}

/* Mobile Grande (480px - 768px) */
@media (max-width: 768px) { 
    .ncg-masonry-grid {
        column-count: 2;
    }
    
    .ncg-country-btn { 
        min-width: 85px; 
        min-height: 85px; 
        font-size: 0.8rem; 
        padding: 8px 5px;
    }
    
    .ncg-btn-flag { 
        width: 32px; 
        height: 24px; 
        font-size: 20px;
        margin-bottom: 6px;
    }
    
    .ncg-btn-name {
        font-size: 0.75rem;
    }
    
    .ncg-carousel-item { 
        width: 180px; 
        height: 252px; 
    }
    
    .ncg-filter-section h2,
    .ncg-featured-carousel-section h2 {
        font-size: 1.4rem;
    }
    
    .ncg-filter-instructions {
        font-size: 0.9rem;
        padding: 10px;
    }
}

/* Mobile Pequeño (hasta 480px) */
@media (max-width: 480px) { 
    .ncg-masonry-grid { 
        column-count: 1; 
    }
    
    .ncg-country-btn { 
        min-width: 75px; 
        min-height: 75px; 
        font-size: 0.7rem; 
        padding: 6px 4px;
    }
    
    .ncg-country-filter {
        justify-content: center;
        gap: 8px;
    }
    
    .ncg-btn-flag { 
        width: 28px; 
        height: 21px; 
        font-size: 18px;
        margin-bottom: 5px;
    }
    
    .ncg-btn-name {
        font-size: 0.7rem;
        max-width: 70px;
    }
    
    .ncg-btn-count {
        font-size: 0.65rem;
        padding: 2px 5px;
        top: 5px;
        right: 5px;
        min-width: 20px;
    }
    
    .ncg-carousel-item { 
        width: 160px; 
        height: 224px; 
    }
    
    .ncg-gallery-container {
        padding: 15px;
    }
    
    .ncg-filter-section,
    .ncg-featured-carousel-section,
    .ncg-gallery-section {
        padding: 15px;
    }
    
    .ncg-format-banner {
        padding: 10px 15px;
        font-size: 0.9rem;
    }
}

/* Extra Small (hasta 360px) */
@media (max-width: 360px) {
    .ncg-country-btn {
        min-width: 70px;
        min-height: 70px;
    }
    
    .ncg-btn-name {
        font-size: 0.65rem;
    }
    
    .ncg-carousel-item {
        width: 140px;
        height: 196px;
    }
}