/*
 * Shared pagination design — single source of truth for every pagination
 * control in the app (Bootstrap-native pagination, DataTables 2.x, the
 * legacy DataTables 1.13.7 bundle, and the hand-rolled website .pag-wrap).
 * Loaded on both the backend (admin/employer/candidate) and frontend
 * (website) layouts so every pagination control renders identically.
 */

/*
 * Laravel Debugbar renders a fixed, full-width bar pinned to the bottom of the
 * viewport with an extremely high z-index. On pages where pagination sits near
 * the bottom of the content flow, scrolling down can place the pagination row
 * underneath that bar, so a click lands on the debugbar instead of the button
 * beneath it (this is what made pagination clicks need 2-3 attempts). Reserve
 * clearance only when the debugbar is actually present — :has() makes this a
 * no-op in production, where the debugbar never renders.
 */
body:has(.phpdebugbar) {
    padding-bottom: 46px;
}
html:has(.phpdebugbar) {
    scroll-padding-bottom: 46px;
}

:root {
    --pagination-brand: #294272;
    --pagination-active-fill: var(--pagination-brand);
    --pagination-border: #e8eaf1;
    --pagination-text: #474747;
    --pagination-muted: #ccc;
    --pagination-surface: #fff;
    --pagination-radius: 8px;
    --pagination-size: 38px;
    --pagination-font-size: 13px;
    --pagination-gap: 6px;
}

/*
 * Dark-mode tokens. This file is shared with the public website layout,
 * which never toggles [data-bs-theme="dark"], so these are self-contained
 * literals rather than references into admin_new/app.css's --card/--line/
 * --brand tokens (those aren't guaranteed to exist wherever this stylesheet
 * loads). Values mirror that same dark palette by eye for visual
 * consistency across Admin + Employer, not by reference.
 *
 * --pagination-brand alone can't serve both roles it has in light mode: as
 * plain text/border color it needs to be light enough to read on a dark
 * background (#71a2ff, already used for dark-mode blue accents elsewhere),
 * but as the active page's solid fill behind white text that same light
 * blue is too close to white to give the number any contrast. --active-fill
 * splits that role out, using #3b82f6 - the same blue+white-text combination
 * already used for flatpickr's dark "selected date" state - so an "active/
 * selected" control looks the same everywhere in the app.
 */
[data-bs-theme="dark"] {
    --pagination-brand: #71a2ff;
    --pagination-active-fill: #3b82f6;
    --pagination-border: #2c3a58;
    --pagination-text: #e5e7eb;
    --pagination-muted: #64748b;
    --pagination-surface: #16233d;
}

/* Bootstrap-native pagination (<ul class="pagination"><li class="page-item">) */
.pagination {
    gap: var(--pagination-gap);
}
.pagination .page-item .page-link {
    min-width: var(--pagination-size);
    height: var(--pagination-size);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--pagination-radius);
    border-color: var(--pagination-border);
    color: var(--pagination-brand);
    font-size: var(--pagination-font-size);
    margin: 0;
}
.pagination .page-item.active .page-link {
    background-color: var(--pagination-active-fill);
    border-color: var(--pagination-active-fill);
    color: #fff;
}
.pagination .page-item.disabled .page-link {
    color: var(--pagination-muted);
    border-color: var(--pagination-border);
}
.pagination .page-item:not(.disabled):not(.active) .page-link:hover {
    border-color: var(--pagination-brand);
    color: var(--pagination-brand);
}
.pagination .page-item.disabled .page-link:hover {
    color: var(--pagination-muted);
    border-color: var(--pagination-border);
}
.pagination .page-item.active .page-link:hover {
    background-color: var(--pagination-active-fill);
    border-color: var(--pagination-active-fill);
    color: #fff;
}
.pagination a:focus,
.pagination button:focus,
.page-link:focus {
    outline: none;
    box-shadow: none;
}

/* DataTables 2.x (Admin + Employer dashboards) */
.dt-container .dt-paging .pagination {
    gap: var(--pagination-gap);
}
.dt-container .dt-paging .page-item {
    /* The <li> is the actual hover/hit-test target wrapping the <button>. Without this,
       the button's own margin created a small gap inside the <li> where the mouse was
       "over" the li (no hover style) but not the button (hover style) — real mouse
       jitter at that boundary flickered the button's hover color rapidly on/off. */
    display: flex;
}
.dt-container .dt-paging .page-link {
    min-width: var(--pagination-size);
    height: var(--pagination-size);
    display: flex;
    align-items: center;
    justify-content: center;
    border-color: var(--pagination-border);
    color: var(--pagination-brand);
    border-radius: var(--pagination-radius);
    font-size: var(--pagination-font-size);
    margin: 0;
}
.dt-container .dt-paging .active .page-link {
    background-color: var(--pagination-active-fill);
    border-color: var(--pagination-active-fill);
    color: #fff;
}
.dt-container .dt-paging .disabled .page-link {
    color: var(--pagination-muted);
    border-color: var(--pagination-border);
}
.dt-container .dt-paging .page-item:not(.disabled):not(.active) .page-link:hover {
    border-color: var(--pagination-brand);
    color: var(--pagination-brand);
}
.dt-container .dt-paging .disabled .page-link:hover {
    color: var(--pagination-muted);
    border-color: var(--pagination-border);
}
.dt-container .dt-paging .active .page-link:hover {
    background-color: var(--pagination-active-fill);
    border-color: var(--pagination-active-fill);
    color: #fff;
}

