/**
 * DARKCOAL Update Manager Styles
 * Version: 2.0.0 - Simplified Virtual Scroll
 */

/* ============================================
 * 🚀 SIMPLIFIED VIRTUAL SCROLL STYLES
 * Windowed message loading with "Load More" buttons
 * ============================================ */

/* Load more buttons at top/bottom of chat */
.virtual-scroll-load-btn {
    width: 100%;
    padding: 12px 16px;
    background: rgba(124, 58, 237, 0.15);
    border: 1px solid rgba(124, 58, 237, 0.3);
    border-radius: 8px;
    color: #a78bfa;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 8px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.virtual-scroll-load-btn:hover {
    background: rgba(124, 58, 237, 0.25);
    border-color: rgba(124, 58, 237, 0.5);
    transform: translateY(-1px);
}

.virtual-scroll-load-btn:active {
    transform: translateY(0);
}

/* Loading state */
.virtual-scroll-load-btn.loading {
    opacity: 0.6;
    pointer-events: none;
    cursor: not-allowed;
}

/* Jump to bottom button */
.jump-to-bottom-btn {
    position: fixed;
    bottom: 100px;
    right: 20px;
    background: rgba(124, 58, 237, 0.9);
    border: 2px solid rgba(167, 139, 250, 0.5);
    border-radius: 24px;
    padding: 10px 20px;
    color: white;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 100;
}

.jump-to-bottom-btn:hover {
    background: rgba(124, 58, 237, 1);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.jump-to-bottom-btn.hidden {
    display: none !important;
}

/* Message count badge on jump button */
.jump-to-bottom-count {
    background: #f472b6;
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

/* Chat container styles for virtual scroll */
#chat-container {
    /* Ensure smooth scrolling */
    scroll-behavior: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Old virtual scroll styles - deprecated but kept for compatibility */
.virtual-scroll-spacer-top,
.virtual-scroll-spacer-bottom {
    width: 100%;
    background: transparent;
    pointer-events: none;
}

/* ============================================
 * END SIMPLIFIED VIRTUAL SCROLL STYLES
 * ============================================ */

/* ============================================
 * 🚀 MESSAGE ELEMENT POOL STYLES (Optional)
 * Object pooling for DOM element reuse
 * ============================================ */

/* Pooled message elements - ready for reuse */
.message-wrapper[data-pooled="true"] {
    will-change: transform, opacity;
}

/* Pool element parts - reusable structure */
[data-pool-part] {
    transition: none;
}

[data-pool-part="messageContent"] {
    min-height: 0;
}

[data-pool-part="avatar"] {
    display: flex;
    align-items: center;
    justify-content: center;
}

[data-pool-part="nameLabel"] {
    /* Reset name label for reuse */
    min-height: 0;
}

/* Pool statistics display (for debugging) */
.pool-stats-debug {
    position: fixed;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: #10b981;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-family: monospace;
    z-index: 9998;
    pointer-events: none;
}

.pool-stats-debug .stat-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.pool-stats-debug .stat-label {
    color: #9ca3af;
}

.pool-stats-debug .stat-value {
    color: #10b981;
}

.pool-stats-debug .stat-highlight {
    color: #f59e0b;
}

/* ============================================
 * END MESSAGE ELEMENT POOL STYLES
 * ============================================ */

/* ============================================
 * 🚀 PHASE 4: IMAGE LAZY LOADING STYLES
 * ============================================ */

/* Placeholder state for lazy images */
.lazy-image-placeholder {
    background: linear-gradient(135deg, #374151 0%, #1f2937 100%);
    min-height: 100px;
    min-width: 100px;
    opacity: 0.7;
    transition: opacity 0.3s ease, background 0.3s ease;
}

/* Loading animation for placeholder */
.lazy-image-placeholder::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 2px solid #4b5563;
    border-top-color: #7c3aed;
    border-radius: 50%;
    animation: lazyImageSpin 0.8s linear infinite;
    opacity: 0.5;
}

@keyframes lazyImageSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Loaded state for lazy images */
.lazy-image-loaded {
    opacity: 1;
    animation: lazyImageFadeIn 0.3s ease-out;
}

@keyframes lazyImageFadeIn {
    from { opacity: 0.7; }
    to { opacity: 1; }
}

/* Error state for failed lazy images */
.lazy-image-error {
    background: linear-gradient(135deg, #7f1d1d 0%, #450a0a 100%);
    opacity: 0.5;
}

/* ============================================
 * END IMAGE LAZY LOADING STYLES
 * ============================================ */

/* ============================================
 * 🚀 PHASE 4: ENHANCED SAVE QUEUE STYLES
 * ============================================ */

/* Save indicator (optional visual feedback) */
.save-indicator {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: #10b981;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 12px;
    font-family: monospace;
    z-index: 9997;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.save-indicator.active {
    opacity: 1;
}

.save-indicator.critical {
    color: #f59e0b;
    border: 1px solid #f59e0b;
}

/* ============================================
 * END ENHANCED SAVE QUEUE STYLES
 * ============================================ */

/* Update Notification Banner */
.update-notification {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
    color: white;
    padding: 16px 24px;
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.4);
    transform: translateY(-100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.update-notification.show {
    transform: translateY(0);
}

.update-notification-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    max-width: 1200px;
    margin: 0 auto;
}

.update-icon {
    font-size: 24px;
    line-height: 1;
}

.update-icon.spinning {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.update-message {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.update-message strong {
    font-size: 16px;
    font-weight: 600;
}

.update-message span {
    font-size: 14px;
    opacity: 0.9;
}

.update-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.update-btn {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.update-btn.update-now {
    background: white;
    color: #7c3aed;
}

.update-btn.update-now:hover {
    background: #f3f4f6;
    transform: translateY(-1px);
}

.update-btn.update-later {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.update-btn.update-later:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Mobile responsive */
@media (max-width: 640px) {
    .update-notification {
        padding: 12px 16px;
    }
    
    .update-notification-content {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
    
    .update-message {
        text-align: center;
    }
    
    .update-actions {
        margin-left: 0;
        width: 100%;
        justify-content: center;
    }
    
    .update-btn {
        flex: 1;
    }
}

/* Version Display in Settings */
.version-display {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(124, 58, 237, 0.1);
    border-radius: 12px;
    border: 1px solid rgba(124, 58, 237, 0.2);
}

.version-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.version-info {
    flex: 1;
}

.version-label {
    font-size: 12px;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.version-number {
    font-size: 16px;
    font-weight: 600;
    color: #e2e8f0;
}

.version-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 500;
}

.version-status.up-to-date {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

.version-status.update-available {
    background: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
}

.version-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.version-status.update-available .version-status-dot {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Check for updates button */
.check-updates-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 12px;
}

.check-updates-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4);
}

.check-updates-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.check-updates-btn .spinner {
    animation: spin 1s linear infinite;
}
