/* Custom animations and styles */
@keyframes bounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* Smooth scrolling for messages */
#messages-container {
    scroll-behavior: smooth;
}

/* Message animations */
.message-bubble {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Typing indicator */
.animate-bounce {
    animation: bounce 1.4s infinite ease-in-out;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Dark mode scrollbar */
.dark ::-webkit-scrollbar-track {
    background: #1f2937;
}

.dark ::-webkit-scrollbar-thumb {
    background: #4b5563;
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

/* Loading spinner for HTMX requests */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-block;
}

/* Hide default icons when loading */
.htmx-request #refresh-icon {
    display: none;
}

/* Smooth transitions for pattern frequency bars */
.pattern-frequency-bar {
    transition: width 0.6s ease-in-out;
}

/* Hover effects for insight cards */
.insight-card {
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.insight-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* Pulse animation for important elements */
.pulse-gentle {
    animation: pulse-gentle 2s infinite;
}

@keyframes pulse-gentle {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
}

/* Custom progress bars with gradients */
.progress-bar-red {
    background: linear-gradient(90deg, #ef4444 0%, #dc2626 100%);
}

.progress-bar-green {
    background: linear-gradient(90deg, #10b981 0%, #059669 100%);
}

.progress-bar-blue {
    background: linear-gradient(90deg, #3b82f6 0%, #2563eb 100%);
}

.progress-bar-purple {
    background: linear-gradient(90deg, #8b5cf6 0%, #7c3aed 100%);
}

/* Responsive text scaling */
@media (max-width: 640px) {
    .insights-title {
        font-size: 1.875rem;
    }
    
    .insights-subtitle {
        font-size: 0.875rem;
    }
}

/* Dark mode improvements */
@media (prefers-color-scheme: dark) {
    .insight-card:hover {
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    }
}

/* Animation for trend icons */
.trend-icon {
    transition: transform 0.2s ease-in-out;
}

.trend-icon:hover {
    transform: scale(1.1);
}

/* Custom scrollbar for long lists */
.custom-scrollbar {
    scrollbar-width: thin;
    scrollbar-color: rgba(156, 163, 175, 0.5) transparent;
}

.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background-color: rgba(156, 163, 175, 0.5);
    border-radius: 3px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background-color: rgba(156, 163, 175, 0.7);
}

/* Fade-in animation for new content */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Loading state overlay */
.loading-overlay {
    position: relative;
}

.loading-overlay::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: none;
    z-index: 10;
}

.loading-overlay.htmx-request::before {
    display: block;
}

/* Skeleton loading animations */
.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: .5;
    }
}

/* Enhanced skeleton animations */
.skeleton-wave {
    position: relative;
    overflow: hidden;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    background-size: 200% 100%;
    animation: wave 1.5s infinite;
}

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

/* Cache indicator styles */
.cache-indicator {
    border-left: 4px solid #3b82f6;
}

.fresh-indicator {
    border-left: 4px solid #10b981;
}

/* Refresh button animations */
.refresh-button {
    transition: all 0.2s ease-in-out;
}

.refresh-button:hover {
    transform: scale(1.05);
}

.refresh-button:active {
    transform: scale(0.95);
}

/* Loading dots animation */
.loading-dots::after {
    content: '';
    animation: dots 2s infinite;
}

@keyframes dots {
    0%, 20% {
        content: '';
    }
    40% {
        content: '.';
    }
    60% {
        content: '..';
    }
    80%, 100% {
        content: '...';
    }
}

/* Smooth content transitions */
.insights-content {
    animation: slideInUp 0.4s ease-out;
}

@keyframes slideInUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Error state styles */
.error-state {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border: 2px dashed #f87171;
}

/* Success state styles */
.success-state {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border: 2px solid #22c55e;
}

/* Loading state enhancements */
.loading-backdrop {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(2px);
}

.dark .loading-backdrop {
    background: rgba(17, 24, 39, 0.95);
}
