/**
 * CodeIQ Loading Animation - Professional Command Center
 * Matches CodeIQ's "Mission Control" design system
 * Clean white backgrounds, high contrast typography, purple accents
 */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Inter:wght@400;500;600;700;800&display=swap');

/* ============================================
   CSS Variables - Command Center Palette
   ============================================ */
.enhanced-loading {
    /* Backgrounds - Clean & Professional */
    --load-bg-primary: #ffffff;
    --load-bg-secondary: #faf8f5;
    --load-bg-inset: #f5f2ed;
    --load-bg-elevated: #ffffff;

    /* Text - High Contrast */
    --load-text-primary: #1a1a1a;
    --load-text-secondary: #475569;
    --load-text-tertiary: #94a3b8;
    --load-text-muted: #c4c0b8;

    /* Accent - CodeIQ Purple (Strategic) */
    --load-accent: #9a4054;
    --load-accent-light: #8b2aad;
    --load-accent-subtle: rgba(154, 64, 84, 0.08);
    --load-accent-border: rgba(154, 64, 84, 0.2);

    /* Status Colors */
    --load-success: #059669;
    --load-success-bg: rgba(5, 150, 105, 0.08);
    --load-warning: #d97706;
    --load-info: #0284c7;

    /* Borders & Shadows */
    --load-border: #d4d0c8;
    --load-border-strong: #c4c0b8;
    --load-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --load-shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --load-shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);

    /* Geometry */
    --load-radius-sm: 4px;
    --load-radius-md: 6px;
    --load-radius-lg: 8px;
    --load-radius-xl: 12px;

    /* Typography */
    --load-font-display: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --load-font-mono: 'JetBrains Mono', 'SF Mono', monospace;
}

/* ============================================
   Main Container - Clean Professional Card
   ============================================ */
.enhanced-loading {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-width: 800px;
    margin: 0 auto;
    padding: 0;
    background: var(--load-bg-primary);
    border-radius: var(--load-radius-xl);
    border: 1px solid var(--load-border);
    box-shadow: var(--load-shadow-lg);
    overflow: hidden;
    animation: loadFadeIn 0.4s ease-out;
}

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

/* ============================================
   Loading Header - Client & Platform
   ============================================ */
.enhanced-loading .loading-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 24px 32px 20px;
    background: var(--load-bg-secondary);
    border-bottom: 1px solid var(--load-border);
}

.enhanced-loading .client-name {
    font-family: var(--load-font-display);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--load-text-primary);
    margin: 0;
    text-align: center;
}

.enhanced-loading .platform-logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 6px 16px;
    background: var(--load-bg-primary);
    border-radius: 100px;
    border: 1px solid var(--load-border);
}

.enhanced-loading .platform-logo {
    height: 20px;
    width: auto;
    max-width: 100px;
    object-fit: contain;
}

.enhanced-loading .platform-badge {
    font-family: var(--load-font-mono);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--load-accent);
    padding: 4px 10px;
    background: var(--load-accent-subtle);
    border-radius: 4px;
}

/* ============================================
   Progress Section - Central Focus
   ============================================ */
.enhanced-loading .progress-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    padding: 32px;
    background: var(--load-bg-primary);
}

/* Progress Circle - Clean & Professional */
.enhanced-loading .progress-circle {
    position: relative !important;
    width: 160px !important;
    height: 160px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: hidden !important; /* Contain all children */
}

.enhanced-loading .circular-progress {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.enhanced-loading .progress-bg {
    fill: none;
    stroke: var(--load-bg-inset);
    stroke-width: 8;
}

.enhanced-loading .progress-fill {
    fill: none;
    stroke: var(--load-accent);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 502.65; /* 2 * π * 80 */
    stroke-dashoffset: 502.65;
    transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.enhanced-loading .progress-content {
    position: absolute !important;
    inset: 0 !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    transform: none !important; /* Override animations.css translate */
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    gap: 2px !important;
    padding: 0 8px !important;
}

.enhanced-loading .percentage {
    font-family: var(--load-font-display) !important;
    font-size: 32px !important;
    font-weight: 600 !important;
    line-height: 1.1 !important;
    color: var(--load-text-primary) !important; /* #1a1a1a - dark text */
    letter-spacing: -0.01em !important;
    margin: 0 !important;
    padding: 0 !important;
}

.enhanced-loading .phase-name {
    font-family: var(--load-font-display) !important;
    font-size: 11px !important;
    font-weight: 500 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.08em !important;
    color: var(--load-accent) !important; /* #9a4054 - purple accent */
    margin-top: 6px !important;
    white-space: nowrap !important;
    display: block !important;
    line-height: 1.3 !important;
}

/* Prevent any child elements (like spinners) from appearing in phase-name */
.enhanced-loading .phase-name * {
    display: none !important;
}

/* Progress Details Panel */
.enhanced-loading .progress-details {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: 100%;
    max-width: 480px;
}

.enhanced-loading .current-phase {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: var(--load-bg-secondary);
    border-radius: var(--load-radius-lg);
    border: 1px solid var(--load-border);
    width: 100%;
}

.enhanced-loading .phase-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--load-accent-subtle);
    border-radius: var(--load-radius-md);
    color: var(--load-accent);
    flex-shrink: 0;
}

