/* =============================================================================
   Loading feedback where the action happened (js/core/busy.js).
   Nothing here blocks the page.
   ============================================================================= */

:root {
    --ob-accent: #4f46e5;
    --ob-track: rgba(79, 70, 229, .14);
}

/* ---------- Small spinner used in buttons and field status ---------- */
.ob-spinner {
    display: inline-block;
    flex: 0 0 auto;
    width: 12px;
    height: 12px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: ob-spin .7s linear infinite;
    vertical-align: -2px;
}

/* ---------- Button: spinner in place of its icon, no double clicks ---------- */
.ob-busy-btn {
    position: relative;
    pointer-events: none;
    cursor: progress;
}

    /* Hide the label and icon (the button keeps its size), show a spinner in the middle */
    .ob-busy-btn,
    .ob-busy-btn:hover,
    .ob-busy-btn:focus {
        color: transparent !important;
    }

        .ob-busy-btn > * {
            visibility: hidden;
        }

    .ob-busy-btn::after {
        content: "";
        position: absolute;
        top: 50%;
        left: 50%;
        width: 14px;
        height: 14px;
        margin: -7px 0 0 -7px;
        border: 2px solid var(--ob-accent);
        border-right-color: transparent;
        border-radius: 50%;
        animation: ob-spin .7s linear infinite;
    }

    .btn-primary.ob-busy-btn::after,
    .btn-danger.ob-busy-btn::after,
    .btn-success.ob-busy-btn::after,
    .btn-info.ob-busy-btn::after,
    .btn-dark.ob-busy-btn::after {
        border-color: #fff;
        border-right-color: transparent;
    }

/* ---------- Form field: "Saving… / Saved / Not saved" in the field header ---------- */
.ob-field-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-left: auto;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: var(--fs-meta, 12px);
    font-weight: 500;
    line-height: 1.6;
    white-space: nowrap;
    transition: opacity .3s ease;
}

    /* sits before the Required/Disabled chips when they're there */
    .of-field-head .ob-field-status {
        order: 5;
    }

    .of-field-head .of-required,
    .of-field-head .of-chip {
        order: 6;
    }

    .ob-field-status[data-state="saving"] {
        color: #697386;
        background: #f4f5fa;
    }

    .ob-field-status[data-state="saved"] {
        color: #1a7f4b;
        background: #e8f7ef;
    }

    .ob-field-status[data-state="failed"] {
        color: #c0392b;
        background: #fdf1f1;
    }

    .ob-field-status[data-state="idle"] {
        opacity: 0;
        pointer-events: none;
    }

    .ob-field-status i {
        font-size: 13px;
        line-height: 1;
    }

/* ---------- Modal: thin bar along the top while it loads/saves ---------- */
.ob-busy-modal {
    position: relative;
}

    .ob-busy-modal::before {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        z-index: 5;
        height: 3px;
        border-radius: 12px 12px 0 0;
        background: linear-gradient(90deg, transparent 0, var(--ob-accent) 40%, var(--ob-accent) 60%, transparent 100%) no-repeat, var(--ob-track);
        background-size: 40% 100%, 100% 100%;
        animation: ob-slide 1.1s ease-in-out infinite;
    }

    .ob-busy-modal .modal-footer .btn-primary,
    .ob-busy-modal .modal-footer .btn-danger {
        pointer-events: none;
        opacity: .65;
    }

/* ---------- Page: thin bar along the top of the window ---------- */
.ob-top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100000;
    height: 3px;
    opacity: 0;
    pointer-events: none;
    background: linear-gradient(90deg, transparent 0, var(--ob-accent) 40%, var(--ob-accent) 60%, transparent 100%) no-repeat, var(--ob-track);
    background-size: 40% 100%, 100% 100%;
    transition: opacity .2s ease;
}

    .ob-top-bar.is-active {
        opacity: 1;
        animation: ob-slide 1.1s ease-in-out infinite;
    }

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

@keyframes ob-slide {
    0% { background-position: -40% 0, 0 0; }
    100% { background-position: 140% 0, 0 0; }
}

@media (prefers-reduced-motion: reduce) {
    .ob-spinner,
    .ob-busy-btn::after,
    .ob-busy-modal::before,
    .ob-top-bar.is-active {
        animation-duration: 2.4s;
    }
}

@media print {
    .ob-field-status,
    .ob-top-bar {
        display: none !important;
    }
}

/* The status takes the free space on the right; Required / Disabled sit after it */
.of-field-head:has(.ob-field-status) .of-required,
.of-field-head:has(.ob-field-status) .of-chip {
    margin-left: 0;
}
