/* Configuración base para el iframe responsivo */
html, body {
    height: auto !important;
    min-height: 0 !important;
}

body { 
    margin: 0; 
    padding: 10px;
    background-color: transparent; /* Se adapta al fondo del OPAC de Koha */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; 
    color: #333;
    overflow-x: hidden; /* Evita solo el scroll horizontal, permite el vertical si es necesario */
}
.search-box { 
    margin-bottom: 25px; 
    display: flex;
    justify-content: center; /* Centra el contenido horizontalmente */
    width: 100%;
}

.search-form { 
    display: flex; 
    gap: 8px; 
    align-items: center; 
    flex-wrap: wrap; 
    justify-content: center; /* Centra los elementos internos (select, input, botón) */
}
.search-box select, .search-box input[type="text"] {
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    background-color: #ffffff;
}

.search-box input[type="text"] { width: 320px; }

.search-box button { 
    padding: 8px 18px; 
    background: #006699; 
    color: white; 
    border: none; 
    border-radius: 4px; 
    cursor: pointer; 
    font-size: 14px;
    font-weight: 600;
}
.search-box button:hover { background: #004b70; }

.tabs-container { margin-top: 15px; }

.nav-tabs { 
    display: flex; 
    list-style: none;
    padding-left: 0;
    margin-bottom: 0;
    border-bottom: 1px solid #ddd; 
    flex-wrap: wrap; 
}

.nav-tabs .tab-button { 
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 16px; 
    cursor: pointer; 
    border: 1px solid #ddd;
    border-bottom: none;
    background-color: #f1f1f1; 
    font-size: 14px; 
    color: #006699;
    font-weight: 600;
    margin-right: 4px;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
    transition: all 0.15s ease-in-out;
    outline: none;
    position: relative;
    bottom: -1px;
    text-align: center;
}

.nav-tabs .tab-button:hover { background-color: #e9ecef; color: #004b70; }

.nav-tabs .tab-button.active { 
    background-color: #ffffff; 
    color: #333333; 
    border-color: #ddd #ddd transparent #ddd;
    border-top: 3px solid #006699;
}

.tab-button .badge-count {
    font-size: 11px;
    font-weight: normal;
    color: #6c757d;
    margin-top: 2px;
}

.nav-tabs .tab-button.active .badge-count { color: #006699; font-weight: 500; }

.tab-content { 
    display: none; 
    background: #ffffff; 
    padding: 20px; 
    border: 1px solid #ddd; 
    border-top: none; 
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.tab-content.active { display: block; }

/* Estilos de Lista y Numeración */
ul.results-list { list-style-type: none; padding: 0; margin: 0; }
ul.results-list li { 
    padding: 12px 0; 
    border-bottom: 1px solid #eee; 
    display: flex;
    gap: 12px;
    align-items: flex-start;
}
ul.results-list li:last-child { border-bottom: none; }

.result-number {
    font-size: 14px;
    font-weight: bold;
    color: #6c757d;
    min-width: 30px;
    text-align: right;
    padding-top: 2px;
}

.result-body { flex: 1; }

.book-title { font-size: 15px; font-weight: bold; color: #006699; text-decoration: none; }
.book-title:hover { text-decoration: underline; color: #004b70; }
.book-author, .book-publisher { font-size: 13px; color: #555; margin-top: 3px; }

/* Paginación */
.pagination {
    display: flex;
    padding-left: 0;
    list-style: none;
    border-radius: 0.25rem;
    margin-top: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 2px;
}
.pagination .page-item .page-link {
    position: relative;
    display: block;
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: #006699;
    text-decoration: none;
    background-color: #fff;
    border: 1px solid #dee2e6;
    border-radius: 3px;
}
.pagination .page-item .page-link:hover {
    color: #004b70;
    background-color: #e9ecef;
    border-color: #dee2e6;
}
.pagination .page-item.active .page-link {
    z-index: 3;
    color: #fff;
    background-color: #006699;
    border-color: #006699;
}

/* Búsqueda Avanzada Grid */
.adv-search-fieldset {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 20px;
    background-color: #fff;
}

.adv-search-fieldset legend {
    font-weight: bold;
    padding: 0 8px;
    color: #006699;
}

.adv-search-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.adv-search-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* Crea exactamente 4 columnas de igual ancho */
    gap: 12px;
    margin-top: 10px;
}

.adv-search-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: #f8f9fa;
    padding: 6px 10px;
    border-radius: 4px;
    border: 1px solid #e9ecef;
}

.itemtype-image {
    width: 32px;  /* Aumentado de 20px a 32px */
    height: 32px; /* Aumentado de 20px a 32px */
    object-fit: contain;
    vertical-align: middle;
}

.itypetext {
    font-size: 13px;
    color: #333;
}

/* Overlay de carga para búsquedas */
/* Container de pantalla completa para el loader */
#loading-overlay {
    display: none; /* Oculto inicialmente */
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(255, 255, 255, 0.9);
    z-index: 99999;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Spinner animado en CSS puro */
.spinner {
    width: 60px;
    height: 60px;
    border: 6px solid #e0e0e0;
    border-top: 6px solid #006699;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#loading-overlay p {
    font-family: sans-serif;
    font-size: 18px;
    font-weight: bold;
    color: #006699;
    margin: 0;
}

/* Adaptación responsiva para pantallas pequeñas (móviles/tablets) */
@media (max-width: 992px) {
    .adv-search-grid {
        grid-template-columns: repeat(2, 1fr); /* Baja a 2 columnas en pantallas medianas */
    }
}

@media (max-width: 576px) {
    .adv-search-grid {
        grid-template-columns: 1fr; /* 1 columna en móviles pequeños */
    }
}

/* Spinner en pestaña */
.tab-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid #006699;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin-tab 0.8s linear infinite;
    margin-left: 6px;
    vertical-align: middle;
}

@keyframes spin-tab {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
