/* ========================================
   Home Sections Carousel Styles
   ======================================== */

.home-sections-wrapper {
    width: 100%;
    overflow: hidden;
}

/* Sección de categoría */
.category-carousel-section {
    padding: 60px 0;
    background: transparent;
}

/* Header con título y navegación */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* margin-bottom: 32px; */
    gap: 20px;
}

.category-title {
    font-size: 32px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0;
    line-height: 1.2;
}

/* Navegación del carousel */
.carousel-nav {
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}

.carousel-nav button {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #e5e7eb;
    color: #1a1a1a;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.carousel-nav button:hover:not(.disabled) {
    background: #2D478A;
    border-color: #2D478A;
    color: #fff;
    box-shadow: 0 4px 12px rgba(45, 71, 138, 0.25);
    transform: scale(1.05);
}

.carousel-nav button:active:not(.disabled) {
    transform: scale(0.95);
}

.carousel-nav button.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #f3f4f6;
    border-color: #e5e7eb;
}

.carousel-nav button svg {
    width: 24px;
    height: 24px;
}

/* Cards del carousel */
.carousel-card-wrapper {
    padding: 8px;
}

.carousel-card {
    display: block;
    background: transparent;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    text-decoration: none;
    color: inherit;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.carousel-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    transform: translateY(-4px);
}

.carousel-card:focus {
    outline: 3px solid #2D478A;
    outline-offset: 2px;
}

/* Imagen del card */
.card-image {
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #f3f4f6;
    position: relative;
}

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

.carousel-card:hover .card-image img {
    transform: scale(1.05);
}

/* Contenido del card */
.card-content {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

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

.card-description {
    font-size: 14px;
    color: #212120;
    line-height: 1.6;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Layout antes de que Owl Carousel inicialice */
.category-posts-carousel {
    display: flex;
    flex-wrap: nowrap;
    gap: 24px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e0 transparent;
    /* Mejorar renderizado inicial */
    will-change: transform;
    padding-bottom: 12px; /* Espacio para scrollbar */
    margin-bottom: -12px; /* Compensar padding */
}

.category-posts-carousel::-webkit-scrollbar {
    height: 8px;
}

.category-posts-carousel::-webkit-scrollbar-track {
    background: transparent;
}

.category-posts-carousel::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 4px;
}

.category-posts-carousel::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Items del carousel antes de Owl */
.category-posts-carousel > .carousel-card-wrapper {
    flex: 0 0 auto; /* No estirarse */
    width: 344px; /* Ancho fijo similar al diseño */
    min-width: 280px;
    max-width: 400px;
    scroll-snap-align: start;
}

/* Owl Carousel customización - cuando ya está inicializado */
.category-posts-carousel.owl-carousel {
    display: block;
    overflow: visible;
    padding-bottom: 0;
    margin-bottom: 0;
}

.category-posts-carousel.owl-carousel .owl-stage-outer {
    overflow: visible;
}

.category-posts-carousel.owl-carousel .owl-stage {
    padding: 8px 0;
    display: flex;
}

.category-posts-carousel.owl-carousel .owl-item {
    opacity: 1;
}

/* Mantener el wrapper dentro de los items de Owl */
.category-posts-carousel.owl-carousel .owl-item > .carousel-card-wrapper {
    width: 100%; /* El item de Owl controla el ancho */
    flex: initial;
    min-width: initial;
    max-width: initial;
}

/* Por si el wrapper está directamente en el carousel (no debería pasar) */
.category-posts-carousel.owl-carousel > .carousel-card-wrapper {
    flex: initial;
    min-width: initial;
    max-width: initial;
}

/* Ocultar scrollbar cuando Owl está activo */
.category-posts-carousel.owl-carousel::-webkit-scrollbar {
    display: none;
}

.category-posts-carousel.owl-carousel {
    scrollbar-width: none;
    overflow-x: hidden;
}

/* Responsive */
@media (max-width: 1199px) {
    .category-carousel-section {
        padding: 50px 0;
    }

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

    .carousel-nav button {
        width: 44px;
        height: 44px;
    }

    .category-posts-carousel > .carousel-card-wrapper {
        width: 320px; /* Ancho fijo para tablets grandes */
    }
}

@media (max-width: 991px) {
    .category-carousel-section {
        padding: 40px 0;
    }

    .section-header {
        margin-bottom: 24px;
    }

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

    .carousel-nav button {
        width: 40px;
        height: 40px;
    }

    .carousel-nav button svg {
        width: 20px;
        height: 20px;
    }

    .category-posts-carousel {
        gap: 20px;
    }

    .category-posts-carousel > .carousel-card-wrapper {
        width: 300px; /* Ancho fijo para tablets */
        min-width: 280px;
    }
}

@media (max-width: 767px) {
    .category-carousel-section {
        padding: 32px 0;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
        margin-bottom: 20px;
    }

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

    .carousel-nav {
        align-self: flex-end;
        width: 100%;
        justify-content: flex-end;
    }

    .card-content {
        padding: 16px;
    }

    .card-title {
        font-size: 16px;
        margin-bottom: 8px;
    }

    .card-description {
        font-size: 13px;
    }

    .category-posts-carousel {
        gap: 16px;
        scrollbar-width: none; /* Ocultar scrollbar en tablets */
    }

    .category-posts-carousel::-webkit-scrollbar {
        display: none;
    }

    .category-posts-carousel > .carousel-card-wrapper {
        width: 280px; /* Ancho fijo para móviles grandes */
        min-width: 240px;
    }
}

@media (max-width: 479px) {
    .category-carousel-section {
        padding: 24px 0;
    }

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

    .carousel-nav button {
        width: 36px;
        height: 36px;
    }

    .carousel-nav button svg {
        width: 18px;
        height: 18px;
    }

    .card-title {
        font-size: 15px;
    }

    .category-posts-carousel > .carousel-card-wrapper {
        width: calc(100vw - 80px); /* Ancho casi completo menos márgenes */
        min-width: 260px;
        max-width: 340px;
    }
}

/* Print styles */
@media print {
    .carousel-nav {
        display: none;
    }

    .carousel-card {
        box-shadow: none;
        border: 1px solid #e5e7eb;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .carousel-card,
    .carousel-nav button,
    .card-image img {
        transition: none;
    }

    .carousel-card:hover {
        transform: none;
    }

    .carousel-card:hover .card-image img {
        transform: none;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .carousel-card {
        border: 2px solid currentColor;
    }

    .carousel-nav button {
        border-width: 3px;
    }
}
