/* ========================================
   SMILEY GALERÍA v9.1 ULTRA - FIXED
   + Lightbox mejorado (botón salir visible)
   + Videos solo con click (no hover)
   + Click fondo para cerrar
   ======================================== */

:root {
    --smiley-red: #ff0000;
    --smiley-green: #33cc33;
    --smiley-yellow: #fbbf24;
    --smiley-dark: #1a202c;
    --smiley-gray: #4a5568;
}

/* ==================== 
   CONTENEDOR PRINCIPAL 
   ==================== */
.smiley-gallery-wrapper-v7 {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto 40px auto;
    padding: 32px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
}

/* ==================== 
   CONTADOR DE FOTOS (v9.1)
   ==================== */
.gallery-counter {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-radius: 12px;
    margin-bottom: 16px;
    border: 2px solid var(--smiley-yellow);
    box-shadow: 0 4px 12px rgba(251, 191, 36, 0.2);
    animation: slideDown 0.5s ease-out;
}

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

.counter-icon {
    font-size: 24px;
}

.counter-text {
    font-size: 16px;
    font-weight: 700;
    color: var(--smiley-dark);
}

.counter-current {
    font-size: 28px;
    font-weight: 900;
    color: var(--smiley-red);
    animation: pulse 0.3s ease-out;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.counter-divider {
    font-size: 20px;
    color: var(--smiley-gray);
    font-weight: 600;
}

.counter-total {
    font-size: 20px;
    font-weight: 700;
    color: var(--smiley-dark);
}

.counter-label {
    font-size: 13px;
    color: #92400e;
    font-weight: 600;
    margin-left: 4px;
}

/* ==================== 
   FILTROS/CATEGORÍAS
   ==================== */
.gallery-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    justify-content: center;
}

.filter-btn {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 700;
    color: var(--smiley-gray);
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 24px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.filter-btn:hover {
    border-color: var(--smiley-green);
    color: var(--smiley-green);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(51, 204, 51, 0.2);
}

.filter-btn.active {
    background: linear-gradient(135deg, var(--smiley-red) 0%, #cc0000 100%);
    border-color: var(--smiley-red);
    color: white;
    box-shadow: 0 4px 12px rgba(255, 0, 0, 0.4);
}

.filter-count {
    display: inline-block;
    background: rgba(255,255,255,0.3);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    margin-left: 4px;
}

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

/* ==================== 
   LAYOUT VERTICAL STACK
   ==================== */
.gallery-main-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 32px;
}

/* ==================== 
   HERO PRINCIPAL 16:9
   ==================== */
.hero-display-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #f8f8f8;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.12);
    cursor: zoom-in;
}

.hero-display-container:hover {
    box-shadow: 0 15px 50px rgba(0,0,0,0.18);
}

/* Overlay hint "Click para ampliar" */
.hero-zoom-hint {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    color: white;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 10;
}

.hero-display-container:hover .hero-zoom-hint {
    opacity: 1;
}

.hero-zoom-hint svg {
    width: 16px;
    height: 16px;
    fill: white;
}

.hero-image-wrapper,
.hero-video-wrapper {
    position: absolute;
    inset: 0;
}

.hero-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

/* Efecto zoom sutil en hover */
.hero-display-container:hover .hero-image {
    transform: scale(1.02);
}

.hero-video-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* ==================== 
   LIGHTBOX FULLSCREEN - MEJORADO
   ==================== */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    display: none;
    animation: fadeIn 0.3s ease;
    cursor: zoom-out;
}

.lightbox-overlay.active {
    display: block;
}

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

.lightbox-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.lightbox-image-container {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    animation: zoomIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: default;
}

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

