/* TailMates admin - global loading (SPA-safe) */

:root {
    --tm-loader-primary: #b5122b;
}

/* Boot splash before JS runs */
html.tm-admin-booting::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 99990;
    background: linear-gradient(160deg, #fff6f0 0%, #f8fafc 45%, #f1f5f9 100%);
}

html.tm-admin-booting::after {
    content: '';
    position: fixed;
    top: calc(50% - 1.5rem);
    left: calc(50% - 1.5rem);
    z-index: 99991;
    width: 3rem;
    height: 3rem;
    border-radius: 9999px;
    border: 3px solid rgb(181 18 43 / 0.15);
    border-top-color: var(--tm-loader-primary);
    animation: tmLoaderSpin 0.75s linear infinite;
}

/* Livewire SPA progress bar */
#nprogress .bar {
    background: var(--tm-loader-primary) !important;
    height: 3px !important;
    box-shadow: 0 0 12px rgb(181 18 43 / 0.45);
}

#nprogress .peg {
    box-shadow:
        0 0 12px var(--tm-loader-primary),
        0 0 6px var(--tm-loader-primary) !important;
}

/* Full-page loader (JS-managed, single instance) */
.tm-admin-loader {
    position: fixed;
    inset: 0;
    z-index: 99990;
    display: none;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #fff6f0 0%, #f8fafc 45%, #f1f5f9 100%);
}

.tm-admin-loader.is-visible {
    display: flex;
}

.tm-admin-loader__card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    padding: 2rem 2.5rem;
    border-radius: 1.25rem;
    background: rgb(255 255 255 / 0.92);
    box-shadow:
        0 20px 45px rgb(15 23 42 / 0.08),
        0 0 0 1px rgb(226 232 240 / 0.9);
}

.tm-admin-loader__logo {
    height: 2.75rem;
    width: auto;
    object-fit: contain;
}

.tm-admin-loader__ring {
    width: 3rem;
    height: 3rem;
    border-radius: 9999px;
    border: 3px solid rgb(181 18 43 / 0.15);
    border-top-color: var(--tm-loader-primary);
    animation: tmLoaderSpin 0.75s linear infinite;
}

.tm-admin-loader__text {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 500;
    color: #64748b;
}

/* Content skeleton overlay - sits ON TOP, does not hide Livewire DOM */
.tm-admin-skeleton {
    display: none;
    position: fixed;
    z-index: 25;
    top: 4rem;
    left: 16rem;
    right: 0;
    bottom: 0;
    padding: 1.25rem 1.5rem;
    background: rgb(241 245 249 / 0.92);
    backdrop-filter: blur(2px);
    overflow: hidden;
    pointer-events: none;
}

.tm-admin-skeleton.is-visible {
    display: block;
    animation: tmFadeIn 0.15s ease;
}

@media (max-width: 1023px) {
    .tm-admin-skeleton {
        left: 0;
    }
}

.tm-skel {
    border-radius: 0.75rem;
    background: linear-gradient(90deg, #e2e8f0 0%, #f8fafc 45%, #e2e8f0 90%);
    background-size: 200% 100%;
    animation: tmShimmer 1.35s ease-in-out infinite;
}

.tm-skel--title {
    height: 1.75rem;
    width: min(16rem, 55%);
    margin-bottom: 0.75rem;
}

.tm-skel--subtitle {
    height: 0.875rem;
    width: min(24rem, 72%);
    margin-bottom: 1.5rem;
    opacity: 0.75;
}

.tm-admin-skeleton__grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(1, minmax(0, 1fr));
}

@media (min-width: 640px) {
    .tm-admin-skeleton__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1280px) {
    .tm-admin-skeleton__grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.tm-skel--card {
    height: 8.5rem;
}

.tm-skel--table {
    height: 14rem;
    margin-top: 1rem;
}

/* Subtle overlay on tables/forms during Livewire requests */
html.tm-admin-requesting .fi-ta-content::after,
html.tm-admin-requesting .fi-form::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 5;
    border-radius: inherit;
    background: rgb(255 255 255 / 0.45);
    pointer-events: none;
}

html.tm-admin-requesting .fi-ta-content,
html.tm-admin-requesting .fi-form {
    position: relative;
}

.fi-ta .fi-loading-indicator {
    color: var(--tm-loader-primary) !important;
    width: 2rem !important;
    height: 2rem !important;
}

@keyframes tmLoaderSpin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes tmShimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

@keyframes tmFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    html.tm-admin-booting::after,
    .tm-admin-loader__ring,
    .tm-skel {
        animation: none !important;
    }
}
