/* ==========================================================================
   SEARCH.CSS
   Página de búsqueda, resultados y modal de ubicación — usada en
   search.html. Requiere base.css cargado antes.
   ========================================================================== */

.search-page {
    max-width: 1200px;
    margin: 3rem auto;
    padding: 0 2rem;
    animation: fadeIn 0.6s ease-out;
}

.search-header {
    background: var(--card-bg);
    padding: 2.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 2.5rem;
}

.search-header h1 {
    font-family: var(--font-serif);
    color: var(--primary-color);
    font-size: 2.2rem;
    margin-bottom: 1.5rem;
}

.search-form {
    display: flex;
    gap: 12px;
}

/* Nota: .search-input base (flex/border/font-size) vive en index.css.
   Estas reglas son self-contained para que search.html no dependa de index.css. */
.search-form .search-input {
    background: var(--bg-color);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill);
    padding: 0.9rem 1.5rem;
    width: 100%;
    font-size: 1.05rem;
}

.search-form .search-input::placeholder {
    color: var(--text-muted);
}

.search-form .search-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.results-container {
    background: var(--card-bg);
    padding: 2.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.results-count {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.8rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.8rem;
}

/* Tarjeta de Libro */
.book-card {
    background: var(--card-bg);
    padding: 1.8rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    border-top: 5px solid var(--primary-color);
    box-shadow: var(--shadow-sm);
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.book-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-lg);
    border-top-color: var(--accent-color);
}

.book-info h3 {
    font-family: var(--font-serif);
    color: var(--text-main);
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 0.4rem;
}

.author {
    color: var(--primary-light);
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

/* Nombre de la biblioteca a la que pertenece el ejemplar, visible
   en la tarjeta antes de dar clic en "Ver disponibilidad". */
.book-biblioteca {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.6rem;
}

.book-details {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1rem 0;
}

.badge {
    background: var(--primary-rgba);
    color: var(--primary-color);
    padding: 0.35rem 0.85rem;
    border-radius: var(--radius-pill);
    font-size: 0.78rem;
    font-weight: 600;
    border: 1px solid rgba(96, 24, 24, 0.15);
    display: inline-block;
}

.badge-warning {
    background: var(--accent-light);
    color: #854d0e;
    border: 1px solid rgba(223, 178, 63, 0.4);
}

.badge-success {
    background: #e6f4ea;
    color: #14532d;
    border: 1px solid #b7e1cd;
}

.editorial {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 1.2rem;
    font-style: italic;
}

.book-actions {
    display: flex;
    gap: 0.8rem;
    margin-top: auto;
}

.btn-ubicacion, .btn-prestamo {
    flex: 1;
    padding: 0.65rem 1rem;
    border: none;
    border-radius: var(--radius-pill);
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: var(--transition-smooth);
}

.btn-ubicacion {
    background: var(--bg-color);
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

.btn-ubicacion:hover {
    background: var(--primary-color);
    color: #ffffff;
}

.btn-prestamo {
    background: var(--accent-color);
    color: var(--primary-dark);
}

.btn-prestamo:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 8px rgba(223, 178, 63, 0.25);
}

.no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}

.no-results p {
    font-size: 1.1rem;
    font-style: italic;
}

/* ==========================================================================
   MODALES (ubicación y préstamo)
   ========================================================================== */
.modal {
    display: none;
    position: fixed;
    z-index: 1100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(45, 14, 14, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: fadeIn 0.3s ease-out;
    overflow-y: auto;
}

.modal-content {
    background: var(--card-bg);
    margin: 5vh auto;
    padding: 2.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    max-width: 550px;
    width: 92%;
    max-height: 90vh;
    overflow-y: auto;
    box-sizing: border-box;
    position: relative;
    animation: zoomIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.close {
    position: absolute;
    top: 1.2rem;
    right: 1.5rem;
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition-fast);
    border: 0;
    background: transparent;
    line-height: 1;
}

.close:hover { color: var(--primary-color); }

.modal-content h2 {
    font-family: var(--font-serif);
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

#ubicacionInfo {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    background: var(--bg-color);
    padding: 1.5rem;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--accent-color);
}

#ubicacionInfo p {
    font-size: 1rem;
    color: var(--text-main);
    display: flex;
    justify-content: space-between;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 0.5rem;
}

#ubicacionInfo p:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

