/*
    AdvancedFilterGrid.css
*/

.afg-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2100;
}

.afg-panel {
    background: #ffffff;
    border-radius: 6px;
    width: 80vw;
    height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    font-family: Roboto, sans-serif;
    color: #424143;
}

.afg-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 5px;
    padding: 18px 20px 12px;
    flex-shrink: 0;
}

.afg-title {
    margin: 0;
    font-size: 20px;
    font-weight: 500;
    color: #424143;
}

.afg-close-btn {
    background: none;
    border: none;
    color: #4d4c4f3b;
    font-size: 16px;
    cursor: pointer;
    padding: 4px 6px;
}

    .afg-close-btn:hover {
        color: #424143;
    }

/* ── Toolbar (icon buttons + search bar) ─────────────────────────────── */
.afg-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px 12px;
    flex-shrink: 0;
}

.afg-toolbar-icons {
    display: flex;
    gap: 4px;
}

.afg-icon-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: 4px;
    color: #605e5c;
    cursor: pointer;
}

    .afg-icon-btn:hover {
        background: #f3f2f1;
    }

.afg-search-wrapper {
    flex: 1;
    position: relative;
}

/* ── Search bar live-suggest dropdown + FILTER field-selection panel ───── */
.afg-suggest-panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #cfd6dd;
    border-radius: 3px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
    z-index: 10;
    overflow: hidden;
}

.afg-suggest-contains {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    font-size: 12px;
    color: #a19f9d;
    border-bottom: 1px solid #f3f2f1;
}

.afg-suggest-list {
    max-height: 220px;
    overflow-y: auto;
}

.afg-suggest-item {
    padding: 7px 12px;
    font-size: 13px;
    color: #424143;
    cursor: pointer;
}

    .afg-suggest-item:hover {
        background: #f3f2f1;
    }

.afg-suggest-empty {
    padding: 12px;
    font-size: 12px;
    color: #a19f9d;
    text-align: center;
}

.afg-suggest-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    border-top: 1px solid #f3f2f1;
}

.afg-suggest-count {
    font-size: 11px;
    background: #f3f2f1;
    color: #605e5c;
    border-radius: 2px;
    padding: 2px 6px;
}

.afg-suggest-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    color: #007faa;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 6px;
}

    .afg-suggest-filter-btn:hover {
        text-decoration: underline;
    }

.afg-field-filter-panel {
    padding: 12px;
}

.afg-field-filter-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #424143;
    margin-bottom: 10px;
}

.afg-field-filter-checklist {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.afg-field-filter-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #424143;
}

.afg-field-filter-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid #f3f2f1;
    padding-top: 10px;
}

.afg-field-filter-reset {
    background: none;
    border: none;
    color: #d7142c;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

    .afg-field-filter-reset:hover {
        text-decoration: underline;
    }

.afg-field-filter-apply {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #ffffff;
    border: 1px solid #007faa;
    color: #007faa;
    border-radius: 2px;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 12px;
    cursor: pointer;
}

    .afg-field-filter-apply:hover {
        background: #eaf6fb;
    }

/* ── Body: sidebar + grid ─────────────────────────────────────────────── */
.afg-content {
    flex: 1;
    display: flex;
    gap: 16px;
    padding: 0 20px 16px;
    overflow: hidden;
    min-height: 0;
}

.afg-sidebar {
    width: 220px;
    flex-shrink: 0;
    overflow-y: auto;
    background: #f8f8f8;
    border: 1px solid #e1dfdd;
    border-radius: 4px;
    padding: 12px;
}

.afg-sidebar-disabled {
    opacity: 0.45;
    pointer-events: none;
    filter: grayscale(40%);
}

.afg-sidebar-title {
    font-size: 13px;
    font-weight: 600;
    color: #424143;
    margin-bottom: 10px;
}

.afg-filter-group {
    margin-bottom: 14px;
}

.afg-filter-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #605e5c;
    margin-bottom: 4px;
}

.afg-select {
    width: 100%;
    height: 30px;
    padding: 0 6px;
    border: 1px solid #cfd6dd;
    border-radius: 2px;
    font-family: inherit;
    font-size: 13px;
    color: #424143;
    background: #ffffff;
}

.afg-checklist {
    max-height: 140px;
    overflow-y: auto;
    background: #ffffff;
    border: 1px solid #e1dfdd;
    border-radius: 4px;
}

.afg-checklist-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    font-size: 12px;
    color: #424143;
    cursor: pointer;
}

    .afg-checklist-item:hover {
        background: #f3f2f1;
    }

