/**
 * TikNet Panel — global & inline loading UI
 */

/* ─── Top progress bar (navigation) ─── */
.panel-loader-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 9998;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    overflow: hidden;
    background: rgba(139, 92, 246, 0.12);
}

.panel-loader-bar.is-active {
    opacity: 1;
}

.panel-loader-bar__shine {
    position: absolute;
    top: 0;
    height: 100%;
    width: 45%;
    background: linear-gradient(
        90deg,
        transparent,
        var(--accent, #8b5cf6),
        #c4b5fd,
        #a78bfa,
        transparent
    );
    box-shadow: 0 0 20px var(--accent-glow, rgba(139, 92, 246, 0.45));
    animation: panel-bar-slide 1.1s ease-in-out infinite;
}

@keyframes panel-bar-slide {
    0% { transform: translateX(-120%); }
    100% { transform: translateX(320%); }
}

/* ─── Full-screen overlay ─── */
.panel-loader-overlay {
    position: fixed;
    inset: 0;
    z-index: 250;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(5, 5, 8, 0.78);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.28s ease, visibility 0.28s ease;
}

.panel-loader-overlay.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.panel-loader-card {
    text-align: center;
    padding: 2rem 2.25rem;
    border-radius: 1.5rem;
    background: linear-gradient(165deg, rgba(28, 28, 36, 0.95) 0%, rgba(16, 16, 20, 0.98) 100%);
    border: 1px solid rgba(139, 92, 246, 0.28);
    box-shadow:
        0 24px 64px rgba(0, 0, 0, 0.55),
        0 0 0 1px rgba(255, 255, 255, 0.04) inset,
        0 0 48px rgba(139, 92, 246, 0.15);
    animation: panel-card-in 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes panel-card-in {
    from {
        opacity: 0;
        transform: scale(0.92) translateY(8px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.panel-loader-text {
    margin: 1.25rem 0 0;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary, #a1a1aa);
    letter-spacing: 0.02em;
}

.panel-loader-sub {
    margin-top: 0.35rem;
    font-size: 0.75rem;
    color: var(--text-muted, #71717a);
}

/* ─── Orbit spinner (shared) ─── */
.panel-loader-orbit {
    position: relative;
    width: 4.5rem;
    height: 4.5rem;
    margin: 0 auto;
}

.panel-loader-orbit--sm {
    width: 2.25rem;
    height: 2.25rem;
}

.panel-loader-orbit--lg {
    width: 5.5rem;
    height: 5.5rem;
}

.panel-loader-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid rgba(139, 92, 246, 0.15);
    border-top-color: var(--accent, #8b5cf6);
    border-right-color: rgba(167, 139, 250, 0.55);
    animation: panel-spin 0.85s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
}

.panel-loader-orbit--sm .panel-loader-ring {
    border-width: 2px;
}

.panel-loader-ring-inner {
    position: absolute;
    inset: 0.65rem;
    border-radius: 50%;
    border: 2px solid transparent;
    border-bottom-color: #c4b5fd;
    border-left-color: rgba(196, 181, 253, 0.35);
    animation: panel-spin 1.15s linear infinite reverse;
}

.panel-loader-orbit--sm .panel-loader-ring-inner {
    inset: 0.35rem;
    border-width: 1.5px;
}

.panel-loader-core {
    position: absolute;
    inset: 1.35rem;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #c4b5fd 0%, var(--accent, #8b5cf6) 45%, var(--accent-deep, #6d28d9) 100%);
    box-shadow:
        0 0 20px var(--accent-glow, rgba(139, 92, 246, 0.5)),
        0 0 40px rgba(139, 92, 246, 0.2);
    animation: panel-core-pulse 1.6s ease-in-out infinite;
}

.panel-loader-orbit--sm .panel-loader-core {
    inset: 0.7rem;
}

.panel-loader-orbit--lg .panel-loader-core {
    inset: 1.65rem;
}

.panel-loader-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 7px;
    height: 7px;
    margin: -3.5px 0 0 -3.5px;
    border-radius: 50%;
    background: #e9d5ff;
    box-shadow: 0 0 10px rgba(196, 181, 253, 0.9);
    transform-origin: 0 -1.6rem;
    animation: panel-orbit-dot 1.8s linear infinite;
}

.panel-loader-dot:nth-child(4) {
    animation-delay: -0.6s;
    background: #a78bfa;
}

.panel-loader-dot:nth-child(5) {
    animation-delay: -1.2s;
    background: #8b5cf6;
}

.panel-loader-orbit--sm .panel-loader-dot {
    width: 4px;
    height: 4px;
    margin: -2px 0 0 -2px;
    transform-origin: 0 -0.85rem;
}

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

@keyframes panel-core-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(0.92); opacity: 0.88; }
}

@keyframes panel-orbit-dot {
    to { transform: rotate(360deg) translateY(-1.6rem); }
}

.panel-loader-orbit--sm .panel-loader-dot {
    animation-name: panel-orbit-dot-sm;
}

@keyframes panel-orbit-dot-sm {
    to { transform: rotate(360deg) translateY(-0.85rem); }
}

/* ─── Inline block (modals, tables) ─── */
.panel-loading-inline {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem 1rem;
    text-align: center;
}

.panel-loading-inline__text {
    font-size: 0.8125rem;
    color: var(--text-muted, #71717a);
    margin: 0;
}

/* ─── Button mini spinner ─── */
.panel-loader-btn {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-top-color: rgba(255, 255, 255, 0.85);
    animation: panel-spin 0.65s linear infinite;
    vertical-align: middle;
    flex-shrink: 0;
}

/* Boot: hide main flash until ready */
html.panel-boot-loading body > *:not(#panel-loader-root) {
    visibility: hidden;
}

html.panel-boot-loading #panel-loader-root .panel-loader-overlay {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Connection status cell — mini loader */
.conn-loading-dots {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    vertical-align: middle;
}

.conn-loading-dots span {
    width: 0.3rem;
    height: 0.3rem;
    border-radius: 50%;
    background: var(--accent, #8b5cf6);
    opacity: 0.35;
    animation: conn-dot-bounce 1s ease-in-out infinite;
}

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

@keyframes conn-dot-bounce {
    0%, 80%, 100% { opacity: 0.35; transform: scale(0.85); }
    40% { opacity: 1; transform: scale(1.15); box-shadow: 0 0 6px var(--accent-glow); }
}

@media (prefers-reduced-motion: reduce) {
    .panel-loader-bar__shine,
    .panel-loader-ring,
    .panel-loader-ring-inner,
    .panel-loader-core,
    .panel-loader-dot,
    .panel-loader-btn {
        animation: none !important;
    }
    .panel-loader-card {
        animation: none !important;
    }
}