.lightbox-image {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.lightbox-video {
    width: 90vw;
    max-width: 1200px;
    aspect-ratio: 16 / 9;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

/* Controles lightbox - MEJORADOS */
.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    background: rgba(255, 0, 0, 0.95);
    backdrop-filter: blur(10px);
    border: 3px solid white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 32px;
    font-weight: 700;
    line-height: 1;
    transition: all 0.3s ease;
    z-index: 10002;
    box-shadow: 0 8px 24px rgba(255, 0, 0, 0.6);
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.95);
    border-color: var(--smiley-red);
    color: var(--smiley-red);
    transform: rotate(90deg) scale(1.15);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    transition: all 0.3s ease;
    z-index: 10001;
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: white;
    transform: translateY(-50%) scale(1.1);
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

/* Contador en lightbox */
.lightbox-counter {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    color: white;
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 16px;
    font-weight: 700;
    z-index: 10001;
}

.lightbox-counter .current {
    color: var(--smiley-red);
    font-size: 20px;
}

/* Caption/título en lightbox */
.lightbox-caption {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 80px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    color: white;
    padding: 16px 20px;
    border-radius: 12px;
    z-index: 10001;
}

.lightbox-caption h3 {
    margin: 0 0 4px 0;
    font-size: 18px;
    font-weight: 700;
}

.lightbox-caption p {
    margin: 0;
    font-size: 14px;
    opacity: 0.9;
}

/* Hint ESC para salir */
.lightbox-hint {
    position: absolute;
    top: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    opacity: 0;
    animation: fadeInOut 4s ease-out;
    pointer-events: none;
    z-index: 10001;
    white-space: nowrap;
}

@keyframes fadeInOut {
    0% { opacity: 0; }
    5% { opacity: 1; }
    95% { opacity: 1; }
    100% { opacity: 0; }
}

/* ==================== 
   CARRUSEL THUMBNAILS HORIZONTAL
   ==================== */
.thumbnails-horizontal-container {
    position: relative;
    width: 100%;
}

.thumbnails-horizontal {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    overflow-y: visible;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
    scrollbar-color: var(--smiley-red) #f3f4f6;
    padding: 8px 0 16px 0;
    position: relative;
    scroll-behavior: smooth;
}

.thumbnails-horizontal::-webkit-scrollbar {
    height: 8px;
}

.thumbnails-horizontal::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 10px;
}

.thumbnails-horizontal::-webkit-scrollbar-thumb {
    background: var(--smiley-red);
    border-radius: 10px;
    transition: background 0.3s ease;
}

.thumbnails-horizontal::-webkit-scrollbar-thumb:hover {
    background: var(--smiley-green);
}

.thumbnails-horizontal::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 16px;
    width: 80px;
    background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%);
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.thumbnails-horizontal.scrolled-end::after {
    opacity: 0;
}

/* Thumbnail horizontal item - MÁS GRANDE */
.thumbnail-horizontal {
    position: relative;
    flex-shrink: 0;
    width: 160px;
    height: 110px;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    scroll-snap-align: start;
}

.thumbnail-horizontal::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0);
    transition: background 0.3s ease;
    pointer-events: none;
    z-index: 1;
}

.thumbnail-horizontal:hover {
    transform: translateY(-6px);
    border-color: var(--smiley-green);
    box-shadow: 0 8px 20px rgba(51, 204, 51, 0.4);
}

.thumbnail-horizontal:hover::before {
    background: rgba(51, 204, 51, 0.1);
}

.thumbnail-horizontal.active {
    border-color: var(--smiley-red);
    box-shadow: 0 6px 16px rgba(255, 0, 0, 0.5);
    transform: translateY(-4px);
}

.thumbnail-horizontal.active::after {
    content: '✓';
    position: absolute;
    top: 8px;
    left: 8px;
    width: 24px;
    height: 24px;
    background: var(--smiley-red);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    z-index: 2;
    animation: checkmark 0.3s ease-out;
}

@keyframes checkmark {
    0% { transform: scale(0) rotate(-45deg); }
    50% { transform: scale(1.2) rotate(0deg); }
    100% { transform: scale(1) rotate(0deg); }
}

.thumbnail-horizontal img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Badge categoría en thumbnail */
.thumbnail-category {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    color: white;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    z-index: 2;
}