.afg-checklist-select-all {
    font-weight: 600;
    border-bottom: 1px solid #e1dfdd;
}

.afg-empty-note {
    padding: 8px;
    font-size: 12px;
    color: #a19f9d;
    text-align: center;
}

/* ── Grid ─────────────────────────────────────────────────────────────── */
.afg-grid-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.afg-grid-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 8px;
}

.afg-selected-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    color: #605e5c;
    background: #f3f2f1;
    border: 1px solid #e1dfdd;
    border-radius: 3px;
    padding: 4px 10px;
    margin-left: auto;
}

.afg-selected-badge-btn {
    font-family: inherit;
    cursor: pointer;
}

    .afg-selected-badge-btn:hover:not(:disabled) {
        background: #e1dfdd;
    }

    .afg-selected-badge-btn:disabled {
        cursor: default;
        opacity: 0.6;
    }

.afg-badge-count {
    background: #007faa;
    color: #ffffff;
    border-radius: 10px;
    min-width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    padding: 0 5px;
}

/* ── "All items on this page are selected" banner ──────────────────────── */
.afg-select-all-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    background: #fff8e1;
    border: 1px solid #f2d675;
    border-radius: 3px;
    padding: 6px 12px;
    font-size: 12px;
    color: #6b5900;
}

    .afg-select-all-banner i {
        color: #c9971f;
    }

.afg-grid-scroll {
    flex: 1;
    overflow: auto;
    border: 1px solid #e1dfdd;
    border-radius: 4px;
    min-height: 0;
}

.afg-grid {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

    .afg-grid thead th {
        position: sticky;
        top: 0;
        background: #ebedf0;
        text-align: left;
        font-weight: 600;
        color: #424143;
        padding: 8px 10px;
        border-bottom: 1px solid #e1dfdd;
        border-right: 1px solid #e1dfdd;
        white-space: nowrap;
    }

        .afg-grid thead th:last-child {
            border-right: none;
        }

    .afg-grid .afg-col-check {
        width: 36px;
    }

    .afg-grid tbody td {
        padding: 7px 10px;
        border-bottom: 1px solid #f3f2f1;
        border-right: 1px solid #f3f2f1;
        color: #424143;
        white-space: nowrap;
    }

        .afg-grid tbody td:last-child {
            border-right: none;
        }

.afg-row:nth-child(even) {
    background: #fafafa;
}

.afg-row-selected {
    background: #eaf3fb;
}

    .afg-row-selected:nth-child(even) {
        background: #dcebf8;
    }

.afg-name-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.afg-row-icon {
    color: #a19f9d;
    font-size: 13px;
}

.afg-row-icon-disabled {
    color: #c8c6c4;
}

.afg-loading-row {
    text-align: center;
    padding: 24px 0 !important;
    color: #a19f9d;
    white-space: normal !important;
}

.afg-error-text {
    color: #a4262c;
    font-weight: 600;
}

/* ── Pager ────────────────────────────────────────────────────────────── */
.afg-pager {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-top: 8px;
    font-size: 12px;
    color: #605e5c;
}

.afg-pager-btn {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid #e1dfdd;
    border-radius: 3px;
    color: #424143;
    cursor: pointer;
}

    .afg-pager-btn:disabled {
        color: #c8c6c4;
        cursor: default;
    }

    .afg-pager-btn:hover:not(:disabled) {
        background: #f3f2f1;
    }

.afg-pager-info {
    margin-left: auto;
}

/* ── Footer ───────────────────────────────────────────────────────────── */
.afg-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid #cad0d7;
    flex-shrink: 0;
    background: #faf9f8;
}

.afg-btn {
    min-width: 90px;
    padding: 8px 20px;
    border: 1px solid #cacaca;
    border-radius: 3px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 175ms cubic-bezier(.1, .65, .1, .65);
}

.afg-btn-cancel {
    color: #d7142c;
    background: transparent;
    border-color: transparent;
}

    .afg-btn-cancel:hover {
        background: #b51125;
        color: #ffffff;
        border-color: #b51125cc;
    }

.afg-btn-add {
    background: #007faa;
    color: #ffffff;
    border-color: #006c91;
}

    .afg-btn-add:hover:not(:disabled) {
        background: #006691;
        border-color: #005478;
    }

    .afg-btn-add:disabled {
        background: #c8e0f4;
        border-color: #c8e0f4;
        color: #ffffff;
        cursor: default;
    }
