/* --- Variables y Estilos Base --- */
:root {
    --primary-color: #0d1b2a;
    --secondary-color: #e0e1dd;
    --background-color: #f8f9fa;
    --text-color: #1b263b;
    --accent-color: #415a77;
    --accent-hover: #e63946;
    --promo-color: #f77f00;
    --success-color: #2a9d8f;
    --error-color: #d62828;
    --warning-color: #fb8500;
    --series-color: #0077b6;
    --card-bg: #ffffff;
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-secondary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.18);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --catalog-card-min-w: 220px;
    --catalog-card-max-w: 245px;
    --catalog-card-gap: 1.2rem;
    --catalog-card-image-h: 208px;
    --catalog-card-image-h-tablet: 205px;
    --catalog-card-image-h-mobile: 260px;
    --catalog-card-content-min-h: 136px;
    --catalog-card-cta-h-desktop: 36px;
    --catalog-card-cta-h-mobile: 40px;
}

*, *::before, *::after { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
}

body {
    font-family: var(--font-secondary);
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex-grow: 1;
}

/* --- Navegación Fija (Sticky Nav) --- */
.sticky-nav {
    position: sticky;
    top: 0;
    z-index: 500;
    background: rgba(13, 27, 42, 0.98);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.sticky-nav__container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    min-height: 56px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.sticky-nav__brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.sticky-nav__logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.sticky-nav__title {
    font-family: var(--font-primary);
    font-size: 0.95rem;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    display: none;
}

.sticky-nav__search {
    flex: 1;
    max-width: 500px;
    position: relative;
    display: flex;
    align-items: center;
}

.sticky-nav__search-input {
    width: 100%;
    padding: 0.4rem 2rem 0.4rem 0.75rem;
    font-size: 0.85rem;
    font-family: var(--font-secondary);
    border: 2px solid transparent;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transition: var(--transition);
}

.sticky-nav__search-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.sticky-nav__search-input:focus {
    outline: none;
    background: white;
    color: var(--text-color);
    border-color: var(--accent-hover);
}

.sticky-nav__search-input:focus::placeholder {
    color: #94a3b8;
}

.sticky-nav__clear-btn {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

.sticky-nav__clear-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.sticky-nav__search.has-text .sticky-nav__clear-btn {
    display: flex;
}

.sticky-nav__search.has-text .sticky-nav__clear-btn {
    color: rgba(255, 255, 255, 0.9);
}

.sticky-nav__back-btn {
    background: #415a77;
    border: none;
    color: white;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: none;
    flex-shrink: 0;
    white-space: nowrap;
}

.sticky-nav__back-btn:hover {
    background: #1b263b;
    transform: translateX(-2px);
}

.sticky-nav__back-btn.visible {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Responsive para tablet y desktop */
@media (min-width: 640px) {
    .sticky-nav__title {
        display: block;
    }
    
    .sticky-nav__search-input {
        padding: 0.7rem 2.75rem 0.7rem 1.25rem;
    }
}

@media (max-width: 480px) {
    .sticky-nav {
        padding: 0.4rem 0.75rem;
        gap: 0.5rem;
    }

    .sticky-nav__container {
        min-height: 50px;
    }
    
    .sticky-nav__logo {
        width: 24px;
        height: 24px;
    }
    
    .sticky-nav__search {
        max-width: none;
    }

    /* Drawer filtros móvil pequeño - Estado primero */
    .filters-drawer {
        max-height: 85vh;
    }
    
    .filters-drawer__content {
        display: flex;
        flex-direction: column;
    }
    
    .filters-drawer__content .filter-group:nth-child(1) {
        order: 2;
    }
    
    .filters-drawer__content .filter-group:nth-child(2) {
        order: 3;
    }
    
    .filters-drawer__content .filter-group:nth-child(3) {
        order: 1;
    }

    #inicio {
        scroll-margin-top: 60px;
    }
}


/* --- Secciones y Footer --- */
.book-listing-section { 
    padding: 0; 
    margin: 0 auto; 
    max-width: 100%; 
}

.listing-content-wrapper { 
    max-width: 1300px; 
    margin: 1rem auto 2rem; 
    padding: 0 1.5rem; 
}

.section-title { 
    font-family: var(--font-primary); 
    text-align: center; 
    font-size: 1.75rem; 
    font-weight: 600;
    margin-bottom: 2rem; 
    color: var(--primary-color); 
    position: relative;
    display: inline-block;
    width: 100%;
}

.section-title::after {
    content: '';
    display: block;
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-hover), var(--promo-color));
    margin: 0.75rem auto 0;
    border-radius: 2px;
}

.main-footer { 
    background-color: var(--primary-color); 
    color: #778da9; 
    text-align: center; 
    padding: 2rem 1rem; 
    margin-top: 3rem; 
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.main-footer p {
    font-size: 0.9rem;
}

.main-footer__back-to-top {
    display: inline-block;
    margin-bottom: 0.75rem;
    color: #e0e8f4;
    font-weight: 600;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.main-footer__back-to-top:hover,
.main-footer__back-to-top:focus-visible {
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.7);
}

/* --- BÃºsqueda (legacy - ya no se usa en index) --- */
/* Los estilos de búsqueda están ahora en .sticky-nav__search */

.no-results-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem 1rem;
    font-size: 1.2rem;
    color: #777;
}

