/*
 * Skeleton loading states for both panels.
 *
 * Registered through FilamentAsset (AppServiceProvider::boot) and published
 * by `php artisan filament:assets`, which the deploy already runs via the
 * composer post-autoload `filament:upgrade` hook.
 *
 * ZERO-LAYOUT-SHIFT RULE (owner, 2026-09-03): a placeholder occupies the
 * same outer geometry as the loaded widget. Stat cards get it structurally —
 * the placeholder reuses Filament's own .fi-wi-stats-overview-stat* classes,
 * so padding/radius/line-heights come from the compiled theme and the bars
 * (transparent-text blocks sized by their own line box) match the real text
 * exactly. Table placeholders replicate Filament's row arithmetic, taken
 * from vendor theme.css:
 *
 *   header (heading p-4, text-base)          = 3.5rem + 1px   (measured 57px)
 *   column-head row (py-3.5 + text-sm)       = 3rem + 0.5px   (measured 48.5px)
 *   body row (py-4 + 1.5rem forced leading)  = 3.5rem + 1px   (measured 57px)
 *   pagination footer                        = 3.75rem + 0.5px (measured 60.5px)
 *   five-row widget total                    = 451px, verified in-browser
 *
 * Neutral panel grays only (Filament's own custom properties) — brand tokens
 * deliberately stay out of loading chrome. Dark mode follows Filament's
 * `.dark` variant convention; shimmer respects prefers-reduced-motion.
 */

.ap-skel {
    position: relative;
    overflow: hidden;
    border-radius: 0.375rem;
    background: color-mix(in srgb, var(--gray-400) 24%, transparent);
}

.ap-skel::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(
        90deg,
        transparent,
        color-mix(in srgb, var(--color-white) 55%, transparent),
        transparent
    );
    animation: ap-skel-shimmer 1.2s ease-in-out infinite;
}

:where(.dark, .dark *) .ap-skel {
    background: color-mix(in srgb, var(--gray-500) 22%, transparent);
}

:where(.dark, .dark *) .ap-skel::after {
    background: linear-gradient(
        90deg,
        transparent,
        color-mix(in srgb, var(--gray-400) 28%, transparent),
        transparent
    );
}

/*
 * A bar whose height IS its own line box: transparent text + one &nbsp;
 * inside an element carrying the real typography class, so the block is
 * exactly as tall as the text it stands in for.
 */
.ap-skel-text {
    display: block;
    color: transparent !important;
    user-select: none;
}

/* Placeholders sit in place of a full-width widget in the dashboard grid. */
.ap-skel-span-full {
    grid-column: 1 / -1;
}

/*
 * Stat-card placeholder grid. The cards themselves are real
 * .fi-wi-stats-overview-stat elements (theme-styled); only the grid is ours,
 * mirroring the stats Section's 3-column layout and 1.5rem gap.
 */
.ap-skel-stats {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(var(--ap-skel-cols, 3), minmax(0, 1fr));
}

@media (max-width: 1023px) {
    .ap-skel-stats {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Generic block placeholder (the `section` variant). */
.ap-skel-card {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1.5rem;
    border-radius: 0.75rem;
    background: var(--color-white);
    box-shadow:
        0 1px 2px 0 rgb(0 0 0 / 0.05),
        0 0 0 1px color-mix(in srgb, var(--gray-950) 6%, transparent);
}

:where(.dark, .dark *) .ap-skel-card {
    background: color-mix(in srgb, var(--color-white) 5%, transparent);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--color-white) 10%, transparent);
}

.ap-skel-bar-value {
    height: 1.75rem;
    width: 65%;
}

/*
 * Table-widget placeholder: the .fi-ta chrome (white card, ring, radius-xl)
 * with header, column-head strip, N body rows and a pagination footer at
 * Filament's real metrics — see the arithmetic in the header comment.
 */
.ap-skel-table {
    border-radius: 0.75rem;
    background: var(--color-white);
    box-shadow:
        0 1px 3px 0 rgb(0 0 0 / 0.1),
        0 0 0 1px color-mix(in srgb, var(--gray-950) 6%, transparent);
    overflow: hidden;
}

:where(.dark, .dark *) .ap-skel-table {
    background: var(--gray-900);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--color-white) 10%, transparent);
}

.ap-skel-table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: calc(3.5rem + 1px);
    padding-inline: 1.5rem;
    border-bottom: 1px solid color-mix(in srgb, var(--gray-950) 8%, transparent);
}

.ap-skel-table-header .ap-skel-bar-heading {
    height: 1.5rem;
    width: 11rem;
    max-width: 40%;
}

.ap-skel-table-header .ap-skel-bar-action {
    height: 1.25rem;
    width: 5rem;
}

.ap-skel-table-colhead {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    height: calc(3rem + 0.5px);
    padding-inline: 1.5rem;
    border-bottom: 1px solid color-mix(in srgb, var(--gray-950) 8%, transparent);
}

.ap-skel-table-colhead .ap-skel-bar-cell {
    height: 0.875rem;
}

.ap-skel-table-row {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    height: calc(3.5rem + 1px);
    padding-inline: 1.5rem;
    border-bottom: 1px solid color-mix(in srgb, var(--gray-950) 5%, transparent);
}

.ap-skel-table-row .ap-skel-bar-cell {
    height: 1rem;
}

.ap-skel-table-footer {
    display: flex;
    align-items: center;
    height: calc(3.75rem + 0.5px);
    padding-inline: 1.5rem;
}

.ap-skel-table-footer .ap-skel-bar-cell {
    height: 1.25rem;
}

:where(.dark, .dark *) .ap-skel-table-header,
:where(.dark, .dark *) .ap-skel-table-colhead,
:where(.dark, .dark *) .ap-skel-table-row {
    border-color: color-mix(in srgb, var(--color-white) 10%, transparent);
}

/*
 * Deferred resource tables: Filament renders the shell (header, search,
 * column heads) with an empty body and `.fi-loading` on the root until
 * loadTable() lands. Reserve the height of a header strip plus five rows so
 * the page doesn't snap when rows arrive, and paint ghost rows at the same
 * 3.5rem rhythm as real ones. Filament exposes no defer-indicator view, so
 * CSS on its own classes is the supported seam.
 */
.fi-ta.fi-loading .fi-ta-content-ctn {
    position: relative;
    min-height: 20.5rem;
}

.fi-ta.fi-loading .fi-ta-content-ctn::before {
    content: "";
    position: absolute;
    inset: 0.75rem 1.5rem;
    border-radius: 0.375rem;
    background: repeating-linear-gradient(
        to bottom,
        color-mix(in srgb, var(--gray-400) 18%, transparent) 0 1rem,
        transparent 1rem 3.5rem
    );
    -webkit-mask-image: linear-gradient(to bottom, black 55%, transparent);
    mask-image: linear-gradient(to bottom, black 55%, transparent);
}

.fi-ta.fi-loading .fi-ta-content-ctn::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(
        90deg,
        transparent,
        color-mix(in srgb, var(--color-white) 40%, transparent),
        transparent
    );
    animation: ap-skel-shimmer 1.2s ease-in-out infinite;
}

:where(.dark, .dark *) .fi-ta.fi-loading .fi-ta-content-ctn::after {
    background: linear-gradient(
        90deg,
        transparent,
        color-mix(in srgb, var(--gray-400) 20%, transparent),
        transparent
    );
}

@keyframes ap-skel-shimmer {
    to {
        transform: translateX(100%);
    }
}

@media (prefers-reduced-motion: reduce) {
    .ap-skel::after,
    .fi-ta.fi-loading .fi-ta-content-ctn::after {
        animation: none;
    }
}
