/* ============================================================================
   Tables - .table, .table-striped, .table-hover, DataTables wrapper
   ============================================================================ */

body.theme-new .table {
    color: var(--text-main);
    background: transparent;
    margin-bottom: 12px;
}

body.theme-new .table > thead > tr > th,
body.theme-new .table > thead > tr > td {
    background: var(--bg-elevated);
    color: var(--text-heading);
    border-bottom: 1px solid var(--border-color);
    border-top: none;
    font-weight: 600;
    letter-spacing: 0.2px;
    padding: 12px 14px;
}

body.theme-new .table > tbody > tr > td,
body.theme-new .table > tfoot > tr > td {
    background: transparent;
    color: var(--text-main);
    border-top: 1px solid var(--border-soft);
    padding: 11px 14px;
    vertical-align: middle;
}

/* Striped */
body.theme-new .table-striped > tbody > tr:nth-of-type(odd) > td {
    background: rgba(255, 255, 255, 0.02);
}

:root[data-theme="light"] body.theme-new .table-striped > tbody > tr:nth-of-type(odd) > td {
    background: rgba(0, 0, 0, 0.02);
}

@media (prefers-color-scheme: light) {
    :root[data-theme="auto"] body.theme-new .table-striped > tbody > tr:nth-of-type(odd) > td {
        background: rgba(0, 0, 0, 0.02);
    }
}

/* Hover - subtle green tint */
body.theme-new .table-hover > tbody > tr:hover > td {
    background: var(--primary-tint);
}

/* Bordered */
body.theme-new .table-bordered,
body.theme-new .table-bordered > thead > tr > th,
body.theme-new .table-bordered > tbody > tr > td {
    border-color: var(--border-soft);
}

/* DataTables wrapper - the chrome around the table */
body.theme-new .dataTables_wrapper {
    color: var(--text-main);
}

body.theme-new .dataTables_wrapper .dataTables_length,
body.theme-new .dataTables_wrapper .dataTables_filter,
body.theme-new .dataTables_wrapper .dataTables_info,
body.theme-new .dataTables_wrapper .dataTables_processing,
body.theme-new .dataTables_wrapper .dataTables_paginate {
    color: var(--text-muted);
}

body.theme-new .dataTables_wrapper .dataTables_length select,
body.theme-new .dataTables_wrapper .dataTables_filter input {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-main);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    transition: border-color var(--transition-speed) var(--ease-standard), box-shadow var(--transition-speed) var(--ease-standard);
}

body.theme-new .dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--input-focus);
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-focus);
}

/* Overrides for info/active rows that have hardcoded black text in legacy CSS */
body.theme-new .table > tbody > tr.info > td,
body.theme-new .table > tbody > tr.info > td a,
body.theme-new .table > tbody > tr.active > td,
body.theme-new .table > tbody > tr.active > td a {
    color: var(--text-main) !important;
}

:root[data-theme="light"] body.theme-new .table > tbody > tr.info > td,
:root[data-theme="light"] body.theme-new .table > tbody > tr.info > td a {
    color: #000000 !important;
}

/* DataTables pagination buttons */
body.theme-new .dataTables_wrapper .dataTables_paginate .paginate_button {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    margin-left: 4px;
    transition:
        background var(--transition-speed) var(--ease-standard),
        color var(--transition-speed) var(--ease-standard),
        border-color var(--transition-speed) var(--ease-standard);
}

body.theme-new .dataTables_wrapper .dataTables_paginate .paginate_button:hover,
body.theme-new .dataTables_wrapper .dataTables_paginate .paginate_button:focus {
    background: var(--primary-tint) !important;
    border-color: var(--primary-color) !important;
    color: var(--text-heading) !important;
}

body.theme-new .dataTables_wrapper .dataTables_paginate .paginate_button.current,
body.theme-new .dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: var(--bg-body) !important;
    font-weight: 600;
}

body.theme-new .dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
body.theme-new .dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover {
    background: transparent !important;
    border-color: var(--border-soft) !important;
    color: var(--text-muted) !important;
    opacity: 0.6;
}

/* DataTables sort indicators */
body.theme-new table.dataTable thead .sorting,
body.theme-new table.dataTable thead .sorting_asc,
body.theme-new table.dataTable thead .sorting_desc {
    cursor: pointer;
}

body.theme-new table.dataTable thead .sorting_asc::after,
body.theme-new table.dataTable thead .sorting_desc::after {
    color: var(--primary-color);
}

/* Empty / no-records row */
body.theme-new table.dataTable tbody tr.dataTables_empty td,
body.theme-new table.dataTable tbody td.dataTables_empty {
    color: var(--text-muted);
    text-align: center;
    padding: 28px 14px;
}

