/* Shared list/grid (Components/Grid/WfDataGrid) and list-page toolbar. */

/* ---------- Toolbar ---------- */

.wf-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 16px;
    margin-bottom: 16px;
}

.wf-search {
    position: relative;
    display: flex;
    align-items: center;
    width: 280px;
    max-width: 100%;
}

    .wf-search .wf-icon {
        position: absolute;
        left: 12px;
        color: var(--wf-text-muted);
        pointer-events: none;
    }

    .wf-search input {
        width: 100%;
        height: 40px;
        padding: 0 12px 0 38px;
        font: inherit;
        color: var(--wf-text);
        background: var(--wf-surface);
        border: 1px solid var(--wf-border);
        border-radius: var(--wf-radius-sm);
        outline: none;
        transition: border-color 0.15s, box-shadow 0.15s;
    }

        .wf-search input:focus {
            border-color: var(--wf-primary);
            box-shadow: var(--wf-focus-ring);
        }

.wf-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    cursor: pointer;
    user-select: none;
}

    .wf-toggle input {
        width: 16px;
        height: 16px;
        margin: 0;
        accent-color: var(--wf-primary-strong);
    }

/* ---------- Buttons, badges, tags ---------- */

.wf-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 36px;
    padding: 0 14px;
    font: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--wf-text);
    text-decoration: none;
    background: var(--wf-surface);
    border: 1px solid var(--wf-border);
    border-radius: var(--wf-radius-sm);
    cursor: pointer;
}

    .wf-btn:hover {
        background: var(--wf-surface-alt);
    }

    .wf-btn:focus-visible {
        outline: none;
        box-shadow: var(--wf-focus-ring);
    }

.wf-btn-primary {
    color: #FFFFFF;
    background: var(--wf-primary-strong);
    border-color: var(--wf-primary-strong);
}

    .wf-btn-primary:hover {
        background: #105C97;
    }

.wf-badge {
    display: inline-block;
    padding: 1px 7px;
    margin-left: 6px;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    vertical-align: 1px;
}

.wf-badge-muted {
    background: #ECECEC;
    color: #5A5A5A;
}