.enhanced-loading .phase-icon svg {
    width: 22px;
    height: 22px;
}

.enhanced-loading .phase-info {
    flex: 1;
    min-width: 0;
}

.enhanced-loading .phase-title {
    font-family: var(--load-font-display);
    font-size: 15px;
    font-weight: 600;
    color: var(--load-text-primary);
    margin-bottom: 2px;
}

.enhanced-loading .phase-message {
    font-family: var(--load-font-display);
    font-size: 13px;
    color: var(--load-text-secondary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.enhanced-loading .time-estimate {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--load-bg-inset);
    border-radius: var(--load-radius-md);
}

.enhanced-loading .estimate-label {
    font-family: var(--load-font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--load-text-tertiary);
}

.enhanced-loading .estimate-value {
    font-family: var(--load-font-mono);
    font-size: 12px;
    font-weight: 600;
    color: var(--load-text-primary);
}

/* ============================================
   Loading Content - Cards Grid
   ============================================ */
.enhanced-loading .loading-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    padding: 0 24px 24px;
    background: var(--load-bg-primary);
}

/* Fact Card */
.enhanced-loading .fact-card {
    background: var(--load-bg-secondary);
    border-radius: var(--load-radius-lg);
    padding: 20px;
    border: 1px solid var(--load-border);
    transition: border-color 0.2s ease;
}

.enhanced-loading .fact-card:hover {
    border-color: var(--load-accent-border);
}

.enhanced-loading .fact-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--load-accent-subtle);
    border-radius: var(--load-radius-md);
    margin-bottom: 12px;
    color: var(--load-accent);
}

.enhanced-loading .fact-icon svg {
    width: 18px;
    height: 18px;
}

.enhanced-loading .fact-content h4 {
    font-family: var(--load-font-mono);
    font-size: 10px;
    font-weight: 700;
    color: var(--load-accent);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.enhanced-loading .fact-text {
    font-family: var(--load-font-display);
    font-size: 13px;
    color: var(--load-text-secondary);
    line-height: 1.6;
    transition: opacity 0.3s ease;
    min-height: 60px;
}

/* Progress Steps */
.enhanced-loading .progress-steps {
    background: var(--load-bg-secondary);
    border-radius: var(--load-radius-lg);
    padding: 20px;
    border: 1px solid var(--load-border);
}

.enhanced-loading .steps-header h4 {
    font-family: var(--load-font-mono);
    font-size: 10px;
    font-weight: 700;
    color: var(--load-text-primary);
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.enhanced-loading .steps-header h4::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--load-accent);
    border-radius: 50%;
}

.enhanced-loading .steps-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.enhanced-loading .step {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--load-radius-md);
    transition: all 0.2s ease;
    background: transparent;
    border-left: 2px solid transparent;
}

.enhanced-loading .step.pending {
    opacity: 0.5;
    border-left-color: var(--load-border);
}

.enhanced-loading .step.active {
    background: var(--load-accent-subtle);
    border-left-color: var(--load-accent);
    opacity: 1;
}

.enhanced-loading .step.completed {
    opacity: 1;
    border-left-color: var(--load-success);
}

.enhanced-loading .step.completed .step-icon {
    color: var(--load-success);
}

.enhanced-loading .step-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--load-text-tertiary);
    flex-shrink: 0;
}

.enhanced-loading .step-icon svg {
    width: 16px;
    height: 16px;
}

.enhanced-loading .step.active .step-icon {
    color: var(--load-accent);
}

.enhanced-loading .step-content {
    flex: 1;
    min-width: 0;
}