/* --- Parrilla de Libros --- */
.book-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(var(--catalog-card-min-w), var(--catalog-card-max-w))); 
    gap: var(--catalog-card-gap); 
    justify-content: center;
}

.book-card { 
    background-color: var(--card-bg); 
    border-radius: var(--radius-md); 
    box-shadow: var(--shadow-sm); 
    overflow: hidden; 
    cursor: pointer; 
    transition: var(--transition); 
    display: flex; 
    flex-direction: column; 
    border: 1px solid rgba(0, 0, 0, 0.04);
    height: 100%;
}

.book-card:hover { 
    transform: translateY(-4px); 
    box-shadow: var(--shadow-md); 
}

.book-card--selected {
    outline: 1px solid rgba(19, 76, 139, 0.22);
    box-shadow: 0 0 0 1px rgba(19, 76, 139, 0.08), 0 2px 10px rgba(19, 76, 139, 0.08);
}

.book-card__image-container {
    position: relative;
    overflow: hidden;
    background: var(--card-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: auto;
    height: var(--catalog-card-image-h);
    min-height: var(--catalog-card-image-h);
    padding: 0.3rem;
    box-sizing: border-box;
}

.book-card__image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center center;
    transition: transform 0.4s ease, filter 0.3s ease;
    background: transparent;
}

.book-card:hover .book-card__image {
    transform: scale(1.04);
    filter: brightness(1.05);
}

/* Placeholder cuando la imagen no carga */
.book-card__image[src*="placeholder"],
.book-card__image[src=""],
.book-card__image:not([src]) {
    background: #f5f5f5;
}