#ubicacionInfo p strong {
    color: var(--text-muted);
    font-weight: 600;
}

#ubicacionInfo p span {
    font-weight: 700;
    color: var(--primary-color);
}

/* Contenedor de disponibilidad multi-sede: una tarjeta por biblioteca
   donde el mismo libro tiene ejemplares registrados. */
#ubicacionSedes {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sede-disponibilidad {
    background: var(--bg-color);
    padding: 1.2rem 1.5rem;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--accent-color);
}

.sede-disponibilidad h4 {
    font-family: var(--font-serif);
    color: var(--primary-color);
    font-size: 1.1rem;
    margin-bottom: 0.6rem;
}

.sede-disponibilidad p {
    font-size: 0.95rem;
    color: var(--text-main);
    display: flex;
    justify-content: space-between;
    border-bottom: 1px dashed var(--border-color);
    padding: 0.35rem 0;
}

.sede-disponibilidad p:last-child {
    border-bottom: none;
}

.sede-disponibilidad p strong {
    color: var(--text-muted);
    font-weight: 600;
}

/* ==========================================================================
   MODAL DE PRÉSTAMO
   ========================================================================== */
.modal .modal-content.modal-content--prestamo {
    max-width: 420px;
    height: auto;
    padding: 1.75rem 1.75rem 2rem;
}

.modal-content--prestamo h2 {
    font-size: 1.6rem;
    margin-bottom: 1.2rem;
    padding-right: 2rem;
}

.prestamo-libro-resumen {
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
}

.prestamo-libro-resumen strong {
    display: block;
    font-size: 1.05rem;
}

.prestamo-libro-resumen .prestamo-libro-meta {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.35rem;
    font-size: 0.85rem;
    color: var(--text-muted, #8a7a6d);
}

.prestamo-usuario-buscar label,
.prestamo-fecha label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
}

.prestamo-usuario-buscar input,
.prestamo-fecha input {
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    font: inherit;
    box-sizing: border-box;
}

.prestamo-usuario-resultados {
    list-style: none;
    margin: 0.4rem 0 0;
    padding: 0;
    max-height: 160px;
    overflow-y: auto;
    border-radius: 6px;
}

.prestamo-usuario-resultados li {
    padding: 0.5rem 0.6rem;
    cursor: pointer;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    font-size: 0.9rem;
}

.prestamo-usuario-resultados li:hover {
    background: rgba(0, 0, 0, 0.04);
}

.prestamo-usuario-resultados li strong {
    display: block;
}

.prestamo-usuario-resultados li span {
    font-size: 0.78rem;
    color: var(--text-muted, #8a7a6d);
}

.prestamo-usuario-resultados .prestamo-sin-resultados {
    cursor: default;
    color: var(--text-muted, #8a7a6d);
    font-style: italic;
}

.prestamo-usuario-seleccionado {
    background: rgba(0, 0, 0, 0.03);
    border-radius: 8px;
    padding: 0.7rem 0.85rem;
    margin-bottom: 1rem;
}

.prestamo-usuario-seleccionado p {
    margin: 0 0 0.3rem;
}

.prestamo-usuario-detalle {
    font-size: 0.82rem;
    color: var(--text-muted, #8a7a6d);
}

.prestamo-link-btn {
    background: none;
    border: none;
    padding: 0;
    color: #7a1f1f;
    font-size: 0.82rem;
    text-decoration: underline;
    cursor: pointer;
}

.prestamo-fecha {
    margin: 1rem 0;
}

.prestamo-error {
    color: #b3261e;
    background: rgba(179, 38, 30, 0.08);
    border-radius: 6px;
    padding: 0.5rem 0.7rem;
    font-size: 0.85rem;
    margin: 0 0 1rem;
}

/* .btn-prestamo trae flex: 1 (pensado para las tarjetas de libros);
   aquí se anula para que el botón no se deforme dentro del modal. */
#prestamoConfirmarBtn {
    flex: none;
    width: 100%;
    margin-top: 0.5rem;
}

#prestamoConfirmarBtn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 768px) {
    .search-form {
        flex-direction: column;
    }
}

.availability {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    margin: 0.8rem 0;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.availability--available { background: #e6f4ea; color: #14532d; }
.availability--loaned { background: #fff3cd; color: #854d0e; }

.btn-prestamo:disabled { cursor: not-allowed; opacity: 0.55; }