/* Contextual rows/cells (info, success, warning, danger)
   Ensures background tints and readable text in dark mode. */
body.theme-new .table > tbody > tr.info > td,
body.theme-new .table > tbody > tr > td.info {
    background: var(--info-tint) !important;
}
body.theme-new .table > tbody > tr.success > td,
body.theme-new .table > tbody > tr > td.success {
    background: var(--success-tint) !important;
}
body.theme-new .table > tbody > tr.warning > td,
body.theme-new .table > tbody > tr > td.warning {
    background: var(--warning-tint) !important;
}
body.theme-new .table > tbody > tr.danger > td,
body.theme-new .table > tbody > tr > td.danger {
    background: var(--danger-tint) !important;
}

/* Overrides for info/active rows that have hardcoded black text in legacy CSS */
body.theme-new .table > tbody > tr.info > td,
body.theme-new .table > tbody > tr.info > td a,
body.theme-new .table > tbody > tr.active > td,
body.theme-new .table > tbody > tr.active > td a {
    color: var(--text-main) !important;
}

:root[data-theme="light"] body.theme-new .table > tbody > tr.info > td,
:root[data-theme="light"] body.theme-new .table > tbody > tr.info > td a {
    color: #000000 !important;
}
   Ensures links inside colored rows/cells remain readable. */
body.theme-new .table > tbody > tr.info > td a,
body.theme-new .table > tbody > tr > td.info a,
body.theme-new .table > tbody > tr.success > td a,
body.theme-new .table > tbody > tr > td.success a,
body.theme-new .table > tbody > tr.warning > td a,
body.theme-new .table > tbody > tr > td.warning a,
body.theme-new .table > tbody > tr.danger > td a,
body.theme-new .table > tbody > tr > td.danger a {
    color: var(--text-main) !important;
}
body.theme-new .table > tbody > tr.info > td a:hover,
body.theme-new .table > tbody > tr > td.info a:hover {
    color: var(--primary-color) !important;
}

/* Perfex panel-table-full wrapper - keep flush against the panel edges */
body.theme-new .panel_s > .panel-body > .dataTables_wrapper,
body.theme-new .panel-body > .panel-table-full {
    margin: 0;
}

body.theme-new .panel-table-full > table {
    margin: 0;
}

/* Skeleton loader rows (PR 3 JS will inject these inside an empty
   .panel-table-full while AJAX is in flight). Defining the keyframes
   here so PR 2 ships skeleton-ready CSS. */
body.theme-new .pp-skeleton-row td {
    background:
        linear-gradient(
            90deg,
            transparent 0%,
            rgba(255, 255, 255, 0.04) 30%,
            rgba(255, 255, 255, 0.08) 50%,
            rgba(255, 255, 255, 0.04) 70%,
            transparent 100%
        ),
        var(--bg-card) !important;
    background-size: 800px 100%, 100% 100%;
    background-repeat: no-repeat;
    animation: ppSkeletonShimmer 1.4s linear infinite;
    color: transparent !important;
    border-color: var(--border-soft) !important;
}

body.theme-new .pp-skeleton-row td * {
    visibility: hidden;
}

@keyframes ppSkeletonShimmer {
    0%   { background-position: -400px 0, 0 0; }
    100% { background-position: 800px 0, 0 0; }
}

@media (prefers-reduced-motion: reduce) {
    body.theme-new .pp-skeleton-row td {
        animation: none !important;
    }
    body.theme-new .dataTables_wrapper .dataTables_paginate .paginate_button {
        transition: none !important;
    }
}

/* ============================================================================
   Pagination row fix: kill ghost-empty paginate buttons + constrain the
   dt-page-jump select to a compact dropdown so it doesn't spawn visual
   placeholders. The user reported empty boxes appearing between
   "Próximo" and the page-jump select on /admin/leads (huge tables).
   ============================================================================ */

/* Hide any paginate_button that has no anchor child (DataTables
   sometimes injects placeholder `<li class="paginate_button">` slots
   with no inner <a>; my .paginate_button rule above gives them a
   border + padding, so they render as a row of empty squares).
   `:empty` doesn't match whitespace-only children, so we use the
   modern `:not(:has(a))` selector. */
body.theme-new .pagination > .paginate_button:not(:has(a)),
body.theme-new .dataTables_wrapper .dataTables_paginate .paginate_button:not(:has(a)),
body.theme-new .dataTables_wrapper .dataTables_paginate .paginate_button:empty,
body.theme-new .dataTables_wrapper .dataTables_paginate .paginate_button > a:empty {
    display: none !important;
    border: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 0 !important;
    height: 0 !important;
    visibility: hidden !important;
}

