/* Enhanced Gallery Styles */
.gallery-section {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

/* Gallery Filters */
.gallery-filters {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: 40px 0 30px;
    padding: 0 20px;
}

.filter-btn {
    padding: 12px 25px;
    background: white;
    border: 2px solid var(--light-gray);
    border-radius: 30px;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--secondary-color);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.filter-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.filter-btn.active {
    background: var(--primary-gradient);
    border-color: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(26, 95, 180, 0.3);
}

/* Gallery Container */
.gallery-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
    margin-top: 20px;
}

/* Gallery Item */
.gallery-item {
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1;
    transform: translateY(0);
    animation: fadeInUp 0.6s ease forwards;
}

.gallery-item.hidden {
    display: none;
    animation: none;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.gallery-item:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
}

/* Gallery Media */
.gallery-media {
    position: relative;
    height: 250px;
    overflow: hidden;
}

.gallery-media img,
.video-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.gallery-item:hover .gallery-media img {
    transform: scale(1.05);
}

.video-thumbnail {
    position: relative;
}

.video-play-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--primary-color);
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 2;
}

.video-play-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: translate(-50%, -50%) scale(1.1);
}

.video-overlay {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    z-index: 2;
}

/* Media Overlay */
.media-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-item:hover .media-overlay {
    opacity: 1;
}

.play-btn {
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: var(--primary-color);
    cursor: pointer;
    transition: all 0.3s ease;
}

.play-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.1);
}

.media-type {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

/* Gallery Info */
.gallery-info {
    padding: 20px;
}

.category-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 15px;
}

.category-badge.salud {
    background: rgba(255, 107, 107, 0.1);
    color: #FF6B6B;
}

.category-badge.energia {
    background: rgba(255, 215, 0, 0.1);
    color: #FFD700;
}

.category-badge.instrumentacion {
    background: rgba(32, 191, 85, 0.1);
    color: #20BF55;
}

.category-badge.mecanica {
    background: rgba(123, 104, 238, 0.1);
    color: #7B68EE;
}

.category-badge.tecnologia {
    background: rgba(255, 154, 0, 0.1);
    color: #FF9A00;
}

.gallery-info h4 {
    font-size: 1.2rem;
    margin-bottom: 10px;
    color: var(--secondary-color);
    line-height: 1.3;
}

.gallery-info p {
    color: var(--gray-color);
    font-size: 0.9rem;
    margin-bottom: 15px;
    line-height: 1.5;
}

.project-details {
    display: flex;
    gap: 15px;
    font-size: 0.85rem;
    color: var(--gray-color);
}

.project-details span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.project-details i {
    font-size: 0.9rem;
}

/* Load More Button */
.load-more-container {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 0 20px;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    padding: 12px 30px;
    border-radius: 30px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.btn-outline:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(26, 95, 180, 0.2);
}

/* Gallery Modal */
.gallery-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-modal.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: white;
    border-radius: 10px;
    max-width: 1000px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    position: relative;
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: rotate(90deg);
}

.modal-media {
    height: 60vh;
    overflow: hidden;
    background: #000;
}

.modal-media img,
.modal-media video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.modal-info {
    padding: 25px;
    border-top: 1px solid var(--light-gray);
}

.modal-category {
    display: inline-block;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 15px;
}

.modal-info h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: var(--secondary-color);
}

.modal-info p {
    color: var(--gray-color);
    margin-bottom: 15px;
    line-height: 1.6;
}

.modal-details {
    display: flex;
    gap: 20px;
    color: var(--gray-color);
    font-size: 0.9rem;
}

