/* css/filter-toolbar.css - High-Density Horizontal Toolbar */

.filter-toolbar {
    background: var(--bg-primary) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 12px !important;
    box-shadow: var(--shadow-sm) !important;
    padding: 0.6rem 1rem !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    margin-bottom: 1rem !important;
}

.filter-toolbar-container {
    display: block !important;
}

.filter-grid {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 0.5rem !important;
    width: auto !important;
    max-width: 100% !important;
}

/* Filter Group (Label + Item) */
.filter-group {
    display: flex !important;
    flex-direction: column !important;
    gap: 0 !important;
    flex: 0 0 auto !important;
}

/* Compact Widths */
.filter-group[data-filter-type="search"] {
    width: 320px !important;
}

.filter-group[data-filter-type="choice"] {
    width: 220px !important;
}

.filter-group[data-filter-type="date"] {
    width: 160px !important;
}

.filter-label {
    display: none !important;
    /* Force hidden as requested */
}

/* Filter Item Container */
.filter-item {
    position: relative !important;
    height: 38px !important;
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 8px !important;
    display: flex !important;
    align-items: center !important;
    /* overflow: hidden !important; -- REMOVED to allow dropdown visibility */
}

.filter-search {
    width: 300px !important;
    padding: 0 !important;
    position: relative !important;
}

.filter-search-icon {
    position: absolute !important;
    left: 12px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    color: var(--text-tertiary) !important;
    z-index: 10 !important;
    pointer-events: none !important;
}

#filter-search-input {
    width: 100% !important;
    height: 100% !important;
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    color: var(--text-primary) !important;
    padding: 0 1rem 0 2.5rem !important;
    font-size: 0.85rem !important;
    outline: none !important;
    box-shadow: none !important;
    -webkit-appearance: none !important;
    appearance: none !important;
}

/* Force transparency on autofill and focus */
#filter-search-input:focus,
#filter-search-input:active,
#filter-search-input:-webkit-autofill {
    background: transparent !important;
    background-color: transparent !important;
    -webkit-box-shadow: 0 0 0px 1000px transparent inset !important;
}

/* TomSelect Integration - Deep Clean */
.filter-choice .ts-wrapper {
    height: 38px !important;
    border: none !important;
    background: transparent !important;
    width: 100% !important;
}

.filter-choice .ts-control {
    height: 38px !important;
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    padding: 0 0.75rem !important;
    /* Slightly tighter padding for remove button */
    display: flex !important;
    align-items: center !important;
    color: var(--text-primary) !important;
    box-shadow: none !important;
    cursor: pointer !important;
}

/* Kill the vertical cursor line and plugin borders */
.filter-choice .ts-control input,
.filter-choice .ts-wrapper.plugin-remove_button .ts-control input {
    caret-color: transparent !important;
    opacity: 0 !important;
    position: absolute !important;
    border: none !important;
    outline: none !important;
    /* Removed pointer-events: none and forced width: 0 to allow the parent ts-control to handle clicks */
    width: 1px !important;
    left: 0 !important;
    top: 0 !important;
}

/* TomSelect remove_button plugin reset */
.filter-choice .ts-wrapper.plugin-remove_button .item {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 38px !important;
    background: transparent !important;
    border: none !important;
    color: var(--text-primary) !important;
    box-shadow: none !important;
    height: 100% !important;
    position: static !important;
}

.filter-choice .ts-wrapper.plugin-remove_button .item .remove {
    border: none !important;
    border-left: none !important;
    border-right: none !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: 1.2rem !important;
    color: var(--text-muted) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 20px !important;
    height: 38px !important;
    /* Match control height */
    position: absolute !important;
    right: 5px !important;
    top: 0 !important;
    bottom: 0 !important;
    background: transparent !important;
}

.filter-choice .ts-wrapper.plugin-remove_button .item .remove::before,
.filter-choice .ts-wrapper.plugin-remove_button .item .remove::after {
    display: none !important;
    content: none !important;
}

.filter-choice .ts-wrapper.plugin-remove_button .item .remove:hover {
    color: var(--danger-color) !important;
    background: transparent !important;
}

/* Vanish the Ghost Cursor / Input when items are present */
.ts-wrapper.has-items .ts-control>input {
    width: 0 !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    opacity: 0 !important;
    position: absolute !important;
}

/* Ensure input is visible and cursor is shown when focused/typing */
.ts-wrapper.focus .ts-control .item {
    display: none !important;
}
.ts-wrapper.focus .ts-control>input {
    width: auto !important;
    min-width: 4px !important;
    opacity: 1 !important;
    position: relative !important;
    caret-color: var(--text-primary, #f1f5f9) !important;
}


/* Kills the '*' and other pseudo glitches */
.ts-control::before,
.ts-control::after,
.ts-wrapper::before,
.ts-wrapper::after,
.ts-wrapper .ts-control>input::placeholder,
.ts-control .item::after {
    display: none !important;
    content: none !important;
}

.filter-choice .ts-control input {
    color: var(--text-primary) !important;
}

.filter-choice .ts-control input::placeholder {
    color: var(--text-muted) !important;
    opacity: 1 !important;
}

/* Date Input Polish */
.filter-date-input {
    width: 100% !important;
    height: 100% !important;
    background: transparent !important;
    border: none !important;
    padding: 0 0.75rem !important;
    color: var(--text-primary) !important;
    font-size: 0.85rem !important;
    outline: none !important;
}

/* Inline Actions */
.filter-actions-inline {
    display: flex !important;
    gap: 0.5rem !important;
    padding-bottom: 0px !important;
}

.filter-btn {
    height: 38px !important;
    padding: 0 1.25rem !important;
    border-radius: 10px !important;
    font-weight: 700 !important;
    font-size: 0.8rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.5rem !important;
    transition: all 0.2s ease !important;
    cursor: pointer !important;
    border: 1px solid var(--border-color) !important;
    white-space: nowrap !important;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%) !important;
    color: var(--white) !important;
    border: none !important;
}

.btn-reset {
    background: var(--bg-tertiary) !important;
    color: var(--text-secondary) !important;
    padding: 0 0.75rem !important;
}

.btn-reset:hover {
    color: var(--danger-color) !important;
    background: var(--danger-light) !important;
    border-color: var(--danger-color) !important;
}

/* TomSelect Dropdown Customization */
.ts-dropdown {
    background: var(--bg-primary) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 10px !important;
    box-shadow: var(--shadow-lg) !important;
    z-index: 9999 !important;
    /* Ensure it floats over everything */
}

.ts-dropdown .active {
    background: var(--bg-selected) !important;
    color: var(--text-primary) !important;
}

.ts-dropdown .option:hover {
    background: var(--bg-selected-hover) !important;
}

@media (max-width: 1024px) {
    .filter-grid {
        flex-wrap: wrap !important;
    }

    .filter-group {
        flex: 1 1 200px !important;
    }
}