/* Play icon para videos */
.play-icon-small {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background: rgba(255, 0, 0, 0.95);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    pointer-events: none;
    z-index: 2;
    transition: transform 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.thumbnail-horizontal.video-thumb:hover .play-icon-small {
    transform: translate(-50%, -50%) scale(1.2);
}

/* Scroll hint horizontal - MÁS VISIBLE */
.thumbnails-scroll-hint {
    text-align: center;
    color: var(--smiley-red);
    font-size: 14px;
    font-weight: 700;
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    animation: slideHint 1.5s ease-in-out infinite;
}

@keyframes slideHint {
    0%, 100% { transform: translateX(0); opacity: 0.7; }
    50% { transform: translateX(8px); opacity: 1; }
}

.thumbnails-scroll-hint svg {
    width: 18px;
    height: 18px;
    fill: var(--smiley-red);
    transform: rotate(-90deg);
}

/* ==================== 
   CARRUSEL BENEFICIOS - PADDING AJUSTADO
   ==================== */
.beneficios-carrusel-container {
    margin-top: 32px;
    padding: 24px 24px 28px 24px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    overflow: visible;
}

.beneficios-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--smiley-dark);
    margin: 0 0 20px 0;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--smiley-green);
}

.beneficios-carrusel {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    overflow-y: visible;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
    scrollbar-color: var(--smiley-red) #f3f4f6;
    padding: 8px 0 16px 0;
    position: relative;
}

.beneficios-carrusel::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 16px;
    width: 80px;
    background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%);
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.beneficios-carrusel::-webkit-scrollbar {
    height: 6px;
}

.beneficios-carrusel::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 10px;
}

.beneficios-carrusel::-webkit-scrollbar-thumb {
    background: var(--smiley-red);
    border-radius: 10px;
}

.beneficios-carrusel::-webkit-scrollbar-thumb:hover {
    background: var(--smiley-green);
}

.beneficio-card {
    flex-shrink: 0;
    width: calc(25% - 12px);
    min-width: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 16px 14px;
    background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
    border-radius: 12px;
    border: 2px solid var(--smiley-green);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    scroll-snap-align: start;
}

.beneficio-card:hover {
    transform: translateY(-2px);
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    box-shadow: 0 6px 16px rgba(51, 204, 51, 0.3);
    border-color: var(--smiley-green);
}

