.auto-width {
    width: auto;
    display: inline-block;
}

/* Override ContentSearchEngine max-width limitation for publications search */
#searchInputContainer {
    min-width: 50% !important;
    max-width: none !important;
}

#searchInputContainer .content-search-input-group {
    max-width: none !important;
}

#searchInputContainer .content-search-modern {
    max-width: none !important;
}

/* Styles for publication grid images, now scoped */
.publication-grid .animate-this {
    height: 230px;
    overflow: hidden;
}

.publication-grid .animate-this img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    /* Improves rendering quality */
    image-rendering: high-quality;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: optimize-contrast;
    /* Improves sharpness with subtle filter */
    filter: contrast(1.02) saturate(1.02);
    /* Enables hardware acceleration for better rendering */
    transform: translateZ(0);
    backface-visibility: hidden;
    will-change: transform;
}

/* Search toolbar styles */
#publicationsToolbar {
    transition: all 0.4s ease;
    margin-bottom: 20px;
}

#sortbyLabel,
#sortbyContainer {
    transition: opacity 0.4s ease, visibility 0.4s ease, transform 0.4s ease;
}

/* Hide sorting when toolbar is expanded (search is active) */
#publicationsToolbar.content-search-toolbar-expanded #sortbyLabel,
#publicationsToolbar.content-search-toolbar-expanded #sortbyContainer {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    position: absolute;
    pointer-events: none;
}

/* Adjust search results container */
.search-results-container {
    margin-top: 20px;
}

/* Style search results info */
.search-results-info {
    margin-bottom: 15px;
}

.search-results-info p {
    font-size: 14px;
    color: #666;
}

/* Ensure search result cards match original grid styling */
.search-publication-card {
    cursor: pointer;
    transition: transform 0.2s ease;
}

.search-publication-card:hover {
    transform: translateY(-5px);
}

/* Publication skeleton loader styles */
.publication-skeleton-card {
    margin-bottom: 2rem;
}

.publication-skeleton-image {
    height: 230px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
}

.publication-skeleton-image::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: shine 1.5s infinite;
}

.publication-skeleton-content {
    padding-top: 1rem;
}

.publication-skeleton-line {
    height: 12px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
    margin-bottom: 8px;
}

.publication-skeleton-metadata {
    width: 75%;
    height: 10px;
    margin-bottom: 10px;
}

.publication-skeleton-title {
    width: 100%;
    height: 20px;
    margin-bottom: 8px;
}

.publication-skeleton-title-line2 {
    width: 65%;
    height: 20px;
    margin-bottom: 10px;
}

.publication-skeleton-author {
    width: 40%;
    height: 10px;
    margin-left: auto;
    margin-bottom: 8px;
}

.publication-skeleton-description {
    width: 100%;
    height: 12px;
    margin-bottom: 6px;
}

.publication-skeleton-description:nth-child(2) {
    width: 95%;
}

.publication-skeleton-description:last-child {
    width: 60%;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

@keyframes shine {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* Mobile responsive */
@media (max-width: 768px) {
    #publicationsToolbar {
        flex-direction: column;
        align-items: flex-start !important;
    }

    #searchInputContainer {
        width: 100% !important;
        max-width: 100% !important;
        margin-bottom: 15px;
    }

    #sortbyLabel {
        margin-bottom: 5px;
    }

    #sortbyContainer {
        padding-left: 1rem; /* pl-3 equivalent only on mobile */
    }
}
