/* Don't show overflow if a table row is swapping */
table:has(tr.htmx-request) {
    overflow: hidden !important;
}

/*
Spinner over an icon in a button:
    <button>
        <span class="htmx-spinner-icon">
            <span class="htmx-indicator"></span>
            <i class="fa fa-link text-secondary"></i>
        </span>
    </button
*/

.htmx-spinner-icon {
    position: relative;
    display: inline-flex;
}
.htmx-spinner-icon .htmx-indicator {
    width: 14px;
    height: 14px;
    color: #4cfd4c;
    position: absolute;
    display: inline-block;
    vertical-align: -.125em;
    border: .25em solid currentcolor;
    border-right-color: transparent;
    border-radius: 50%;
    -webkit-animation: .75s linear infinite spinner-border;
    animation: .75s linear infinite spinner-border;
}


/* HTMX Loading: Pulse Blur Effect */
.htmx-loading-pulse-blur.htmx-request {
    animation: pulse-blur 1s ease-in-out infinite;
}
@keyframes pulse-blur {
    0%, 100% {
        opacity: 1;
        filter: blur(0px);
    }
    50% {
        opacity: 0.4;
        filter: blur(1px);
    }
}

/* HTMX Loading: Skeleton Shimmer Effect */
.htmx-loading-skeleton-shimmer.htmx-request {
    position: relative;
    pointer-events: none;
    overflow: hidden;
}
.htmx-loading-skeleton-shimmer.htmx-request::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    background: linear-gradient(
            90deg,
            rgba(255, 255, 255, 0) 0,
            rgba(255, 255, 255, 0.08) 20%,
            rgba(255, 255, 255, 0.15) 60%,
            rgba(255, 255, 255, 0)
    );
    animation: shimmer 2s infinite;
}
@keyframes shimmer {
    100% {
        transform: translateX(100%);
    }
}

/* HTMX Loading: Breathing Scale Effect */
.htmx-loading-breathing-scale.htmx-request {
    animation: scale-fade 0.8s ease-in-out infinite alternate;
    transform-origin: center;
}
@keyframes scale-fade {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0.3;
        transform: scale(0.98);
    }
}

/* HTMX Loading: Centered Dots Overlay Effect */
.htmx-loading-dots-overlay.htmx-request {
    position: relative;
    opacity: 0.6;
    pointer-events: none;
}
.htmx-loading-dots-overlay.htmx-request::after {
    content: "●●●";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    letter-spacing: 8px;
    color: #3b82f6;
    animation: dots 1.5s steps(4, end) infinite;
    background: rgba(255, 255, 255, 0.95);
    padding: 10px 20px;
    border-radius: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
@keyframes dots {
    0%, 20% { content: "●"; }
    40% { content: "●●"; }
    60%, 100% { content: "●●●"; }
}

/* HTMX Loading: Sliding Line Progress - Fixed for no overflow */
.htmx-loading-sliding-line.htmx-request {
    position: relative;
    opacity: 0.6;
    overflow: hidden !important;
}
.htmx-loading-sliding-line.htmx-request::after {
    content: "";
    position: absolute;
    top: 0;
    left: -30%;
    height: 4px;
    width: 30%;
    background: linear-gradient(90deg, transparent, #3b82f6, transparent);
    animation: slide-line 1.5s linear infinite;
}
@keyframes slide-line {
    0% {
        left: -30%;
    }
    100% {
        left: 100%;
    }
}

/* HTMX Loading: Ripple Effect */
.htmx-loading-ripple.htmx-request {
    transition: opacity 0.15s ease-out;
    opacity: 0.55;
}
.htmx-loading-ripple.htmx-request::before,
.htmx-loading-ripple.htmx-request::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 160px;
    height: 160px;
    border-radius: 50%;
    border: 3px solid #3b82f6;
    transform: translate(-50%, -50%);
    animation: ripple 1.5s cubic-bezier(0, 0.2, 0.8, 1) infinite;
    z-index: 9999999;
}
.htmx-loading-ripple.htmx-request::after {
    animation-delay: -0.5s;
}
@keyframes ripple {
    0% {
        width: 0;
        height: 0;
        opacity: 1;
    }
    100% {
        width: 320px;
        height: 320px;
        opacity: 0;
    }
}

/* Modifier: Center ripple vertically in viewport */
.htmx-loading-ripple.ripple-viewport-center.htmx-request::before,
.htmx-loading-ripple.ripple-viewport-center.htmx-request::after {
    position: fixed;
    top: 50vh;
    left: 50%
}

/* HTMX Loading: Glitch Effect */
.htmx-loading-glitch.htmx-request {
    position: relative;
    animation: glitch 2s steps(20) infinite;
}
@keyframes glitch {
    0%, 100% {
        filter: hue-rotate(0deg) saturate(100%);
        transform: translateX(0);
    }
    20% {
        filter: hue-rotate(90deg) saturate(120%);
        transform: translateX(-2px);
    }
    40% {
        filter: hue-rotate(180deg) saturate(110%);
        transform: translateX(2px);
    }
    60% {
        filter: hue-rotate(270deg) saturate(130%);
        transform: translateX(-1px);
    }
    80% {
        filter: hue-rotate(360deg) saturate(100%);
        transform: translateX(1px);
    }
}

/* HTMX Loading: Scanner Effect */
.htmx-loading-scanner.htmx-request {
    position: relative;
    opacity: 0.85;
    overflow: hidden;
}
.htmx-loading-scanner.htmx-request::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #10b981, transparent);
    box-shadow: 0 0 10px #10b981;
    animation: scan 2s linear infinite;
}
@keyframes scan {
    0% {
        top: 0;
    }
    50% {
        top: 100%;
    }
    51% {
        top: 100%;
    }
    100% {
        top: 0;
    }
}

/* Disable click events on the hx-indicator element */
body .htmx-request, body.htmx-request, body[disabled] {
    pointer-events: none;
    cursor: wait;
}

/* Disable all interaction when modal dialog is loading */
html:has(#htmx-modal-dialog:is(.htmx-request, .htmx-modal-loading)),
html:has(#htmx-modal-dialog:is(.htmx-request, .htmx-modal-loading)) * {
    cursor: wait !important;
}
body:has(#htmx-modal-dialog:is(.htmx-request, .htmx-modal-loading)) * {
    pointer-events: none !important;
}

/* HTMX Modal Spinner - centered in viewport by default */
.htmx-modal-spinner {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1060; /* Above modal backdrop (1050) */
    pointer-events: none;
    color: rgba(180, 180, 180, 0.7);
}

/* Show outer spinner when modal is loading (fallback, viewport centered) */
#htmx-modal:has(#htmx-modal-dialog:is(.htmx-request, .htmx-modal-loading)) > .htmx-modal-spinner {
    display: block;
}

/* Hide outer spinner if inner spinner exists (to avoid duplicates) */
#htmx-modal:has(#htmx-modal-dialog .htmx-modal-spinner) > .htmx-modal-spinner {
    display: none;
}

/* Inner spinner (added by JS when modal has content) - centered in the dialog */
#htmx-modal-dialog .htmx-modal-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1060;
    display: block;
}
