/**
 * CodeIQ - Animation Styles
 * Enhanced loading animations and micro-interactions
 */

/* ==================== LOADING ANIMATIONS ==================== */

.enhanced-loading {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    max-width: 800px;
    margin: 0 auto;
    animation: fadeIn 0.5s ease-out;
}

/* Loading Header */
.loading-header {
    text-align: center;
    padding: var(--space-4) 0;
    background: linear-gradient(135deg, rgba(196, 87, 106, 0.03) 0%, rgba(168, 85, 247, 0.03) 100%);
    border-radius: var(--radius-xl);
    margin-bottom: var(--space-3);
    border: 1px solid rgba(196, 87, 106, 0.1);
}

.client-name {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    margin-bottom: var(--space-3);
    color: var(--text-primary);
    font-style: normal;
    letter-spacing: -0.02em;
}

.platform-logo-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: var(--space-2);
}

.platform-logo {
    height: 32px;
    max-width: 180px;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

/* Fallback badge if logo doesn't load */
.platform-logo-container .platform-badge {
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-full);
    font-size: var(--font-size-sm);
    font-weight: 500;
    text-transform: capitalize;
}

/* Progress Section */
.progress-section {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: var(--space-5);
    align-items: center;
    background: white;
    padding: var(--space-4);
    border-radius: var(--radius-xl);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

/* Circular Progress */
.progress-circle {
    position: relative;
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.progress-bg {
    fill: none;
    stroke: var(--gray-200);
    stroke-width: 8;
}

.progress-fill {
    fill: none;
    stroke: var(--primary-500);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 339.29; /* 2 * π * 54 */
    stroke-dashoffset: 339.29;
    transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.3));
}

.progress-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.percentage {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-600);
    line-height: 1;
    margin-bottom: var(--space-1);
    font-style: normal;
}

.phase-name {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    font-weight: 500;
    font-style: normal;
    text-transform: capitalize;
}

/* Progress Details */
.progress-details {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.current-phase {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.phase-icon {
    font-size: var(--font-size-3xl);
    animation: bounce 2s infinite;
}

.phase-info {
    flex: 1;
}

.phase-title {
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-1);
    font-style: normal;
}

.phase-message {
    font-size: var(--font-size-base);
    color: var(--text-secondary);
    line-height: 1.6;
    font-style: normal;
    font-weight: 400;
}

.time-estimate {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--font-size-sm);
}

.estimate-label {
    color: var(--text-secondary);
}

.estimate-value {
    color: var(--text-primary);
    font-weight: var(--font-weight-medium);
}

/* Loading Content */
.loading-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
}

/* Fact Card */
.fact-card {
    background: linear-gradient(135deg, #ffffff 0%, #fdf5f7 100%);
    border-radius: var(--radius-xl);
    padding: var(--space-4);
    box-shadow: 0 2px 12px rgba(196, 87, 106, 0.08);
    border-left: 4px solid var(--primary-500);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.fact-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(196, 87, 106, 0.12);
}

.fact-icon {
    color: var(--magenta-500);
    margin-bottom: var(--space-3);
}

.fact-icon svg {
    display: block;
}

.fact-card h4 {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-3);
    font-style: normal;
}

.fact-text {
    font-size: var(--font-size-base);
    color: var(--text-secondary);
    line-height: 1.6;
    transition: opacity 0.3s ease-in-out;
    font-style: normal;
}

/* Progress Steps */
.progress-steps {
    background: #ffffff;
    border-radius: var(--radius-xl);
    padding: var(--space-4);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.progress-steps:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.steps-header h4 {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-4);
    font-style: normal;
}

.steps-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.step {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
}

.step.completed {
    background-color: var(--success-50);
    border-left: 3px solid var(--success-400);
}

.step.active {
    background-color: var(--magenta-50);
    border-left: 3px solid var(--magenta-500);
    animation: glow 2s infinite;
}

.step.pending {
    background-color: var(--gray-50);
    border-left: 3px solid var(--gray-300);
}

.step-icon {
    font-size: var(--font-size-lg);
    width: 24px;
    text-align: center;
}

.step-content {
    flex: 1;
}

.step-title {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--space-1);
    font-style: normal;
}

.step-status {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    font-style: normal;
}

.step-indicator {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
}

.step.completed .step-indicator {
    color: var(--success-600);
}

.step.active .step-indicator {
    color: var(--magenta-600);
}

/* Spinner for active steps - scoped to step indicators */
.step .spinner {
    width: 12px;
    height: 12px;
    border: 2px solid var(--gray-300);
    border-top: 2px solid var(--primary-500);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Loading Footer */
.loading-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-4) 0;
    border-top: 1px solid var(--border-light);
}