.modal-details span {
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-nav {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    pointer-events: none;
}

.modal-prev,
.modal-next {
    width: 50px;
    height: 50px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    pointer-events: all;
    transition: all 0.3s ease;
}

.modal-prev:hover,
.modal-next:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .gallery-container {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

@media (max-width: 992px) {
    .gallery-filters {
        overflow-x: auto;
        justify-content: flex-start;
        padding-bottom: 10px;
        margin: 30px 0 20px;
    }
    
    .filter-btn {
        flex-shrink: 0;
    }
    
    .modal-content {
        max-width: 95%;
    }
    
    .modal-media {
        height: 50vh;
    }
}

@media (max-width: 768px) {
    .gallery-container {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 20px;
    }
    
    .gallery-media {
        height: 200px;
    }
    
    .modal-content {
        max-width: 100%;
        border-radius: 0;
        max-height: 100vh;
    }
    
    .modal-media {
        height: 40vh;
    }
    
    .modal-info {
        padding: 20px;
    }
    
    .modal-info h3 {
        font-size: 1.3rem;
    }
}

@media (max-width: 576px) {
    .gallery-container {
        grid-template-columns: 1fr;
    }
    
    .gallery-filters {
        gap: 8px;
    }
    
    .filter-btn {
        padding: 10px 15px;
        font-size: 0.85rem;
    }
    
    .gallery-info {
        padding: 15px;
    }
    
    .gallery-info h4 {
        font-size: 1.1rem;
    }
    
    .project-details {
        flex-direction: column;
        gap: 8px;
    }
    
    .modal-nav {
        padding: 0 10px;
    }
    
    .modal-prev,
    .modal-next {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
}

/* Animation for filter change */
@keyframes filterChange {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.gallery-item.filter-animate {
    animation: filterChange 0.4s ease forwards;
}

/* Stats counter animation */
.project-details span i {
    transition: transform 0.3s ease;
}

.gallery-item:hover .project-details span i {
    transform: scale(1.2);
}

/* Video thumbnail hover effect */
.video-thumbnail::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
}

.gallery-item:hover .video-thumbnail::before {
    opacity: 1;
}

/* Estilos adicionales para funcionalidad */

/* Mejorar visibilidad de filtros activos */
.filter-btn.active {
    position: relative;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(26, 95, 180, 0.3);
}

.filter-btn.active::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 3px;
    background: var(--primary-color);
    border-radius: 2px;
    animation: filterActive 0.3s ease;
}

@keyframes filterActive {
    from { width: 0; }
    to { width: 30px; }
}

/* Mejorar clickabilidad */
.gallery-item,
.gallery-media,
.gallery-media img {
    cursor: pointer !important;
}

.gallery-item:hover {
    cursor: pointer;
}

/* Mejorar el modal */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1;
}

.modal-container {
    position: relative;
    z-index: 2;
    width: 90%;
    max-width: 1200px;
    max-height: 90vh;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    animation: modalAppear 0.3s ease;
}

@keyframes modalAppear {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-media-container {
    position: relative;
    height: 60vh;
    min-height: 400px;
    background: #000;
    overflow: hidden;
}

.modal-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.modal-video {
    width: 100%;
    height: 100%;
    display: block;
}

.modal-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-nav-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: translateY(-50%) scale(1.1);
}

.modal-prev {
    left: 20px;
}

.modal-next {
    right: 20px;
}

.modal-info {
    padding: 25px;
    background: white;
}

.modal-header {
    margin-bottom: 15px;
}

.modal-category {
    display: inline-block;
    padding: 6px 15px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 10px;
    background: var(--light-color);
    color: var(--primary-color);
}

.modal-info h3 {
    font-size: 1.5rem;
    margin: 0;
    color: var(--secondary-color);
}

.modal-info p {
    color: var(--gray-color);
    line-height: 1.6;
    margin-bottom: 20px;
}

.modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 15px;
    border-top: 1px solid var(--light-gray);
}

.modal-details {
    display: flex;
    gap: 20px;
    font-size: 0.9rem;
    color: var(--gray-color);
}

.modal-details span {
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-details i {
    color: var(--primary-color);
}

.detail-text {
    margin-top: 2px;
}

.modal-counter {
    font-size: 0.9rem;
    color: var(--gray-color);
    font-weight: 600;
}

/* Animaciones para cambios de filtro */
.gallery-item {
    animation: itemAppear 0.4s ease forwards;
}

@keyframes itemAppear {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mejorar botón de video */
.video-play-btn {
    cursor: pointer;
    z-index: 5;
}

.video-play-btn:hover {
    animation: pulsePlay 1.5s infinite;
}

@keyframes pulsePlay {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.1); }
}

/* Responsive mejorado */
@media (max-width: 768px) {
    .modal-container {
        width: 95%;
        max-height: 95vh;
    }
    
    .modal-media-container {
        height: 50vh;
        min-height: 300px;
    }
    
    .modal-nav-btn {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    .modal-info {
        padding: 20px;
    }
    
    .modal-info h3 {
        font-size: 1.3rem;
    }
    
    .modal-footer {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
}

@media (max-width: 576px) {
    .modal-container {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .modal-media-container {
        height: 40vh;
    }
    
    .filter-group {
        overflow-x: auto;
        padding-bottom: 10px;
    }
    
    .filter-btn {
        flex-shrink: 0;
    }
}