/**
 * Loading States - Skeletons och Spinners
 * För HDH plattformen
 */

/* ==================== SPINNER ==================== */
.spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top-color: #334155;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

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

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

/* ==================== LOADING OVERLAY ==================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.2s ease;
}

.loading-overlay-content {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    min-width: 200px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.loading-overlay-content .spinner {
    margin: 0 auto 1rem;
}

.loading-overlay-text {
    color: #1e293b;
    font-weight: 500;
    font-size: 1rem;
}

/* ==================== SKELETON SCREENS ==================== */
.skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e0e0e0 50%,
        #f0f0f0 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Skeleton variants */
.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.skeleton-text-lg {
    height: 1.5rem;
    margin-bottom: 0.75rem;
}

.skeleton-title {
    height: 2rem;
    width: 60%;
    margin-bottom: 1rem;
}

.skeleton-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

.skeleton-avatar-lg {
    width: 80px;
    height: 80px;
    border-radius: 50%;
}

.skeleton-card {
    height: 200px;
    border-radius: 12px;
}

.skeleton-button {
    height: 40px;
    width: 120px;
    border-radius: 8px;
}

/* ==================== SKELETON DASHBOARD STATS ==================== */
.skeleton-stat-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.skeleton-stat-card .skeleton-text {
    height: 0.875rem;
    width: 60%;
    margin-bottom: 0.75rem;
}

.skeleton-stat-card .skeleton-value {
    height: 2.5rem;
    width: 40%;
    margin-bottom: 0.5rem;
}

/* ==================== SKELETON PROJECT CARD ==================== */
.skeleton-project-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 1rem;
}

.skeleton-project-card .skeleton-title {
    width: 70%;
    margin-bottom: 1rem;
}

.skeleton-project-card .skeleton-text {
    margin-bottom: 0.5rem;
}

.skeleton-project-card .skeleton-text:last-child {
    width: 40%;
}

/* ==================== SKELETON TABLE ==================== */
.skeleton-table {
    width: 100%;
    border-collapse: collapse;
}

.skeleton-table-row {
    border-bottom: 1px solid #e5e7eb;
}

.skeleton-table-cell {
    padding: 1rem;
}

.skeleton-table-cell .skeleton {
    height: 1rem;
}

/* ==================== INLINE LOADING ==================== */
.loading-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.loading-inline .spinner {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

/* ==================== BUTTON LOADING STATE ==================== */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid #ffffff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.btn-loading > * {
    opacity: 0;
}

/* ==================== CONTENT LOADING ==================== */
.content-loading {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 1rem;
}

.content-loading-text {
    color: #64748b;
    font-size: 0.875rem;
}

/* ==================== PULSE ANIMATION ==================== */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* ==================== FADE IN ANIMATION ==================== */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

/* ==================== DARK MODE ==================== */
body.dark-mode .skeleton {
    background: linear-gradient(
        90deg,
        #2d2d2d 25%,
        #3d3d3d 50%,
        #2d2d2d 75%
    );
    background-size: 200% 100%;
}

body.dark-mode .loading-overlay-content {
    background: #1f2937;
}

body.dark-mode .loading-overlay-text {
    color: #f9fafb;
}

body.dark-mode .skeleton-stat-card,
body.dark-mode .skeleton-project-card {
    background: #1f2937;
}

body.dark-mode .content-loading-text {
    color: #9ca3af;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    .loading-overlay-content {
        padding: 1.5rem;
        min-width: 150px;
    }
    
    .spinner {
        width: 32px;
        height: 32px;
    }
}

/* ==================== UTILITY CLASSES ==================== */
.loading-hidden {
    display: none !important;
}

.loading-visible {
    display: block !important;
}

/* ==================== SKELETON GRID ==================== */
.skeleton-grid {
    display: grid;
    gap: 1rem;
}

.skeleton-grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.skeleton-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.skeleton-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 768px) {
    .skeleton-grid-2,
    .skeleton-grid-3,
    .skeleton-grid-4 {
        grid-template-columns: 1fr;
    }
}


