/* Inventory SaaS — Theme Package 3
   Tables, filters, list pages, pagination, status badges, empty states
*/

:root {
    --table-header-bg: #f8fafc;
    --table-row-hover: #f8fbff;
    --filter-bg: #ffffff;
    --muted-2: #94a3b8;
}

/* Page toolbar */
.list-toolbar,
.report-toolbar,
.filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.list-toolbar-left,
.list-toolbar-right,
.filter-bar-left,
.filter-bar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.list-toolbar h1,
.list-toolbar h2,
.report-toolbar h1,
.report-toolbar h2 {
    margin: 0;
}

.list-subtitle {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

/* Search */
.search-box {
    position: relative;
    min-width: 260px;
}

.search-box input {
    margin: 0;
    padding-left: 38px;
    background: #fff;
}

.search-box::before {
    content: "⌕";
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted-2);
    font-size: 18px;
    pointer-events: none;
}

/* Filter bar */
.filter-bar {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--filter-bg);
    box-shadow: var(--shadow);
}

.filter-bar label {
    margin: 0;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
}

.filter-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 150px;
}

.filter-field input,
.filter-field select {
    margin: 0;
    min-height: 38px;
}

.filter-actions {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding-top: 18px;
}

/* Data card/table */
.table-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.table-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
}

.table-card-title {
    margin: 0;
    font-size: 15px;
    font-weight: 750;
}

.table-card-meta {
    color: var(--muted);
    font-size: 12px;
}

.table-scroll {
    width: 100%;
    overflow-x: auto;
}

.table-modern {
    width: 100%;
    margin: 0;
    border-collapse: collapse;
}

.table-modern th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--table-header-bg);
    color: #475569;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .045em;
    text-transform: uppercase;
    white-space: nowrap;
}

.table-modern td,
.table-modern th {
    padding: 13px 15px;
    border-bottom: 1px solid #edf2f7;
}

.table-modern tbody tr {
    transition: background .12s ease;
}

.table-modern tbody tr:hover {
    background: var(--table-row-hover);
}

.table-modern tbody tr:last-child td {
    border-bottom: 0;
}

.table-modern td.numeric,
.table-modern th.numeric {
    text-align: right;
}

.table-modern td.actions {
    white-space: nowrap;
    text-align: right;
}

.table-modern .primary-cell {
    font-weight: 700;
    color: #0f172a;
}

.table-modern .secondary-text {
    color: var(--muted);
    font-size: 12px;
}

/* Compact action links */
.row-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.row-actions a,
.row-actions button {
    min-height: 32px;
    padding: 6px 9px;
    margin: 0;
    border-radius: 7px;
    font-size: 12px;
    box-shadow: none;
}

.row-actions .action-secondary {
    background: #fff;
    color: #334155;
    border: 1px solid var(--border);
}

.row-actions .action-secondary:hover {
    background: #f8fafc;
}

.row-actions .action-danger {
    background: #fff;
    color: var(--danger);
    border: 1px solid #fecaca;
}

.row-actions .action-danger:hover {
    background: var(--danger-bg);
}

/* Generic badges */
.badge,
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 750;
    white-space: nowrap;
}

.badge-neutral {
    background: #f1f5f9;
    color: #475569;
}

.badge-success,
.status-active,
.status-paid,
.status-approved,
.status-completed,
.status-received {
    background: var(--success-bg);
    color: #166534;
}

.badge-warning,
.status-pending,
.status-partially_paid,
.status-partial,
.status-draft {
    background: var(--warning-bg);
    color: #854d0e;
}

.badge-danger,
.status-overdue,
.status-cancelled,
.status-canceled,
.status-void,
.status-rejected,
.status-inactive {
    background: var(--danger-bg);
    color: #991b1b;
}

.badge-info,
.status-processing,
.status-open,
.status-issued {
    background: var(--info-bg);
    color: #075985;
}

/* Inventory emphasis */
.stock-low {
    color: var(--danger);
    font-weight: 750;
}

.stock-ok {
    color: var(--success);
    font-weight: 700;
}

.money-positive {
    color: var(--success);
    font-weight: 700;
}

.money-negative {
    color: var(--danger);
    font-weight: 700;
}

/* Pagination */
.pagination-wrap {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 14px 16px;
    border-top: 1px solid var(--border);
    background: #fff;
}

.pagination-summary {
    color: var(--muted);
    font-size: 12px;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 5px;
}

.pagination a,
.pagination span {
    min-width: 34px;
    min-height: 34px;
    display: inline-grid;
    place-items: center;
    padding: 0 9px;
    border: 1px solid var(--border);
    border-radius: 7px;
    color: #334155;
    background: #fff;
    text-decoration: none;
    font-size: 12px;
    font-weight: 650;
}

.pagination a:hover {
    background: #f8fafc;
}

.pagination .active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.pagination .disabled {
    opacity: .45;
    pointer-events: none;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--muted);
}

.empty-state-icon {
    width: 52px;
    height: 52px;
    margin: 0 auto 14px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 22px;
    font-weight: 800;
}

.empty-state h3 {
    margin: 0 0 7px;
    color: var(--text);
    font-size: 16px;
}

.empty-state p {
    max-width: 460px;
    margin: 0 auto 16px;
}

/* Summary strip for reports */
.summary-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.summary-strip .summary-item {
    padding: 14px 16px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.summary-item-label {
    color: var(--muted);
    font-size: 11px;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: .045em;
}

.summary-item-value {
    margin-top: 5px;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -.025em;
}

/* Utilities */
.text-muted { color: var(--muted) !important; }
.text-right { text-align: right !important; }
.text-center { text-align: center !important; }
.nowrap { white-space: nowrap !important; }

@media (max-width: 760px) {
    .list-toolbar,
    .report-toolbar,
    .filter-bar {
        align-items: stretch;
    }

    .list-toolbar-left,
    .list-toolbar-right,
    .filter-bar-left,
    .filter-bar-right {
        width: 100%;
    }

    .search-box,
    .filter-field {
        min-width: 100%;
        width: 100%;
    }

    .filter-actions {
        width: 100%;
        padding-top: 0;
    }

    .filter-actions .btn,
    .filter-actions button {
        flex: 1;
    }

    .table-modern td,
    .table-modern th {
        white-space: nowrap;
    }

    .pagination-wrap {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media print {
    .list-toolbar-right,
    .filter-bar,
    .pagination-wrap,
    .row-actions {
        display: none !important;
    }

    .table-card {
        border: 0;
        box-shadow: none;
    }

    .table-modern th {
        position: static;
    }
}
