/*
 * Pricing screens: Price by Product and Marketplace Price Rules. The shared components come
 * from ktmp-ui.css; this file holds only what no other screen has. Loaded on the Pricing page.
 */

/* Toolbar above the grid: search fields on the left, the Columns control at the end. */
.ktmp-wrap .ktmp-price-search {
    width: 200px;
}

.ktmp-price-columns {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--ktmp-space-2);
}

.ktmp-wrap .ktmp-price-columns > .ktmp-price-columns-toggle {
    padding: 0 8px 0 10px;
}

.ktmp-price-columns-toggle .ktmp-button__icon.ktmp-price-columns-chevron {
    width: 16px;
    height: 16px;
    font-size: 16px;
}

.ktmp-price-columns-chevron {
    transition: transform var(--ktmp-motion);
}

.ktmp-price-columns-toggle[aria-expanded="true"] .ktmp-price-columns-chevron {
    transform: rotate(180deg);
}

.ktmp-tag.ktmp-price-columns-hint {
    background: var(--ktmp-border-light);
}

.ktmp-price-columns-panel {
    width: 304px;
}

.ktmp-price-columns-fields {
    min-width: 0;
    margin: 0;
    border: 0;
}

.ktmp-price-columns-search {
    position: relative;
    margin-bottom: var(--ktmp-space-2);
}

.ktmp-price-columns-search .dashicons {
    position: absolute;
    top: 50%;
    inset-inline-start: var(--ktmp-space-2);
    width: 16px;
    height: 16px;
    font-size: 16px;
    color: var(--ktmp-text-muted);
    transform: translateY(-50%);
}

.ktmp-wrap .ktmp-price-columns-search .ktmp-input {
    padding-inline-start: 30px;
}

.ktmp-price-columns-group {
    display: flex;
    flex-direction: column;
}

.ktmp-price-columns-codes {
    font-size: var(--ktmp-type-small-size);
    color: var(--ktmp-text-muted);
}

.ktmp-price-columns-match {
    background: var(--ktmp-accent-tint);
    font-weight: var(--ktmp-weight-strong);
}

.ktmp-price-columns-divider {
    margin: var(--ktmp-space-2) 0;
    border: 0;
    border-top: 1px solid var(--ktmp-border-light);
}

.ktmp-price-columns-message {
    margin: 0;
    padding: 0 var(--ktmp-space-3) 10px;
}

.ktmp-price-columns-actions {
    align-items: center;
}

.ktmp-price-columns-all {
    margin-inline-end: auto;
}

.wp-core-ui .button-link.ktmp-price-columns-all:disabled {
    color: var(--ktmp-text-muted);
}

/* Product list card */
.ktmp-price-card .ktmp-card__header {
    align-items: center;
}

.ktmp-price-card .ktmp-card__action {
    gap: var(--ktmp-space-3);
}

/* The card's main action is the 30px primary button of the toolbar row, not the tall one. */
.ktmp-price-card .ktmp-card__action .button.ktmp-button {
    min-height: var(--ktmp-control-height-sm);
    padding: 0 var(--ktmp-space-3);
}

.ktmp-price-count {
    margin: 0;
    font-size: var(--ktmp-type-body-size);
    color: var(--ktmp-text-secondary);
}

.ktmp-price-pages {
    justify-content: flex-end;
}

.ktmp-price-pages .ktmp-pagination {
    margin: 0;
}

/*
 * The product table classes are shared with other screens, whose rules in admin-style.css
 * centre every cell, frame it on all sides and make the header sticky. Inside the grid the
 * table follows the shared data table instead.
 */
.ktmp-price-grid .ktmp-product-list thead {
    position: static;
}

.ktmp-price-grid .ktmp-price-table th,
.ktmp-price-grid .ktmp-price-table td {
    border-top: 0;
    border-inline: 0;
    text-align: start;
}

.ktmp-price-grid .ktmp-price-table td {
    height: 44px;
    white-space: nowrap;
}

.ktmp-price-grid .ktmp-price-table .ktmp-num {
    text-align: end;
}

.ktmp-price-grid td.ktmp-product-checkbox {
    display: table-cell;
    text-align: center;
}

.ktmp-price-grid td.ktmp-product-checkbox input[type="checkbox"] {
    margin: 0;
}

