/* ESTILOS ESPECÍFICOS PARA LAS TARJETAS DEL BLOG */

/* Espaciado adicional para las cards */
.cards-section {
    margin-bottom: 60px;
    display: grid;
    gap: 30px;
    justify-items: center;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    padding: 0 20px;
}

/* MÁXIMO 3 TARJETAS POR FILA */
.cards-section {
    grid-template-columns: repeat(auto-fit, minmax(350px, 380px));
    justify-content: center;
    /* Limitar a máximo 3 columnas */
    grid-template-columns: repeat(auto-fit, minmax(max(350px, calc((100% - 60px) / 3)), 380px));
}

/* Cuando hay una sola card */
.cards-section.single-card {
    grid-template-columns: 1fr;
    max-width: 400px;
    justify-content: center;
}

.cards-section.single-card .service-card {
    max-width: 400px;
    width: 100%;
}

/* Cuando hay exactamente 2 cards */
.cards-section.few-cards {
    grid-template-columns: repeat(2, minmax(350px, 380px));
    gap: 30px;
    justify-content: center;
    max-width: 800px;
}

.cards-section.few-cards .service-card {
    max-width: 380px;
}

/* Estilos para la tarjeta de servicio */
.service-card {
    background: white;
    border-radius: 20px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
    width: 100%;
    max-width: 380px;
    position: relative;
}

.service-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
}

/* Estilos para la imagen de la card */
.card-image {
    position: relative;
    height: 220px;
    overflow: hidden;
    border-radius: 20px 20px 0 0;
}

.blog-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.3s ease;
}

.service-card:hover .blog-card-img {
    transform: scale(1.1);
}

/* Badge de categoría como en la imagen - MÁS ESPECÍFICO */
.card-image .badge,
.card-image .badge-pill,
.card-image .badge-danger {
    position: absolute !important;
    top: 16px !important;
    left: 16px !important;
    z-index: 2 !important;
    background: #007bff !important;
    color: white !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    padding: 8px 16px !important;
    border-radius: 20px !important;
    border: none !important;
    text-transform: capitalize !important;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3) !important;
    text-shadow: none !important;
}

/* Asegurar que funcione en ambas secciones */
.blog-categories-container .card-image .badge,
.cards-section .card-image .badge {
    position: absolute !important;
    top: 16px !important;
    left: 16px !important;
    z-index: 2 !important;
    background: #007bff !important;
    color: white !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    padding: 8px 16px !important;
    border-radius: 20px !important;
    border: none !important;
    text-transform: capitalize !important;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3) !important;
    text-shadow: none !important;
}

/* Contenido de la tarjeta */
.card-content {
    padding: 24px;
    background: white;
}

.card-date {
    color: #6c757d;
    font-size: 13px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

.card-date i {
    color: #007bff;
}

.card-title {
    font-size: 18px;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 12px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-description {
    color: #495057;
    font-size: 14px;
    margin-bottom: 10px;
    font-weight: 600;
}

.card-resumen {
    color: #6c757d;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 20px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-link {
    color: #007bff;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
    padding: 8px 0;
}

.card-link:hover {
    color: #0056b3;
    text-decoration: none;
    transform: translateX(5px);
}

.card-link i {
    transition: transform 0.3s ease;
}

.card-link:hover i {
    transform: translateX(3px);
}

/* Si no hay artículos, mantener altura mínima */
.cards-section:empty::after {
    content: "";
    display: block;
    height: 300px;
}

/* ESTILOS PARA "TODAS LAS CATEGORÍAS" (grid separado por categorías) */
.blog-categories-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.category-section {
    margin-bottom: 60px;
}

.category-header {
    text-align: center;
    margin-bottom: 40px;
}

.category-title {
    font-size: 28px;
    font-weight: 700;
    color: #2c3e50;
    margin: 0;
    text-align: center;
    position: relative;
    display: inline-block;
}

.category-title::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, #007bff, #0056b3);
    border-radius: 2px;
}

/* MÁXIMO 3 TARJETAS POR FILA EN CATEGORÍAS TAMBIÉN */
.category-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(max(350px, calc((100% - 60px) / 3)), 380px));
    gap: 30px;
    justify-content: center;
    justify-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

/* Aplicar las mismas reglas de centrado para pocas tarjetas en categorías */
.category-cards:has(.service-card:nth-child(1):last-child) {
    /* 1 tarjeta */
    grid-template-columns: 1fr;
    max-width: 400px;
    justify-content: center;
}

