/**
 * Shakti Loading Styles - Consistent loading component styles
 * Provides unified visual design for all loading states across the application
 */

/* =================================================================
   BASE LOADING COMPONENTS
   ================================================================= */

/* Loading Container */
.shakti-loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    text-align: center;
    min-height: 120px;
}

/* Spinner Base */
.shakti-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e5e7eb;
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    animation: shakti-spin 1s linear infinite;
    margin-bottom: 1rem;
}

.shakti-spinner-large {
    width: 60px;
    height: 60px;
    border-width: 6px;
}

.shakti-spinner-small {
    width: 20px;
    height: 20px;
    border-width: 2px;
    margin-bottom: 0.5rem;
}

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

/* Loading Message */
.shakti-loading-message {
    color: #6b7280;
    font-size: 16px;
    font-weight: 500;
    line-height: 1.5;
    margin: 0;
}

/* =================================================================
   BUTTON LOADING STATES
   ================================================================= */

.shakti-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
    cursor: not-allowed !important;
}

.shakti-loading:hover {
    opacity: 0.7 !important;
    transform: none !important;
}

/* Button specific loading styles */
button.shakti-loading {
    background-color: #9ca3af !important;
    border-color: #9ca3af !important;
    color: #ffffff !important;
}

/* =================================================================
   PROGRESS LOADING
   ================================================================= */

.shakti-progress-container {
    padding: 1.5rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin: 1rem 0;
}

.shakti-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.shakti-progress-text {
    color: #374151;
    font-size: 16px;
    font-weight: 500;
    flex: 1;
}

.shakti-progress-percent {
    color: #3b82f6;
    font-size: 16px;
    font-weight: 600;
    margin-left: 1rem;
}

.shakti-progress-track {
    width: 100%;
    height: 8px;
    background-color: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}

.shakti-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6 0%, #1d4ed8 100%);
    border-radius: 4px;
    transition: width 0.3s ease-in-out;
    position: relative;
}

/* Progress bar animation */
.shakti-progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.3) 50%,
        transparent 100%
    );
    animation: shakti-progress-shimmer 2s infinite;
}

@keyframes shakti-progress-shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* =================================================================
   PAGE LOADING OVERLAY
   ================================================================= */

.shakti-page-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.shakti-page-loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 2rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* =================================================================
   TIMEOUT MESSAGE
   ================================================================= */

.shakti-timeout-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    text-align: center;
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: 8px;
    margin: 1rem 0;
}

.shakti-timeout-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.shakti-timeout-message {
    color: #92400e;
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.shakti-timeout-subtext {
    color: #a16207;
    font-size: 14px;
    line-height: 1.5;
}

/* =================================================================
   LOADING TYPE VARIATIONS
   ================================================================= */

/* Translation Loading */
.shakti-loading-translation .shakti-spinner {
    border-top-color: #10b981;
}

.shakti-loading-translation .shakti-loading-message {
    color: #065f46;
}

/* Analysis Loading */
.shakti-loading-analysis .shakti-spinner {
    border-top-color: #8b5cf6;
}

.shakti-loading-analysis .shakti-loading-message {
    color: #5b21b6;
}

/* Story Loading */
.shakti-loading-story .shakti-spinner {
    border-top-color: #f59e0b;
}

.shakti-loading-story .shakti-loading-message {
    color: #92400e;
}

/* Progress Type Variations */
.shakti-progress-story .shakti-progress-bar {
    background: linear-gradient(90deg, #f59e0b 0%, #d97706 100%);
}

.shakti-progress-translation .shakti-progress-bar {
    background: linear-gradient(90deg, #10b981 0%, #059669 100%);
}

.shakti-progress-analysis .shakti-progress-bar {
    background: linear-gradient(90deg, #8b5cf6 0%, #7c3aed 100%);
}

/* =================================================================
   RESPONSIVE DESIGN
   ================================================================= */

@media (max-width: 768px) {
    .shakti-loading-container {
        padding: 1.5rem 1rem;
        min-height: 100px;
    }

    .shakti-spinner {
        width: 32px;
        height: 32px;
        border-width: 3px;
    }

    .shakti-spinner-large {
        width: 48px;
        height: 48px;
        border-width: 4px;
    }

    .shakti-loading-message {
        font-size: 14px;
    }

    .shakti-progress-container {
        padding: 1rem;
    }

    .shakti-progress-text,
    .shakti-progress-percent {
        font-size: 14px;
    }

    .shakti-progress-track {
        height: 6px;
    }

    .shakti-page-loading-content {
        padding: 1.5rem;
        margin: 1rem;
    }

    .shakti-timeout-container {
        padding: 1.5rem 1rem;
    }

    .shakti-timeout-icon {
        font-size: 2.5rem;
    }
}

/* =================================================================
   ACCESSIBILITY
   ================================================================= */

/* Screen reader support */
.shakti-loading-container[aria-live="polite"],
.shakti-progress-container[aria-live="polite"],
.shakti-timeout-container[aria-live="assertive"] {
    /* Ensure screen readers announce loading state changes */
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .shakti-spinner {
        animation: none;
        border-top-color: transparent;
        border-right-color: #3b82f6;
    }

    .shakti-progress-bar {
        transition: none;
    }

    .shakti-progress-bar::after {
        animation: none;
        display: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .shakti-spinner {
        border-color: #000000;
        border-top-color: #ffffff;
    }

    .shakti-loading-message {
        color: #000000;
        font-weight: 600;
    }

    .shakti-progress-track {
        background-color: #000000;
        border: 1px solid #ffffff;
    }

    .shakti-progress-bar {
        background: #ffffff;
    }
}

/* =================================================================
   INTEGRATION WITH EXISTING STYLES
   ================================================================= */

/* Ensure compatibility with existing loading classes */
.loading.shakti-loading-container {
    /* Override any conflicting styles from existing .loading class */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Maintain compatibility with existing button loading */
.translate-btn.shakti-loading,
.listen-btn.shakti-loading,
.play-btn.shakti-loading,
.auth-btn.shakti-loading {
    /* Ensure proper loading state for existing button classes */
    opacity: 0.7;
    pointer-events: none;
}

/* =================================================================
   DARK MODE SUPPORT (if needed in future)
   ================================================================= */

@media (prefers-color-scheme: dark) {
    .shakti-loading-container {
        background: #1f2937;
    }

    .shakti-loading-message {
        color: #d1d5db;
    }

    .shakti-spinner {
        border-color: #4b5563;
        border-top-color: #60a5fa;
    }

    .shakti-progress-container {
        background: #1f2937;
        border-color: #4b5563;
    }

    .shakti-progress-text {
        color: #f3f4f6;
    }

    .shakti-progress-track {
        background-color: #4b5563;
    }

    .shakti-page-loading {
        background: rgba(31, 41, 55, 0.9);
    }

    .shakti-page-loading-content {
        background: #1f2937;
        color: #f3f4f6;
    }
}




