/* =========================================
   1. ESTILOS DEL CATÁLOGO (GRILLA Y SIDEBARS)
   ========================================= */
.ic-wrapper {
    display: grid;
    grid-template-columns: 260px 1fr 240px; 
    grid-template-areas: "sidebar results recent";
    gap: 2rem;
    align-items: start; 
    font-family: 'Poppins', sans-serif;
}

.ic-sidebar {
    grid-area: sidebar;
    background-color: #ce0021;
    padding: 25px;
    border-radius: 8px;
}
.ic-search {
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    padding: 10px 15px;
    border-radius: 50px;
    background: #ffffff;
    border: none;
    width: 100%;
    margin-bottom: 15px;
    box-sizing: border-box;
    outline: none;
}

.ic-sort-controls { display: flex; gap: 10px; margin-bottom: 15px; }
.ic-sort-btn {
    flex: 1; background: rgba(255,255,255,0.2); color: #fff; border: none; padding: 8px;
    border-radius: 5px; font-size: 13px; cursor: pointer; font-family: 'Poppins', sans-serif;
    transition: 0.2s; display: flex; justify-content: center; align-items: center; gap: 5px;
}
.ic-sort-btn:hover { background: rgba(255,255,255,0.3); }
.ic-sort-btn[data-state="asc"], .ic-sort-btn[data-state="desc"] { background: #fff; color: #ce0021; font-weight: bold; }

.ic-active-filters { margin-bottom: 15px; display: flex; flex-wrap: wrap; gap: 8px; }
.ic-filter-chip {
    background: rgba(255,255,255,0.2); color: #fff; padding: 4px 10px;
    border-radius: 15px; font-size: 12px; display: flex; align-items: center; gap: 5px;
}
.ic-filter-remove { cursor: pointer; font-weight: bold; font-size: 14px; }
.ic-filter-remove:hover { color: #ffcccc; }

.ic-multi-select { position: relative; margin-bottom: 15px; width: 100%; }
.ic-ms-header {
    background: #fff; padding: 10px 15px; border-radius: 50px; font-size: 14px;
    cursor: pointer; display: flex; justify-content: space-between; align-items: center; color: #333;
}
.ic-ms-dropdown {
    position: absolute; top: 100%; left: 0; right: 0; background: #f9f9f9;
    border-radius: 5px; box-shadow: 0 4px 10px rgba(0,0,0,0.15); z-index: 10;
    display: none; margin-top: 5px; overflow: hidden;
}
.ic-multi-select.is-open .ic-ms-dropdown { display: block; }
.ic-ms-search-wrapper { padding: 8px; background: #fff; border-bottom: 1px solid #eee; }
.ic-ms-search {
    width: 100%; padding: 8px 10px; border: 1px solid #ddd; border-radius: 4px;
    font-size: 13px; font-family: 'Poppins', sans-serif; box-sizing: border-box; outline: none;
}
.ic-ms-search:focus { border-color: #ce0021; }
.ic-ms-options-container { max-height: 180px; overflow-y: auto; padding: 8px; }
.ic-ms-option { display: block; padding: 5px 0; font-size: 13px; color: #333; cursor: pointer; }
.ic-ms-option input { margin-right: 8px; }
.ic-ms-empty { font-size: 13px; color: #888; padding: 10px; text-align: center; }

.ic-apply-btn {
    width: 100%; background: #ffffff; color: #ce0021; border: 2px solid #ffffff;
    padding: 12px; border-radius: 50px; font-family: 'Yo', sans-serif; font-weight: bold;
    cursor: pointer; margin-top: 10px; transition: 0.3s;
}
.ic-apply-btn:hover { background: #000000; color: #ffffff; border: 2px solid #ffffff; }

.ic-filter-group { margin-bottom: 15px; }
.ic-range-slider { position: relative; width: 100%; height: 30px; }
.ic-range-slider input[type="range"] {
    position: absolute; width: 100%; pointer-events: none; -webkit-appearance: none;
    background: transparent; z-index: 2;
}
.ic-range-slider input[type="range"]::-webkit-slider-thumb {
    pointer-events: all; position: relative; z-index: 3; -webkit-appearance: none;
    height: 15px; width: 15px; border-radius: 50%; background: #fff; cursor: pointer; margin-top: -6px;
}
.ic-range-slider::before {
    content: ''; position: absolute; width: 100%; height: 3px; background: #ffffff;
    top: 50%; transform: translateY(-50%); z-index: 1;
}
.ic-label-white { color: #ffffff; display: block; margin-bottom: 5px; font-size: 14px; }

.ic-recent-wrapper { grid-area: recent; background-color: #ce0021; padding: 25px; border-radius: 8px; }
.ic-recent-title { font-family: 'Poppins', sans-serif; font-weight: 900; color: #ffffff; text-transform: uppercase; margin-top: 0; margin-bottom: 10px; }
.ic-recent { list-style: none; padding: 0; margin: 0; }
.ic-recent li { margin: 0; }
.ic-recent li a {
    font-family: 'Yo', sans-serif; color: #ffffff; display: block; padding: 12px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.3); text-decoration: none; transition: 0.3s ease;
}
.ic-recent li:last-child a { border-bottom: none; }
.ic-recent li a:hover { background-color: rgba(0,0,0,0.15); border-radius: 4px; }

/* GRILLA DE RESULTADOS */
.ic-results-grid {
    grid-area: results; 
    display: grid; 
    grid-template-columns: repeat(5, 1fr);
    gap: 15px; 
    align-content: start;
}

.ic-card { position: relative; background: transparent; border: none; box-shadow: none; display: block; }
.ic-card-link-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; z-index: 1; }
.ic-img img, .ic-placeholder {
    width: 100%; height: auto; aspect-ratio: 3/4; object-fit: cover; background: #ddd;
    display: flex; align-items: center; justify-content: center; margin-bottom: 10px;
}
.ic-meta { padding: 0 5px; position: relative; }
.ic-title { font-family: 'Yo', sans-serif; font-weight: 800; font-size: 1.1rem; line-height: 1.2; margin-bottom: 5px; margin-top: 5px; }

.ic-autor { font-family: 'Poppins', sans-serif; font-weight: 300; font-size: 0.9rem; color: #444; margin-bottom: 5px; position: relative; z-index: 2; pointer-events: auto; }
.ic-autor-item { display: block; line-height: 1.4; }
.ic-autor-link { cursor: pointer; text-decoration: underline; transition: color 0.2s; }
.ic-autor-link:hover { color: #ce0021; }

/* =========================================
   SISTEMA DE PAGINACIÓN CUADRADA
   ========================================= */
.ic-pagination {
    grid-column: 1 / -1; /* Obliga a la paginación a abarcar todo el ancho de la grilla */
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 35px;
    margin-bottom: 15px;
    width: 100%;
}

.ic-page-btn, .ic-page-dots {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px; /* Tamaño del cuadrado */
    height: 44px;
    font-family: 'Yo', sans-serif; /* Tipografía obligatoria */
    font-size: 18px;
    background: #ffffff;
    color: #ce0021;
    border: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06); /* Sombra sutil imitando el recuadro blanco de la imagen */
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    border-radius: 2px;
}

.ic-page-dots {
    box-shadow: none;
    background: transparent;
    cursor: default;
    color: #ce0021;
}

.ic-page-btn:hover {
    background: #ce0021;
    color: #ffffff;
}

.ic-page-btn.active {
    background: #ce0021; /* El rojo solicitado reemplazando al negro */
    color: #ffffff;
    cursor: default;
}

/* =========================================
   REGLAS RESPONSIVAS Y LÍMITES DE PANTALLA
   ========================================= */

@media(max-width: 1024px) {
    .ic-wrapper { 
        grid-template-columns: 250px 1fr; 
        grid-template-areas: "sidebar results" "recent results"; 
    }
    .ic-results-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media(max-width: 768px) {
    .ic-wrapper { 
        grid-template-columns: 1fr; 
        grid-template-areas: "sidebar" "results" "recent"; 
    }
    .ic-results-grid {
        grid-template-columns: repeat(2, 1fr); 
    }
}

/* =========================================
   2. ESTILOS DEL MODAL DE LECTURA Y SCROLL
   ========================================= */
.ic-pdf-modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 15, 15, 0.95); backdrop-filter: blur(5px);
    z-index: 999999; display: flex; flex-direction: column; font-family: 'Poppins', sans-serif;
}
.ic-pdf-header {
    background: #ce0021; padding: 12px 25px; display: flex; justify-content: space-between;
    align-items: center; box-shadow: 0 4px 15px rgba(0,0,0,0.5); position: relative; z-index: 10;
}

/* Burbuja Flotante */
.ic-pdf-bubble {
    position: fixed; left: 30px; top: 50%; transform: translateY(-50%);
    width: 50px; height: 50px; border-radius: 50%; background: #ffffff; color: #ce0021;
    display: flex; align-items: center; justify-content: center;
    font-family: 'Yo', sans-serif; font-size: 18px; font-weight: normal;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5); z-index: 9999999; pointer-events: none;
    opacity: 0; transition: opacity 0.3s ease;
}
.ic-pdf-bubble.show { opacity: 1; }

.ic-pdf-controls { display: flex; align-items: center; gap: 8px; }

/* Botones Circulares Blancos (#ce0021 Text/Stroke) */
.ic-pdf-controls button, .ic-pdf-download-btn, #ic-pdf-close {
    background: #ffffff !important; 
    color: #ce0021 !important; 
    border: none !important; 
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    cursor: pointer; 
    font-family: 'Yo', sans-serif;
    font-size: 22px; 
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    text-decoration: none;
    padding: 0;
    box-sizing: border-box;
    flex-shrink: 0;
}

.ic-pdf-controls button svg, .ic-pdf-download-btn svg {
    stroke: #ce0021 !important; transition: stroke 0.2s;
}

.ic-pdf-controls button:hover, .ic-pdf-download-btn:hover, #ic-pdf-close:hover { 
    background: #000000 !important; color: #ffffff !important; 
}
.ic-pdf-controls button:hover svg, .ic-pdf-download-btn:hover svg { 
    stroke: #ffffff !important; 
}

#ic-pdf-close { background: #000000 !important; color: #ffffff !important; border: 1px solid rgba(255,255,255,0.2) !important; margin-left: auto; font-size: 18px; }
#ic-pdf-close:hover { background: #ffffff !important; color: #ce0021 !important; }

/* Input Numérico de Página */
.ic-pdf-page-info { 
    color: #ffffff; margin: 0 20px; font-size: 15px; font-family: 'Yo', sans-serif; 
    display: flex; align-items: center; gap: 6px; 
}
#ic-pdf-num-input {
    width: 46px; background: rgba(255,255,255,0.2); border: 1px solid rgba(255,255,255,0.3);
    color: #ffffff; border-radius: 4px; text-align: center; font-family: 'Yo', sans-serif;
    font-size: 15px; padding: 3px 0; outline: none; transition: all 0.2s;
}
#ic-pdf-num-input:focus { background: #ffffff; color: #ce0021; border-color: #ffffff; }
#ic-pdf-num-input::-webkit-outer-spin-button, #ic-pdf-num-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
#ic-pdf-num-input[type=number] { -moz-appearance: textfield; }

/* Cuerpo de Lectura (Scroll) */
.ic-pdf-body { flex-grow: 1; overflow-y: auto; text-align: center; padding: 30px; scroll-behavior: smooth; position: relative; }
#ic-pdf-canvas-wrapper { display: flex; flex-direction: column; align-items: center; width: 100%; }

/* Altura mínima estricta para evitar colapso de intersección y memoria */
.ic-pdf-page-wrapper { display: flex; justify-content: center; align-items: center; width: 100%; min-height: 800px; margin-bottom: 25px; }
.ic-pdf-page-wrapper canvas { background: #ffffff; box-shadow: 0 0 25px rgba(0,0,0,0.8); max-width: 100%; height: auto; display: block; }

/* Responsivo Móvil de Modales */
@media(max-width: 768px) {
    .ic-mobile-hide { display: none; }
    
    .ic-pdf-header { position: relative; flex-direction: column; padding: 15px; gap: 12px; }
    .ic-pdf-page-info { width: 100%; order: -1; justify-content: center; margin: 0; }
    
    .ic-pdf-controls { 
        display: flex; flex-direction: row; flex-wrap: nowrap; 
        justify-content: center; align-items: center; gap: 10px; 
        width: 100%; padding: 0 50px 0 0; box-sizing: border-box; 
    }
    
    /* Burbuja en móvil abajo a la izquierda */
    .ic-pdf-bubble { left: 15px; top: auto; bottom: 25px; transform: none; width: 45px; height: 45px; font-size: 16px; box-shadow: 0 4px 12px rgba(0,0,0,0.5); }
    
    #ic-pdf-close { position: absolute; top: 15px; right: 15px; }
    .ic-pdf-body { padding: 15px 10px; }
}