.ktmp-price-table .ktmp-price-col-id { min-width: 56px; }
.ktmp-price-table .ktmp-price-col-sku { min-width: 104px; }
.ktmp-price-table .ktmp-price-col-select { min-width: 64px; }
.ktmp-price-table .ktmp-price-col-expand { min-width: 100px; }
.ktmp-price-table .ktmp-price-col-date { min-width: 170px; }
.ktmp-price-table .ktmp-price-col-product { min-width: 200px; }
.ktmp-price-table .ktmp-price-col-site,
.ktmp-price-table .ktmp-price-col-constant { min-width: 140px; }
.ktmp-price-table th.ktmp-col-editable { min-width: 120px; }
.ktmp-price-table th.ktmp-col-region { min-width: 352px; }

.ktmp-price-grid .ktmp-price-table th.ktmp-col-editable {
    text-align: end;
}

/* The Expand button keeps a class the product list script binds to, which admin-style.css
   paints blue with !important on the other screens; here it keeps the shared button fill. */
.ktmp-price-grid .ktmp-price-table .button.ktmp-expand-button {
    background-color: var(--ktmp-surface-card) !important;
}

.ktmp-price-grid .ktmp-price-table .button.ktmp-expand-button:hover {
    background-color: var(--ktmp-surface) !important;
}

/* admin-style.css also drops the border and paints the text white; these rules restore them. */
.ktmp-price-table .ktmp-expand.ktmp-expand-button {
    border: 1px solid var(--ktmp-accent);
    color: var(--ktmp-accent);
    font-size: var(--ktmp-type-body-size);
}

.ktmp-price-table .ktmp-expand.ktmp-expand-button:hover,
.ktmp-price-table .ktmp-expand.ktmp-expand-button[aria-expanded="true"] {
    border-color: var(--ktmp-accent-hover);
    color: var(--ktmp-accent-hover);
}

.ktmp-price-grid .ktmp-price-table .button.ktmp-expand-button[aria-expanded="true"] {
    background-color: var(--ktmp-accent-tint) !important;
}

/* Fixed columns end at Product Constant; the marketplace columns follow. */
.ktmp-price-grid .ktmp-price-table .ktmp-price-divider,
.ktmp-price-grid .ktmp-price-table td[data-constant] {
    border-inline-end: 1px solid var(--ktmp-border-strong);
}

.ktmp-price-row-parent .ktmp-price-title {
    font-weight: var(--ktmp-weight-strong);
}

/* Editable cell: a button until clicked, then a number box over the whole cell. */
.ktmp-price-grid td.ktmp-cell-editable {
    position: relative;
    padding: var(--ktmp-space-1) 6px;
    cursor: pointer;
}

.ktmp-price-cell {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    box-sizing: border-box;
    width: 100%;
    min-height: var(--ktmp-control-height-sm);
    margin: 0;
    padding: 0 var(--ktmp-space-2);
    border: 1px dashed transparent;
    border-radius: var(--ktmp-radius-sm);
    background: none;
    font: inherit;
    color: inherit;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    transition: background-color var(--ktmp-motion), border-color var(--ktmp-motion);
}

.ktmp-price-grid td.ktmp-cell-editable:hover .ktmp-price-cell {
    border-color: var(--ktmp-border);
    background: var(--ktmp-surface);
}

.ktmp-price-cell:focus-visible {
    outline: var(--ktmp-focus-width) solid var(--ktmp-accent);
    outline-offset: var(--ktmp-focus-offset);
}

.ktmp-price-grid .ktmp-cell-input {
    position: absolute;
    inset: var(--ktmp-space-1) 6px;
    box-sizing: border-box;
    width: calc(100% - 12px);
    min-height: 0;
    margin: 0;
    padding: 0 var(--ktmp-space-2);
    text-align: end;
    font-variant-numeric: tabular-nums;
}

.ktmp-price-grid td.ktmp-cell-saving .spinner {
    position: absolute;
    top: 50%;
    inset-inline-start: 10px;
    z-index: 1;
    transform: translateY(-50%);
}

.ktmp-price-grid td.ktmp-cell-saving .ktmp-cell-input {
    padding-inline-start: 34px;
}

.ktmp-price-grid td.ktmp-cell-saved {
    background: var(--ktmp-success-tint);
    box-shadow: inset 3px 0 0 var(--ktmp-success);
}

.ktmp-price-grid td.ktmp-cell-error {
    background: var(--ktmp-error-tint);
    box-shadow: inset 0 0 0 1px var(--ktmp-error);
}

.ktmp-price-grid .ktmp-cell-error-text {
    justify-content: flex-end;
    margin: 2px 0 0;
}

/* Region cell: up to three country tags, "+N", then Edit, on one line. */
.ktmp-chip-summary {
    display: inline-flex;
    gap: var(--ktmp-space-1);
    vertical-align: middle;
}