.category-cards:has(.service-card:nth-child(2):last-child) {
    /* 2 tarjetas */
    grid-template-columns: repeat(2, minmax(350px, 380px));
    gap: 30px;
    justify-content: center;
    max-width: 800px;
}

.category-cards:has(.service-card:nth-child(3):last-child) {
    /* 3 tarjetas */
    grid-template-columns: repeat(3, minmax(350px, 380px));
    gap: 30px;
    justify-content: center;
    max-width: 1200px;
}

/* Fallback para navegadores que no soportan :has() */
@supports not (selector(:has(*))) {
    .category-cards {
        grid-template-columns: repeat(auto-fit, minmax(max(350px, calc((100% - 60px) / 3)), 380px));
        gap: 30px;
        justify-content: center;
        max-width: 1200px;
    }
}

/* Responsive - Tablets */
@media (max-width: 1024px) {
    .cards-section {
        max-width: 100%;
        padding: 0 15px;
        gap: 25px;
        /* Máximo 2 en tablets */
        grid-template-columns: repeat(auto-fit, minmax(max(300px, calc((100% - 25px) / 2)), 350px));
    }

    .cards-section,
    .cards-section.few-cards {
        grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    }

    .cards-section.single-card {
        max-width: 380px;
    }

    .blog-categories-container {
        padding: 0 15px;
    }

    .category-cards {
        /* Máximo 2 en tablets */
        grid-template-columns: repeat(auto-fit, minmax(max(300px, calc((100% - 25px) / 2)), 350px));
        gap: 25px;
        max-width: 725px;
        margin: 0 auto;
    }

    .category-cards:has(.service-card:nth-child(1):last-child) {
        grid-template-columns: 1fr;
        max-width: 350px;
    }

    .category-cards:has(.service-card:nth-child(2):last-child) {
        grid-template-columns: repeat(2, minmax(300px, 350px));
        max-width: 725px;
    }

    .service-card {
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    .cards-section {
        margin-bottom: 40px;
        gap: 20px;
        padding: 0 15px;
    }
    
    .cards-section,
    .cards-section.single-card,
    .cards-section.few-cards {
        grid-template-columns: 1fr;
        max-width: 100%;
        justify-content: center;
    }
    
    .cards-section.single-card .service-card,
    .cards-section.few-cards .service-card {
        max-width: 100%;
    }
    
    .card-image {
        height: 200px;
    }
    
    .card-content {
        padding: 20px;
    }

    /* Responsive para categorías */
    .blog-categories-container {
        padding: 0 15px;
    }
    
    .category-title {
        font-size: 24px;
    }
    
    .category-cards,
    .category-cards:has(.service-card:nth-child(1):last-child),
    .category-cards:has(.service-card:nth-child(2):last-child),
    .category-cards:has(.service-card:nth-child(3):last-child) {
        grid-template-columns: 1fr;
        gap: 20px;
        max-width: 100%;
    }

    .category-section {
        margin-bottom: 50px;
    }

    .category-header {
        margin-bottom: 30px;
    }
}

/* Responsive - Móviles */
@media (max-width: 480px) {
    .cards-section {
        gap: 15px;
        padding: 0 10px;
    }
    
    .card-image {
        height: 180px;
    }
    
    .card-title {
        font-size: 16px;
    }
    
    .card-content {
        padding: 16px;
    }
    
    .card-date {
        font-size: 12px;
    }
    
    .card-description,
    .card-resumen {
        font-size: 13px;
    }
    
    .card-link {
        font-size: 13px;
    }

    /* Responsive móvil para categorías */
    .blog-categories-container {
        padding: 0 10px;
    }

    .category-title {
        font-size: 20px;
    }

    .category-cards {
        gap: 15px;
        max-width: 100%;
        grid-template-columns: 1fr;
    }

    .service-card {
        border-radius: 16px;
    }

    .card-image {
        border-radius: 16px 16px 0 0;
    }
}

/* Estilos adicionales para el layout general del blog */
#main-content {
    margin-bottom: 80px;
    min-height: 85vh;
    padding-bottom: 60px;
}

.footer-spacer {
    height: 100px;
    width: 100%;
    clear: both;
}

/* Responsive para el layout general */
@media (max-width: 768px) {
    #main-content {
        min-height: 80vh;
        margin-bottom: 60px;
        padding-bottom: 40px;
    }
    
    .footer-spacer {
        height: 80px;
    }
}