/* (c) Adrian Ranta. All rights reserved. Unauthorised use, reproduction and or distribution is strictly prohibited. */
/* ========================================
   EXCEL-STYLE COLUMN FILTERS
   Dropdown checkbox filters for list table headers
   ======================================== */

/* Header cell layout: label + filter icon side by side */
.compact-list-table thead th.col-filterable {
    position: relative;
}

.col-header-wrap {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* The filter funnel icon button */
.col-filter-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 3px;
    color: #9ca3af;
    font-size: 11px;
    line-height: 1;
    transition: color 0.15s ease, background 0.15s ease;
    flex-shrink: 0;
    vertical-align: middle;
}

.col-filter-btn:hover {
    color: #6b7280;
    background: rgba(0, 0, 0, 0.06);
}

/* Active filter indicator: filled/coloured funnel */
.col-filter-btn.filter-active {
    color: var(--primary-color, #7366ef);
    background: rgba(115, 102, 239, 0.10);
}

.col-filter-btn.filter-active:hover {
    background: rgba(115, 102, 239, 0.18);
}

/* The funnel SVG icon */
.col-filter-btn svg {
    width: 12px;
    height: 12px;
    pointer-events: none;
}

/* ========================================
   FILTER DROPDOWN PANEL
   ======================================== */
.col-filter-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1050;
    min-width: 180px;
    max-width: 260px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    padding: 0;
    margin-top: 2px;
    font-size: 12px;
    font-weight: 400;
    text-align: left;
    cursor: default;
    max-height: 320px;
    display: flex;
    flex-direction: column;
}

/* Action buttons row (Select All / Clear All) */
.col-filter-actions {
    display: flex;
    gap: 6px;
    padding: 6px 8px;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.col-filter-actions button {
    flex: 1;
    padding: 3px 6px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    background: #f9fafb;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    color: #374151;
    transition: background 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
}

.col-filter-actions button:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

/* Scrollable options list */
.col-filter-options {
    overflow-y: auto;
    padding: 4px 0;
    flex: 1;
    min-height: 0;
}

/* Individual checkbox option */
.col-filter-option {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    cursor: pointer;
    transition: background 0.1s ease;
    user-select: none;
}

.col-filter-option:hover {
    background: #f3f4f6;
}

.col-filter-option input[type="checkbox"] {
    margin: 0;
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    accent-color: var(--primary-color, #7366ef);
    cursor: pointer;
}

.col-filter-option label {
    flex: 1;
    cursor: pointer;
    color: #1f2937;
    font-size: 12px;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Count badge next to option label */
.col-filter-count {
    font-size: 10px;
    color: #9ca3af;
    margin-left: auto;
    flex-shrink: 0;
}

/* Empty values display as italicised placeholder */
.col-filter-option-empty label {
    font-style: italic;
    color: #9ca3af;
}


/* ========================================
   DARK MODE OVERRIDES
   ======================================== */
body.dark-mode .col-filter-btn {
    color: #6b7280;
}

body.dark-mode .col-filter-btn:hover {
    color: #9ca3af;
    background: rgba(255, 255, 255, 0.08);
}

body.dark-mode .col-filter-btn.filter-active {
    color: #a78bfa;
    background: rgba(167, 139, 250, 0.15);
}

body.dark-mode .col-filter-btn.filter-active:hover {
    background: rgba(167, 139, 250, 0.22);
}

body.dark-mode .col-filter-dropdown {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

body.dark-mode .col-filter-actions {
    border-bottom-color: #334155;
}

body.dark-mode .col-filter-actions button {
    background: #0f172a;
    border-color: #475569;
    color: #e2e8f0;
}

body.dark-mode .col-filter-actions button:hover {
    background: #334155;
    border-color: #64748b;
}

body.dark-mode .col-filter-option:hover {
    background: rgba(255, 255, 255, 0.06);
}

body.dark-mode .col-filter-option label {
    color: #e2e8f0;
}

body.dark-mode .col-filter-count {
    color: #64748b;
}

body.dark-mode .col-filter-option-empty label {
    color: #64748b;
}
