/* ============================================
   Global Page Loader Overlay
   ============================================ */

.page-loader-overlay {
    display: none;
    position: fixed;
    top: var(--header-height, 70px);
    left: var(--nav-width-collapsed, 70px);
    width: calc(100% - var(--nav-width-collapsed, 70px));
    height: calc(100% - var(--header-height, 70px));
    background: rgba(0, 0, 0, 0.45);
    z-index: 99999;
    pointer-events: all;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.2s ease-in, left 0.5s ease, width 0.5s ease;
}

/* Adjust loader position when sidebar is expanded */
body.sidebar-open .page-loader-overlay {
    left: var(--nav-width-expanded, 200px);
    width: calc(100% - var(--nav-width-expanded, 200px));
}

.page-loader-overlay.active {
    display: flex !important;
    opacity: 1;
}

.loader-content {
    text-align: center;
}

/* Shape spinner — cycles through diamond shape images */
.shape-spinner {
    position: relative;
    width: 64px;
    height: 64px;
    margin: 0 auto 16px auto;
}

.shape-spinner img {
    position: absolute;
    top: 0;
    left: 0;
    width: 64px;
    height: 64px;
    object-fit: contain;
    opacity: 0;
    filter: brightness(0) invert(1); /* make shapes white on dark overlay */
    animation: shape-rotate 10s linear infinite;
}

/* Stagger each shape: visible for 1s (its turn), hidden for 9s */
.shape-spinner img:nth-child(1)  { animation-delay: 0s; }
.shape-spinner img:nth-child(2)  { animation-delay: 1s; }
.shape-spinner img:nth-child(3)  { animation-delay: 2s; }
.shape-spinner img:nth-child(4)  { animation-delay: 3s; }
.shape-spinner img:nth-child(5)  { animation-delay: 4s; }
.shape-spinner img:nth-child(6)  { animation-delay: 5s; }
.shape-spinner img:nth-child(7)  { animation-delay: 6s; }
.shape-spinner img:nth-child(8)  { animation-delay: 7s; }
.shape-spinner img:nth-child(9)  { animation-delay: 8s; }
.shape-spinner img:nth-child(10) { animation-delay: 9s; }

@keyframes shape-rotate {
    /* Fade in */
    0%   { opacity: 0; transform: rotate(0deg); }
    1%   { opacity: 1; transform: rotate(0deg); }
    /* Rotate 360deg during this shape's 10% window */
    9%   { opacity: 1; transform: rotate(360deg); }
    /* Fade out */
    10%  { opacity: 0; transform: rotate(360deg); }
    /* Stay hidden for remaining 90% */
    100% { opacity: 0; transform: rotate(360deg); }
}

.loader-content p {
    margin: 0;
    color: #ffffff;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.5px;
}

/* Disabled button style during loading */
.btn-loading {
    opacity: 0.6 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
}