.ktmp-price-grid .ktmp-region-edit {
    margin-inline-start: var(--ktmp-space-2);
}

/* Bulk and region windows */
.ktmp-price-modal-table {
    width: 100%;
    border-collapse: collapse;
}

.ktmp-price-modal-table th,
.ktmp-price-modal-table td {
    padding: 6px 0;
    vertical-align: middle;
}

.ktmp-price-modal-table th {
    padding-inline-end: var(--ktmp-space-3);
    text-align: start;
    font-weight: 400;
}

.ktmp-price-modal-table td {
    position: relative;
    padding-inline-end: 80px;
    white-space: nowrap;
}

/* Clear and Undo sit at the end of each row, so they form one column down the window. */
.ktmp-window .ktmp-price-modal-table .button.ktmp-price-clear {
    position: absolute;
    top: 50%;
    inset-inline-end: 0;
    box-sizing: border-box;
    min-width: 68px;
    height: var(--ktmp-control-height-sm);
    min-height: 0;
    margin: 0;
    padding: 0 10px;
    font-size: var(--ktmp-type-body-size);
    line-height: 1;
    transform: translateY(-50%);
}

.ktmp-window .ktmp-price-modal-table .ktmp-input {
    width: 140px;
    margin-inline-end: var(--ktmp-space-2);
}

.ktmp-price-currency {
    display: inline-block;
    min-width: 32px;
    margin-inline-end: var(--ktmp-space-2);
    color: var(--ktmp-text-secondary);
}

.ktmp-price-modal-resolved {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-inline-start: var(--ktmp-space-3);
    color: var(--ktmp-text-secondary);
    font-variant-numeric: tabular-nums;
}

.ktmp-price-modal-table tr.is-cleared > * {
    background: var(--ktmp-surface);
}

.ktmp-price-modal-table tr.is-cleared .ktmp-price-modal-resolved {
    color: var(--ktmp-text-muted);
    text-decoration: line-through;
}

.ktmp-price-modal-group th {
    padding: var(--ktmp-space-2) 0 0;
}

.ktmp-price-modal-group .ktmp-disclosure__toggle {
    padding-inline: 0;
}

.ktmp-price-modal-child > * {
    background: var(--ktmp-surface);
}

.ktmp-price-modal-child th {
    padding-inline-start: var(--ktmp-space-6);
}

/*
 * The bulk window keeps its label column and scrollbar space when a region opens, so the
 * price boxes do not move. Narrow screens keep the automatic layout, which fits the boxes.
 */
@media screen and (min-width: 783px) {
    .ktmp-price-modal #ktmp-bulk-form .ktmp-window__body {
        scrollbar-gutter: stable;
    }

    #ktmp-bulk-form .ktmp-price-modal-table {
        table-layout: fixed;
    }

    #ktmp-bulk-form .ktmp-price-modal-row > th {
        width: 40%;
    }

    #ktmp-bulk-form .ktmp-price-modal-table th {
        overflow-wrap: anywhere;
    }
}

.ktmp-price-modal-message {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
}

/* Marketplace Price Rules: marketplace list beside the rule card. */
.ktmp-price-rules {
    display: grid;
    grid-template-columns: minmax(220px, 260px) minmax(0, 820px);
    gap: var(--ktmp-space-5);
    align-items: start;
}

.ktmp-price-rules-nav {
    padding: var(--ktmp-space-2) 0;
}

.ktmp-price-rules-nav__list,
.ktmp-sidebar-children {
    margin: 0;
    padding: 0;
    list-style: none;
}

.ktmp-price-rules-nav li {
    margin: 0;
}

.ktmp-price-rules-nav__link {
    display: flex;
    align-items: center;
    min-height: 36px;
    padding: 0 var(--ktmp-space-4);
    color: var(--ktmp-text);
    text-decoration: none;
    box-shadow: inset 3px 0 0 transparent;
}

.ktmp-price-rules-nav__link:hover,
.ktmp-price-rules-nav__link:focus {
    background: var(--ktmp-surface);
    color: var(--ktmp-text);
}

.ktmp-price-rules-nav__link[aria-current="page"] {
    background: var(--ktmp-accent-tint);
    color: var(--ktmp-accent-hover);
    font-weight: var(--ktmp-weight-strong);
    box-shadow: inset 3px 0 0 var(--ktmp-accent);
}

.ktmp-sidebar-children .ktmp-price-rules-nav__link {
    padding-inline-start: 10px;
}

.ktmp-price-rules-card .ktmp-card__header {
    align-items: center;
}

/* "Copy rules from" link and its popover in the card header */
.ktmp-price-copy {
    position: relative;
}

