/* ============================================
   FriendRewind Loading States CSS
   Provides consistent loading states across the app
   ============================================ */

/* Basic Spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #1E90FF;
    animation: spin 0.8s linear infinite;
}

.spinner-lg {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

.spinner-sm {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

.spinner-dark {
    border-color: rgba(0, 0, 0, 0.1);
    border-top-color: #333;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Centered Loading Container */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100px;
    padding: 20px;
}

.loading-container .spinner {
    margin-bottom: 10px;
}

.loading-text {
    color: #666;
    font-size: 14px;
    margin-top: 10px;
}

/* Skeleton Loaders */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 14px;
    margin-bottom: 8px;
}

.skeleton-title {
    height: 24px;
    margin-bottom: 12px;
    width: 60%;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.skeleton-box {
    height: 100px;
    margin-bottom: 10px;
}

/* Inline Loading States */
.loading-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.loading-inline .spinner {
    margin: 0;
}

/* Button Loading States */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

.btn-loading.btn-dark::after {
    border-color: rgba(0, 0, 0, 0.1);
    border-top-color: #333;
}

/* Overlay Loading */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: inherit;
}

.loading-overlay.dark {
    background: rgba(0, 0, 0, 0.8);
}

/* Pulse Animation for Loading Items */
.loading-pulse {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Loading Dots */
.loading-dots {
    display: inline-block;
    position: relative;
    width: 60px;
    height: 14px;
}

.loading-dots div {
    position: absolute;
    top: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #1E90FF;
    animation-timing-function: cubic-bezier(0, 1, 1, 0);
}

.loading-dots div:nth-child(1) {
    left: 6px;
    animation: loading-dots1 0.6s infinite;
}

.loading-dots div:nth-child(2) {
    left: 6px;
    animation: loading-dots2 0.6s infinite;
}

.loading-dots div:nth-child(3) {
    left: 26px;
    animation: loading-dots2 0.6s infinite;
}

.loading-dots div:nth-child(4) {
    left: 45px;
    animation: loading-dots3 0.6s infinite;
}

@keyframes loading-dots1 {
    0% {
        transform: scale(0);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes loading-dots3 {
    0% {
        transform: scale(1);
    }
    100% {
        transform: scale(0);
    }
}

@keyframes loading-dots2 {
    0% {
        transform: translate(0, 0);
    }
    100% {
        transform: translate(19px, 0);
    }
}

/* Message Loading States */
.messages-loading {
    text-align: center;
    padding: 20px;
    color: #999;
}

.message-sending {
    opacity: 0.6;
    position: relative;
}

.message-sending::after {
    content: '';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: #1E90FF;
    animation: spin 0.8s linear infinite;
}

/* Friend List Loading */
.friends-loading {
    padding: 20px;
}

.friend-skeleton {
    display: flex;
    align-items: center;
    padding: 10px;
    margin-bottom: 10px;
}

.friend-skeleton .skeleton-avatar {
    margin-right: 12px;
}

.friend-skeleton .skeleton-info {
    flex: 1;
}

.friend-skeleton .skeleton-name {
    height: 16px;
    width: 120px;
    margin-bottom: 6px;
}

.friend-skeleton .skeleton-status {
    height: 12px;
    width: 80px;
}

/* Error States */
.loading-error {
    color: #d32f2f;
    text-align: center;
    padding: 20px;
}

.loading-error .error-icon {
    font-size: 48px;
    margin-bottom: 10px;
}

.loading-error .error-message {
    font-size: 14px;
    margin-bottom: 15px;
}

.loading-error .retry-button {
    background: #d32f2f;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
}

.loading-error .retry-button:hover {
    background: #b71c1c;
}

/* Fade In Animation */
.fade-in-up {
    animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