.beneficio-emoji {
    font-size: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.beneficio-texto {
    font-size: 15px;
    font-weight: 600;
    color: var(--smiley-dark);
    text-align: center;
    line-height: 1.4;
}

.scroll-hint {
    text-align: center;
    color: var(--smiley-gray);
    font-size: 14px;
    margin: 12px 0 0 0;
    animation: pulse-hint 2s ease-in-out infinite;
}

@keyframes pulse-hint {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* ==================== 
   RESPONSIVE TABLET 
   ==================== */
@media (max-width: 1024px) {
    .smiley-gallery-wrapper-v7 {
        padding: 24px;
    }
    
    .thumbnail-horizontal {
        width: 140px;
        height: 100px;
    }
    
    .beneficio-card {
        min-width: 200px;
    }
    
    .gallery-filters {
        gap: 6px;
    }
    
    .filter-btn {
        padding: 8px 16px;
        font-size: 13px;
    }
}

/* ==================== 
   RESPONSIVE MÓVIL 
   ==================== */
@media (max-width: 768px) {
    .smiley-gallery-wrapper-v7 {
        padding: 20px;
    }
    
    /* Ocultar filtros en móvil */
    .gallery-filters {
        display: none;
    }
    
    /* Contador más compacto */
    .gallery-counter {
        padding: 10px 16px;
    }
    
    .counter-current {
        font-size: 24px;
    }
    
    .counter-total {
        font-size: 18px;
    }
    
    .counter-text {
        font-size: 14px;
    }
    
    /* Ocultar carrusel horizontal desktop */
    .thumbnails-horizontal-container {
        display: none;
    }
    
    /* Mostrar thumbnails móvil */
    .thumbnails-mobile {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        padding: 8px 0 12px 0;
        scroll-snap-type: x mandatory;
        scrollbar-width: thin;
        scrollbar-color: var(--smiley-red) #f3f4f6;
    }
    
    .thumbnails-mobile::-webkit-scrollbar {
        height: 6px;
    }
    
    .thumbnails-mobile::-webkit-scrollbar-track {
        background: #f3f4f6;
        border-radius: 10px;
    }
    
    .thumbnails-mobile::-webkit-scrollbar-thumb {
        background: var(--smiley-red);
        border-radius: 10px;
    }
    
    .thumbnail-mobile {
        position: relative;
        flex-shrink: 0;
        width: 90px;
        height: 90px;
        border-radius: 8px;
        overflow: hidden;
        cursor: pointer;
        border: 3px solid transparent;
        transition: all 0.3s ease;
        scroll-snap-align: start;
    }
    
    .thumbnail-mobile:hover {
        transform: translateY(-4px);
        border-color: var(--smiley-green);
    }
    
    .thumbnail-mobile.active {
        border-color: var(--smiley-red);
        box-shadow: 0 4px 12px rgba(255, 0, 0, 0.5);
    }
    
    .thumbnail-mobile img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    
    /* Lightbox móvil */
    .lightbox-content {
        padding: 20px;
    }
    
    .lightbox-nav {
        width: 44px;
        height: 44px;
    }
    
    .lightbox-close {
        width: 50px;
        height: 50px;
        font-size: 28px;
        top: 15px;
        right: 15px;
    }
    
    .lightbox-caption {
        display: none;
    }
    
    .lightbox-hint {
        font-size: 12px;
        padding: 8px 14px;
    }
    
    /* Beneficios grid móvil */
    .beneficios-carrusel-container {
        padding: 20px;
        margin-top: 24px;
    }
    
    .beneficios-title {
        font-size: 20px;
    }
    
    .beneficios-carrusel {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        overflow-x: visible;
    }
    
    .beneficios-carrusel::after {
        display: none;
    }
    
    .beneficio-card {
        width: 100%;
        min-width: 0;
        padding: 14px 10px;
    }
    
    .beneficio-emoji {
        font-size: 28px;
        width: 48px;
        height: 48px;
    }
    
    .beneficio-texto {
        font-size: 13px;
    }
    
    .scroll-hint {
        display: none;
    }
}

/* ==================== 
   MÓVIL PEQUEÑO 
   ==================== */
@media (max-width: 480px) {
    .smiley-gallery-wrapper-v7 {
        padding: 16px;
        margin-bottom: 24px;
    }
    
    .hero-display-container {
        border-radius: 12px;
    }
    
    .thumbnail-mobile {
        width: 80px;
        height: 80px;
    }
    
    .gallery-counter {
        padding: 8px 12px;
    }
    
    .counter-current {
        font-size: 20px;
    }
}

/* ==================== 
   ANIMACIONES 
   ==================== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.thumbnail-horizontal {
    animation: fadeIn 0.3s ease backwards;
    animation-delay: calc(var(--index, 0) * 0.03s);
}

.beneficio-card {
    animation: fadeIn 0.4s ease backwards;
    animation-delay: calc(var(--index, 0) * 0.05s);
}

/* Touch optimization */
@media (hover: none) and (pointer: coarse) {
    .thumbnail-horizontal:hover,
    .thumbnail-mobile:hover,
    .beneficio-card:hover {
        transform: none;
    }
    
    .thumbnail-horizontal:active {
        transform: scale(0.95);
    }
    
    .thumbnail-mobile:active {
        transform: scale(0.95);
    }
}

/* Drag to scroll hint (cursor) */
.thumbnails-horizontal {
    cursor: grab;
}

.thumbnails-horizontal:active {
    cursor: grabbing;
}

/* Hide desktop elements */
.thumbnails-mobile {
    display: none;
}