/**
 * Kisoma button-loading UX (shared across dashboard, school and public
 * layouts). Pairs with `setButtonLoading()` in assets/js/custom/function.js
 * and the `showLoading()`/`closeLoading()` compact processing modal.
 *
 * Replaces the old pattern of a full-screen "Please wait... / Processing
 * your request" SweetAlert for ordinary form submissions with a small
 * spinner inside the submit control itself.
 */

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

/* <button>/<a> loading state: a small inline spinner + label, built from
   real child markup so it can use currentColor and match whatever the
   button's own foreground color already is. */
.kisoma-btn-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-inline-end: 8px;
    vertical-align: -2px;
    border: 2px solid currentColor;
    border-inline-start-color: transparent;
    border-radius: 50%;
    opacity: .85;
    animation: kisoma-btn-spin .6s linear infinite;
}

button.kisoma-btn-loading,
a.kisoma-btn-loading {
    cursor: progress;
}

/* <a> has no native disabled state, so setButtonLoading()'s disabled prop
   alone won't stop a second click -- block pointer interaction too. */
a.kisoma-btn-loading {
    pointer-events: none;
}

/* <input type="submit"|"button"> can't hold child markup, and browsers
   don't render ::before/::after on it (it's a replaced element like
   <img>), so the spinner is painted as a background image instead -- an
   inline SVG that animates via its own SMIL <animateTransform>, entirely
   independent of this file's CSS animation (so the reduced-motion swap
   below still applies). White reads correctly against Kisoma's default
   filled/primary submit buttons; a differently-styled submit input can
   override `background-image`/`color` if it's ever needed. */
input.kisoma-btn-loading[type="submit"],
input.kisoma-btn-loading[type="button"] {
    background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHZpZXdCb3g9JzAgMCAyNCAyNCcgd2lkdGg9JzI0JyBoZWlnaHQ9JzI0Jz48Y2lyY2xlIGN4PScxMicgY3k9JzEyJyByPSc5JyBmaWxsPSdub25lJyBzdHJva2U9JyNmZmZmZmYnIHN0cm9rZS1vcGFjaXR5PScwLjM1JyBzdHJva2Utd2lkdGg9JzMnLz48cGF0aCBkPSdNMjEgMTJhOSA5IDAgMCAwLTktOScgZmlsbD0nbm9uZScgc3Ryb2tlPScjZmZmZmZmJyBzdHJva2Utd2lkdGg9JzMnIHN0cm9rZS1saW5lY2FwPSdyb3VuZCc+PGFuaW1hdGVUcmFuc2Zvcm0gYXR0cmlidXRlTmFtZT0ndHJhbnNmb3JtJyB0eXBlPSdyb3RhdGUnIGZyb209JzAgMTIgMTInIHRvPSczNjAgMTIgMTInIGR1cj0nMC43cycgcmVwZWF0Q291bnQ9J2luZGVmaW5pdGUnLz48L3BhdGg+PC9zdmc+");
    background-repeat: no-repeat;
    background-position: 14px center;
    background-size: 15px 15px;
    padding-inline-start: 34px !important;
    cursor: progress;
}

[dir="rtl"] input.kisoma-btn-loading[type="submit"],
[dir="rtl"] input.kisoma-btn-loading[type="button"] {
    background-position: right 14px center;
}

@media (prefers-reduced-motion: reduce) {
    .kisoma-btn-spinner {
        animation: none;
    }

    input.kisoma-btn-loading[type="submit"],
    input.kisoma-btn-loading[type="button"] {
        background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHZpZXdCb3g9JzAgMCAyNCAyNCcgd2lkdGg9JzI0JyBoZWlnaHQ9JzI0Jz48Y2lyY2xlIGN4PScxMicgY3k9JzEyJyByPSc5JyBmaWxsPSdub25lJyBzdHJva2U9JyNmZmZmZmYnIHN0cm9rZS1vcGFjaXR5PScwLjM1JyBzdHJva2Utd2lkdGg9JzMnLz48cGF0aCBkPSdNMjEgMTJhOSA5IDAgMCAwLTktOScgZmlsbD0nbm9uZScgc3Ryb2tlPScjZmZmZmZmJyBzdHJva2Utd2lkdGg9JzMnIHN0cm9rZS1saW5lY2FwPSdyb3VuZCcvPjwvc3ZnPg==");
    }
}

/* Compact processing modal (reference: task's "Setting up your school"
   example) -- overrides SweetAlert2's default oversized popup (large
   padding, big title, big icon) with a small, calm, single-message card
   for the few operations that genuinely must block interaction. Token
   fallbacks keep this readable on both the dashboard theme (which defines
   --kisoma-surface/--kisoma-text) and the public/school layouts (which
   don't). */
.kisoma-processing-modal.swal2-popup {
    width: auto;
    max-width: 320px;
    padding: 28px 26px;
    border-radius: 14px;
    background: var(--kisoma-surface, #fff);
    box-shadow: var(--kisoma-dropdown-shadow, 0 12px 30px rgba(15, 23, 42, .16));
}

.kisoma-processing-modal .swal2-html-container {
    margin: 0;
    padding: 0;
}

.kisoma-processing-modal .kisoma-processing-modal__body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
}

.kisoma-processing-modal .kisoma-btn-spinner {
    width: 22px;
    height: 22px;
    margin: 0;
    border-width: 3px;
    color: var(--kisoma-primary, #22577a);
}

.kisoma-processing-modal__title {
    color: var(--kisoma-text, #172033);
    font-size: 15px;
    font-weight: 700;
    line-height: 1.4;
}

.kisoma-processing-modal__hint {
    margin-top: -8px;
    color: var(--kisoma-muted, #64748b);
    font-size: 13px;
    line-height: 1.4;
}

@media (max-width: 420px) {
    .kisoma-processing-modal.swal2-popup {
        max-width: calc(100vw - 48px);
        padding: 24px 20px;
    }
}