.processing-stats {
    display: flex;
    gap: var(--space-6);
}

.stat {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--font-size-sm);
}

.stat-label {
    color: var(--text-secondary);
}

.stat-value {
    color: var(--text-primary);
    font-weight: var(--font-weight-medium);
    min-width: 24px;
    text-align: center;
}

.cancel-btn {
    padding: var(--space-2) var(--space-4);
    background-color: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.cancel-btn:hover {
    background-color: var(--error-50);
    color: var(--error-600);
    border-color: var(--error-300);
}

/* ==================== ERROR STATES ==================== */

.error-state {
    animation: fadeIn 0.5s ease-out;
}

.error-details {
    background-color: var(--bg-secondary);
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--error-500);
}

.error-message {
    margin-bottom: var(--space-6);
}

.error-message h3 {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
    color: var(--error-600);
    margin-bottom: var(--space-3);
}

.error-message p {
    font-size: var(--font-size-base);
    color: var(--text-secondary);
    margin-bottom: var(--space-4);
    line-height: 1.6;
}

.error-time {
    font-size: var(--font-size-sm);
    color: var(--text-tertiary);
    font-style: italic;
}

.error-actions {
    display: flex;
    gap: var(--space-4);
    flex-wrap: wrap;
}

/* ==================== WELCOME SCREEN ==================== */

.welcome-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    animation: fadeIn 0.8s ease-out;
}

.welcome-content {
    text-align: center;
    max-width: 600px;
    padding: var(--space-8);
}

.welcome-icon {
    font-size: 4rem;
    margin-bottom: var(--space-6);
    animation: bounce 3s infinite;
}

.welcome-content h2 {
    font-size: var(--font-size-3xl);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    margin-bottom: var(--space-4);
}

.welcome-content p {
    font-size: var(--font-size-lg);
    color: var(--text-secondary);
    margin-bottom: var(--space-8);
    line-height: 1.6;
}

.welcome-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-6);
    margin-bottom: var(--space-8);
}

.feature {
    text-align: center;
    padding: var(--space-6);
    background-color: var(--bg-secondary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
}

.feature:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.feature-icon {
    font-size: var(--font-size-3xl);
    margin-bottom: var(--space-4);
}

.feature h3 {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.feature p {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ==================== ANIMATION KEYFRAMES ==================== */

@keyframes bounce {
    0%, 20%, 53%, 80%, 100% {
        transform: translate3d(0, 0, 0);
    }
    40%, 43% {
        transform: translate3d(0, -8px, 0);
    }
    70% {
        transform: translate3d(0, -4px, 0);
    }
    90% {
        transform: translate3d(0, -2px, 0);
    }
}

@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(59, 130, 246, 0.1);
    }
}

@keyframes pulse-ring {
    0% {
        transform: scale(0.8);
        opacity: 1;
    }
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

@keyframes progress-glow {
    0%, 100% {
        filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.3));
    }
    50% {
        filter: drop-shadow(0 0 16px rgba(59, 130, 246, 0.6));
    }
}

@keyframes post-button-glow-pulse {
    0%, 100% {
        box-shadow: 0 0 8px 2px rgba(139, 92, 246, 0.4);
    }
    50% {
        box-shadow: 0 0 16px 4px rgba(139, 92, 246, 0.6);
    }
}

@keyframes glow-rotate {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* ==================== RESPONSIVE ANIMATIONS ==================== */

@media (max-width: 768px) {
    .progress-section {
        grid-template-columns: 1fr;
        text-align: center;
        gap: var(--space-6);
    }
    
    .progress-circle {
        width: 120px;
        height: 120px;
        margin: 0 auto;
    }
    
    .loading-content {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }
    
    .loading-footer {
        flex-direction: column;
        gap: var(--space-4);
        text-align: center;
    }
    
    .processing-stats {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .welcome-features {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .enhanced-loading {
        gap: var(--space-6);
    }
    
    .progress-circle {
        width: 100px;
        height: 100px;
    }
    
    .percentage {
        font-size: var(--font-size-xl);
    }
    
    .phase-title {
        font-size: var(--font-size-lg);
    }
    
    .fact-card,
    .progress-steps {
        padding: var(--space-4);
    }
    
    .welcome-content {
        padding: var(--space-4);
    }
    
    .welcome-icon {
        font-size: 3rem;
    }
    
    .welcome-content h2 {
        font-size: var(--font-size-2xl);
    }
}

/* ==================== REDUCED MOTION SUPPORT ==================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .progress-fill {
        transition: none;
    }
    
    .fact-text {
        transition: none;
    }
}