/**
 * GIPIX CRM — панель фильтров главной и чипы (токены --gipix-*).
 * Подключать после gipix-tokens / components-material.
 */

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--gipix-gray-100, #f3f4f6);
}

::-webkit-scrollbar-thumb {
    background: var(--gipix-gray-200, #e5e7eb);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #cbd5e1;
}

/* ===== Панель фильтров (карточка CRM) ===== */
.modern-filter-panel {
    background: var(--gipix-gray-50, #f9fafb);
    border-radius: 0;
    padding: var(--space-sm, 8px) var(--space-md, 16px) var(--space-md, 16px);
    margin-bottom: 0;
    box-shadow: none;
    border: none;
    border-bottom: 1px solid var(--gipix-border, #e5e7eb);
}

.modern-filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: var(--space-sm, 8px) var(--space-md, 16px);
    align-items: end;
}

.filter-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.filter-item.search-filter {
    min-width: 0;
}

.filter-label {
    display: flex;
    align-items: center;
    gap: var(--gipix-icon-gap, 6px);
    font-size: 11px;
    font-weight: 500;
    color: var(--gipix-text-muted, #6b7280);
    text-transform: none;
    letter-spacing: 0.01em;
    margin-bottom: 0;
}

.filter-label .material-icons {
    font-size: 14px;
    width: 14px;
    height: 14px;
    color: var(--gipix-text-muted, #6b7280);
    opacity: 0.9;
}

.modern-input,
.modern-select {
    height: 36px;
    border: 1px solid var(--gipix-border, #e5e7eb);
    border-radius: var(--radius-button, 8px);
    padding: 0 12px;
    font-size: 13px;
    font-weight: 400;
    background: var(--gipix-surface, #fff);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    color: var(--gipix-text, #111827);
}

.modern-input:focus,
.modern-select:focus {
    border-color: var(--gipix-primary, #2563eb);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
    outline: none;
}

.modern-input::placeholder {
    color: var(--gipix-text-muted, #6b7280);
    font-weight: 400;
}

.modern-select {
    cursor: pointer;
    background-position: right 10px center;
    background-repeat: no-repeat;
    background-size: 14px;
    padding-right: 32px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M3 4.5L6 7.5L9 4.5'/%3E%3C/svg%3E");
}

.filter-actions-modern {
    display: flex;
    gap: var(--space-sm, 8px);
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    grid-column: 1 / -1;
    padding-top: 2px;
}

.btn-modern {
    height: 34px;
    padding: 0 14px;
    border: 1px solid var(--gipix-border, #e5e7eb);
    border-radius: var(--radius-button, 8px);
    font-size: 13px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
    background: var(--gipix-gray-50, #f9fafb);
    color: var(--gipix-text-muted, #6b7280);
}

.btn-primary-modern {
    background: var(--gipix-primary, #2563eb);
    border-color: var(--gipix-primary, #2563eb);
    color: #fff;
    box-shadow: var(--shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.05));
}

.btn-primary-modern:hover {
    background: var(--gipix-primary-hover, #1d4ed8);
    border-color: var(--gipix-primary-hover, #1d4ed8);
    color: #fff;
}

.btn-secondary-modern {
    background: var(--gipix-surface, #fff);
    color: var(--gipix-text-muted, #6b7280);
}

.btn-secondary-modern:hover {
    background: var(--gipix-gray-100, #f3f4f6);
    border-color: #d1d5db;
    color: var(--gipix-text, #111827);
}

.btn-modern .material-icons {
    font-size: 16px;
    opacity: 0.9;
}

/* ===== Активные фильтры — компактная полоса ===== */
.modern-active-filters.gipix-active-filters {
    margin-top: var(--space-sm, 8px);
    padding: 6px 0 0;
    background: transparent;
    border-radius: 0;
    border: none;
    border-top: 1px solid var(--gipix-border, #e5e7eb);
    display: none;
}

.gipix-active-filters__row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
}

.gipix-active-filters__label {
    font-size: 11px;
    font-weight: 500;
    color: var(--gipix-text-muted, #6b7280);
    flex-shrink: 0;
}

.gipix-active-filters__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    font-size: 10px;
    font-weight: 600;
    background: var(--gipix-gray-200, #e5e7eb);
    color: var(--gipix-text-muted, #6b7280);
    flex-shrink: 0;
}

.active-filters-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex: 1;
    min-width: 120px;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 100%;
    padding: 2px 4px 2px 8px;
    background: var(--gipix-surface, #fff);
    color: var(--gipix-text, #111827);
    border: 1px solid var(--gipix-border, #e5e7eb);
    border-radius: var(--radius-chip, 6px);
    font-size: 12px;
    font-weight: 400;
    line-height: 1.35;
    box-shadow: none;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.filter-chip:hover {
    border-color: #d1d5db;
    background: var(--gipix-gray-50, #f9fafb);
}

.filter-chip .material-icons {
    font-size: 14px;
    width: 14px;
    height: 14px;
    color: var(--gipix-text-muted, #6b7280);
    flex-shrink: 0;
}

.filter-chip > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chip-remove {
    background: transparent;
    border: none;
    color: var(--gipix-text-muted, #6b7280);
    border-radius: var(--radius-button, 8px);
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    transition: background 0.15s ease, color 0.15s ease;
    margin-left: 0;
    flex-shrink: 0;
}

.chip-remove:hover {
    background: var(--gipix-gray-100, #f3f4f6);
    color: var(--gipix-danger, #ef4444);
}

.chip-remove .material-icons {
    font-size: 14px;
    width: 14px;
    height: 14px;
    color: inherit;
}

/* Адаптивность */
@media (max-width: 768px) {
    .modern-filter-panel {
        padding: var(--space-sm, 8px) 12px var(--space-md, 16px);
    }

    .modern-filters-grid {
        gap: 10px;
    }

    .filter-actions-modern {
        justify-content: stretch;
    }

    .btn-modern {
        flex: 1;
        justify-content: center;
    }
}
