/* ===========================================================================
   Index pages: Candidates, Roles, Clients
   ===========================================================================

   These three pages exist to find things. You search, filter, explore, then
   open what you found -- and every action lives inside that record. So there
   is no row selection and nothing here changes a record, which is also why the
   whole row is the click target rather than a small button at the end of it.

   Values come from tokens.css. Where a literal appears below it is because the
   value is genuinely local (a column width, a rail width), not a colour or a
   size that belongs to the system.
   =========================================================================== */

.index-page-wrapper {
    padding: 15px 0 20px 0;
    font-family: var(--tpt-font) !important;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.index-page-wrapper *,
.index-page-wrapper button,
.index-page-wrapper input,
.index-page-wrapper select,
.index-page-wrapper label,
.ts-wrapper * {
    font-family: var(--tpt-font) !important;
}

.index-page-wrapper .fa-solid,
.index-page-wrapper .fa-regular,
.index-page-wrapper .fa-brands,
.index-page-wrapper [class*="fa-"] {
    font-family: 'Font Awesome 6 Free', 'Font Awesome 5 Free', 'FontAwesome' !important;
}

/* --- page header --------------------------------------------------------- */

.index-main-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: var(--tpt-space-4);
    margin-bottom: var(--tpt-space-3);
    padding: 0 var(--tpt-space-1);
    flex-shrink: 0;
}
.index-main-header h1 {
    font-size: var(--tpt-text-xl);
    font-weight: 800;
    color: var(--tpt-text);
    margin: 0 0 2px 0;
    letter-spacing: -0.01em;
}
.total-count-badge {
    font-size: var(--tpt-text-base);
    color: var(--tpt-text-subtle);
    font-weight: 600;
}
.total-count-badge strong {
    color: var(--tpt-text-strong);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.btn-primary-action {
    display: inline-flex;
    align-items: center;
    gap: var(--tpt-space-1);
    background-color: var(--tpt-accent);
    color: #FFFFFF;
    padding: 9px 16px;
    border-radius: var(--tpt-radius);
    text-decoration: none;
    font-weight: 700;
    font-size: var(--tpt-text-base);
    border: 1px solid transparent;
    transition: background-color 0.15s ease;
}
.btn-primary-action:hover { background-color: var(--tpt-accent-hover); }

/* --- the two-column layout: filter rail beside the results --------------- */

.list-layout {
    display: flex;
    align-items: stretch;
    gap: var(--tpt-space-4);
    width: 100%;
    flex: 0 0 auto;
    height: calc(100vh - 85px);
    min-height: 0;
}

.list-results {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Open beside the results rather than over them. The filters used to sit in a
   modal that slid in from the left, so once it closed the only trace of what
   you had asked for was a count badge -- you could not see the twelve active
   filters, let alone remove one. */
.list-rail {
    width: 260px;
    flex-shrink: 0;
    align-self: stretch;
    background: var(--tpt-surface);
    border: 1px solid var(--tpt-border);
    border-radius: var(--tpt-radius-lg);
    box-shadow: var(--tpt-shadow-sm);
    padding: var(--tpt-space-4);
    max-height: none;
    overflow-y: auto;
}

/* The rhythm lives on the form, not on the rail.
   `form_with` wraps every field in a <form>, so the rail has exactly one flex
   child -- a gap set on the rail has nothing to sit between and silently does
   nothing. The fields were rendering flush against each other at 0px while the
   label sat 6px above its own control, so each label read as belonging to the
   box above it. 18 between fields against 6 inside one. */
.list-rail > form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* The header is not a field, so it does not sit in the field rhythm: it needs
   clear air beneath it or the first label reads as part of it. */
.list-rail-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: var(--tpt-space-3);
    margin-bottom: -2px;
    border-bottom: 1px solid var(--tpt-border);
}
.list-rail-head .tpt-eyebrow {
    font-size: 12px;
    letter-spacing: 0.08em;
    color: var(--tpt-text-strong);
}
.list-rail-head .tpt-link { font-size: 13px; }

.list-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.list-field > label,
.list-rail .modal-field-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--tpt-text-muted);
    margin-bottom: 3px;
}
.list-field-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--tpt-space-2);
}
.list-field-pair > * { min-width: 0; }

