/* History Manager Styles */

/* Load More Button */
.load-more-history-btn {
    width: 100%;
    padding: 12px 16px;
    margin: 8px 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.load-more-history-btn:hover:not(:disabled) {
    background: var(--bg-tertiary);
    border-color: var(--accent-color);
    color: var(--text-primary);
}

.load-more-history-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.load-more-history-btn:disabled::after {
    content: '';
    width: 12px;
    height: 12px;
    border: 2px solid transparent;
    border-top: 2px solid var(--text-secondary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 8px;
}

/* Conversation Status Indicators */
.conversation-status {
    font-size: 14px;
    margin-right: 6px;
    opacity: 0.8;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
}

.conversation-status.error {
    color: #ef4444;
}

.conversation-status.attachments {
    opacity: 0.6;
    color: #6b7280;
}

/* Loading spinner for main loading state only */
.loading-spinner-modern {
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 8px;
    font-size: 16px;
    color: #3b82f6;
    animation: rotateProcessing 1s linear infinite;
}

@keyframes rotateProcessing {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Conversation List Enhancements */
.conversation-list {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.conversation-list::-webkit-scrollbar {
    width: 6px;
}

.conversation-list::-webkit-scrollbar-track {
    background: transparent;
}

.conversation-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.conversation-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Conversation Item Loading State */
.conversation-item.loading {
    opacity: 0.6;
    pointer-events: none;
}

.conversation-item.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 40px;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    border: 2px solid transparent;
    border-top: 2px solid var(--text-secondary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* History Error States */
.history-error {
    padding: 16px;
    margin: 8px 0;
    background: var(--error-bg, #fee);
    border: 1px solid var(--error-border, #fcc);
    border-radius: 8px;
    color: var(--error-text, #c33);
    font-size: 14px;
    text-align: center;
}

.history-empty {
    padding: 24px 16px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
}

.history-empty svg {
    width: 32px;
    height: 32px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* Immediate Loading Animation */
.history-loading {
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
}

.loading-spinner-modern {
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 8px;
    font-size: 16px;
    color: #3b82f6;
    animation: rotateProcessing 1s linear infinite;
}

/* Fast conversation appearance */
.conversation-item {
    animation: slideInFast 0.2s ease-out;
}

@keyframes slideInFast {
    0% {
        opacity: 0;
        transform: translateX(-5px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Dark mode adjustments */
:root.dark .load-more-history-btn {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-secondary);
}

:root.dark .load-more-history-btn:hover:not(:disabled) {
    background: var(--bg-tertiary);
    border-color: var(--accent-color);
    color: var(--text-primary);
}

:root.dark .history-error {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

/* Animation for loading states */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Fade in animation for new history items */
.conversation-item.new {
    animation: fadeInSlide 0.3s ease-out;
}

@keyframes fadeInSlide {
    0% {
        opacity: 0;
        transform: translateX(-10px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Enhanced conversation meta with better spacing */
.conversation-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
    gap: 8px;
}

.conversation-time {
    font-size: 11px;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.conversation-delete {
    opacity: 0;
    transition: opacity 0.2s ease;
    flex-shrink: 0;
}

.conversation-item:hover .conversation-delete {
    opacity: 1;
}

/* Better responsive behavior for sidebar */
@media (max-width: 768px) {
    .conversation-list {
        max-height: calc(100vh - 160px);
    }

    .load-more-history-btn {
        padding: 10px 14px;
        font-size: 13px;
    }

    .conversation-delete {
        opacity: 1; /* Always visible on mobile */
    }
}

/* Loading shimmer effect for conversation items */
.conversation-item.loading-shimmer {
    background: linear-gradient(90deg,
        var(--bg-secondary) 25%,
        var(--bg-tertiary) 50%,
        var(--bg-secondary) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Success state for newly stored conversations */
.conversation-item.just-added {
    border-left: 3px solid var(--accent-color);
    animation: highlightNew 2s ease-out;
}

@keyframes highlightNew {
    0% {
        background: var(--accent-color-light, rgba(99, 102, 241, 0.1));
    }
    100% {
        background: transparent;
    }
}