/*
 * Logs screens: Error Logs, Transactions and the transaction detail. The shared components come
 * from ktmp-ui.css; this file holds only what no other screen has. Loaded on the Logs page.
 */

/* Transaction sub-tabs sit under the page tabs. */
.ktmp-logs .nav-tab-wrapper + .ktmp-tab-content .ktmp-tablist {
    margin-top: var(--ktmp-space-4);
}

/*
 * Core pagination as a row at the end, exactly as wide as the table frame under or above it,
 * with the item count centred on the 30px line of the buttons.
 */
.ktmp-logs .tablenav {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    box-sizing: border-box;
    max-width: 100%;
    height: auto;
    min-height: var(--ktmp-control-height-sm);
    margin: 0 0 var(--ktmp-space-2);
    padding: 0;
}

.ktmp-logs .tablenav.bottom {
    margin: var(--ktmp-space-2) 0 0;
}

.ktmp-logs .tablenav > br.clear {
    display: none;
}

.ktmp-logs .tablenav .tablenav-pages {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: var(--ktmp-space-3);
    float: none;
    max-width: 100%;
    margin: 0;
}

.ktmp-logs .tablenav .displaying-num {
    margin: 0;
}

/* Core pagination: the page form stays on the pagination line. */
.ktmp-logs .tablenav-pages .pagination-links {
    display: inline;
}

.ktmp-logs .tablenav .tablenav-pages .current-page {
    margin: 0 2px 0 0;
}

/* Error Logs */
.ktmp-logs-errors .ktmp-logs-col-id {
    width: 64px;
}

.ktmp-logs-errors .ktmp-logs-col-code {
    width: 100px;
}

.ktmp-logs-errors .ktmp-logs-col-date {
    width: 170px;
}

.ktmp-logs-errors .ktmp-logs-col-transaction {
    width: 120px;
}

/* Long messages wrap at a readable width and are never cut. */
.ktmp-logs-message {
    max-width: 92ch;
    overflow-wrap: anywhere;
}

/*
 * Transactions: the filter form on the left, the pagination at the right end, also when it
 * wraps under the form. The pagination line is as high as the controls, so the item count
 * sits level with them.
 */
.ktmp-logs-toolbar {
    align-items: flex-start;
}

.ktmp-logs-toolbar .tablenav {
    clear: none;
    margin: 0;
    margin-inline-start: auto;
}

.ktmp-logs-filters {
    margin: 0;
}

/* Every filter control and the Filter button are the same 30px high. */
.ktmp-logs-filters .ktmp-select--sm,
.ktmp-logs-filters .ktmp-input--sm,
.ktmp-logs-filters .ktmp-toolbar__filters > .button {
    height: var(--ktmp-control-height-sm);
}

.ktmp-logs-date {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--ktmp-text-secondary);
}

.ktmp-logs-transactions .ktmp-logs-col-id {
    width: 72px;
}

/* The row whose Delete link has focus is marked while the browser asks to confirm. */
.widefat.ktmp-data-table > tbody > tr:has(.ktmp-logs-delete:focus) {
    background: var(--ktmp-accent-tint);
}

.widefat.ktmp-data-table > tbody > tr:has(.ktmp-logs-delete:focus) > :first-child {
    box-shadow: inset 3px 0 0 var(--ktmp-accent);
}

/* The "Unknown" status: grey, no dot. */
.ktmp-badge.ktmp-logs-badge--plain::before {
    content: none;
}

/* Transaction detail */
.ktmp-logs-back {
    margin: 0 0 var(--ktmp-space-4);
}

.ktmp-logs-back a {
    display: inline-flex;
    align-items: center;
    gap: var(--ktmp-space-1);
}

.ktmp-logs-back .dashicons {
    width: 16px;
    height: 16px;
    font-size: 16px;
}

.ktmp-logs .ktmp-card + .ktmp-log {
    margin-top: var(--ktmp-space-5);
}

/* Included products: a native details element drawn as the shared disclosure card. */
.ktmp-transaction-products > summary {
    list-style: none;
    border-radius: 7px;
}

.ktmp-transaction-products > summary::-webkit-details-marker {
    display: none;
}

.ktmp-transaction-products[open] > summary {
    border-radius: 7px 7px 0 0;
}

.ktmp-transaction-products[open] > summary .ktmp-disclosure__icon {
    transform: rotate(90deg);
}

.rtl .ktmp-transaction-products:not([open]) > summary .ktmp-disclosure__icon {
    transform: scaleX(-1);
}

.ktmp-transaction-products .ktmp-table-scroll--sticky {
    max-height: 400px;
    border-radius: 0 0 7px 7px;
}

/* Log rows here have no time column. */
.ktmp-logs-log .ktmp-log__item {
    grid-template-columns: 20px minmax(0, 1fr);
}

.ktmp-logs-log--response {
    max-height: 560px;
}

.ktmp-logs-dot {
    display: block;
    box-sizing: border-box;
    width: 8px;
    height: 8px;
    margin: 0 auto;
    border-radius: var(--ktmp-radius-pill);
    background: var(--ktmp-text-muted);
}

.ktmp-logs-item--info .ktmp-log__icon {
    color: var(--ktmp-accent);
}

/* A row that opens keeps the colour of its type and puts the chevron at the end. */
.ktmp-logs-log .ktmp-log__group > .ktmp-disclosure__toggle {
    color: inherit;
}

.ktmp-logs-log .ktmp-log__group .ktmp-disclosure__title {
    flex: 1;
    overflow-wrap: anywhere;
}

.ktmp-logs-log .ktmp-log__messages {
    padding-inline-start: 40px;
    list-style: disc;
    color: var(--ktmp-text);
}

.ktmp-logs-log .ktmp-log__messages li {
    margin: 0 0 var(--ktmp-space-1);
}

/* Stat cards above the response log. */
.ktmp-response-header {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--ktmp-space-4);
    margin: 0 0 var(--ktmp-space-5);
}

.ktmp-response-card {
    display: flex;
    align-items: center;
    gap: var(--ktmp-space-4);
    padding: var(--ktmp-space-4) var(--ktmp-space-5);
    border: 1px solid var(--ktmp-border-strong);
    border-radius: var(--ktmp-radius-lg);
    background: var(--ktmp-surface-card);
}

.ktmp-response-card-icon {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: var(--ktmp-radius-pill);
    background: var(--ktmp-neutral-tint);
    color: var(--ktmp-text-secondary);
}

.ktmp-response-card--info .ktmp-response-card-icon {
    background: var(--ktmp-accent-tint);
    color: var(--ktmp-accent);
}

.ktmp-response-card--success .ktmp-response-card-icon {
    background: var(--ktmp-success-tint);
    color: var(--ktmp-success-text);
}

.ktmp-response-card--warning .ktmp-response-card-icon {
    background: var(--ktmp-warning-tint);
    color: var(--ktmp-warning-text);
}

.ktmp-response-card--error .ktmp-response-card-icon {
    background: var(--ktmp-error-tint);
    color: var(--ktmp-error-text);
}

.ktmp-response-card-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.ktmp-response-card-label {
    font-size: var(--ktmp-type-body-size);
    color: var(--ktmp-text-secondary);
}

.ktmp-response-card-stat {
    font-size: 28px;
    line-height: 1.2;
    font-weight: var(--ktmp-weight-strong);
    color: var(--ktmp-text);
    font-variant-numeric: tabular-nums;
}

@media screen and (max-width: 782px) {
    .ktmp-logs-toolbar .tablenav-pages {
        width: 100%;
    }
}
