/* Custom animations and additional styles for recursive threading */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

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

.animate-spin {
    animation: spin 1s linear infinite;
}

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

/* Thread visualization */
.thread-comment {
    position: relative;
    transition: all 0.3s ease;
}

.thread-comment::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, #374151, transparent);
    opacity: 0.3;
}

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

/* Custom scrollbar for webkit browsers */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #1a1a1b;
}

::-webkit-scrollbar-thumb {
    background: #272729;
    border-radius: 4px;
}

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

/* Enhanced focus styles for accessibility */
button:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid #0079d3;
    outline-offset: 2px;
}

/* Thread depth indicators */
.thread-depth-0 { border-left-color: #0079d3; }
.thread-depth-1 { border-left-color: #10b981; }
.thread-depth-2 { border-left-color: #f59e0b; }
.thread-depth-3 { border-left-color: #8b5cf6; }
.thread-depth-4 { border-left-color: #ec4899; }
.thread-depth-5 { border-left-color: #ef4444; }

/* Responsive design for mobile threading */
@media (max-width: 640px) {
    html {
        font-size: 14px;
    }
    
    .thread-comment {
        margin-left: 0 !important;
        padding-left: 10px;
    }
    
    .thread-comment::before {
        left: 5px;
    }
}

/* Mobile horizontal scroll for deep threads */
@media (max-width: 768px) {
    .thread-container {
        overflow-x: auto;
        max-width: 100vw;
    }
    
    .thread-comment {
        min-width: 280px;
    }
}

/* Hover effects for thread navigation */
.thread-comment:hover {
    transform: translateX(2px);
}

/* Collapsed thread indicators */
.collapsed-indicator {
    background: linear-gradient(to right, #374151, transparent);
    border-radius: 4px;
    padding: 4px 8px;
    margin: 2px 0;
}

/* AI response styling */
.ai-response {
    background: linear-gradient(135deg, #065f46 0%, #064e3b 100%);
    border: 1px solid #10b981;
}

/* Thread navigation breadcrumbs */
.thread-breadcrumb {
    font-size: 0.75rem;
    color: #6b7280;
    padding: 2px 6px;
    background: rgba(55, 65, 81, 0.5);
    border-radius: 12px;
    margin: 0 2px;
}

/* Loading states for nested comments */
.comment-loading {
    background: linear-gradient(90deg, #272729 25%, #374151 50%, #272729 75%);
    background-size: 200% 100%;
    animation: loading-shimmer 1.5s infinite;
}

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

/* Ensure proper contrast for links */
a:hover {
    text-decoration: underline;
}

/* Deep thread warnings */
.depth-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid #f59e0b;
    border-radius: 6px;
    padding: 8px 12px;
    margin: 8px 0;
    font-size: 0.875rem;
}

/* Context-aware reply forms */
.reply-form {
    background: rgba(39, 39, 41, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    border: 1px solid #374151;
}

/* Thread expansion animations */
.thread-expand {
    animation: expandThread 0.3s ease-out;
}

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

/* Performance optimization for large threads */
.thread-virtualized {
    contain: layout style paint;
}