/* Estilos para la etiqueta de semestre */
.semestre-badge {
    display: inline-block;
    background-color: var(--brand-primary);
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    margin-top: 5px;
}

/* Sidebar list overrides */
.list-group-item.active {
    background-color: var(--brand-primary) !important;
    border-color: #000 !important;
    color: white !important;
}

.list-group-item {
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

.list-group-item:hover {
    background-color: var(--brand-primary);
    border-color: #000;
    color: white;
}

/* Para cuando no hay libros visibles */
.no-results {
    text-align: center;
    padding: 40px;
    color: #666;
    font-size: 18px;
}

/* Botón de "Subir" */
#topBtn {
    display: none;
    position: fixed;
    bottom: 90px;
    right: 20px;
    padding: 10px 15px;
    font-size: 16px;
    background-color: var(--brand-primary);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0px 2px 6px rgba(0,0,0,0.3);
    z-index: 1000;
}

/* Botón de WhatsApp */
.whatsapp-float {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    background-color: #25D366;
    border-radius: 50%;
    padding: 12px;
    box-shadow: 0px 2px 6px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    color: white !important;
    font-size: 35px;
    text-decoration: none;
}

.whatsapp-float:hover {
    transform: scale(1.1);
    transition: 0.2s ease;
    color: white !important;
}

/* Estilos para series de libros */
.serie-header {
    margin-top: 30px;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--brand-primary);
    width: 100%;
}

.serie-subheader {
    margin-top: 20px;
    margin-bottom: 15px;
    padding-left: 10px;
    border-left: 4px solid var(--brand-primary);
    width: 100%;
}

/* Paginación */
.pagination-container {
    margin-top: 30px;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
}

.page-info {
    text-align: center;
    margin: 15px 0;
    color: #666;
    font-size: 14px;
}

.book-card {
    display: none; /* Ocultamos todos inicialmente */
}

.book-card.visible {
    display: block; /* Solo los libros visibles en la página actual */
}

/* Estilos para la paginación */
.page-link {
    cursor: pointer;
    color: #000 !important;
}

.page-link:hover {
    color: white !important;
}

.page-item.active .page-link {
    background-color: var(--brand-primary) !important;
    border-color: var(--brand-primary) !important;
    color: white !important;
}

/* Botones de items por página */
.items-per-page .btn {
    margin: 2px;
}

.items-per-page .btn.active {
    background-color: var(--brand-primary);
    color: white;
}

/* ============================================
ESTILOS RESPONSIVOS PARA IMÁGENES Y LAYOUT
============================================ */

/* Responsividad general para las tarjetas de libros */
.book-card .card-img {
    width: 100%;
    height: auto;
    max-height: 400px;
    object-fit: contain;
    object-position: center;
    background-color: #f8f9fa;
    padding: 10px;
    transition: transform 0.3s ease;
}

.book-card .card-img:hover {
    transform: scale(1.03);
}

/* Ajustes responsivos para las tarjetas */
.book-card .card {
    height: 100%;
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.3s ease;
}

.book-card .card:hover {
    box-shadow: 0 10px 20px rgba(0,0,0,0.15);
}

.book-card .card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 15px;
}

.book-card .card-body a {
    font-size: 1.1rem;
    line-height: 1.4;
    margin-bottom: 10px;
    color: #333;
    text-decoration: none;
    flex-grow: 1;
}

.book-card .card-body a:hover {
    color: var(--brand-primary);
}

/* ============================================
ESTILOS RESPONSIVOS - CUADRÍCULA SIEMPRE VISIBLE
============================================ */

/* Asegurar que las imágenes sean responsivas */
.book-card .card-img {
    width: 100%;
    height: 250px; /* Altura fija para uniformidad */
    object-fit: contain;
    object-position: center;
    background-color: #f8f9fa;
    padding: 15px;
    transition: transform 0.3s ease;
}

.book-card .card-img:hover {
    transform: scale(1.03);
}

/* Asegurar que todas las tarjetas tengan la misma altura */
.book-card .card {
    height: 100%;
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.3s ease;
    border: 1px solid #dee2e6;
}

.book-card .card:hover {
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
    border-color: var(--brand-primary);
}

.book-card .card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 15px;
}

