/* Pagination
   Pagination */

/* ======= PAGINATION STYLES ======= */

.pagination {
    display: flex;
    padding-left: 0;
    list-style: none;
    border-radius: var(--border-radius-md);
}

.page-item {
    margin: 0 2px;
}

    .page-item:first-child .page-link {
        border-top-left-radius: var(--border-radius-md);
        border-bottom-left-radius: var(--border-radius-md);
    }

    .page-item:last-child .page-link {
        border-top-right-radius: var(--border-radius-md);
        border-bottom-right-radius: var(--border-radius-md);
    }

html[dir="rtl"] .page-item:first-child .page-link {
    border-radius: 0;
    border-top-right-radius: var(--border-radius-md);
    border-bottom-right-radius: var(--border-radius-md);
}

html[dir="rtl"] .page-item:last-child .page-link {
    border-radius: 0;
    border-top-left-radius: var(--border-radius-md);
    border-bottom-left-radius: var(--border-radius-md);
}

.page-item.active .page-link {
    z-index: 3;
    color: #fff;
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.page-item.disabled .page-link {
    color: var(--text-light);
    pointer-events: none;
    cursor: auto;
    background-color: var(--card-bg-color);
    border-color: var(--border-color);
}

.page-link {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.75rem;
    min-width: 2.5rem;
    text-align: center;
    line-height: 1.25;
    color: var(--primary-color);
    background-color: var(--card-bg-color);
    border: 1px solid var(--border-color);
    text-decoration: none;
    cursor: pointer;
    font-weight: 500;
    transition: all var(--transition-fast);
}

    .page-link:hover {
        z-index: 2;
        color: var(--primary-color);
        text-decoration: none;
        background-color: var(--tertiary-color);
        border-color: var(--border-color);
    }

.page-link:focus {
    z-index: 3;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(var(--primary-color-rgb), 0.15);
}

/* ── ERP Pagination — desktop grid footer style ── */
.erp-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.4rem 0.6rem;
    width: 100%;
    padding: 0.4rem 0.75rem;
    background: color-mix(in srgb, var(--primary-color) 6%, white);
}

/* Right side — item count */
.erp-pagination__info {
    color: #334155;
    font-size: 0.78rem;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Left side — controls */
.erp-pagination__controls {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: nowrap;
}

/* Page-size picker */
.erp-pagination__size {
    height: 24px;
    width: auto;
    min-width: 3.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid color-mix(in srgb, var(--primary-color) 26%, white);
    border-radius: 2px;
    background: #fff;
    color: var(--primary-dark);
    padding: 0 0.4rem;
    cursor: pointer;
    margin-inline-end: 0.35rem;
}

/* All nav buttons (prev/next/first/last + numbered) */
.erp-pagination__btn {
    height: 24px;
    min-width: 24px;
    padding: 0 0.35rem;
    font-size: 0.72rem;
    font-weight: 600;
    border: 1px solid color-mix(in srgb, var(--primary-color) 26%, white);
    border-radius: 2px;
    background: #fff;
    color: var(--primary-dark);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s, border-color 0.12s;
    white-space: nowrap;
}

.erp-pagination__btn:hover:not(:disabled) {
    background: color-mix(in srgb, var(--primary-color) 12%, white);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.erp-pagination__btn:disabled {
    opacity: 0.38;
    cursor: not-allowed;
}

/* Numbered pages wrapper */
.erp-pagination__pages {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}

/* Numbered page button */
.erp-pagination__num {
    min-width: 24px;
    padding: 0 0.3rem;
}

/* Active page */
.erp-pagination__num--active {
    background: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: #fff !important;
}

/* Ellipsis */
.erp-pagination__ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    color: #64748b;
    font-size: 0.78rem;
    user-select: none;
}

/* RTL — no flex-direction override here: the ambient dir="rtl" already flows
   these buttons right-to-left, matching .erp-pagination__pages below it. Adding
   row-reverse would cancel that back to LTR ordering while the icons stay
   mirrored, pointing every arrow the wrong way. */
html[dir="rtl"] .erp-pagination .fa-chevron-left,
html[dir="rtl"] .erp-pagination .fa-chevron-right,
html[dir="rtl"] .erp-pagination .fa-angle-double-left,
html[dir="rtl"] .erp-pagination .fa-angle-double-right {
    transform: scaleX(-1);
}

/* Responsive */
@media (max-width: 768px) {
    .erp-pagination {
        flex-direction: column;
        align-items: flex-start;
    }

    .erp-pagination__pages {
        flex-wrap: wrap;
    }
}
