/**
 * 🎨 Tags Tree - Ultra Compact Design
 * Оптимизация для максимальной информационной плотности
 * Стиль: Hunter Config (каждый пиксель важен)
 */

/* ============================================================================
   БАЗОВЫЕ СТИЛИ - КОМПАКТНЫЕ РАЗМЕРЫ
   ============================================================================ */

.tree-item {
    display: flex;
    align-items: center;
    height: 28px;
    padding: 4px 8px;
    font-size: 0.85rem;
    line-height: 1.2;
    cursor: pointer;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
    position: relative;
}

.tree-item:hover {
    background: rgba(255, 255, 255, 0.05);
    transform: translateX(2px);
}

.tree-item.selected {
    background: rgba(33, 150, 243, 0.15);
    border-left-color: #2196F3;
}

/* ============================================================================
   ИЕРАРХИЯ - ВИЗУАЛЬНЫЕ УРОВНИ
   ============================================================================ */

.tree-item.level-0 {
    padding-left: 8px;
    font-weight: 500;
}

.tree-item.level-1 {
    padding-left: 24px;  /* +16px indent */
    font-size: 0.825rem;
}

.tree-item.level-2 {
    padding-left: 40px;  /* +32px indent */
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.85);
}

.tree-item.level-3 {
    padding-left: 56px;  /* +48px indent */
    font-size: 0.775rem;
    color: rgba(255, 255, 255, 0.75);
}

/* ============================================================================
   ЦВЕТОВАЯ СХЕМА ПО КАТЕГОРИЯМ
   ============================================================================ */

.tag-region {
    border-left-color: #2196F3;  /* Синий - регионы */
}

.tag-country {
    border-left-color: #4CAF50;  /* Зеленый - страны */
}

.tag-city {
    border-left-color: #FF9800;  /* Оранжевый - города */
}

.tag-language {
    border-left-color: #9C27B0;  /* Фиолетовый - языки */
}

.tag-action {
    border-left-color: #F44336;  /* Красный - действия */
}

.tag-risk {
    border-left-color: #FFC107;  /* Желтый - риски */
}

.tag-canonical {
    border-left-color: #757575;  /* Серый - canonical */
}

/* ============================================================================
   CANONICAL КАТЕГОРИИ - РАСШИРЕННАЯ ЦВЕТОВАЯ СХЕМА
   ============================================================================ */

.tag-communication {
    border-left-color: #2196F3;  /* Синий - коммуникации */
}

.tag-finance {
    border-left-color: #4CAF50;  /* Зеленый - финансы */
}

.tag-marketing {
    border-left-color: #9C27B0;  /* Фиолетовый - маркетинг */
}

.tag-data {
    border-left-color: #FF5722;  /* Оранжево-красный - данные */
}

.tag-adult {
    border-left-color: #E91E63;  /* Розовый - взрослый контент */
}

.tag-technical {
    border-left-color: #607D8B;  /* Серо-голубой - техническое */
}

/* ============================================================================
   ЭЛЕМЕНТЫ СТРОКИ - КОМПАКТНАЯ РАСКЛАДКА
   ============================================================================ */

.tree-item .expand-icon {
    width: 16px;
    min-width: 16px;
    text-align: center;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    margin-right: 4px;
}

.tree-item .icon {
    width: 18px;
    min-width: 18px;
    text-align: center;
    font-size: 0.9rem;
    margin-right: 6px;
}

.tree-item .name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 8px;
}

.tree-item .count {
    min-width: 40px;
    text-align: right;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 500;
    margin-right: 6px;
}

/* ============================================================================
   BADGES - ЕДИНЫЙ СТИЛЬ
   ============================================================================ */

.badge-auto,
.badge-canonical {
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 4px;
}

.badge-auto {
    background: #4CAF50;
    color: white;
}

.badge-canonical {
    background: #757575;
    color: white;
}

/* ============================================================================
   ЧЕКБОКСЫ - КОМПАКТНЫЕ
   ============================================================================ */

.checkbox-compact {
    width: 14px;
    height: 14px;
    margin: 0;
    margin-left: 4px;
    cursor: pointer;
}

/* ============================================================================
   РАСКРЫТИЕ/СВОРАЧИВАНИЕ
   ============================================================================ */

.tree-item .children {
    overflow: hidden;
    transition: max-height 0.2s ease, opacity 0.2s ease;
}

