/**
 * Form Loader Styles
 * Loading states for buttons and forms
 */

/* Button loading state */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
    cursor: not-allowed !important;
}

/* Spinner container */
.btn-spinner {
    display: inline-block;
    margin-right: 8px;
    vertical-align: middle;
}

/* Spinner icon animation */
.spinner-icon {
    display: inline-block;
    animation: spin 0.8s linear infinite;
    font-size: inherit;
    line-height: 1;
}

/* Spin animation */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Form submitting state */
.form-submitting {
    position: relative;
}

.form-submitting::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(2px);
    z-index: 10;
    pointer-events: all;
    cursor: wait;
}

/* Dark mode support */
[data-bs-theme="dark"] .form-submitting::after {
    background: rgba(0, 0, 0, 0.3);
}

/* Ensure spinner is visible in different button types */
.btn-primary .spinner-icon,
.btn-success .spinner-icon,
.btn-danger .spinner-icon,
.btn-warning .spinner-icon,
.btn-info .spinner-icon,
.btn-dark .spinner-icon {
    color: currentColor;
}

/* Loading state for different button sizes */
.btn-sm.btn-loading .btn-spinner {
    margin-right: 6px;
}

.btn-lg.btn-loading .btn-spinner {
    margin-right: 10px;
}

/* Prevent button text from shifting */
.btn-loading {
    min-width: fit-content;
}

/* Loading pulse effect (optional alternative) */
.btn-loading.btn-pulse {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.7;
    }
    50% {
        opacity: 0.5;
    }
}

/* Icon button loading state */
.btn-icon.btn-loading {
    padding: 0.375rem 0.75rem;
}

.btn-icon.btn-loading .btn-spinner {
    margin-right: 0;
}

/* Smooth transition */
.btn {
    transition: opacity 0.2s ease, background-color 0.2s ease;
}

/* Loading skeleton for async content */
.skeleton-loader {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

[data-bs-theme="dark"] .skeleton-loader {
    background: linear-gradient(90deg, #2d2d2d 25%, #1d1d1d 50%, #2d2d2d 75%);
    background-size: 200% 100%;
}

/* Disabled link style during loading */
a.btn-loading {
    pointer-events: none;
    text-decoration: none;
}

/* Loading overlay for cards/sections */
.loading-overlay {
    position: relative;
}

.loading-overlay::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(3px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
}

.loading-overlay::after {
    content: '\F1310'; /* Remix Icon loader */
    font-family: 'remixicon';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    color: #438EFF;
    z-index: 101;
    animation: spin 0.8s linear infinite;
}

[data-bs-theme="dark"] .loading-overlay::before {
    background: rgba(0, 0, 0, 0.7);
}

/* Small loader for inline elements */
.loader-inline {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #438EFF;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-left: 8px;
}

/* Prevent layout shift when button gets loading state */
.btn {
    min-height: 38px; /* Default button height */
}

.btn-sm {
    min-height: 31px;
}

.btn-lg {
    min-height: 48px;
}

/* Loading state for submit buttons in modals */
.modal.show .btn-loading {
    opacity: 0.6;
}

/* Accessibility: screen reader text */
.sr-only-loading {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
