/* Infinite Scroll Styles */
#loading-indicator {
    padding: 30px;
    text-align: center;
    background: transparent;
    margin: 20px auto;
    max-width: 300px;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Simple CSS-only loading dots */
.loading-dots {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin: 20px 0;
}

.loading-dots div {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #007bff;
    animation: pulse-dot 1.4s infinite ease-in-out both;
}

.loading-dots div:nth-child(1) { animation-delay: -0.32s; }
.loading-dots div:nth-child(2) { animation-delay: -0.16s; }
.loading-dots div:nth-child(3) { animation-delay: 0s; }

@keyframes pulse-dot {
    0%, 80%, 100% { 
        opacity: 0.3;
        transform: scale(0.8);
    }
    40% { 
        opacity: 1;
        transform: scale(1);
    }
}

/* Fallback spinner for compatibility */
.spinner-border {
    width: 3rem;
    height: 3rem;
    border: 0.25em solid #e9ecef;
    border-right-color: #007bff;
    border-radius: 50%;
    animation: spinner-border 0.75s linear infinite;
}

@keyframes spinner-border {
    to { transform: rotate(360deg); }
}

/* Loading text animation */
.loading-text {
    color: #999;
    font-size: 14px;
    font-weight: 400;
    animation: pulse-text 1.5s ease-in-out infinite;
}

@keyframes pulse-text {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

#load-more-btn {
    margin: 20px 0;
    padding: 12px 30px;
    font-size: 16px;
    transition: all 0.3s ease;
}

#load-more-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

#end-message {
    padding: 25px;
    text-align: center;
    background: rgba(0,0,0,0.02);
    border-radius: 8px;
    margin: 20px auto;
    max-width: 300px;
    font-style: italic;
    color: #999;
    border: 1px solid rgba(0,0,0,0.03);
}

#end-message::before {
    content: "✓";
    display: block;
    font-size: 24px;
    color: #28a745;
    margin-bottom: 10px;
    font-style: normal;
    font-weight: bold;
}

/* Smooth animations for new articles */
.news-link {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Error message styling */
.infinite-scroll-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 0.375rem;
    margin: 20px auto;
    max-width: 600px;
}

/* Loading state for manual button */
#load-more-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #loading-indicator {
        padding: 30px 20px;
        margin: 15px auto;
        max-width: 280px;
    }
    
    .loading-dots {
        width: 60px;
        height: 18px;
    }
    
    .loading-dots div {
        width: 10px;
        height: 10px;
    }
    
    .loading-dots div:nth-child(1) { left: 6px; }
    .loading-dots div:nth-child(2) { left: 6px; }
    .loading-dots div:nth-child(3) { left: 24px; }
    .loading-dots div:nth-child(4) { left: 42px; }
    
    @keyframes loading-dots2 {
        0% { transform: translateY(-50%) translateX(0px) scale(1); }
        100% { transform: translateY(-50%) translateX(18px) scale(1); }
    }
    
    .loading-text {
        font-size: 13px;
    }
    
    .spinner-border {
        width: 2rem;
        height: 2rem;
    }
    
    #load-more-btn {
        width: 100%;
        margin: 15px 0;
    }
    
    #end-message {
        padding: 25px 15px;
        margin: 15px auto;
        max-width: 280px;
        font-size: 14px;
    }
}

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}

/* News container improvements */
#news-container {
    min-height: 400px;
}

/* Prevent layout shifts during loading */
#loading-indicator {
    min-height: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Smooth transitions for all loading elements */
#loading-indicator, #end-message {
    will-change: opacity, transform;
}

/* Animation for new content */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.news-article-new {
    animation: fadeInUp 0.5s ease forwards;
}