/* Also: strip border+padding from `.paginate_button` <li> wrappers
   entirely; let the inner <a> own the visual styling. This guarantees
   that even older browsers (no `:has()` support) won't render empty
   <li> as boxes. */
body.theme-new ul.pagination > li.paginate_button {
    background: transparent !important;
    border: 0 !important;
    padding: 0 !important;
    margin: 0 2px !important;
    list-style: none;
}
body.theme-new ul.pagination > li.paginate_button > a {
    display: inline-block;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    text-decoration: none;
    transition:
        background var(--transition-speed) var(--ease-standard),
        color var(--transition-speed) var(--ease-standard),
        border-color var(--transition-speed) var(--ease-standard);
}
body.theme-new ul.pagination > li.paginate_button > a:hover,
body.theme-new ul.pagination > li.paginate_button > a:focus {
    background: var(--primary-tint) !important;
    border-color: var(--primary-color) !important;
    color: var(--text-heading) !important;
}
body.theme-new ul.pagination > li.paginate_button.active > a,
body.theme-new ul.pagination > li.paginate_button.current > a {
    background: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: #fff !important;
    font-weight: 600;
}
body.theme-new ul.pagination > li.paginate_button.disabled > a {
    color: var(--text-muted) !important;
    border-color: var(--border-soft) !important;
    cursor: not-allowed;
}

/* Empty inner #colvis (column-visibility container) - hide the box
   entirely when DataTables didn't inject anything into it */
body.theme-new .dataTables_paging #colvis:empty,
body.theme-new .dataTables_paging > div:empty {
    display: none !important;
}

/* Make the page-jump select render as a clean compact native dropdown,
   not as a wide bootstrap-select-style multi-row control. Even with a
   1890-option list, the select should be a single 32px-tall pill. */
body.theme-new .dt-page-jump {
    display: inline-flex;
    align-items: center;
    margin-left: 8px;
    vertical-align: middle;
}
body.theme-new .dt-page-jump-select,
body.theme-new select.dt-page-jump-select.form-control {
    width: auto !important;
    min-width: 70px;
    max-width: 90px;
    height: 32px !important;
    padding: 4px 24px 4px 10px !important;
    background-color: var(--input-bg) !important;
    border: 1px solid var(--input-border) !important;
    color: var(--text-main) !important;
    border-radius: var(--radius-sm) !important;
    font-size: 13px;
    appearance: menulist;            /* native arrow */
}

/* If bootstrap-select wrapper accidentally caught it, neutralize */
body.theme-new .dt-page-jump .bootstrap-select,
body.theme-new .dt-page-jump .bootstrap-select > .btn,
body.theme-new .dt-page-jump .bootstrap-select .dropdown-toggle {
    width: auto !important;
    max-width: 90px;
}

/* dataTables_paging container: clean flex layout so children align
   naturally and no phantom whitespace boxes appear */
body.theme-new .dataTables_paging,
body.theme-new .col-md-8.dataTables_paging {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
}
body.theme-new .dataTables_paging > div {
    display: inline-flex;
    align-items: center;
}

/* Infinity-loop loader (replaces the legacy 3-square .dt-loader).
   Rendered by pp_loop_loader_markup() in datatables_helper.php as the
   language.processing string for every server-side DataTable, plus the
   contactcenter manual AJAX injection. Pure SVG + SMIL — colors come
   from theme tokens so dark/light mode just work. */
body.theme-new .pp-loop-loader {
    display: inline-block;
    width: 88px;
    height: 44px;
    position: relative;
    line-height: 0;
}
body.theme-new .pp-loop-loader__svg {
    width: 100%;
    height: 100%;
    overflow: visible;
    filter: drop-shadow(0 0 6px var(--primary-glow, rgba(0, 224, 155, 0.35)));
}
body.theme-new .pp-loop-loader__rail  { stroke: var(--primary-300, rgba(0, 224, 155, 0.35)); }
body.theme-new .pp-loop-loader__line  { stroke: var(--primary-color); opacity: 0.85; }
body.theme-new .pp-loop-loader__dot-a { fill: var(--primary-color); }
body.theme-new .pp-loop-loader__dot-b { fill: var(--text-main, #fff); }

/* DataTables centers .dataTables_processing absolutely; make sure our
   loader sits centered inside it instead of left-aligned. */
body.theme-new .dataTables_wrapper .dataTables_processing {
    text-align: center;
    background: transparent;
    border: 0;
    box-shadow: none;
}

@media (prefers-reduced-motion: reduce) {
    /* SMIL motion can't be CSS-stopped cross-browser; the static rail
       still reads as a continuous loop, which is enough indication. */
    body.theme-new .pp-loop-loader__dot-a,
    body.theme-new .pp-loop-loader__dot-b {
        opacity: 0.6;
    }
}