/* The native date control reserves room for its own picker button, so it does
   not shrink below its intrinsic width and overflowed the rail. Full width, and
   never allowed to push past the container. */
.list-rail input[type="date"] {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.list-rail-note {
    border-top: 1px solid var(--tpt-border);
    padding-top: var(--tpt-space-4);
    margin: var(--tpt-space-1) 0 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--tpt-text-subtle);
    line-height: 1.5;
}

/* --- toolbar ------------------------------------------------------------- */

.list-toolbar {
    display: flex;
    align-items: center;
    gap: var(--tpt-space-2);
    flex-wrap: wrap;
    margin-bottom: var(--tpt-space-3);
}

/* The search is its own form so Enter submits it; the form is the flex item. */
.list-search-form {
    display: flex;
    flex: 1;
    min-width: 220px;
    max-width: 340px;
}

.list-search {
    display: flex;
    align-items: center;
    gap: var(--tpt-space-2);
    flex: 1;
    min-width: 0;
    padding: 8px 12px;
    background: var(--tpt-surface);
    border: 1px solid var(--tpt-border-strong);
    border-radius: var(--tpt-radius);
    box-shadow: var(--tpt-shadow-sm);
    color: var(--tpt-text-faint);
}
.list-search:focus-within {
    border-color: var(--tpt-accent);
    box-shadow: var(--tpt-focus-ring);
}
.list-search input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    font-size: var(--tpt-text-base);
    font-weight: 600;
    color: var(--tpt-text);
    padding: 0;
}
.list-search input::placeholder {
    color: var(--tpt-text-faint);
    font-weight: 500;
}
.list-search input[type="search"]::-webkit-search-decoration,
.list-search input[type="search"]::-webkit-search-cancel-button {
    -webkit-appearance: none;
}

/* Status tabs. A segmented control, not pills scattered across the page. */
.list-seg {
    display: flex;
    background: var(--tpt-surface);
    border: 1px solid var(--tpt-border-strong);
    border-radius: var(--tpt-radius);
    overflow: hidden;
    box-shadow: var(--tpt-shadow-sm);
}
.list-seg a {
    font-size: var(--tpt-text-xs);
    font-weight: 600;
    color: var(--tpt-text-muted);
    padding: 8px 13px;
    text-decoration: none;
    border-right: 1px solid var(--tpt-border);
    white-space: nowrap;
}
.list-seg a:last-child { border-right: none; }
.list-seg a:hover { background: var(--tpt-surface-sunken); }
.list-seg a.active {
    background: var(--tpt-accent-tint);
    color: var(--tpt-accent-deep);
    font-weight: 800;
}



/* --- active filter chips ------------------------------------------------- */

.list-chips {
    display: flex;
    align-items: center;
    gap: var(--tpt-space-2);
    flex-wrap: wrap;
    margin-bottom: var(--tpt-space-3);
}

.list-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 4px 9px 4px 11px;
    background: var(--tpt-surface);
    border: 1px solid var(--tpt-border-strong);
    border-radius: 16px;
    font-size: var(--tpt-text-xs);
    font-weight: 600;
    color: var(--tpt-text-strong);
    text-decoration: none;
    white-space: nowrap;
}
.list-chip:hover {
    border-color: var(--tpt-accent);
    color: var(--tpt-text);
}
.list-chip b { font-weight: 800; color: var(--tpt-text); }
.list-chip .list-chip-x {
    color: var(--tpt-text-faint);
    font-weight: 700;
    font-size: 13px;
    line-height: 1;
}
.list-chip:hover .list-chip-x { color: var(--tpt-accent); }

.list-chip-clear {
    font-size: var(--tpt-text-xs);
    font-weight: 700;
    color: var(--tpt-text-muted);
    text-decoration: underline;
}

/* --- the table ----------------------------------------------------------- */

.table-container-card {
    background: var(--tpt-surface);
    border-radius: var(--tpt-radius-lg);
    box-shadow: var(--tpt-shadow-sm);
    border: 1px solid var(--tpt-border);
    width: 100%;
    position: relative;
    /* Grows into the results column rather than hugging three rows. The card is
       the scroll container, which is what the sticky header sticks to. */
    flex: 1;
    min-height: 240px;
    overflow-y: auto;
    overflow-x: hidden;
}