.enhanced-loading .step-title {
    font-family: var(--load-font-display);
    font-size: 12px;
    font-weight: 600;
    color: var(--load-text-primary);
    margin-bottom: 1px;
}

.enhanced-loading .step.pending .step-title {
    color: var(--load-text-tertiary);
}

.enhanced-loading .step-status {
    font-family: var(--load-font-mono);
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--load-text-tertiary);
}

.enhanced-loading .step.active .step-status {
    color: var(--load-accent);
}

.enhanced-loading .step.completed .step-status {
    color: var(--load-success);
}

.enhanced-loading .step-indicator {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--load-font-display);
    font-size: 11px;
    font-weight: 700;
}

.enhanced-loading .step.completed .step-indicator {
    color: var(--load-success);
}

/* Spinner for active step */
.enhanced-loading .spinner {
    width: 14px !important;
    height: 14px !important;
    border: 2px solid var(--load-border) !important;
    border-top-color: var(--load-accent) !important; /* #9a4054 - purple */
    border-radius: 50% !important;
    animation: loadSpin 0.8s linear infinite !important;
}

@keyframes loadSpin {
    to { transform: rotate(360deg); }
}

/* ============================================
   Loading Footer - Stats Bar
   ============================================ */
.enhanced-loading .loading-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--load-bg-secondary);
    border-top: 1px solid var(--load-border);
}

.enhanced-loading .processing-stats {
    display: flex;
    gap: 32px;
}

.enhanced-loading .stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.enhanced-loading .stat-label {
    font-family: var(--load-font-mono);
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--load-text-tertiary);
}

.enhanced-loading .stat-value {
    font-family: var(--load-font-mono);
    font-size: 18px;
    font-weight: 700;
    color: var(--load-text-primary);
    min-width: 40px;
    transition: color 0.3s ease;
}

.enhanced-loading .stat-value.updating {
    color: var(--load-accent);
}

.enhanced-loading .cancel-section {
    display: flex;
    align-items: center;
}

.enhanced-loading .cancel-btn {
    font-family: var(--load-font-display);
    font-size: 12px;
    font-weight: 600;
    padding: 8px 16px;
    background: transparent;
    color: var(--load-text-secondary);
    border: 1px solid var(--load-border);
    border-radius: var(--load-radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
}

.enhanced-loading .cancel-btn:hover {
    background: rgba(220, 38, 38, 0.08);
    color: #dc2626;
    border-color: rgba(220, 38, 38, 0.3);
}

/* ============================================
   Hide Neural Particles (dark theme element)
   ============================================ */
.neural-particles {
    display: none;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 768px) {
    .enhanced-loading {
        margin: 12px;
        border-radius: var(--load-radius-lg);
    }

    .enhanced-loading .loading-header {
        padding: 20px 20px 16px;
    }

    .enhanced-loading .client-name {
        font-size: 18px;
    }

    .enhanced-loading .progress-section {
        padding: 24px 20px;
    }

    .enhanced-loading .progress-circle {
        width: 140px;
        height: 140px;
    }

    .enhanced-loading .percentage {
        font-size: 28px;
    }

    .enhanced-loading .loading-content {
        grid-template-columns: 1fr;
        padding: 0 16px 16px;
    }

    .enhanced-loading .current-phase {
        padding: 14px 16px;
    }

    .enhanced-loading .loading-footer {
        flex-direction: column;
        gap: 16px;
        padding: 16px;
        text-align: center;
    }

    .enhanced-loading .processing-stats {
        justify-content: center;
        gap: 24px;
    }
}

@media (max-width: 480px) {
    .enhanced-loading {
        margin: 8px;
    }

    .enhanced-loading .client-name {
        font-size: 16px;
    }

    .enhanced-loading .progress-circle {
        width: 120px;
        height: 120px;
    }

    .enhanced-loading .percentage {
        font-size: 24px;
    }

    .enhanced-loading .phase-name {
        font-size: 10px;
    }

    .enhanced-loading .fact-card,
    .enhanced-loading .progress-steps {
        padding: 16px;
    }

    .enhanced-loading .step {
        padding: 8px 10px;
    }

    .enhanced-loading .processing-stats {
        gap: 16px;
    }

    .enhanced-loading .stat-value {
        font-size: 16px;
    }
}

/* ============================================
   Reduced Motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .enhanced-loading,
    .enhanced-loading *,
    .enhanced-loading *::before,
    .enhanced-loading *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