/* Efecto shimmer para estado de carga */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.book-card__image.loading {
    background: linear-gradient(90deg, 
        #f0f2f5 25%, 
        #e8eaed 50%, 
        #f0f2f5 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.book-card__content { 
    padding: 0.75rem; 
    flex-grow: 1; 
    display: flex; 
    flex-direction: column;
    min-height: var(--catalog-card-content-min-h);
}

.book-card__title { 
    font-family: var(--font-primary); 
    font-size: 0.92rem; 
    margin-bottom: 0.2rem; 
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    /* min-height: calc(1.3em * 2); */
}

.book-card__meta { 
    font-size: 0.8rem; 
    color: #666; 
    margin-bottom: 0.2rem; 
    line-height: 1.3; 
}

.book-card__meta:last-of-type {
    margin-bottom: 0;
}

.book-card__meta--author {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

.book-card__price { 
    margin-top: auto; 
    padding-top: 0.75rem;
    margin-bottom: 0.4rem;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

/* Ajuste tipográfico y distribución de precio en cards del catálogo */
#book-listing .book-card__price .price-container,
.more-books-section .book-card__price .price-container {
    gap: 0.25rem;
    align-items: flex-end;
}

#book-listing .book-card__price .price-current,
.more-books-section .book-card__price .price-current {
    font-size: 1.1rem;
    line-height: 1.1;
}

#book-listing .book-card__price .price-original,
.more-books-section .book-card__price .price-original {
    font-size: 0.78rem;
}

#book-listing .book-card__price .promo-tag,
.more-books-section .book-card__price .promo-tag {
    margin-left: auto;
    white-space: nowrap;
}

/* --- Badge de Serie en la tarjeta --- */
.series-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(13, 27, 42, 0.85);
    color: white;
    font-size: 1rem;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    z-index: 2;
    opacity: 1;
    transition: transform 0.2s ease;
}

.series-badge:hover {
    transform: scale(1.15);
}

.defects-badge {
    position: absolute;
    left: 8px;
    bottom: 8px;
    z-index: 2;
    background: rgba(255, 243, 205, 0.96);
    color: #a04000;
    border: 1px solid rgba(247, 127, 0, 0.55);
    border-radius: 999px;
    padding: 0.25rem 0.65rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    line-height: 1.4;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(160, 64, 0, 0.2);
    pointer-events: none;
}

/* --- Contenedor de badges en tarjeta --- */
.book-card__badges {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    pointer-events: none;
}

.book-card__badges .status-badge {
    position: absolute;
    top: 8px;
    right: 8px;
}

.series-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    flex-shrink: 0;
}

.defects-badge {
    position: absolute;
    bottom: 8px;
    left: 8px;
}

/* --- Condición como texto simple --- */
/* .book-card__condition {
    font-size: 0.75rem;
    color: #666;
    margin: 0.15rem 0 0 0;
    line-height: 1.3;
} */

/* --- Condición como píldora compacta --- */
 .book-card__condition {
     display: inline-block;
     font-size: 0.7rem;
     color: #555;
     background: #f1f3f5;
     border: 1px solid #dee2e6;
     border-radius: 999px;
     padding: 0.15rem 0.55rem;
     margin: 0.4rem 0 0 0;
     line-height: 1.4;
     white-space: nowrap;
     overflow: hidden;
     text-overflow: ellipsis;
     max-width: 100%;
 }


/* --- Botón de compra rápida --- */
.book-card__quick-buy {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    width: 100%;
    padding: 0.4rem 0.65rem;
    margin-top: 0.65rem;
    min-height: var(--catalog-card-cta-h-desktop);
    box-sizing: border-box;
    background: linear-gradient(135deg, #25D366 0%, #20bf6b 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(37, 211, 102, 0.3);
}

.book-card__quick-buy:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
    background: linear-gradient(135deg, #1da851 0%, #1a9f57 100%);
}

.book-card__quick-buy--disabled {
    background: linear-gradient(135deg, #9ca3af 0%, #6b7280 100%);
    cursor: not-allowed;
    box-shadow: none;
    min-height: var(--catalog-card-cta-h-desktop);
}

.book-card__quick-buy--disabled:hover {
    transform: none;
    box-shadow: none;
}

/* --- Estilo del autor --- */
.book-card__author {
    font-size: 0.8rem;
    color: #666;
    margin: 0.15rem 0 0 0;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
  /*   display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    min-height: calc(1.4em * 2); */
    white-space: nowrap;
}

/* --- Precios y Etiquetas --- */
.price-container { 
    display: flex; 
    align-items: center; 
    flex-wrap: wrap; 
    gap: 0.5rem;
}

.price-original { 
    font-size: 0.85rem; 
    color: #94a3b8; 
    text-decoration: line-through; 
    font-weight: 400;
}

.price-current { 
    font-size: 1.5rem; 
    font-weight: 700; 
    color: var(--primary-color); 
}

.promo-tag { 
    background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
    color: white; 
    font-size: 0.7rem; 
    font-weight: 600; 
    padding: 0.25rem 0.6rem; 
    border-radius: 20px; 
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge { 
    padding: 0.35rem 0.85rem; 
    border-radius: 20px; 
    color: white; 
    font-weight: 600; 
    font-size: 0.75rem; 
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge--available { 
    background: linear-gradient(135deg, #06d6a0 0%, #00b894 100%);
    box-shadow: 0 2px 8px rgba(6, 214, 160, 0.3);
}

.status-badge--sold { 
    background: linear-gradient(135deg, #ef476f 0%, #d6336c 100%);
    box-shadow: 0 2px 8px rgba(239, 71, 111, 0.3);
}

/* --- Vista de Detalle --- */
.book-detail-view { 
    margin: 1rem auto; 
    padding: 2rem 1rem 1rem 1rem; 
    max-width: 1200px; 
    box-sizing: border-box;
}

/* --- Sección Más Libros (Autor/Género) --- */
.more-books-section {
    max-width: 1200px;
    margin: 0.5rem auto;
    /* padding: 0 1rem; */
    box-sizing: border-box;
}

.more-books-wrapper {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    margin: 0.25rem 1rem;
    padding: 1rem;
    box-sizing: border-box;
}

.more-books-section .section-title {
    margin-bottom: 1.5rem;
    font-size: 1.4rem;
}

.more-books-section .book-grid {
    grid-template-columns: repeat(auto-fill, minmax(var(--catalog-card-min-w), var(--catalog-card-max-w)));
    gap: var(--catalog-card-gap);
    justify-content: center;
}

.hidden { 
    display: none; 
}

.back-button { 
    background: var(--card-bg); 
    border: 2px solid var(--secondary-color); 
    color: var(--text-color); 
    padding: 0.6rem 1.25rem; 
    border-radius: var(--radius-md); 
    cursor: pointer; 
    font-size: 0.9rem; 
    font-weight: 500;
    margin-bottom: 1rem; 
    transition: var(--transition); 
}

.back-button:hover { 
    background-color: var(--primary-color); 
    color: white;
    border-color: var(--primary-color);
    transform: translateX(-4px);
}

.book-detail-content { 
    display: flex; 
    flex-direction: column;
    gap: 2rem; 
    background-color: var(--card-bg); 
    padding: 2rem 1rem; 
    border-radius: var(--radius-lg); 
    box-shadow: var(--shadow-md); 
    max-width: 1200px;
    margin: 0 auto;
    border: 1px solid rgba(0, 0, 0, 0.04);
    box-sizing: border-box;
}

@media (min-width: 768px) {
    .book-detail-content {
        flex-direction: row;
        gap: 2rem;
        padding: 1.65rem;
    }
}

.book-detail__cover { 
    flex-shrink: 0; 
    width: 200px;
    max-width: 200px;
    height: auto;
    max-height: 300px;
    object-fit: contain; 
    background-color: var(--background-color); 
    border-radius: var(--radius-md); 
    cursor: zoom-in;
    transition: var(--transition);
}

@media (min-width: 768px) {
    .book-detail__cover {
        width: 300px;
        max-width: 300px;
        max-height: 450px;
    }
}

@media (min-width: 1024px) and (max-width: 1400px) {
    .book-detail__cover {
        width: 320px;
        max-width: 320px;
        max-height: 450px;
    }
}

@media (min-width: 1401px) {
    .book-detail__cover {
        width: 350px;
        max-width: 350px;
        max-height: 450px;
    }
}

.book-detail__cover:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-md);
}

.book-detail__info { 
    display: flex; 
    flex-direction: column; 
    flex: 1;
    min-width: 0;
}

.book-detail__title { 
    font-family: var(--font-primary); 
    font-size: 1.3rem; 
    color: var(--primary-color); 
    line-height: 1.2; 
    margin-bottom: 0.5rem;
}

.book-detail__author { 
    font-size: 1rem; 
    color: #666; 
    margin-bottom: 0.5rem; 
}

.book-detail__meta-list { 
    list-style: none; 
    margin-bottom: 0.65rem; 
    padding-left: 0; 
    color: #444; 
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.25rem 1rem;
}

.book-detail__meta-list li { 
    margin-bottom: 0; 
    font-size: 0.9rem;
}

.book-detail__defects {
    background: linear-gradient(135deg, #fff3cd 0%, #ffecb3 100%);
    border-left: 4px solid #f77f00;
    padding: 0.6rem 1rem;
    margin: 0.5rem;
    border-radius: var(--radius-sm);
    box-shadow: 0 2px 8px rgba(247, 127, 0, 0.15);
}

.book-detail__defects strong {
    color: #d35400;
    display: block;
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
}

.book-detail__defects p {
    margin: 0;
    color: #a04000;
    font-size: 0.85rem;
}

.book-detail__description { 
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
    line-height: 1.45;
    max-width: 72ch;
}

.book-detail__footer {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--secondary-color);
    padding-top: 0.75rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.book-detail__price .price-original { 
    font-size: 0.85rem;
    color: #94a3b8; 
    text-decoration: line-through; 
}

.book-detail__price .price-current { 
    font-size: 1.1rem; 
}

.book-detail__actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* --- Purchase Section (precio + CTAs) --- */
.book-detail__purchase {
    margin: 0.75rem 0;
    padding: 0.85rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: var(--radius-md);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.book-detail__purchase .book-detail__price {
    margin-bottom: 0.6rem;
}

.book-detail__purchase .book-detail__price .price-current {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--primary-color);
}

.book-detail__purchase .book-detail__price .price-original {
    font-size: 0.9rem;
    color: #94a3b8;
    text-decoration: line-through;
}

.book-detail__purchase .book-detail__actions {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    width: 100%;
}

.detail-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 0.9rem;
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    box-sizing: border-box;
}

.detail-cta--primary {
    background: linear-gradient(135deg, #25D366 0%, #20bf6b 100%);
    color: white;
    border: none;
}

.detail-cta--primary:hover {
    background: linear-gradient(135deg, #1da851 0%, #1a9f57 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
}

.detail-cta--secondary {
    background: #f8fbff;
    color: #2f5d9e;
    border: 1px solid #9eb9e4;
}

.detail-cta--secondary:hover {
    background: #eef5ff;
    color: #1c4377;
}

.detail-cta.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.detail-cta--primary.disabled,
.detail-cta--secondary.disabled,
.detail-cta.disabled {
    background: #9ca3af !important;
    border: 1px solid #9ca3af !important;
    color: #ffffff !important;
    box-shadow: none !important;
}

.detail-cta--primary.disabled:hover,
.detail-cta--secondary.disabled:hover,
.detail-cta.disabled:hover {
    background: #9ca3af !important;
    border-color: #9ca3af !important;
    transform: none !important;
    box-shadow: none !important;
}

/* --- Location Info --- */
.book-detail__location-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 1rem 0;
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: var(--radius-sm);
}

.location-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: #555;
}

.location-icon {
    font-size: 1rem;
}

.location-text strong {
    color: var(--primary-color);
}

/* --- Details Accordion --- */
.book-detail__details-accordion {
    margin-top: 1rem;
    border: 1px solid #e0e0e0;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.book-detail__details-toggle {
    display: block;
    width: 100%;
    padding: 0.6rem 0.9rem;
    background: #f5f5f5;
    color: var(--primary-color);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-align: left;
    transition: background 0.2s;
}

.book-detail__details-toggle:hover {
    background: #e8e8e8;
}

.book-detail__details-accordion[open] .book-detail__details-toggle {
    background: var(--accent-color);
    color: white;
}

.book-detail__details-accordion .book-detail__meta-list {
    margin: 0;
    padding: 1rem;
    background: white;
}

/* --- Advertencia de Serie --- */
.series-warning {
    background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
    border-left: 4px solid #0077b6;
    padding: 0.6rem 1rem;
    margin: 0.5rem;
    border-radius: var(--radius-sm);
    box-shadow: 0 2px 8px rgba(0, 119, 182, 0.15);
}

.series-warning__header {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
    color: #0077b6;
}

.series-warning__icon {
    font-size: 1.2rem;
}

.series-warning__message {
    margin: 0;
    color: #023e8a;
    line-height: 1.3;
}

.series-warning__alert {
    display: block;
    margin-top: 0.5rem;
    font-weight: 600;
    color: #d62828;
}

.series-warning__success {
    display: block;
    margin-top: 0.5rem;
    font-weight: 600;
    color: #2a9d8f;
}

/* --- Libros Relacionados --- */
.related-books {
    margin: 0.35rem 0;
    padding: 0.5rem;
    background-color: #F5F5F5;
    border-radius: 8px;
}

.related-books__title {
    font-family: var(--font-primary);
    font-size: 1.0rem;
    color: var(--primary-color);
   /* margin-bottom: 0.5rem;*/
    margin: 0 0.2rem 0.2rem 0.2rem;
}

.related-books__grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 100%;
}

.related-book {
    background-color: white;
    border-radius: 8px;
    padding: 0.6rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    display: flex;
    gap: 0.6rem;
    align-items: center;
}

.related-book:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-color: var(--accent-color);
}

.related-book.sold-out {
    opacity: 0.6;
}

.related-book.sold-out:hover {
    transform: none;
    box-shadow: none;
}

.related-book__image {
    width: 58px;
    height: 82px;
    object-fit: contain;
    border-radius: 4px;
    flex-shrink: 0;
    background-color: #FAFAFA;
}

.related-book__info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.related-book__title {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-color);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

.related-book__price {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0 0.4rem 0 0;
    display: inline-block;
    vertical-align: middle;
}

.related-book__status {
    font-size: 0.7rem;
    padding: 0.2rem 0.45rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    font-weight: 600;
}

.book-detail-gallery {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.35rem;
    flex-wrap: wrap;
}

.book-detail-thumb {
    width: 44px;
    height: 44px;
    object-fit: contain;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.book-detail-thumb:hover {
    border-color: #60a5fa;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

.book-detail-thumb.is-active {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.related-book.available .related-book__status {
    background-color: var(--success-color);
    color: white;
}

.related-book.sold-out .related-book__status {
    background-color: var(--error-color);
    color: white;
}

/* --- Botones de Compartir --- */
.share-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.share-button {
    background: linear-gradient(135deg, #25D366 0%, #20bf6b 100%);
    color: white;
    border: none;
    padding: 0.65rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    box-shadow: 0 4px 14px rgba(37, 211, 102, 0.3);
}

.share-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(37, 211, 102, 0.4);
}

.share-button:active {
    transform: translateY(0);
}

.share-button--copy {
    background-color: var(--accent-color);
}

.share-button--copy:hover {
    background-color: var(--primary-color);
}

.share-button--facebook {
    background-color: #1877F2;
}

.share-button--facebook:hover {
    background-color: #0C63D4;
}

.share-button--facebook-link {
    background-color: #1877F2;
    text-decoration: none;
}

.share-button--facebook-link:hover {
    background-color: #0C63D4;
}

/* Botones deshabilitados cuando el libro estÃ¡ agotado */
/* IMPORTANTE: NO usar pointer-events: none porque bloquea el cursor */
.share-button.disabled,
span.share-button.disabled {
    background-color: #9e9e9e !important;
    cursor: not-allowed !important;
    opacity: 0.7 !important;
}

.share-button.disabled:hover,
span.share-button.disabled:hover {
    transform: none !important;
    box-shadow: none !important;
    background-color: #9e9e9e !important;
    cursor: not-allowed !important;
}

/* --- Modal de Imagen --- */
.no-scroll {
    overflow: hidden;
}

/* --- Modal de Imagen Mejorado --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(26, 26, 46, 0.97);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease-in-out;
    padding: 1rem;
}

.modal-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 60px;
    box-sizing: border-box;
}

.modal-overlay.visible .modal-content {
    transform: scale(1) translateY(0);
}

.modal-image-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 90vw;
    max-width: 420px;
    height: 80vh;
    max-height: 600px;
    overflow: hidden;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.05);
    touch-action: pan-x pan-y pinch-zoom;
}

.modal-image {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
    border-radius: var(--radius-sm);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    cursor: zoom-in;
    transition: transform 0.15s ease, transform-origin 0.15s ease;
    user-select: none;
    -webkit-user-drag: none;
    transform-origin: 50% 50%;
}

.modal-image.zoomed {
    cursor: grab;
    max-width: none;
    max-height: none;
}

.modal-image-wrapper.zooming {
    cursor: grab;
    overflow: auto;
}

@media (hover: none) and (pointer: coarse) {
    .modal-image {
        cursor: zoom-in;
    }
}

.modal-image-wrapper.zooming {
    cursor: zoom-out;
}

.modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    backdrop-filter: blur(8px);
    z-index: 10;
}

.modal-nav:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-50%) scale(1.1);
}

.modal-nav--prev {
    left: 10px;
}

.modal-nav--next {
    right: 10px;
}

.modal-close {
    position: absolute;
    top: -12px;
    right: -12px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px);
    border: none;
    color: white;
    font-size: 1.5rem;
    font-weight: 300;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    z-index: 20;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.1);
}

.modal-close:active {
    transform: scale(0.95);
}

.modal-counter {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    margin-top: 1rem;
    font-weight: 500;
    letter-spacing: 0.5px;
}

/* Instrucciones para móvil */
.modal-hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
    color: rgba(255, 255, 255, 0.6);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.75rem;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.modal-overlay.visible .modal-hint {
    opacity: 1;
}

/* Portátil/Desktop: ampliar modal de zoom para que destaque frente a la portada */
@media (min-width: 769px) and (max-width: 1600px) {
    .modal-content {
        max-width: 94vw;
        max-height: 92vh;
        padding: 0 64px;
    }

    .modal-image-wrapper {
        width: min(72vw, 680px);
        max-width: 680px;
        height: min(78vh, 760px);
        max-height: 760px;
    }

    .modal-image {
        max-width: 100%;
        max-height: 76vh;
    }
}

/* Móvil: optimizaciones */

.fab-whatsapp {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #25D366 0%, #20bf6b 100%);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-shadow: 0 8px 24px rgba(37, 211, 102, 0.4);
  transition: var(--transition);
  z-index: 1000;
  border: none;
}

.fab-whatsapp:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 12px 32px rgba(37, 211, 102, 0.5);
}

.fab-whatsapp:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.fab-whatsapp svg {
  display: block;
  width: 48px;
  height: 48px;
}

/* Visually hidden helper for accessibility */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}


.notification {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background-color: var(--success-color);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    font-size: 1rem;
    font-weight: 500;
    z-index: 2000;
    max-width: 350px;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease-in-out;
}

.notification.visible {
    opacity: 1;
    transform: translateY(0);
}

.notification--error {
    background-color: var(--error-color);
}

/* --- Media Queries --- */
@media (max-width: 480px) {
    .book-grid { 
        grid-template-columns: repeat(2, 1fr); 
        gap: 0.6rem;
        padding: 0 0.1rem;
    }

    .book-card__image-container {
   /*      height: var(--catalog-card-image-h-mobile);
        min-height: var(--catalog-card-image-h-mobile); */
        height: 150px;
        min-height: 150px;
    }
    
    .hero-header {
        min-height: 280px;
    }

    .book-detail-content {
        gap: 0.85rem;
        padding: 0.68rem 0.7rem 0.9rem;
    }

    .book-detail-view {
        margin: 0.2rem auto 0.45rem;
        padding-top: 0.16rem;
    }

    .book-detail__cover {
        width: min(100%, 380px);
        max-height: 56dvh;
    }

    .book-detail__title {
        font-size: 1.12rem;
        margin-bottom: 0.35rem;
    }

    .book-detail__author {
        font-size: 0.95rem;
        margin-bottom: 0.35rem;
    }

    .book-detail__location-info {
        margin: 0.6rem 0;
        padding: 0.6rem;
        gap: 0.4rem;
    }
     .book-card__content {
         padding: 0.5rem;
         min-height: auto;
     }
     .book-card__title {
         font-size: 0.8rem;
     }
     .book-card__author {
         font-size: 0.72rem;
     }
     #book-listing .book-card__price .price-current {
         font-size: 0.95rem;
     }
     .book-card__quick-buy {
         font-size: 0.75rem;
         padding: 0.35rem 0.4rem;
         gap: 0.25rem;
     }
     .book-card__quick-buy svg {
         width: 14px;
         height: 14px;
         flex-shrink: 0;
     }

    .book-detail__meta-list {
        grid-template-columns: 1fr;
        gap: 0.2rem;
    }
    
    .btn-suffix {
        display: none;
    }
}


/* BotÃ³n WhatsApp â€” color oficial (verde) */
.share-button--whatsapp,
.share-button.share-button--whatsapp {
  background-color: #25D366 !important;
  color: #ffffff;
}

.share-button--whatsapp:hover,
.share-button.share-button--whatsapp:hover {
  background-color: #1DB954 !important;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* === REGLAS CRÍTICAS PARA BOTONES DESHABILITADOS === */
/* DEBEN estar al final del archivo para máxima especificidad */
/* NO usar pointer-events: none porque bloquea el cursor */
.share-button--whatsapp.disabled,
span.share-button--whatsapp.disabled,
a.share-button--whatsapp.disabled,
.share-button--facebook-link.disabled,
span.share-button--facebook-link.disabled,
a.share-button--facebook-link.disabled,
.share-button.disabled,
span.share-button.disabled {
    background-color: #9e9e9e !important;
    cursor: not-allowed !important;
    opacity: 0.7 !important;
}

.share-button--whatsapp.disabled:hover,
span.share-button--whatsapp.disabled:hover,
a.share-button--whatsapp.disabled:hover,
.share-button--facebook-link.disabled:hover,
span.share-button--facebook-link.disabled:hover,
a.share-button--facebook-link.disabled:hover,
.share-button.disabled:hover,
span.share-button.disabled:hover {
    background-color: #9e9e9e !important;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
}

/* --- Filtros de Categorías (Chips) --- */
.filters-container {
    max-width: 1200px;
    margin: 0 auto 1rem;
    padding: 0.75rem 1rem;
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    position: sticky;
    top: 60px;
    z-index: 100;
}

.filters-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.filters-row--scrollable {
    flex-wrap: nowrap;
}

.filters-label {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--primary-color);
    min-width: 60px;
    flex-shrink: 0;
}

.filters-chips-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

.filters-nav-btn {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    border: 1px solid var(--secondary-color);
    background: white;
    color: var(--text-color);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.filters-nav-btn:hover:not(:disabled) {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.filters-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.filters-chips {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.4rem;
    overflow-x: hidden;
    scroll-behavior: smooth;
    padding: 0.25rem 0;
}

.filter-chip {
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--secondary-color);
    border-radius: 20px;
    background: white;
    font-size: 0.8rem;
    font-family: var(--font-secondary);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}

.filter-chip:hover {
    border-color: var(--accent-color);
    background: #f0f4f8;
}

.filter-chip.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.filters-clear {
    padding: 0.35rem 0.75rem;
    background: transparent;
    border: 1px solid var(--error-color);
    color: var(--error-color);
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.8rem;
    font-family: var(--font-secondary);
    transition: var(--transition);
    white-space: nowrap;
}

.filters-clear:hover {
    background: var(--error-color);
    color: white;
}

.filters-clear:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.filters-clear:disabled:hover {
    background: transparent;
    color: var(--error-color);
}

.filters-count {
    font-size: 0.75rem;
    color: #666;
    margin-left: auto;
    flex-shrink: 0;
}

/* --- Botón de Filtros en sticky-nav --- */
.filters-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.75rem;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.filters-toggle:hover {
    background: var(--primary-color);
    transform: translateY(-1px);
}

.filters-toggle__text {
    display: none;
}

.filters-toggle__count {
    background: white;
    color: var(--accent-color);
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    font-size: 0.75rem;
    min-width: 20px;
    text-align: center;
    font-weight: 700;
}

.filters-toggle__count:empty,
.filters-toggle__count[data-count="0"] {
    display: none;
}

@media (min-width: 480px) {
    .filters-toggle__text {
        display: inline;
    }
}

/* --- Controles de Ordenamiento --- */
.sort-controls {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
    background: var(--accent-color);
    padding: 0.2rem 0.35rem;
    border-radius: 6px;
}

.sort-label {
    display: none;
    font-size: 0.85rem;
    color: white;
    font-weight: 500;
}

.sort-select {
    padding: 0.15rem 1.5rem 0.15rem 0.25rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    background-color: var(--accent-color);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23ffffff' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.4rem center;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    font-size: 0.75rem;
    font-family: var(--font-primary);
    color: white;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    max-width: 120px;
    width: 100%;
}

.sort-select:hover {
    border-color: var(--accent-color);
}

.sort-select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(65, 90, 119, 0.15);
}

/* Sidebar oculto por defecto (se muestra en >= 1024px) */
.filters-sidebar {
    display: none;
}

@media (min-width: 1024px) {
    /* Sort label */
    .sort-label { display: inline; }
    
    /* Layout sidebar */
    .listing-content-wrapper {
        display: flex;
        gap: 1rem;
        align-items: flex-start;
    }
    .filters-sidebar {
        display: block;
        width: 220px;
        flex-shrink: 0;
        background: white;
        border-radius: 12px;
        padding: 1rem;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
        border: 1px solid rgba(0, 0, 0, 0.05);
        position: sticky;
        top: 80px;
        max-height: calc(100vh - 100px);
        overflow-y: auto;
    }
    .book-grid {
        flex: 1;
        min-width: 0;
        grid-template-columns: repeat(4, 1fr);
        justify-content: flex-start;
        gap: 1rem;
    }
    #filters-toggle { display: none; }
    body.viewing-detail .filters-sidebar { display: none !important; }
    body.viewing-detail .catalog-toolbar { display: none !important; }
    
    /* Ocultar sort en header, mostrar toolbar */
    .catalog-toolbar { display: flex; }
}

.filters-drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 75vh;
    background: white;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.2);
    z-index: 1001;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.filters-drawer.open {
    transform: translateY(0);
}

.filters-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.filters-overlay.open {
    opacity: 1;
    visibility: visible;
}

.filters-drawer__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
}

.filters-drawer__header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-color);
}