.book-card .card-body a {
    font-size: 1rem;
    line-height: 1.3;
    margin-bottom: 10px;
    color: #333;
    text-decoration: none;
    flex-grow: 1;
    min-height: 60px; /* Altura mínima para uniformidad */
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.book-card .card-body a:hover {
    color: var(--brand-primary);
}

/* ============================================
CUADRÍCULA RESPONSIVA - SIEMPRE MÚLTIPLES COLUMNAS
============================================ */

/* Desktop grande: 4 columnas */
@media (min-width: 1200px) {
    .col-md-4 {
        flex: 0 0 25%;
        max-width: 25%;
    }
    
    .book-card .card-img {
        height: 280px;
    }
}

/* Desktop normal: 3 columnas */
@media (min-width: 992px) and (max-width: 1199px) {
    .col-md-4 {
        flex: 0 0 33.333333%;
        max-width: 33.333333%;
    }
    
    .book-card .card-img {
        height: 260px;
    }
    
    .book-card .card-body a {
        font-size: 0.95rem;
        min-height: 70px;
    }
}

/* Tablet: 2 columnas */
@media (min-width: 768px) and (max-width: 991px) {
    .col-md-4 {
        flex: 0 0 50%;
        max-width: 50%;
    }
    
    .book-card .card-img {
        height: 240px;
    }
    
    .book-card .card-body a {
        font-size: 0.9rem;
        min-height: 80px;
    }
    
    .serie-header h1 {
        font-size: 1.6rem;
    }
    
    .serie-subheader h2,
    .serie-subheader h3 {
        font-size: 1.3rem;
    }
}

/* Móvil grande: 2 columnas */
@media (min-width: 576px) and (max-width: 767px) {
    .col-md-4 {
        flex: 0 0 50%;
        max-width: 50%;
    }
    
    .book-card .card-img {
        height: 220px;
        padding: 10px;
    }
    
    .book-card .card-body a {
        font-size: 0.85rem;
        min-height: 85px;
        line-height: 1.2;
    }
    
    .semestre-badge {
        font-size: 0.75rem;
        padding: 2px 5px;
    }
    
    .serie-header h1 {
        font-size: 1.4rem;
    }
    
    .serie-subheader h2,
    .serie-subheader h3 {
        font-size: 1.1rem;
    }
}

/* Móvil pequeño: 2 columnas más compactas */
@media (max-width: 575px) {
    .col-md-4 {
        flex: 0 0 50%;
        max-width: 50%;
    }
    
    .book-card .card {
        margin-bottom: 10px;
    }
    
    .book-card .card-img {
        height: 200px;
        padding: 8px;
    }
    
    .book-card .card-body {
        padding: 10px;
    }
    
    .book-card .card-body a {
        font-size: 0.8rem;
        min-height: 90px;
        line-height: 1.15;
    }
    
    .semestre-badge {
        font-size: 0.7rem;
        padding: 1px 4px;
    }
    
    /* Ajustar filtros para móvil */
    #editorial-filter,
    #semester-filter {
        display: flex;
        flex-wrap: wrap;
        gap: 5px;
        margin-bottom: 10px;
    }
    
    #editorial-filter .list-group-item,
    #semester-filter .list-group-item {
        flex: 1;
        min-width: 45%;
        text-align: center;
        padding: 6px 3px;
        font-size: 0.8rem;
        margin-bottom: 5px;
    }
    
    /* Headers más pequeños */
    .serie-header h1 {
        font-size: 1.3rem;
        margin-bottom: 10px;
    }
    
    .serie-subheader h2,
    .serie-subheader h3 {
        font-size: 1rem;
        margin-bottom: 10px;
    }
    
    /* Reordenar layout en móvil */
    .col-md-3 {
        order: 2;
        margin-top: 15px;
    }
    
    .col-md-9 {
        order: 1;
    }
}

/* Móvil muy pequeño: 1 columna solo en casos extremos */
@media (max-width: 360px) {
    .col-md-4 {
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    .book-card .card-img {
        height: 220px;
    }
    
    .book-card .card-body a {
        min-height: auto;
        font-size: 0.85rem;
    }
    
    /* Filtros en columna única */
    #editorial-filter .list-group-item,
    #semester-filter .list-group-item {
        flex: 0 0 100%;
        min-width: 100%;
    }
}

/* ============================================
MEJORAS PARA LA CUADRÍCULA
============================================ */

/* Asegurar que las filas tengan espaciado consistente */
#book-list .row {
    display: flex;
    flex-wrap: wrap;
    margin-left: -8px;
    margin-right: -8px;
}

#book-list .col-md-4 {
    padding-left: 8px;
    padding-right: 8px;
    margin-bottom: 16px;
}

/* Mejorar la visualización de series */
.serie-header, .serie-subheader {
    width: 100%;
    padding-left: 8px;
    padding-right: 8px;
}

.serie-header {
    margin-top: 25px;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--brand-primary);
}

.serie-subheader {
    margin-top: 20px;
    margin-bottom: 12px;
    padding-left: 12px;
    border-left: 4px solid var(--brand-primary);
}

/* Asegurar que los títulos no se desborden */
.book-card .card-body a {
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3; /* Máximo 3 líneas */
    -webkit-box-orient: vertical;
    word-break: break-word;
}

/* Paginación responsiva */
.pagination-container {
    margin-top: 20px;
}

.pagination {
    flex-wrap: wrap;
    justify-content: center;
}

.pagination .page-item {
    margin: 2px;
}

.pagination .page-link {
    padding: 6px 12px;
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    .pagination .page-link {
        padding: 4px 8px;
        font-size: 0.8rem;
    }
}

/* Botones de items por página */
.items-per-page .btn {
    padding: 4px 8px;
    font-size: 0.85rem;
    margin: 2px;
}

/* Contenedor principal */
.container.py-5 {
    padding-top: 2rem !important;
    padding-bottom: 2rem !important;
}

@media (max-width: 768px) {
    .container.py-5 {
        padding-top: 1.5rem !important;
        padding-bottom: 1.5rem !important;
    }
}

/* Asegurar que no haya desbordamientos horizontales */
html, body {
    overflow-x: hidden;
    max-width: 100%;
}

.container {
    max-width: 100%;
    padding-left: 15px;
    padding-right: 15px;
}

/* Typography branding */
h1, h2, h3, .serie-header h1, .serie-subheader h2 {
    font-family: 'Playfair Display', serif;
}