/* DataTables 1.13.7 legacy bundle (Candidate dashboard) */
div.dataTables_wrapper div.dataTables_paginate ul.pagination {
    gap: var(--pagination-gap);
}
div.dataTables_wrapper div.dataTables_paginate ul.pagination li {
    min-width: var(--pagination-size);
    height: var(--pagination-size);
    text-align: center;
}
div.dataTables_wrapper div.dataTables_paginate ul.pagination li.disabled {
    opacity: 1;
}
div.dataTables_wrapper div.dataTables_paginate ul.pagination li a,
div.dataTables_wrapper div.dataTables_paginate ul.pagination li .page-link {
    font-size: var(--pagination-font-size);
    border-radius: var(--pagination-radius);
    border: 1px solid var(--pagination-border);
    color: var(--pagination-brand);
    min-width: var(--pagination-size);
    height: var(--pagination-size);
    display: flex;
    align-items: center;
    justify-content: center;
}
div.dataTables_wrapper div.dataTables_paginate ul.pagination li.disabled a,
div.dataTables_wrapper div.dataTables_paginate ul.pagination li.disabled .page-link {
    color: var(--pagination-muted);
}
div.dataTables_wrapper div.dataTables_paginate ul.pagination .active > .page-link,
div.dataTables_wrapper div.dataTables_paginate ul.pagination .page-link.active {
    background-color: var(--pagination-active-fill);
    border-color: var(--pagination-active-fill);
    color: #fff;
}
div.dataTables_wrapper div.dataTables_paginate ul.pagination li:not(.disabled):not(.active) a:hover,
div.dataTables_wrapper div.dataTables_paginate ul.pagination li:not(.disabled):not(.active) .page-link:hover {
    border-color: var(--pagination-brand);
    color: var(--pagination-brand);
}
div.dataTables_wrapper div.dataTables_paginate ul.pagination li.disabled a:hover,
div.dataTables_wrapper div.dataTables_paginate ul.pagination li.disabled .page-link:hover {
    color: var(--pagination-muted);
}
div.dataTables_wrapper div.dataTables_paginate ul.pagination .active > .page-link:hover,
div.dataTables_wrapper div.dataTables_paginate ul.pagination .page-link.active:hover {
    background-color: var(--pagination-active-fill);
    border-color: var(--pagination-active-fill);
    color: #fff;
}

/* Public website hand-rolled pagination (.pag-wrap / .pag-btn) */
.pag-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--pagination-gap);
    padding: 16px 0;
}
.pag-btn {
    min-width: var(--pagination-size);
    height: var(--pagination-size);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--pagination-border);
    border-radius: var(--pagination-radius);
    font-size: var(--pagination-font-size);
    color: var(--pagination-text);
    cursor: pointer;
    background: var(--pagination-surface);
    user-select: none;
}
.pag-btn:hover:not(.disabled):not(.dots):not(.active) {
    border-color: var(--pagination-brand);
    color: var(--pagination-brand);
}
.pag-btn.active {
    background: var(--pagination-active-fill);
    color: #fff;
    border-color: var(--pagination-active-fill);
    font-weight: 700;
}
.pag-btn.active:hover {
    background: var(--pagination-active-fill);
    color: #fff;
    border-color: var(--pagination-active-fill);
}
.pag-btn.disabled {
    color: var(--pagination-muted);
    cursor: not-allowed;
}
.pag-btn.disabled:hover {
    border-color: var(--pagination-border);
    color: var(--pagination-muted);
}
.pag-btn.dots {
    border: none;
    cursor: default;
}

/*
 * None of the pagination markup variants above wrap by default (Bootstrap's
 * .pagination is a non-wrapping flex row), so a page with enough page-number
 * buttons can overflow narrow viewports instead of reflowing. Let every
 * variant wrap and center on small screens, and trim the hit-target size a
 * touch so more buttons fit per row before wrapping.
 */
@media (max-width: 575.98px) {
    :root {
        --pagination-size: 34px;
        --pagination-gap: 4px;
    }
    .pagination,
    div.dataTables_wrapper div.dataTables_paginate ul.pagination,
    .pag-wrap {
        flex-wrap: wrap;
        justify-content: center;
    }
}
