/* ============================================
   HKU Portal - Loading System v2.0
   
   İki tip loading:
   1. Full-page: Sayfa geçişleri, modül açılması
   2. Inline: Tablo, grafik, card içi yükleme
   
   Performans optimizasyonları:
   - GPU accelerated animasyonlar
   - will-change ile layer hint
   - Minimum repaint/reflow
   ============================================ */

/* =============================================
   CSS Variables - Kurumsal Renkler
   ============================================= */
:root {
    --hku-loading-primary: #003865;
    --hku-loading-secondary: #00a8e8;
    --hku-loading-accent: #00d4aa;
    --hku-loading-gold: #ffd700;
    --hku-loading-text: #ffffff;
    --hku-loading-overlay-bg: rgba(0, 56, 101, 0.92);
}

/* =============================================
   1. FULL-PAGE LOADING OVERLAY
   Modüllere tıklama, sayfa geçişleri
   ============================================= */
.hku-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--hku-loading-overlay-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease-out, visibility 0.25s ease-out;
    will-change: opacity, visibility;
}

.hku-loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Spinner Container */
.hku-loading-logo-container {
    position: relative;
    width: 120px;
    height: 120px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Logo - Gizli tutulabilir */
.hku-loading-logo {
    display: none;
}

/* Ana Spinner - Triple Ring */
.hku-loading-spinner {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid transparent;
    border-top-color: var(--hku-loading-secondary);
    border-right-color: var(--hku-loading-secondary);
    border-radius: 50%;
    animation: hku-spin 1s linear infinite;
    will-change: transform;
}

.hku-loading-spinner::before {
    content: '';
    position: absolute;
    top: 6px;
    left: 6px;
    right: 6px;
    bottom: 6px;
    border: 3px solid transparent;
    border-top-color: var(--hku-loading-accent);
    border-left-color: var(--hku-loading-accent);
    border-radius: 50%;
    animation: hku-spin 1.5s linear infinite reverse;
    will-change: transform;
}

.hku-loading-spinner::after {
    content: '';
    position: absolute;
    top: 18px;
    left: 18px;
    right: 18px;
    bottom: 18px;
    border: 2px solid transparent;
    border-bottom-color: var(--hku-loading-gold);
    border-right-color: var(--hku-loading-gold);
    border-radius: 50%;
    animation: hku-spin 0.75s linear infinite;
    will-change: transform;
}

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

/* Loading Text */
.hku-loading-text {
    margin-top: 24px;
    color: var(--hku-loading-text);
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.5px;
    text-align: center;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Animated Dots */
.hku-loading-dots {
    display: inline-flex;
    gap: 3px;
}

.hku-loading-dots span {
    width: 5px;
    height: 5px;
    background-color: var(--hku-loading-secondary);
    border-radius: 50%;
    animation: hku-dot-bounce 1.2s ease-in-out infinite;
    will-change: transform, opacity;
}

.hku-loading-dots span:nth-child(2) { animation-delay: 0.15s; }
.hku-loading-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes hku-dot-bounce {
    0%, 80%, 100% { 
        transform: scale(0.6); 
        opacity: 0.4; 
    }
    40% { 
        transform: scale(1); 
        opacity: 1; 
    }
}

/* Progress Bar */
.hku-loading-progress {
    width: 180px;
    height: 3px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
    margin-top: 16px;
    overflow: hidden;
}

.hku-loading-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, 
        var(--hku-loading-secondary), 
        var(--hku-loading-accent), 
        var(--hku-loading-secondary));
    background-size: 200% 100%;
    animation: hku-progress-shimmer 1.2s ease-in-out infinite;
    border-radius: 3px;
    will-change: background-position;
}

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

/* =============================================
   2. INLINE/SECTION LOADING
   Tablo, grafik, card içi yükleme
   Transparan arka plan
   ============================================= */
.hku-section-loading {
    position: relative;
    min-height: 100px;
}

.hku-section-loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(2px);
    z-index: 10;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease;
    will-change: opacity;
}

.hku-section-loading.loading::before {
    opacity: 1;
    visibility: visible;
}

/* Section Loader Element */
.hku-section-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 11;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease;
    will-change: opacity;
}

.hku-section-loading.loading .hku-section-loader {
    opacity: 1;
    visibility: visible;
}

/* Mini Spinner for Sections */
.hku-section-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e9ecef;
    border-top-color: var(--hku-loading-primary);
    border-radius: 50%;
    animation: hku-spin 0.8s linear infinite;
    will-change: transform;
}