.filters-drawer__close {
    width: 32px;
    height: 32px;
    border: none;
    background: #f0f0f0;
    border-radius: 50%;
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: background 0.2s;
}

.filters-drawer__close:hover {
    background: #e0e0e0;
}

.filters-drawer__content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem;
}

.filters-drawer__footer {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
}

.filters-drawer__footer button {
    flex: 1;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary {
    background: white;
    border: 1px solid #ccc;
    color: #666;
}

.btn-secondary:hover {
    background: #f5f5f5;
}

.btn-primary {
    background: var(--accent-color);
    border: none;
    color: white;
}

.btn-primary:hover {
    background: var(--primary-color);
}

/* --- Grupos de Filtros en Drawer --- */
.filter-group {
    margin-bottom: 1.25rem;
}

.filter-group:last-child {
    margin-bottom: 0;
}

.filter-group h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 180px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.filter-options::-webkit-scrollbar {
    width: 4px;
}

.filter-options::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

.filter-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}

.filter-option:hover {
    background: #f5f5f5;
}

.filter-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-color);
    cursor: pointer;
    pointer-events: auto;
    position: relative;
    z-index: 1;
}

.filter-option label {
    flex: 1;
    font-size: 0.9rem;
    color: #444;
    cursor: pointer;
    line-height: 1.3;
}

