/* Estilos del Portafolio - Versión Mejorada */
.portfolio-header {
    position: relative;
    margin: 40px 0;
    text-align: center;
}

.portfolio-filters {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 12px 25px;
    border: none;
    border-radius: 30px;
    background: var(--light);
    box-shadow: var(--box-shadow);
    font-family: 'Poppins', sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    font-weight: 500;
}

.filter-btn.active {
    background: var(--gradient-bg);
    color: white;
    transform: scale(1.05);
}

.video-grid {
    display: flex;
    flex-direction: column;
    gap: 40px;
    margin-top: 30px;
}

.video-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    padding: 10px;
}

.video-item {
    position: relative;
    border-radius: 15px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    background: var(--light);
    box-shadow: var(--box-shadow);
    cursor: pointer;
}

.video-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

.video-wrapper {
    position: relative;
    padding-top: 56.25%;
    overflow: hidden;
}

.video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    transition: opacity 0.3s ease;
}

.video-info {
    padding: 15px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    background: var(--light);
}

.video-action {
    width: 35px;
    height: 35px;
    border: none;
    border-radius: 50%;
    background: var(--gradient-bg);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--box-shadow);
    transition: transform 0.3s ease;
}

.video-action:hover {
    transform: scale(1.1);
}

/* Popup de Video */
.video-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.video-popup-overlay.active {
    opacity: 1;
    visibility: visible;
}

.video-popup-container {
    position: relative;
    width: 80%;
    max-width: 1000px;
    background: var(--light);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.close-popup-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--gradient-bg);
    color: white;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: transform 0.3s ease;
}

.close-popup-btn:hover {
    transform: rotate(90deg);
}

.popup-video-wrapper {
    position: relative;
    padding-top: 56.25%;
    width: 100%;
    overflow: hidden;
    border-radius: 10px;
    background: #000;
}

#popup-iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.popup-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
}

.nav-btn {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    background: var(--gradient-bg);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--box-shadow);
    transition: transform 0.3s ease;
}

.nav-btn:hover {
    transform: scale(1.1);
}

.nav-btn i {
    font-size: 1.2rem;
}

/* Responsive */
@media (max-width: 1024px) {
    .video-popup-container {
        width: 90%;
    }
}

@media (max-width: 768px) {
    .video-list {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
    
    .video-popup-container {
        width: 95%;
        padding: 15px;
    }
    
    .close-popup-btn {
        width: 35px;
        height: 35px;
        font-size: 1.3rem;
    }
    
    .nav-btn {
        width: 45px;
        height: 45px;
    }
}

@media (max-width: 480px) {
    .video-list {
        grid-template-columns: 1fr;
    }
    
    .portfolio-filters {
        gap: 10px;
    }
    
    .filter-btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
    
    .video-popup-container {
        padding: 10px;
    }
    
    .popup-navigation {
        margin-top: 15px;
    }
}

.video-category {
    display: none;
}

.video-category[data-category="explicativos"] {
    display: block;
}

/* Asegurar que los videos ocultos no afecten el layout */
.video-item {
    display: none;
}

.video-item:nth-child(-n+3) {
    display: block;
}

/* Animación de aparición */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Estilos para el contenedor Show More */
.show-more-container {
    width: 100%;
    display: flex;
    justify-content: center;
    margin: 30px 0;
    padding: 20px 0;
}

.show-more-btn {
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 50%;
    background: var(--gradient-bg);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--box-shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.show-more-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.show-more-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.show-more-btn:hover::after {
    opacity: 1;
}

.show-more-btn.expanded {
    transform: rotate(180deg);
}

.show-more-btn.expanded:hover {
    transform: rotate(180deg) scale(1.05);
}

.arrow-icon {
    width: 24px;
    height: 24px;
    fill: white;
    transition: transform 0.3s ease;
}

/* Estilos para la visualización inicial de videos */
.video-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.video-item {
    display: none; /* Ocultar todos inicialmente */
    animation: none;
    transition: all 0.3s ease;
}

.video-item:nth-child(-n+3) {
    display: block; /* Mostrar solo los primeros 3 */
}

/* Animación para los videos que aparecen */
@keyframes fadeIn {
    from { 
        opacity: 0; 
        transform: translateY(20px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

/* Estilos responsive */
@media (max-width: 1024px) {
    .video-list {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
    
    .show-more-btn {
        width: 55px;
        height: 55px;
    }
}

@media (max-width: 768px) {
    .video-list {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
    
    .show-more-btn {
        width: 50px;
        height: 50px;
    }
    
    .arrow-icon {
        width: 20px;
        height: 20px;
    }
}

@media (max-width: 480px) {
    .video-list {
        grid-template-columns: 1fr;
    }
    
    .show-more-btn {
        width: 45px;
        height: 45px;
    }
}

/* Asegurar que el contenedor se oculte si no hay más videos */
.show-more-container[style*="display: none"] {
    display: none !important;
}










/* Estilos Mobile Popup - Versión Corregida */
@media (max-width: 768px) {
  .video-popup-overlay {
    align-items: flex-start;
    justify-content: center;
    padding-top: 10px; /* Espacio para el botón cerrar */
  }

  .video-popup-container {
    width: 100%;
    max-width: 450px;
    height: calc(100vh - 60px); /* Ajuste altura */
    margin-top: 5px; /* Espacio debajo del botón cerrar */
  }

  .popup-video-wrapper {
    height: 85%;
    margin-top: 0;
  }

  .popup-navigation {
    bottom: 10px;
    gap: 15px;
    padding: 15px 0;
    pointer-events: none; /* Permite clicks en el video */
  }

  .nav-btn {
    pointer-events: auto; /* Habilita clicks en botones */
    background: rgba(0,0,0,0.7);
    border: 2px solid rgba(255,255,255,0.5);
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  }

  #popup-iframe {
    pointer-events: auto; /* Habilita controles de video */
    z-index: 0; /* Detrás de los botones */
  }

  .close-popup-btn {
    top: 10px;
    right: 10px;
    z-index: 1004; /* Máxima prioridad */
  }
}

@media (max-width: 480px) {
  .video-popup-container {
    height: calc(100vh - 50px);
  }
  
  .popup-video-wrapper {
    height: 82%;
  }
  
  .nav-btn {
    width: 40px;
    height: 40px;
  }
}