/* Status pills (Active/Inactive, export states), as in Route Local's Status column. */
.wf-status {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.wf-status-success {
    background: #E6F6F1;
    color: #1E6F5C;
}

.wf-status-error {
    background: #FCEEF1;
    color: var(--wf-error-text);
    cursor: help;
}

.wf-status-info {
    background: var(--wf-primary-tint);
    color: var(--wf-primary-strong);
}

.wf-status-muted {
    background: #EFEFEF;
    color: #5A5A5A;
}

.wf-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.wf-tag {
    padding: 1px 8px;
    border-radius: 4px;
    background: var(--wf-primary-tint);
    color: var(--wf-primary-strong);
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

/* ---------- Grid ---------- */

.wf-grid {
    background: var(--wf-surface);
    border: 1px solid var(--wf-border);
    border-radius: var(--wf-radius);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.wf-grid-note {
    padding: 8px 16px;
    font-size: 0.8125rem;
    color: #7A4A12;
    background: #FFF6EC;
    border-bottom: 1px solid #F6DDC4;
    border-radius: var(--wf-radius) var(--wf-radius) 0 0;
}

.wf-grid-scroll {
    overflow-x: auto;
}

.wf-grid-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.875rem;
}

    .wf-grid-table th {
        position: sticky;
        top: 0;
        z-index: 1;
        padding: 0 12px;
        height: 44px;
        text-align: left;
        font-size: 0.75rem;
        font-weight: 600;
        letter-spacing: 0.03em;
        text-transform: uppercase;
        color: var(--wf-text-muted);
        background: #FAFBFC;
        border-bottom: 1px solid var(--wf-border);
        white-space: nowrap;
    }

        .wf-grid-table th:first-child {
            border-top-left-radius: var(--wf-radius);
        }

        .wf-grid-table th:last-child {
            border-top-right-radius: var(--wf-radius);
        }

    .wf-grid-table td {
        padding: 10px 12px;
        border-bottom: 1px solid #EEEEEE;
        vertical-align: middle;
    }

    .wf-grid-table tbody tr:last-child td {
        border-bottom: none;
    }

    .wf-grid-table tbody tr.is-clickable {
        cursor: pointer;
    }

    .wf-grid-table tbody tr:not(.wf-grid-state):not(.wf-grid-skeleton):hover td {
        background: #F7FAFD;
    }

    .wf-grid-table tbody tr:focus-visible {
        outline: 2px solid var(--wf-primary);
        outline-offset: -2px;
    }

    /* An open row and its detail underneath (RowDetail) */
    .wf-grid-table tbody tr.is-expanded td {
        background: var(--wf-primary-tint);
        border-bottom-color: transparent;
    }

    .wf-grid-table tbody tr.wf-grid-detail > td {
        padding: 0 12px 12px 24px;
        background: var(--wf-primary-tint);
    }

    .wf-grid-table tbody tr.wf-grid-detail:hover > td {
        background: var(--wf-primary-tint);
    }

    .wf-grid-table tr.is-inactive td {
        color: var(--wf-text-muted);
    }

.wf-grid.is-refreshing tbody {
    opacity: 0.55;
    transition: opacity 0.15s;
}

.wf-nowrap {
    white-space: nowrap;
}

.wf-cell-stack {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.wf-cell-title {
    font-weight: 600;
    color: var(--wf-text);
}

.is-inactive .wf-cell-title {
    color: var(--wf-text-muted);
}

.wf-cell-sub {
    font-size: 0.8125rem;
    color: var(--wf-text-muted);
}

/* Sort buttons */
.wf-sort-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    color: inherit;
    background: none;
    border: none;
    cursor: pointer;
}

    .wf-sort-btn:hover {
        color: var(--wf-text);
    }

    .wf-sort-btn:focus-visible {
        outline: none;
        box-shadow: var(--wf-focus-ring);
        border-radius: 4px;
    }

.wf-sort-icon {
    width: 8px;
    height: 12px;
    opacity: 0.35;
    background:
        linear-gradient(45deg, transparent 50%, currentColor 50%) top / 8px 5px no-repeat,
        linear-gradient(135deg, currentColor 50%, transparent 50%) bottom / 8px 5px no-repeat;
}

    .wf-sort-icon.is-asc,
    .wf-sort-icon.is-desc {
        opacity: 1;
        color: var(--wf-primary-strong);
    }

    .wf-sort-icon.is-asc {
        background: linear-gradient(45deg, transparent 50%, currentColor 50%) center / 8px 5px no-repeat;
        transform: rotate(-45deg) translate(1px, 1px);
    }

    .wf-sort-icon.is-desc {
        background: linear-gradient(135deg, currentColor 50%, transparent 50%) center / 8px 5px no-repeat;
        transform: rotate(-45deg) translate(-1px, -1px);
    }

th[aria-sort] {
    color: var(--wf-primary-strong);
}

/* Loading / empty / error */
.wf-skeleton {
    display: block;
    height: 12px;
    width: 70%;
    border-radius: 4px;
    background: linear-gradient(90deg, #EEF1F4 25%, #F7F9FB 50%, #EEF1F4 75%);
    background-size: 200% 100%;
    animation: wf-shimmer 1.2s infinite linear;
}

.wf-grid-skeleton td:nth-child(2n) .wf-skeleton {
    width: 50%;
}

@keyframes wf-shimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

.wf-grid-state td {
    padding: 0;
}

.wf-grid-state-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 48px 24px;
    text-align: center;
    color: var(--wf-text-muted);
}

    .wf-grid-state-body strong {
        font-size: 1rem;
        color: var(--wf-text);
    }

    .wf-grid-state-body .wf-btn {
        margin-top: 8px;
    }

/* Footer: range, page size, pager */
/* Centred, as in Route Local: "Showing 1 to 25 of N customers  « ‹ 1 2 3 › »  [25]" */
.wf-grid-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px 16px;
    padding: 12px 16px;
    font-size: 0.875rem;
    color: var(--wf-text-muted);
    border-top: 1px solid var(--wf-border);
}

.wf-grid-size {
    height: 32px;
    padding: 0 8px;
    font: inherit;
    color: var(--wf-text);
    background: var(--wf-surface);
    border: 1px solid var(--wf-border);
    border-radius: var(--wf-radius-sm);
    cursor: pointer;
}

    .wf-grid-size:focus-visible {
        outline: none;
        box-shadow: var(--wf-focus-ring);
    }

.wf-pager {
    display: flex;
    align-items: center;
    gap: 2px;
}

.wf-pager-btn {
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    font: inherit;
    color: var(--wf-text);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 50%;
    cursor: pointer;
}

    .wf-pager-btn:hover:not(:disabled):not(.is-current) {
        background: var(--wf-surface-alt);
    }

    .wf-pager-btn.is-current {
        color: var(--wf-primary-strong);
        background: var(--wf-primary-tint);
        font-weight: 700;
    }

    .wf-pager-btn:disabled {
        color: #BBBBBB;
        cursor: default;
    }

    .wf-pager-btn:focus-visible {
        outline: none;
        box-shadow: var(--wf-focus-ring);
    }

/* ---------- Phones: rows become cards ---------- */

@media (max-width: 768px) {
    .wf-grid {
        background: transparent;
        border: none;
        box-shadow: none;
    }

    .wf-grid-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }

    .wf-grid-table,
    .wf-grid-table tbody,
    .wf-grid-table tr,
    .wf-grid-table td {
        display: block;
    }

        .wf-grid-table tbody tr {
            margin-bottom: 10px;
            padding: 12px 14px;
            background: var(--wf-surface);
            border: 1px solid var(--wf-border);
            border-radius: var(--wf-radius);
        }

            /* A card's detail joins the card above it */
            .wf-grid-table tbody tr.is-expanded,
            .wf-grid-table tbody tr.wf-grid-detail {
                background: var(--wf-primary-tint);
            }

                .wf-grid-table tbody tr.is-expanded td,
                .wf-grid-table tbody tr.wf-grid-detail > td {
                    background: none;
                }

            .wf-grid-table tbody tr.is-expanded {
                margin-bottom: 0;
                border-bottom: none;
                border-radius: var(--wf-radius) var(--wf-radius) 0 0;
            }

            .wf-grid-table tbody tr.wf-grid-detail {
                padding-top: 0;
                border-top: none;
                border-radius: 0 0 var(--wf-radius) var(--wf-radius);
            }

        .wf-grid-table td {
            display: grid;
            grid-template-columns: 96px 1fr;
            gap: 8px;
            padding: 3px 0;
            border: none;
        }

            .wf-grid-table td::before {
                content: attr(data-label);
                font-size: 0.75rem;
                font-weight: 600;
                color: var(--wf-text-muted);
                text-transform: uppercase;
                letter-spacing: 0.03em;
                padding-top: 2px;
            }

            .wf-grid-table td.wf-cell-primary {
                display: block;
                padding-bottom: 6px;
                font-size: 1rem;
            }

                .wf-grid-detail td::before,
                .wf-grid-table td.wf-cell-primary::before,
                .wf-grid-state td::before,
                .wf-grid-skeleton td::before {
                    content: none;
                }

        .wf-grid-table .wf-grid-detail td,
        .wf-grid-table .wf-grid-state td,
        .wf-grid-table .wf-grid-skeleton td {
            display: block;
        }

    .wf-grid-footer {
        border-top: none;
        padding: 8px 0;
    }

    .wf-pager {
        justify-content: center;
    }
}