.tree-item .children.hidden {
    max-height: 0;
    opacity: 0;
    display: none;
}

.tree-item .children.visible {
    max-height: 2000px;
    opacity: 1;
}

/* ============================================================================
   КАТЕГОРИИ - ЗАГОЛОВКИ
   ============================================================================ */

.tree-category {
    margin-bottom: 4px;
}

.category-header {
    display: flex;
    align-items: center;
    height: 32px;
    padding: 6px 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 4px;
    transition: all 0.15s ease;
}

.category-header:hover {
    background: rgba(255, 255, 255, 0.08);
}

.category-header .expand-icon {
    width: 18px;
    min-width: 18px;
    text-align: center;
    margin-right: 6px;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
}

.category-header .category-icon {
    width: 20px;
    min-width: 20px;
    text-align: center;
    font-size: 1rem;
    margin-right: 8px;
}

.category-header .category-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.category-header .category-count {
    min-width: 50px;
    text-align: right;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 500;
}

.category-children {
    padding-left: 0;
    overflow: hidden;
    transition: max-height 0.25s ease, opacity 0.25s ease;
}

.category-children.hidden {
    max-height: 0;
    opacity: 0;
    display: none;
}

.category-children.visible {
    max-height: 5000px;
    opacity: 1;
}

/* ============================================================================
   SCROLLBAR - ТОНКИЙ
   ============================================================================ */

.filter-tree::-webkit-scrollbar {
    width: 6px;
}

.filter-tree::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.filter-tree::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.filter-tree::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ============================================================================
   КОНТЕЙНЕР ДЕРЕВА - ВЫСОТА
   ============================================================================ */

.filter-tree {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    overflow-x: hidden;
}

/* ============================================================================
   АНИМАЦИЯ КЛИКА
   ============================================================================ */

.tree-item.clicking {
    transform: scale(0.98);
    background: rgba(33, 150, 243, 0.2);
}

/* ============================================================================
   ПОИСК - ПОДСВЕТКА
   ============================================================================ */

.tree-item.highlight {
    background: rgba(255, 193, 7, 0.15);
    animation: highlight-pulse 0.5s ease;
}

@keyframes highlight-pulse {
    0%, 100% {
        background: rgba(255, 193, 7, 0.15);
    }
    50% {
        background: rgba(255, 193, 7, 0.3);
    }
}

/* ============================================================================
   ПОСТУЛАТЫ - СПЕЦИАЛЬНАЯ СЕКЦИЯ
   ============================================================================ */

.postulates-section {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.postulates-header {
    display: flex;
    align-items: center;
    padding: 8px;
    margin-bottom: 4px;
    background: rgba(76, 175, 80, 0.1);
    border-radius: 4px;
    border-left: 3px solid #4CAF50;
}

.postulates-header .icon {
    font-size: 1.1rem;
    margin-right: 8px;
}

.postulates-header .title {
    flex: 1;
    font-weight: 600;
    font-size: 0.9rem;
    color: #4CAF50;
}

.postulates-header .badge-auto {
    margin-left: 8px;
}

/* ============================================================================
   АДАПТИВНОСТЬ - МЕДИА-ЗАПРОСЫ
   ============================================================================ */

@media (max-width: 768px) {
    .tree-item {
        height: 32px;
        padding: 6px 8px;
        font-size: 0.9rem;
    }
    
    .tree-item.level-1 {
        padding-left: 20px;
    }
    
    .tree-item.level-2 {
        padding-left: 36px;
    }
}

@media (min-width: 1400px) {
    /* На больших экранах можно еще компактнее */
    .tree-item {
        height: 26px;
        padding: 3px 8px;
        font-size: 0.825rem;
    }
    
    .category-header {
        height: 30px;
        padding: 5px 8px;
        font-size: 0.875rem;
    }
}

/* ============================================================================
   ACCESSIBILITY - A11Y
   ============================================================================ */

.tree-item:focus,
.category-header:focus {
    outline: 2px solid #2196F3;
    outline-offset: -2px;
}

.tree-item[aria-checked="true"]::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #2196F3;
}

/* ============================================================================
   LOADING STATE
   ============================================================================ */

.tree-item.loading {
    opacity: 0.5;
    pointer-events: none;
}

.tree-item.loading::after {
    content: '⏳';
    margin-left: auto;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

