/**
 * NOBTI global loading feedback — progress bar, buttons, toasts, skeletons.
 */

:root {
    --nobti-loading-z: 1000002;
    --nobti-loading-bar: #2563eb;
    --nobti-loading-bar-glow: #38bdf8;
    --nobti-header-height: 70px;
}

/* —— Top progress bar (below fixed navbar) —— */
.nobti-page-progress {
    position: fixed;
    top: var(--nobti-header-height, 70px);
    left: 0;
    right: 0;
    height: 3px;
    z-index: var(--nobti-loading-z);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.18s ease;
}

@media (max-width: 768px) {
    :root {
        --nobti-header-height: 58px;
    }

    .nobti-page-progress {
        height: 4px;
        box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
    }
}

.nobti-page-progress.is-active {
    opacity: 1;
}

.nobti-page-progress__bar {
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--nobti-loading-bar), var(--nobti-loading-bar-glow));
    box-shadow: 0 0 12px rgba(37, 99, 235, 0.45);
    transition: width 0.28s ease;
}

.nobti-page-progress.is-active .nobti-page-progress__bar {
    width: 78%;
}

.nobti-page-progress.is-busy .nobti-page-progress__bar {
    animation: nobti-progress-indeterminate 1.1s ease-in-out infinite;
}

.nobti-page-progress.is-complete .nobti-page-progress__bar {
    width: 100% !important;
    animation: none;
    transition: width 0.15s ease;
}

@keyframes nobti-progress-indeterminate {
    0% {
        width: 35%;
    }
    50% {
        width: 88%;
    }
    100% {
        width: 35%;
    }
}

/* —— Slow-action / mobile nav pill (below navbar) —— */
.nobti-loading-pill,
.nobti-mobile-loading-pill {
    position: fixed;
    top: calc(var(--nobti-header-height, 70px) + env(safe-area-inset-top, 0px) + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    z-index: var(--nobti-loading-z);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.92);
    color: #f8fafc;
    font-weight: 900;
    font-size: 0.82rem;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.28);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.nobti-loading-pill.is-visible,
.nobti-mobile-loading-pill.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.nobti-loading-pill.is-nav {
    background: rgba(37, 99, 235, 0.96);
    box-shadow: 0 10px 28px rgba(37, 99, 235, 0.35);
}

/* —— Button loading —— */
.nobti-btn-loading {
    position: relative;
    pointer-events: none !important;
    opacity: 0.88;
}

.nobti-btn-loading[aria-busy="true"] {
    cursor: wait;
}

.nobti-spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    margin-inline-end: 6px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    vertical-align: -0.12em;
    animation: nobti-spin 0.65s linear infinite;
}

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

/* —— Toasts —— */
.nobti-toast-host {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(112px + env(safe-area-inset-bottom, 0px));
    z-index: calc(var(--nobti-loading-z) - 2);
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.nobti-toast {
    align-self: center;
    max-width: min(420px, 100%);
    padding: 11px 16px;
    border-radius: 16px;
    font-weight: 900;
    font-size: 0.88rem;
    line-height: 1.45;
    text-align: center;
    box-shadow: 0 14px 36px rgba(15, 23, 42, 0.2);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.nobti-toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.nobti-toast--info {
    background: #0f172a;
    color: #f8fafc;
}

.nobti-toast--success {
    background: #ecfdf5;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.nobti-toast--error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.nobti-toast--warn {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

/* —— Inline skeleton (map sheet etc.) —— */
.nobti-skeleton {
    position: relative;
    overflow: hidden;
    background: #e2e8f0;
    border-radius: 12px;
}

.nobti-skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
    animation: nobti-shimmer 1.1s ease-in-out infinite;
}

@keyframes nobti-shimmer {
    100% {
        transform: translateX(100%);
    }
}

.nobti-inline-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 900;
    color: #64748b;
}

.nobti-inline-status .nobti-spinner {
    width: 0.85em;
    height: 0.85em;
    margin: 0;
}

@media (prefers-reduced-motion: reduce) {
    .nobti-page-progress__bar,
    .nobti-spinner,
    .nobti-skeleton::after {
        animation: none !important;
        transition: none !important;
    }

    .nobti-page-progress.is-active .nobti-page-progress__bar {
        width: 85%;
    }
}
