/* 
  Lavdin Loader Component
  ─────────────────────────────────────────────
  Extracted from core/components/lavdin_loader.php
*/

:root {
    --ld-primary: var(--color-blue-500);
    --ld-success: var(--color-emerald-500);
    --ld-error: var(--color-red-500);
    --ld-bg: var(--color-white);
    --ld-blur: 15px;
    --ld-transition: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    /* ld-sidebar-width is now handled statically below */
}

:root {
    --ld-sidebar-width: 0px;
}

body.admin-dashboard-body:not(.tenant-page) {
    --ld-sidebar-width: 280px;
}

@media (max-width: 991px) {
    :root {
        --ld-sidebar-width: 0px !important;
    }

    body.admin-dashboard-body:not(.tenant-page) {
        --ld-sidebar-width: 0px !important;
    }
}

[data-theme="dark"],
.dark-theme,
.theme-elegant,
[data-theme="dark"] {
    --ld-bg: var(--color-slate-900);
    --ld-primary: var(--color-blue-400);
}

body.system-booting {
    overflow: hidden !important;
}

/* Component visibility is managed by the loader overlay z-index and opacity */

/* ── TOP PROGRESS BAR ────────────────────────── */
#ld-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--ld-primary), var(--color-blue-400), var(--ld-primary));
    background-size: 200% 100%;
    animation: ld-progress-shine 3s linear infinite;
    z-index: 2001;
    /* Above EVERYTHING */
    width: 0;
    opacity: 0;
    transition: width 0.4s cubic-bezier(0.1, 0.7, 0.1, 1), opacity 0.3s ease;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.4);
    pointer-events: none;
}

@keyframes ld-progress-shine {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* ── FULL PAGE BOOTER ─────────────────────────── */
#lavdin-booter {
    position: fixed;
    inset: 0;
    z-index: 9999 !important;
    background: var(--ld-bg);
    backdrop-filter: blur(var(--ld-blur));
    -webkit-backdrop-filter: blur(var(--ld-blur));
    display: flex;
    box-sizing: border-box;
    transition: opacity var(--ld-transition), visibility var(--ld-transition), backdrop-filter 0.5s ease;
    margin-left: var(--ld-sidebar-width, 0px);
}

.ld-booter-content {
    margin: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    perspective: 1000px;
}

#lavdin-booter.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
}

/* ── CIRCULAR LIQUID LOADER ───────────────────── */
.ld-loader-container {
    position: relative;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ld-circle-bg {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 4px solid rgba(59, 130, 246, 0.1);
    /* fallback rgb */
    background: rgba(59, 130, 246, 0.05);
}

.ld-circle-liquid {
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    border: 4px solid transparent;
    border-top-color: var(--ld-primary);
    border-right-color: var(--ld-primary);
    animation: ld-liquid-spin 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
    filter: drop-shadow(0 0 5px var(--ld-primary));
}

.ld-circle-inner {
    position: absolute;
    width: 44px;
    height: 44px;
    background: transparent;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.ld-circle-inner img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

[data-theme="dark"] .ld-circle-inner img,
.dark-theme .ld-circle-inner img,
.theme-elegant .ld-circle-inner img {
    filter: brightness(0) invert(1);
}

@keyframes ld-liquid-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes ld-heartbeat {

    0%,
    100% {
        opacity: 1;
        transform: translateY(0);
        opacity: 1;
    }

    50% {
        opacity: 0.9;
        transform: translateY(10px);
        opacity: 0.8;
    }
}

/* ── TEXT & MESSAGES ─────────────────────────── */
.ld-text {
    margin-top: 32px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--ld-primary);
}

.ld-status-msg {
    margin-top: 10px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text-muted, var(--color-text-muted));
    opacity: 0;
    transform: translateY(10px);
    animation: ld-fade-in-up 0.6s ease-out 0.2s forwards;
}

@keyframes ld-fade-in-up {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── BOOTER PROGRESS BAR ────────────────────── */
.ld-boot-progress-wrap {
    width: 180px;
    height: 4px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
    margin-top: 40px;
    overflow: hidden;
    position: relative;
    opacity: 0;
    animation: ld-fade-in 1s ease-out 0.5s forwards;
}

[data-theme="dark"] .ld-boot-progress-wrap,
.dark-theme .ld-boot-progress-wrap,
.theme-elegant .ld-boot-progress-wrap {
    background: rgba(255, 255, 255, 0.05);
}

.ld-boot-progress-inner {
    position: absolute;
    inset: 0;
    width: 0%;
    background: linear-gradient(90deg, var(--ld-primary), var(--color-blue-400));
    border-radius: inherit;
    transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}

@keyframes ld-fade-in {
    to {
        opacity: 1;
    }
}

/* ── INLINE CONTAINER ────────────────────────── */
.ld-inline-wrap {
    position: absolute;
    inset: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    border-radius: inherit;
}

[data-theme="dark"] .ld-inline-wrap,
.dark-theme .ld-inline-wrap,
.theme-elegant .ld-inline-wrap {
    background: rgba(10, 15, 25, 0.7);
}

.ld-inline-wrap.active {
    opacity: 1;
    visibility: visible;
}

/* ── STATES (SUCCESS/ERROR) ──────────────────── */
.ld-state-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    display: none;
    animation: ld-pop-in 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes ld-pop-in {
    from {
        opacity: 0.5;
        transform: translateY(10px);
        opacity: 0;
    }

    to {
        opacity: 1;
        transform: translateY(0);
        opacity: 1;
    }
}

.ld-inline-wrap.success .ld-state-icon.success {
    display: block;
    color: var(--ld-success);
}

.ld-inline-wrap.error .ld-state-icon.error {
    display: block;
    color: var(--ld-error);
}

.ld-inline-wrap.success .ld-loader-container,
.ld-inline-wrap.error .ld-loader-container {
    display: none;
}