/* erp-table.css split (5/6): preview drawer, table footer, rows-per-page and
 * pagination. */

.erp-preview-heading p,
.erp-preview-section-label {
    margin: 0 0 0.25rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.erp-preview-heading h2 {
    margin: 0;
    color: var(--color-kview);
    font-size: 1.22rem;
    font-weight: 700;
    line-height: 1.18;
}

.erp-preview-heading span {
    display: block;
    margin-top: 0.18rem;
    color: var(--text-secondary);
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.erp-preview-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
}

.erp-preview-close:hover,
.erp-preview-close:focus-visible {
    background: var(--surface-alt);
    color: var(--primary);
    outline: none;
}

.erp-preview-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 20px;
    min-height: 0;
    padding: 24px;
    overflow: auto;
}

.erp-preview-summary {
    margin: 0;
    padding: 14px 16px;
    border: 1px solid var(--divider);
    border-radius: var(--radius-lg);
    background: var(--surface-alt);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.erp-preview-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.erp-preview-badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--surface-alt);
    color: var(--color-ink);
    font-size: 0.73rem;
    font-weight: 700;
}

.erp-preview-badge--primary {
    border-color: rgba(18, 69, 252, 0.2);
    background: var(--primary-50);
    color: var(--primary);
}

.erp-preview-badge--accent {
    border-color: rgba(31, 162, 243, 0.26);
    background: var(--accent-50);
    color: var(--accent-600);
}

.erp-preview-badge--success {
    border-color: rgba(22, 163, 74, 0.18);
    background: var(--success-bg);
    color: var(--success-fg);
}

.erp-preview-badge--warning {
    border-color: rgba(245, 158, 11, 0.22);
    background: var(--warning-bg);
    color: var(--warning-fg);
}

.erp-preview-badge--danger {
    border-color: rgba(220, 38, 38, 0.2);
    background: var(--error-bg);
    color: var(--error-fg);
}

.erp-preview-badge--muted {
    background: var(--slate-50);
    color: var(--slate-600);
}

.erp-preview-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.erp-preview-metric {
    padding: 16px;
    border: 1px solid var(--divider);
    border-radius: var(--radius-lg);
    background: var(--surface-alt);
}

.erp-preview-metric-label {
    display: block;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
}

.erp-preview-metric-value {
    display: block;
    margin-top: 0.25rem;
    color: var(--color-kview);
    font-family: var(--font-mono);
    font-size: 1.05rem;
    font-weight: 700;
}

.erp-preview-metric-meta {
    display: block;
    margin-top: 0.15rem;
    color: var(--text-secondary);
    font-size: 0.76rem;
}

.erp-preview-section-label {
    margin-bottom: 10px;
}

.erp-preview-field-list {
    margin: 0;
}

.erp-preview-field {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--divider);
    font-size: 0.9rem;
}

.erp-preview-field dt {
    color: var(--text-secondary);
}

.erp-preview-field dd {
    margin: 0;
    color: var(--color-kview);
    font-weight: 700;
    text-align: right;
}

.erp-preview-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 16px;
    border-top: 1px solid var(--divider);
    background: var(--surface);
}

.erp-preview-overlay {
    background: rgba(11, 23, 48, 0.4);
    backdrop-filter: none;
}

.ui-dialog-content.erp-preview-panel--vue {
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    width: min(480px, 100vw);
    max-height: 100vh;
    max-height: 100dvh;
    overflow: hidden;
    border-width: 0 0 0 1px;
    border-radius: 0;
    transform: none;
}

.ui-dialog-content.erp-preview-panel--vue[data-state="open"] {
    animation: erpPreviewDrawerEnter var(--dur-slow) var(--ease-out);
}

.erp-preview-panel--vue .erp-preview-header > .ui-tooltip {
    justify-self: end;
}

@keyframes erpPreviewDrawerEnter {
    from {
        opacity: 0;
        transform: translateX(100%);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .ui-dialog-content.erp-preview-panel--vue {
        animation: none !important;
    }
}

.erp-empty-state {
    display: grid;
    justify-items: center;
    gap: 0.35rem;
    padding: 2.4rem 1rem;
    color: var(--text-secondary);
    text-align: center;
}

.erp-empty-state > .kv-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--primary-50);
    color: var(--primary);
}

.erp-empty-state strong {
    color: var(--color-kview);
    font-family: var(--font-heading);
    font-size: 1rem;
}

.erp-empty-state span {
    font-size: 0.86rem;
}

.erp-table-footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--surface);
}

.erp-table-footnote {
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.erp-page-size-form {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.82rem;
    line-height: 1.25;
    white-space: nowrap;
}

/* KviewFormField normally reserves one rem below every field. The page-size
 * control lives inside a one-line table footer, so that form rhythm would
 * create 16 px of invisible height and misalign all three footer groups. */
.erp-page-size-form .ui-form-field {
    margin-bottom: 0;
}

.erp-page-size-form .ui-dropdown {
    width: 64px;
    flex: 0 0 64px;
}

.erp-page-size-form .ui-dropdown-trigger {
    min-height: 32px;
    padding: 0 0.45rem;
    border-color: var(--border);
    border-radius: 6px;
    font-size: 0.82rem;
}

.erp-table-pagination .pagination {
    justify-content: flex-end;
}

.erp-table-card--vue .erp-pagination-boundary {
    width: 2rem;
    min-width: 2rem;
    padding: 0;
}

.erp-table-card--vue .erp-pagination-boundary .kv-icon {
    flex: 0 0 auto;
}
.erp-table-card.is-ui-loading .erp-table-shell {
    opacity: 0.58;
}

@keyframes tableProcessingSweep {
    0% {
        transform: translateX(-35%) scaleX(0.2);
    }

    50% {
        transform: translateX(18%) scaleX(0.65);
    }

    100% {
        transform: translateX(58%) scaleX(0.2);
    }
}

@media (prefers-reduced-motion: reduce) {
    .erp-table-card.is-erp-processing .erp-table-toolbar::after {
        animation-duration: 1ms;
    }
}

@media (max-width: 991px) {
    .erp-table-header,
    .erp-table-footer {
        align-items: stretch;
        grid-template-columns: 1fr;
        flex-direction: column;
    }

    .erp-table-header-actions {
        justify-content: flex-start;
    }

    .erp-table-toolbar-leading {
        width: auto;
        min-width: 0;
    }

    .erp-table-search {
        width: min(420px, 100%);
        min-width: 0;
        flex: 1 1 420px;
    }

    .erp-table-pagination .pagination {
        justify-content: flex-start;
    }
}

@media (max-width: 720px) {
    .erp-preview-drawer {
        grid-template-columns: 1fr;
    }

    .erp-preview-panel {
        grid-column: 1;
        width: 100%;
        border-left: 0;
    }

    .erp-preview-metrics {
        grid-template-columns: 1fr;
    }
}