/* More status colours (job statuses) */
.wf-status-warning {
    background: #FFF1E6;
    color: #8A4A12;
}

.wf-status-review {
    background: #F1ECFB;
    color: #5B3C99;
}

/* Small buttons and a two/three-way switch (e.g. Open | All) */
.wf-btn-sm {
    height: 30px;
    padding: 0 10px;
    gap: 4px;
    font-size: 0.8125rem;
}

.wf-btn:disabled {
    opacity: 0.55;
    cursor: default;
}

.wf-segmented {
    display: inline-flex;
    padding: 2px;
    background: var(--wf-surface-alt);
    border: 1px solid var(--wf-border);
    border-radius: var(--wf-radius-sm);
}

    .wf-segmented button {
        height: 24px;
        padding: 0 10px;
        font: inherit;
        font-size: 0.8125rem;
        color: var(--wf-text-muted);
        background: transparent;
        border: none;
        border-radius: 4px;
        cursor: pointer;
    }

        .wf-segmented button.is-selected {
            color: var(--wf-text);
            font-weight: 600;
            background: var(--wf-surface);
            box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
        }

        .wf-segmented button:focus-visible {
            outline: none;
            box-shadow: var(--wf-focus-ring);
        }

/* Destructive actions (e.g. Deactivate) */
.wf-btn-danger {
    color: #FFFFFF;
    background: var(--wf-error-text);
    border-color: var(--wf-error-text);
}

    .wf-btn-danger:hover {
        background: #962035;
    }