.crm-data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    table-layout: fixed;
}
.crm-data-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    background-color: var(--tpt-surface-sunken);
    padding: 11px 16px;
    font-size: var(--tpt-text-xs);
    font-weight: 700;
    color: var(--tpt-text-muted);
    border-bottom: 1px solid var(--tpt-border);
    white-space: nowrap;
}
.crm-data-table td {
    padding: 12px 16px;
    font-size: var(--tpt-text-base);
    color: var(--tpt-text-strong);
    border-bottom: 1px solid var(--tpt-border);
    vertical-align: middle;
}

/* Sortable headers. `.table-sort-icon` was styled here and never rendered --
   the columns simply were not clickable. */
.crm-data-table th a {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: inherit;
    text-decoration: none;
}
.crm-data-table th a:hover { color: var(--tpt-text); }
.table-sort-icon {
    font-size: 10px;
    color: var(--tpt-text-faint);
}
.crm-data-table th a.sorted { color: var(--tpt-accent); }
.crm-data-table th a.sorted .table-sort-icon { color: var(--tpt-accent); }

/* The row is the way in, so it has to look and behave like one. */
.crm-data-table tbody tr {
    cursor: pointer;
    transition: background-color 0.12s ease;
}
.crm-data-table tbody tr:hover { background-color: var(--tpt-accent-tint); }
.crm-data-table tbody tr:focus-within { background-color: var(--tpt-accent-tint); }

/* A pointer gets the whole row; a keyboard gets this real link on the name.
   An absolutely-positioned overlay link cannot cover a table row reliably, so
   the row click is delegated in JavaScript and the link is the accessible
   route -- not the other way round. */
.row-open-link {
    text-decoration: none;
    color: inherit;
    display: block;
    min-width: 0;
}
.row-open-link:focus-visible {
    outline: 2px solid var(--tpt-accent);
    outline-offset: 2px;
    border-radius: var(--tpt-radius-sm);
}

.entity-identity-cell {
    display: flex;
    align-items: center;
    gap: var(--tpt-space-3);
}
.entity-avatar-placeholder {
    width: 32px;
    height: 32px;
    background-color: var(--tpt-surface-muted);
    border-radius: var(--tpt-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--tpt-text-subtle);
}
.entity-name-text {
    font-weight: 700;
    color: var(--tpt-text);
}

.cell-truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cell-nowrap { white-space: nowrap; }
.cell-sub {
    display: block;
    font-size: var(--tpt-text-xs);
    color: var(--tpt-text-subtle);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------------------------------------------------------------------------
   Infinitely scrolling lists
   Replaces the numbered pagination that used to sit under these tables. On
   Candidates and Roles those numbers were plain text rather than links, so
   nothing past the fiftieth record could be reached at all.
   --------------------------------------------------------------------------- */

/* Watched by the infinite-scroll controller. Height, not just presence: a
   zero-height element never reports as intersecting in some browsers. */
.list-sentinel { height: 1px; }

.list-more {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--tpt-space-2);
    padding: var(--tpt-space-4);
    font-size: var(--tpt-text-xs);
    font-weight: 600;
    color: var(--tpt-text-subtle);
}
.list-more b {
    color: var(--tpt-text-strong);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}
.list-more-error { color: var(--tpt-critical); }
.list-more-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid var(--tpt-border-strong);
    border-right-color: var(--tpt-accent);
    border-radius: 50%;
    animation: listMoreSpin 0.7s linear infinite;
}
@keyframes listMoreSpin {
    to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
    .list-more-spinner { animation: none; }
}

.empty-state-card {
    background: var(--tpt-surface);
    padding: 56px 40px;
    text-align: center;
    border-radius: var(--tpt-radius-lg);
    border: 1px dashed var(--tpt-border-strong);
}
.empty-state-icon {
    font-size: 40px;
    margin-bottom: var(--tpt-space-3);
}
.empty-state-card h2 {
    font-size: var(--tpt-text-xl);
    font-weight: 800;
    color: var(--tpt-text);
    margin: 0 0 var(--tpt-space-2) 0;
}
.empty-state-card p {
    color: var(--tpt-text-muted);
    font-size: var(--tpt-text-md);
    max-width: 420px;
    margin: 0 auto;
}


