/*
 * The stock list (POOL-338). Its columns of figures have to fit beside the menu, where the list has 1216 px on a
 * 1600 px screen and 1056 px on a 1440 px one, so the gutters between columns are half those of the rest of the
 * panel. Scoped to the page of the resource. The widths of the fields are set, in characters, by
 * App\Filament\Resources\Stock\Tables\StockTable.
 */

/* Gutters between columns: 0.375rem a side instead of 0.75rem. The outer edges of the list keep theirs. */
.fi-resource-stock .fi-ta-table .fi-ta-header-cell:not(:first-of-type) {
    padding-inline-start: 0.375rem;
}

.fi-resource-stock .fi-ta-table .fi-ta-header-cell:not(:last-of-type) {
    padding-inline-end: 0.375rem;
}

.fi-resource-stock .fi-ta-table .fi-ta-cell:not(:first-of-type) > .fi-ta-col > :is(.fi-ta-text, .fi-ta-text-input) {
    padding-inline-start: 0.375rem;
}

.fi-resource-stock .fi-ta-table .fi-ta-cell:not(:last-of-type) > .fi-ta-col > :is(.fi-ta-text, .fi-ta-text-input) {
    padding-inline-end: 0.375rem;
}

/* The name of the product wraps, but not word by word. */
.fi-resource-stock .fi-ta-table .fi-ta-cell-product-label {
    min-width: 10.5rem;
}

/* The cost field keeps its «€» close: the room of the figure is the width StockTable gives the input. */
.fi-resource-stock .fi-ta-table .fi-ta-cell-cost .fi-input {
    padding-inline: 0.5rem 0.125rem;
}

.fi-resource-stock .fi-ta-table .fi-ta-cell-cost .fi-input-wrp-suffix {
    padding-inline: 0.125rem 0.5rem;
}

/*
 * A saved cell. StockTable puts `data-saved` on the cell for two and a half seconds after a save without an error: a
 * green ring on the field and a tick on its corner, that fade by themselves. Nothing moves, takes the focus or covers
 * the figure, so several cells can be edited in a row. The message for screen readers is Filament's.
 */
.fi-resource-stock .fi-ta-text-input[data-saved] .fi-input-wrp {
    position: relative;
    outline: 2px solid var(--success-600);
    outline-offset: 1px;
    animation: poolmania-stock-saved-ring 2.5s ease-out both;
}

.fi-resource-stock .fi-ta-text-input[data-saved] .fi-input-wrp::after {
    content: '';
    position: absolute;
    inset-block-start: -0.5rem;
    inset-inline-end: -0.5rem;
    width: 1rem;
    height: 1rem;
    border-radius: 9999px;
    background: var(--success-600)
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.75 8.5l2.75 2.75 5.75-6'/%3E%3C/svg%3E")
        center / 0.75rem no-repeat;
    pointer-events: none;
    animation: poolmania-stock-saved-tick 2.5s ease-out both;
}

@keyframes poolmania-stock-saved-ring {
    0%,
    70% {
        outline-color: var(--success-600);
    }

    100% {
        outline-color: transparent;
    }
}

@keyframes poolmania-stock-saved-tick {
    0%,
    70% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .fi-resource-stock .fi-ta-text-input[data-saved] .fi-input-wrp,
    .fi-resource-stock .fi-ta-text-input[data-saved] .fi-input-wrp::after {
        animation-timing-function: step-end;
    }
}