.wf-btn-danger-outline {
    color: var(--wf-error-text);
}

    .wf-btn-danger-outline:hover {
        background: #FCEEF1;
    }

/* Row action buttons (e.g. Open / Replace / Delete) */
.wf-row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

.wf-icon-btn-sm {
    width: 30px;
    height: 30px;
    color: var(--wf-text-muted);
}

    .wf-icon-btn-sm:hover {
        color: var(--wf-primary-strong);
        background: var(--wf-primary-tint);
    }

.wf-icon-btn-danger:hover {
    color: var(--wf-error-text);
    background: #FCEEF1;
}

/* Toolbar filters under a page header (e.g. main Jobs list) */
.wf-toolbar select,
.wf-toolbar-input {
    height: 36px;
    padding: 0 10px;
    font: inherit;
    font-size: 0.875rem;
    color: var(--wf-text);
    background: var(--wf-surface);
    border: 1px solid var(--wf-border);
    border-radius: var(--wf-radius-sm);
}

.wf-toolbar-input {
    width: 180px;
}

/* Long text in a cell, cut to one line (full text on hover) */
.wf-clip {
    display: inline-block;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}

/* A row for something no longer in use (e.g. an obsolete visit result) */
.wf-grid-table tbody tr.is-muted td {
    color: var(--wf-text-muted);
}

/* ---------- Filters panel (WfFilterPanel) ---------- */

.wf-filter-panel-host {
    position: relative;
}

    .wf-filter-panel-host > .wf-btn.is-filtered {
        border-color: var(--wf-primary);
        background: var(--wf-primary-tint);
    }

.wf-filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #FFFFFF;
    background: var(--wf-primary-strong);
    border-radius: 10px;
}

.wf-filter-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 20;
    width: min(560px, calc(100vw - 32px));
    padding: 0;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.wf-filter-panel-body {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 16px;
    max-height: min(70vh, 560px);
    overflow-y: auto;
    padding: 16px;
}

    .wf-filter-panel-body .wf-field-wide {
        grid-column: 1 / -1;
    }

    .wf-filter-panel-body .wf-field select,
    .wf-filter-panel-body .wf-field input {
        width: 100%;
    }

    /* A filter in use stands out. */
    .wf-filter-panel-body select.is-active {
        border-color: var(--wf-primary);
        background: var(--wf-primary-tint);
    }

.wf-filter-panel > footer {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 16px;
    border-top: 1px solid var(--wf-border);
}

.wf-filter-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
}

@media (max-width: 768px) {
    .wf-filter-panel {
        position: fixed;
        top: auto;
        left: 16px;
        right: 16px;
        bottom: 16px;
        width: auto;
    }

    .wf-filter-panel-body {
        grid-template-columns: minmax(0, 1fr);
        max-height: 70vh;
    }
}

    .wf-filter-panel-body input.is-active {
        border-color: var(--wf-primary);
        background: var(--wf-primary-tint);
    }

/* ---------- Multi-select (SelectKey) ---------- */

.wf-grid-table .wf-grid-check {
    width: 40px;
    padding-right: 0;
    text-align: center;
}

    .wf-grid-table .wf-grid-check input {
        width: 16px;
        height: 16px;
        cursor: pointer;
    }

.wf-grid-selection {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
    padding: 8px 12px;
    font-size: 0.875rem;
    background: var(--wf-primary-tint);
    border-bottom: 1px solid var(--wf-border);
}

.wf-grid-selection-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Money and other numbers right-aligned in a list column (Class="wf-num") */
.wf-grid-table td.wf-num,
.wf-grid-table th.wf-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
