/*
 * Probable duplicates, the same look wherever the application reports them: the products of the stock
 * (StocksInventoryCurrentGrid) and the purchase orders (StocksPurchaseOrderGrid). The mark on an item, the group rows
 * of the duplicates view and their actions, the toolbar above it with what was already decided, the dialogs listing
 * those decisions, and the rows brought into view (wwwroot/js/reveal-row.js).
 */

/* The mark of an item probably entered twice, after its name: amber like an item to check, opening the duplicates */
.btn-duplicate {
    flex: none;
    border: 1px solid color-mix(in oklab, var(--warning-color) 60%, white);
    border-radius: 999px;
    background-color: color-mix(in oklab, var(--warning-color) 16%, white);
    cursor: pointer;
    margin: 0 0 0 .4rem;
    padding: 0 .45rem;
    font-size: var(--fs-300);
    line-height: 1.4;
    white-space: nowrap;
    color: var(--alert-warning-fg);
}

    .btn-duplicate:hover,
    .btn-duplicate:focus-visible {
        background-color: color-mix(in oklab, var(--warning-color) 30%, white);
    }

/* The actions of a group of duplicates, kept together when the title row wraps */
.group-actions {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .3rem var(--sp-4, 1rem);
    margin-left: var(--sp-4, 1rem);
    vertical-align: middle;
}

/* The main action of a group (merge, compare) after its title, and the actions of its dialogs: a small button */
.btn-group-action {
    padding: .1rem .7rem;
    font-size: var(--fs-300);
    vertical-align: middle;
}

    .btn-group-action i {
        margin-right: .35rem;
    }

.not-duplicate-list {
    margin: .4rem 0 .6rem;
    padding-left: 1.2rem;
    list-style: disc;
}

/* "Pas un doublon": a quiet text button after the main action of a group */
.btn-not-duplicate {
    padding: 0;
    border: none;
    background: transparent;
    font-size: var(--fs-300);
    font-weight: 400;
    color: var(--gray-medium);
    text-decoration: underline;
    cursor: pointer;
}

    .btn-not-duplicate:hover,
    .btn-not-duplicate:focus-visible {
        color: var(--main-color-1);
    }

/* Above the duplicates: the way back on the left, what was already decided on the right */
.duplicates-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    margin-bottom: var(--sp-2, .5rem);
}

.duplicates-history {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-left: auto;
}

.history-chip {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .25rem .8rem;
    border: 1px solid var(--main-color-1);
    border-radius: 999px;
    background: transparent;
    color: var(--main-color-1);
    font-size: var(--fs-300);
    font-weight: 600;
    cursor: pointer;
}

    .history-chip:hover,
    .history-chip:focus-visible {
        background: var(--main-color-1);
        color: white;
    }

/* The lists of what was already decided (merges, groups or pairs set aside), in their dialogs */
.history-intro {
    margin: 0 0 .6rem;
    color: var(--gray-medium);
}

.history-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

    .history-list li {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        gap: .3rem .8rem;
        padding: .4rem 0;
        border-bottom: 1px solid var(--gray-light, #ddd);
    }

.declared-distinct-by {
    font-size: var(--fs-300);
    color: var(--gray-medium);
}

.btn-restore {
    margin-left: auto;
    padding: .1rem .7rem;
    font-size: var(--fs-300);
}

/* In the dialogs: what an action leaves, and why an action is refused or to be checked */
.merge-note {
    margin: 0;
    font-size: var(--fs-300);
    color: var(--gray-medium);
}

.merge-warning {
    padding: .5rem .7rem;
    border-radius: .4rem;
    background-color: color-mix(in oklab, var(--warning-color) 16%, white);
    color: var(--alert-warning-fg);
}

    .merge-warning p {
        margin: 0 0 .4rem;
    }

/* The merge dialog: the item to keep chosen among the group, then what the merge does */
.merge-dialog {
    display: flex;
    flex-direction: column;
    gap: .8rem;
}

.merge-targets {
    display: flex;
    flex-direction: column;
    gap: .4rem;
    margin: 0;
    padding: 0;
    border: none;
}

    .merge-targets legend {
        font-size: var(--fs-400, 1rem);
        font-weight: 600;
        margin-bottom: .3rem;
    }

.merge-target {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: .6rem;
    align-items: baseline;
    padding: .45rem .6rem;
    border: 1px solid var(--gray-light, #ddd);
    border-radius: .4rem;
    cursor: pointer;
}

    .merge-target:has(input:checked) {
        border-color: var(--main-color-1);
        background-color: color-mix(in oklab, var(--main-color-1) 8%, white);
    }

.merge-target-details {
    grid-column: 2;
    font-size: var(--fs-300);
    color: var(--gray-medium);
}

.merge-summary {
    font-weight: 600;
}

/* Above the duplicates view reached from the mark of an item: back to the list, on that item */
.back-from-duplicates .btn-secondary-ga {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
}

/* The group of the item whose mark was clicked, and that item, stay marked while the view is shown */
.focused-duplicate-group > th {
    box-shadow: inset 4px 0 0 var(--warning-color);
}

.focused-duplicate-item > td:first-child {
    box-shadow: inset 4px 0 0 var(--warning-color);
    font-weight: 600;
}

/* The rows brought into view flash once, so that the eye finds them */
.reveal-flash > th,
.reveal-flash > td {
    animation: reveal-flash 2.4s ease-out;
}

@keyframes reveal-flash {
    0%, 35% {
        background-color: color-mix(in oklab, var(--warning-color) 35%, white);
    }

    100% {
        background-color: inherit;
    }
}

@media (prefers-reduced-motion: reduce) {
    .reveal-flash > th,
    .reveal-flash > td {
        animation-duration: .01s;
    }
}

/* Touch screens: the mark gets a finger-sized box */
@media (pointer: coarse) {
    .btn-duplicate {
        display: inline-flex;
        justify-content: center;
        align-items: center;
        min-width: 2rem;
        min-height: 2rem;
    }
}