.modal-field-label {
    display: block;
    font-size: var(--tpt-text-xs);
    font-weight: 700;
    color: var(--tpt-text-muted);
    margin-bottom: var(--tpt-space-1);
}
.modal-input-field,
.modal-select-field {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--tpt-border-strong);
    border-radius: var(--tpt-radius);
    font-size: var(--tpt-text-base);
    font-weight: 600;
    color: var(--tpt-text);
    background-color: var(--tpt-surface);
    box-sizing: border-box;
    box-shadow: var(--tpt-shadow-sm);
}
.modal-input-field:focus,
.modal-select-field:focus {
    outline: none;
    border-color: var(--tpt-accent);
    box-shadow: var(--tpt-focus-ring);
}

.list-rail .modal-input-field,
.list-rail .ts-control {
    padding: 9px 12px !important;
    font-size: 13px !important;
    font-weight: 500 !important;
}

.list-rail .ts-wrapper.is-set .ts-control,
.list-rail .modal-input-field.is-set {
    border-color: var(--tpt-accent) !important;
    color: var(--tpt-text) !important;
    font-weight: 600 !important;
}

/* ==========================================
   TomSelect Integration Styles
   ========================================== */

/* 1. Force the wrapper container to full width and strip default offsets */
.list-rail .ts-wrapper,
.list-rail .ts-wrapper.single,
.list-rail .ts-wrapper.plugin-dropdown_input {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 100% !important;
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

/* 2. Control input box spanning 100% edge-to-edge */
.list-rail .ts-wrapper .ts-control,
.list-rail .ts-wrapper.single .ts-control {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 100% !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    background-color: var(--tpt-surface) !important;
    border: 1px solid var(--tpt-border-strong) !important;
    border-radius: var(--tpt-radius) !important;
    color: var(--tpt-text) !important;
    padding: 8px 34px 8px 12px !important; /* Space for caret on the right */
    font-size: 13px !important;
    box-shadow: var(--tpt-shadow-sm) !important;
    position: relative !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
}

/* 3. Remove native gray text selection rectangle inside TomSelect items */
.list-rail .ts-control .item,
.list-rail .ts-control .item.active {
    background-color: transparent !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* 4. Unfilled Chevron Arrow (Clean SVG Mask) */
.list-rail .ts-wrapper.single .ts-control::after {
    content: "" !important;
    position: absolute !important;
    top: 50% !important;
    right: 12px !important;
    width: 12px !important;
    height: 12px !important;
    margin-top: -6px !important;
    border: none !important;
    background-color: var(--tpt-text-muted, #6b7280) !important;
    -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M19.5 8.25l-7.5 7.5-7.5-7.5" /></svg>') center/contain no-repeat !important;
    mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M19.5 8.25l-7.5 7.5-7.5-7.5" /></svg>') center/contain no-repeat !important;
    transition: transform 0.15s ease !important;
    pointer-events: none !important;
}

/* 5. Caret flip on open */
.list-rail .ts-wrapper.single.dropdown-active .ts-control::after {
    transform: rotate(180deg) !important;
}

/* 6. Dropdown Menu Container */
.list-rail .ts-dropdown {
    width: 100% !important;
    box-sizing: border-box !important;
    background: var(--tpt-surface) !important;
    border: 1px solid var(--tpt-border-strong);
    border-radius: var(--tpt-radius) !important;
    box-shadow: var(--tpt-shadow-sm) !important;
    color: var(--tpt-text) !important;
    z-index: 100 !important;
}

.list-rail .ts-dropdown .option {
    padding: 8px 12px !important;
    font-size: 13px !important;
    color: var(--tpt-text) !important;
}

.list-rail .ts-dropdown .option.active,
.list-rail .ts-dropdown .option:hover {
    background-color: var(--tpt-accent-tint) !important;
    color: var(--tpt-accent-deep) !important;
}

@media (max-width: 1100px) {
    .list-layout { flex-direction: column; height: auto; }
    .list-rail { width: 100%; }
}