/* Autor en filtros: una sola línea con elipsis */
#drawer-author-filters .filter-option label,
#sidebar-author-filters .filter-option label {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.filter-option input:checked + label {
    color: var(--primary-color);
    font-weight: 500;
}

/* --- Sidebar de Filtros (Desktop) --- */
.filters-sidebar__content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.filters-sidebar .filter-group {
    margin-bottom: 0;
}

.filters-sidebar .filter-group h4 {
    margin: 0 0 0.4rem 0;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.filters-sidebar .filter-options {
    max-height: 140px;
    overflow-y: auto;
    padding-right: 0.25rem;
    gap: 0.15rem;
}

.filters-sidebar .filter-option {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.4rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
}

.filters-sidebar .filter-option:hover {
    background: #f0f0f0;
}

.filters-sidebar .filter-option input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--accent-color);
    cursor: pointer;
    pointer-events: auto;
    position: relative;
    z-index: 1;
}

.filters-sidebar .filter-option label {
    font-size: 0.8rem;
    color: #555;
    cursor: pointer;
    line-height: 1.2;
}

.filters-sidebar__clear {
    margin-top: 0.75rem;
    padding: 0.4rem 0.75rem;
    background: transparent;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.8rem;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.filters-sidebar__clear:hover {
    background: #f5f5f5;
    border-color: #999;
    color: #333;
}

/* --- Desktop: Panel Lateral --- */
@media (min-width: 769px) {
    .book-detail-view {
        padding-top: 0rem;
    }
    
    .filters-drawer {
        position: fixed;
        top: 70px;
        bottom: auto;
        left: auto;
        right: 1rem;
        max-width: 320px;
        max-height: calc(100vh - 90px);
        border-radius: 12px;
        transform: translateX(120%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .filters-drawer.open {
        transform: translateX(0);
    }
    
    .filters-toggle {
        padding: 0.5rem 1rem;
    }
    
    .filters-toggle__text {
        display: inline;
    }
}

/* Catalog main wrapper */
.catalog-main {
    flex: 1;
    min-width: 0;
}

.catalog-type-toggle {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.catalog-type-toggle__btn {
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #334155;
    border-radius: 999px;
    padding: 0.35rem 0.75rem;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.catalog-type-toggle__btn:hover {
    background: #e2e8f0;
}

.catalog-type-toggle__btn.is-active {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: #fff;
}

/* Catalog toolbar */
.catalog-toolbar {
    display: none;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid #eee;
}

/* Mostrar toolbar desde 768px */
@media (min-width: 768px) {
    .catalog-toolbar {
        display: flex;
    }
    /* Ocultar sort del nav, mostrar solo en toolbar */
    .sticky-nav .sort-controls {
        display: none;
    }
}

.results-count {
    font-size: 0.9rem;
    color: #666;
}

.sort-controls--toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: transparent;
    padding: 0;
}

.sort-controls--toolbar .sort-label {
    display: inline;
    font-size: 0.85rem;
    color: #666;
    font-weight: 500;
}

.sort-controls--toolbar .sort-select {
    padding: 0.4rem 2rem 0.4rem 0.6rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    background-color: white;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23334155' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    color: var(--text-color);
    font-size: 0.85rem;
    font-family: var(--font-primary);
    cursor: pointer;
    max-width: none;
    width: auto;
}

/* Consolidado: todos los estilos para móvil/tablet <= 768px */
@media (max-width: 768px) {
    /* Book card */
    .book-card__image-container {
        height: var(--catalog-card-image-h-tablet);
        min-height: var(--catalog-card-image-h-tablet);
    }
    .book-card__content {
        min-height: 165px;
    }
    .book-card__quick-buy,
    .book-card__quick-buy--disabled {
        min-height: var(--catalog-card-cta-h-mobile);
    }
    
    /* Modal */
    .modal-overlay {
        padding: 0;
        align-items: center;
    }
    .modal-content {
        max-width: 100vw;
        max-height: 95vh;
        width: 100%;
    }
    .modal-image-wrapper {
        width: 95vw;
        height: auto;
        max-height: 75vh;
        min-height: 50vh;
    }
    .modal-image {
        max-height: 70vh;
        border-radius: 0;
    }
    .modal-nav {
        display: none;
    }
    
    /* Hero y Detail */
    .book-detail-content {
        flex-direction: column;
        align-items: center;
        gap: 1rem;
        padding: 0.8rem 0.85rem 1rem;
    }
    .book-detail__cover {
        width: min(100%, 390px);
        max-width: 100%;
        max-height: 62dvh;
        height: auto;
        margin-bottom: 0.35rem;
    }
    .book-detail__info {
        text-align: left;
        width: 100%;
    }
    .book-detail__purchase {
        margin: 0.35rem 0;
        padding: 0.65rem;
    }
    .book-detail__purchase .book-detail__price .price-current {
        font-size: 1.3rem;
    }
    .detail-cta {
        padding: 0.62rem 0.8rem;
        font-size: 0.9rem;
    }
    
    /* Filtros */
    .filters-container {
        margin: 0 0.5rem 1rem;
        border-radius: var(--radius-sm);
        position: sticky;
        top: 50px;
    }
    .filters-label {
        display: none;
    }
    .filter-chip {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
    }
    .filters-nav-btn {
        width: 28px;
        height: 28px;
        min-width: 28px;
        font-size: 0.85rem;
    }

    /* Drawer filtros: Estado primero */
    .filters-drawer {
        max-height: 85vh;
    }
    .filters-drawer__content {
        display: flex;
        flex-direction: column;
    }
    .filters-drawer__content .filter-group:nth-child(1) {
        order: 2;
    }
    .filters-drawer__content .filter-group:nth-child(2) {
        order: 3;
    }
    .filters-drawer__content .filter-group:nth-child(3) {
        order: 1;
    }

    /* Scroll al inicio */
    #inicio {
        scroll-margin-top: 60px;
    }
}

/* En pantallas grandes (>1200px): imagen con ancho 100% y altura automática */
@media (min-width: 1200px) {
}

/* Ocultar filtros cuando se ve el detalle del libro */
body.viewing-detail .filters-container,
body.viewing-detail .filters-toggle,
body.viewing-detail .filters-drawer,
body.viewing-detail .filters-overlay,
body.viewing-detail .sort-controls {
    display: none !important;
}

@media (max-width: 768px) {
    .sticky-nav {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
}