.wp-core-ui .button-link.ktmp-price-copy-toggle {
    font-size: var(--ktmp-type-small-size);
    text-decoration: none;
}

.ktmp-price-copy-toggle .ktmp-button__icon.dashicons {
    width: 14px;
    height: 14px;
    font-size: 14px;
}

.ktmp-price-copy-popover {
    width: 320px;
}

/* Without JavaScript the link cannot open anything, so the form shows in the card header. */
.no-js .ktmp-price-copy-toggle {
    display: none;
}

.no-js .ktmp-price-copy-popover {
    position: static;
    box-shadow: none;
}

.no-js .ktmp-price-copy-popover .ktmp-popover__arrow {
    display: none;
}

.ktmp-price-copy-popover label {
    display: block;
    margin-bottom: var(--ktmp-space-1);
    font-weight: var(--ktmp-weight-strong);
}

.ktmp-price-copy-popover select {
    width: 100%;
    max-width: 100%;
}

.ktmp-price-copy-notice {
    flex-wrap: wrap;
    align-items: center;
    margin: 0 0 var(--ktmp-space-4);
}

.ktmp-price-copy-notice > a {
    margin-inline-start: auto;
}

.ktmp-price-inherited {
    margin: 0 0 var(--ktmp-space-4);
}

.ktmp-price-inherited tbody th {
    width: 220px;
}

.ktmp-price-rules-card .ktmp-card__body > .ktmp-form-row:first-child,
.ktmp-price-rules-card #ktmp-own-rules > .ktmp-form-row:first-child {
    padding-top: 0;
}

.ktmp-wrap .ktmp-price-rules-select {
    max-width: 240px;
}

.ktmp-wrap .ktmp-price-rules-round-value {
    max-width: 160px;
}

/* Rule rows: handle, label, name, operation, value and Remove; they wrap on narrow screens. */
.ktmp-price-rules-list {
    padding: 0 0 var(--ktmp-space-4);
}

.ktmp-price-rule-list {
    margin: 0 0 var(--ktmp-space-3);
    border: 1px solid var(--ktmp-border-light);
    border-radius: var(--ktmp-radius-lg);
}

.ktmp-price-rule {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--ktmp-space-2);
    margin: 0;
    padding: var(--ktmp-space-2) var(--ktmp-space-3);
    border-bottom: 1px solid var(--ktmp-border-light);
    background: var(--ktmp-surface-card);
}

.ktmp-price-rule:first-child {
    border-radius: 7px 7px 0 0;
}

.ktmp-price-rule:last-child {
    border-bottom: 0;
    border-radius: 0 0 7px 7px;
}

.ktmp-price-rule:only-child {
    border-radius: 7px;
}

.ktmp-price-rule .ktmp-rule-label {
    min-width: 56px;
    font-weight: var(--ktmp-weight-strong);
}

.ktmp-wrap .ktmp-price-rule .ktmp-rule-name {
    flex: 1 1 160px;
    width: auto;
}

.ktmp-wrap .ktmp-price-rule .ktmp-rule-operation {
    flex: 0 0 auto;
    width: auto;
}

.ktmp-wrap .ktmp-price-rule .ktmp-price-value {
    flex: 0 0 110px;
    width: 110px;
}

/* Core recolours every state of a link button; an id plus a class keeps Remove red and
   leaves the core focus ring in place. */
#ktmp-input-container .ktmp-remove-btn,
#ktmp-input-container .ktmp-remove-btn:hover,
#ktmp-input-container .ktmp-remove-btn:active,
#ktmp-input-container .ktmp-remove-btn:focus {
    color: var(--ktmp-error-text);
}

.ktmp-price-rules-empty {
    margin: 0 0 var(--ktmp-space-3);
}

.ktmp-price-rules-round {
    border-top: 1px solid var(--ktmp-border-light);
}

.ktmp-price-rules-rounding .ktmp-form-row {
    padding: var(--ktmp-space-2) 0;
}

@media screen and (max-width: 782px) {
    .ktmp-price-rules {
        grid-template-columns: minmax(0, 1fr);
    }

    .ktmp-wrap .ktmp-price-search {
        width: 100%;
    }

    .ktmp-window .ktmp-price-modal-table .button.ktmp-price-clear {
        height: var(--ktmp-control-height-touch);
    }

    .ktmp-price-card .ktmp-card__action .button.ktmp-button {
        min-height: var(--ktmp-control-height-touch);
    }
}

@media (prefers-reduced-motion: reduce) {
    .ktmp-price-columns-chevron,
    .ktmp-price-cell {
        transition: none;
    }
}