/* Section Loading Text */
.hku-section-text {
    font-size: 13px;
    color: #495057;
    font-weight: 500;
    white-space: nowrap;
}

/* =============================================
   3. SKELETON LOADING
   İçerik placeholder'ları
   ============================================= */
.hku-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: hku-skeleton-shimmer 1.5s infinite;
    border-radius: 4px;
    will-change: background-position;
}

.hku-skeleton-text {
    height: 14px;
    margin-bottom: 8px;
}

.hku-skeleton-text.short { width: 40%; }
.hku-skeleton-text.medium { width: 70%; }
.hku-skeleton-text.long { width: 100%; }

.hku-skeleton-circle {
    border-radius: 50%;
}

.hku-skeleton-rect {
    border-radius: 4px;
}

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

/* =============================================
   4. CARD LOADING
   Dashboard card'ları için
   ============================================= */
.hku-card-loading {
    position: relative;
    overflow: hidden;
}

.hku-card-loading .hku-card-loader {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 8px;
    z-index: 5;
}

.hku-card-loader .hku-card-spinner {
    width: 28px;
    height: 28px;
    border: 2px solid #dee2e6;
    border-top-color: var(--hku-loading-primary);
    border-radius: 50%;
    animation: hku-spin 0.7s linear infinite;
    will-change: transform;
}

.hku-card-loader .hku-card-text {
    font-size: 12px;
    color: #6c757d;
    font-weight: 500;
}

/* =============================================
   5. TABLE LOADING
   Tablo yükleme durumu
   ============================================= */
.hku-table-loading {
    position: relative;
}

.hku-table-loading tbody {
    opacity: 0.3;
    pointer-events: none;
}

.hku-table-loading .hku-table-loader {
    position: absolute;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.hku-table-loader .hku-table-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e9ecef;
    border-top-color: var(--hku-loading-primary);
    border-radius: 50%;
    animation: hku-spin 0.7s linear infinite;
    will-change: transform;
}

.hku-table-loader .hku-table-text {
    font-size: 13px;
    color: #495057;
    font-weight: 500;
}

/* =============================================
   6. CHART LOADING
   Grafik yükleme durumu
   ============================================= */
.hku-chart-loading {
    position: relative;
    min-height: 200px;
}

.hku-chart-loading .hku-chart-loader {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.9);
    z-index: 5;
}

.hku-chart-loader .hku-chart-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e9ecef;
    border-top-color: var(--hku-loading-primary);
    border-radius: 50%;
    animation: hku-spin 0.8s linear infinite;
    will-change: transform;
}

.hku-chart-loader .hku-chart-text {
    font-size: 13px;
    color: #6c757d;
    font-weight: 500;
}

/* =============================================
   7. BUTTON LOADING
   Buton içi loading
   ============================================= */
.hku-btn-loading {
    position: relative;
    pointer-events: none;
    color: transparent !important;
}

.hku-btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-top: -8px;
    margin-left: -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: hku-spin 0.7s linear infinite;
    will-change: transform;
}

.hku-btn-loading .btn-text {
    visibility: hidden;
}

/* =============================================
   8. RESPONSIVE
   ============================================= */
@media (max-width: 576px) {
    .hku-loading-logo-container {
        width: 90px;
        height: 90px;
    }
    
    .hku-loading-text {
        font-size: 13px;
    }
    
    .hku-loading-progress {
        width: 150px;
    }
}

/* =============================================
   9. REDUCED MOTION
   Erişilebilirlik - Hareket hassasiyeti
   ============================================= */
@media (prefers-reduced-motion: reduce) {
    .hku-loading-spinner,
    .hku-loading-spinner::before,
    .hku-loading-spinner::after,
    .hku-section-spinner,
    .hku-card-spinner,
    .hku-table-spinner,
    .hku-chart-spinner,
    .hku-btn-loading::after {
        animation-duration: 2s;
    }
    
    .hku-loading-dots span,
    .hku-loading-progress-bar,
    .hku-skeleton {
        animation: none;
    }
}

/* =============================================
   10. PRINT
   Yazdırma sırasında gizle
   ============================================= */
@media print {
    .hku-loading-overlay,
    .hku-section-loader,
    .hku-card-loader,
    .hku-table-loader,
    .hku-chart-loader {
        display: none !important;
    }
}
