/* ==========================================================================
   Speedy Admin — Data tables & pagination
   ========================================================================== */

.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.data-table thead th {
    padding: 10px 14px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    color: var(--text-3);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    text-align: left;
    white-space: nowrap;
    user-select: none;
}
.data-table thead th.sortable { cursor: pointer; }
.data-table thead th.sortable:hover { color: var(--text); }
.data-table thead th .sort-arrow { display: inline-block; margin-left: 4px; opacity: 0.9; font-size: 10px; }

.data-table tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tbody tr.clickable { cursor: pointer; }
.data-table tbody tr.row-deleted { opacity: 0.55; }
.data-table tbody tr.row-deleted td:first-child { text-decoration: line-through; }

.data-table .cell-main { font-weight: 600; }
.data-table .cell-sub { display: block; font-size: 12px; color: var(--text-3); }
.data-table .cell-actions { text-align: right; white-space: nowrap; }
.data-table .cell-num { text-align: right; font-variant-numeric: tabular-nums; }

/* Amount coloring */
.amount { font-variant-numeric: tabular-nums; font-weight: 600; }
.amount.negative { color: var(--danger); }

/* ---------- Pagination ---------- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}
.pagination-info { font-size: 12.5px; color: var(--text-3); }
.pagination-controls { display: flex; gap: 4px; }

.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 30px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-2);
    font-family: var(--font);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.page-btn:hover:not(:disabled):not(.active) { border-color: var(--border-strong); color: var(--text); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- Invoice line items editor ---------- */
.items-editor {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    overflow: hidden;
}
.items-editor .item-row {
    display: grid;
    grid-template-columns: 1fr 72px 112px 76px 112px 42px;
    gap: 4px;
    align-items: center;
    padding: 3px 6px;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}
.items-editor .item-row:last-child { border-bottom: 0; }
.items-editor .item-row:not(.item-head):focus-within { background: var(--surface-2); }
.items-editor .item-head {
    padding: 8px 6px;
    background: var(--surface-2);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-3);
}
.items-editor .item-head span { padding: 0 9px; }
/* Numeric columns (qty / unit price / vat / total) align right */
.items-editor .item-head span:nth-child(n+2):nth-child(-n+5) { text-align: right; }
/* Description cell with billing-cycle picker (recurring catalog lines) */
.items-editor .item-desc { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.items-editor .item-desc select {
    width: fit-content;
    max-width: 100%;
    padding: 2px 24px 2px 9px;
    font-size: 11.5px;
    color: var(--text-2);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    cursor: pointer;
}
.items-editor .item-desc select:hover { border-color: var(--border-strong); }
.items-editor .item-desc select:focus {
    outline: none;
    background-color: var(--surface);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.items-editor .line-total {
    text-align: right;
    padding-right: 9px;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
}
.item-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    justify-self: center;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-3);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    transition: all var(--transition);
}
.item-remove:hover { color: var(--danger); background: var(--danger-soft); }

.invoice-totals {
    margin-top: 14px;
    margin-left: auto;
    width: 280px;
    font-size: 13.5px;
}
.invoice-totals .row { display: flex; justify-content: space-between; padding: 5px 0; }
.invoice-totals .row.total {
    border-top: 2px solid var(--border-strong);
    margin-top: 4px;
    padding-top: 9px;
    font-size: 15px;
    font-weight: 800;
}

@media (max-width: 760px) {
    .items-editor .item-row { grid-template-columns: 1fr 54px 90px 62px 90px 34px; }
}
