/* ==== ФККО — ТАБЛИЦА И ФИЛЬТРЫ ==== */

/* Контейнер таблицы */
.table-container.virtual {
    min-height: auto;
    height: auto;
    overflow-y: auto;
    position: relative;
    border: 1px solid #e0e0e0;
    border-radius: var(--radius);
    background: var(--white);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.table-container {
    width: 100%;
    box-sizing: border-box;
}

#table-body {
    display: block;
}

.virtual-row {
    display: flex;
    height: auto;
    background: white;
    border: none;
    margin: 0;
    padding: 0;
    border-top: 1px solid #f0f0f0;
    flex-direction: row;
}

/* Убираем линию у первой строки */
.table-header+#table-body .virtual-row,
.virtual-row:first-child {
    border-top: none;
}

/* Единый стиль для ячеек */
.virtual-cell {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 0.95rem;
    color: var(--secondary);
    padding: 0 12px;
    word-break: break-word;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
    height: 100%;
    font-weight: normal;
    display: flex;
    align-items: center;
    position: relative;
    box-sizing: border-box;
}

/* Ширины столбцов */
.virtual-cell:nth-child(1) {
    flex: 0 0 18%;
    justify-content: center;
    font-family: monospace;
    font-size: 0.9rem;
}

.virtual-cell:nth-child(2) {
    flex: 1;
    padding: 0 10px;
}

.virtual-cell:nth-child(3) {
    flex: 0 0 12%;
    justify-content: center;
    font-weight: 600;
    text-align: center;
}

/* Подсветка поиска — общий стиль */
.virtual-cell .highlight {
    font-weight: 600;
    color: white;
    background-color: #7b2dff;
    padding: 0px;
    border-radius: 3px;
    line-height: 1.4;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
    text-decoration: none;
    text-shadow: 0 0 1px rgba(0, 0, 0, 0.3);
}


/* Поиск */
.search-input {
    width: 100%;
    padding: 12px 16px;
    margin: 0;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
}

.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(123, 45, 255, 0.2);
}

/* Шапка таблицы — фиксирована */
.table-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--accent);
    border-radius: var(--radius) var(--radius) 0 0;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.header-row {
    display: flex;
    height: 60px;
    align-items: center;
    background: var(--accent);
}

.header-row .virtual-cell {
    color: var(--text-light);
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    align-items: center;
    padding: 0 8px;
    line-height: 1.2;
    white-space: normal;
    text-align: center;
}

/* Пагинация */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin: 20px 0 10px;
}

.pagination span {
    padding: 6px 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    color: var(--text);
    font-weight: 500;
    text-align: center;
}

.pagination-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.pagination-btn:hover:not(:disabled) {
    background: #6a20e0;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(123, 45, 255, 0.25);
}

.pagination-btn:disabled {
    background: #c7c7c7;
    color: #666;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.pagination-btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(123, 45, 255, 0.3);
}

/* ==== ОДИНАКОВАЯ ШИРИНА ПОИСКА И ТАБЛИЦЫ ==== */
.table-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    box-sizing: border-box;
}

.table-wrapper .search-input,
.table-wrapper .table-container,
#table-body {
    width: 100%;
    max-width: none;
    box-sizing: border-box;
}

/* ==== ФИЛЬТРЫ ПО КЛАССУ ОПАСНОСТИ ==== */
.filter-buttons button {
    padding: 10px 16px;
    margin: 5px;
    border: 2px solid #ddd;
    background: white;
    color: #333;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 60px;
    text-align: center;
}

.filter-buttons button:hover:not(.active) {
    background: #f8f8f8;
    border-color: #aaa;
    transform: translateY(-1px);
}

.filter-buttons button.active {
    background: #7b2dff;
    color: white;
    border-color: #7b2dff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(123, 45, 255, 0.25);
}

/* ==== РЕЖИМ ПОИСКА ==== */
.search-mode-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0;
    justify-content: center;
}

.search-mode-buttons button {
    padding: 8px 12px;
    border: 2px solid #ddd;
    background: white;
    color: #333;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 130px;
}

.search-mode-buttons button:hover:not(.active) {
    background: #f8f8f8;
    border-color: #aaa;
}

.search-mode-buttons button.active {
    background: #7b2dff;
    color: white;
    border-color: #7b2dff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(123, 45, 255, 0.2);
}

/* Подсказка для режима "два слова" */
.words2-hint {
    font-size: 0.9rem;
    color: #e74c3c;
    margin: 8px 0;
    padding: 10px;
    background-color: #fdf2f2;
    border: 1px dashed #e74c3c;
    border-radius: 6px;
    text-align: center;
    animation: blink 1.5s infinite;
}

.words2-hint.hidden {
    display: none;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.6;
        transform: scale(0.98);
    }
}

/* ==== ФИЛЬТР АГРЕГАТНОГО СОСТОЯНИЯ ==== */
.aggregate-filter-container {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
    width: 100%;
    position: relative;
    margin: 0 auto;
    min-height: 40px;
}

#aggregateFilterBtn {
    flex-shrink: 0;
    min-width: 200px;
    min-height: 50px;
    padding: 10px 14px 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.95rem;
    font-weight: 500;
    color: #333;
    background: white;
    border: 2px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    z-index: 10;
}

#aggregateFilterBtn:hover {
    border-color: #7b2dff;
    color: #7b2dff;
}

#aggregateFilterBtn.active {
    background: #7b2dff;
    color: white;
}

/* Индикатор выбранных фильтров */
#aggregateFiltersBadge {
    flex: 1;
    min-height: 38px;
    padding: 8px 12px;
    background: #f9f9f9;
    border: 1px dashed #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    color: #555;
    font-style: italic;
    line-height: 1.5;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    display: none;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 4px;
    white-space: normal;
    overflow: hidden;
}

#aggregateFiltersBadge.active {
    display: flex;
}

#aggregateFiltersBadge span {
    display: inline-block;
    background: #e9d8ff;
    color: #7b2dff;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
    font-size: 0.85rem;
}

/* Выпадающее меню */
#aggregateDropdown {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
}

.filter-dropdown-btn {
    position: relative;
    padding: 10px 14px 10px 16px;
    background: white;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 280px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.filter-dropdown-btn::after {
    content: '';
    width: 8px;
    height: 8px;
    border-right: 2px solid #7b2dff;
    border-bottom: 2px solid #7b2dff;
    transform: rotate(45deg);
    transition: transform 0.3s ease;
    margin-left: 8px;
}

.filter-dropdown-btn.active::after {
    transform: rotate(-135deg);
}

.filter-dropdown-btn:hover {
    border-color: #7b2dff;
    color: #7b2dff;
}

.filter-dropdown-btn.active {
    background: #7b2dff;
    color: white;
    border-color: #7b2dff;
}

.dropdown-content {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    width: auto;
    min-width: 300px;
    max-width: 90vw;
    max-height: 400px;
    background: white;
    border: 1px solid #7b2dff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    font-size: 0.95rem;
    box-sizing: border-box;
}

.dropdown-content.show {
    display: flex;
}

#aggregateOptions {
    max-height: 320px;
    overflow-y: auto;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.dropdown-header {
    padding: 12px 16px;
    background: #7b2dff;
    color: white;
    font-weight: 600;
    text-align: center;
    border-radius: 6px 6px 0 0;
}

.aggregate-option {
    display: flex;
    align-items: center;
    padding: 0;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    background: white;
    color: #333;
    transition: background 0.2s;
    white-space: nowrap;
    font-size: 0.95rem;
}

.aggregate-option:hover {
    background: #f0e6ff;
}

.aggregate-option input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid #7b2dff;
    border-radius: 4px;
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
    background: white;
    margin-right: 10px;
    transition: all 0.2s ease;
}

.aggregate-option input[type="checkbox"]:checked {
    background: #7b2dff;
}

.aggregate-option input[type="checkbox"]:checked::after {
    content: '✔';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    font-weight: bold;
    pointer-events: none;
}

.aggregate-option input[type="checkbox"]:hover {
    border-color: #6a20e0;
    box-shadow: 0 0 0 3px rgba(123, 45, 255, 0.1);
}

.aggregate-option span.code {
    font-family: monospace;
    font-size: 0.9rem;
    color: #666;
    margin-left: auto;
    flex-shrink: 0;
}

.dropdown-actions {
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: 12px 16px;
    background: white;
    border-top: 1px solid #eee;
    border-radius: 0 0 8px 8px;
    box-sizing: border-box;
    flex-shrink: 0;
}

.dropdown-actions button {
    flex: 1;
    padding: 10px;
    margin: 0 4px;
    border: none;
    background: #f8f8f8;
    color: #666;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 6px;
}

.dropdown-actions button:first-child {
    margin-left: 0;
}

.dropdown-actions button:last-child {
    margin-right: 0;
}

.dropdown-actions button#clearAggregateFilters {
    color: #e74c3c;
}

.dropdown-actions button#clearAggregateFilters:hover {
    background: #ffeaea;
    color: #e74c3c;
}

.dropdown-actions button#applyAggregateFilters {
    color: #7b2dff;
}

.dropdown-actions button#applyAggregateFilters:hover {
    background: #f0e6ff;
    color: #6a20e0;
    border-color: #7b2dff;
}

/* ==== ПОДСКАЗКА ПОД ТАБЛИЦЕЙ ==== */
.hint-box {
    margin: 20px 0 0;
    padding: 16px;
    background: #f9f9f9;
    border-left: 3px solid #7b2dff;
    border-radius: 6px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 0.95rem;
    color: #555;
    line-height: 1.55;
}

.hint-box p {
    margin: 8px 0;
}

.hint-box p:last-child {
    margin: 0;
}

.hint-box code {
    font-family: 'Segoe UI Mono', Consolas, 'Courier New', monospace;
    background: #f0e6ff;
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 0.95em;
    color: #333;
    font-weight: 500;
    border: 1px solid #e0d0ff;
    box-shadow: 0 1px 3px rgba(123, 45, 255, 0.1);
}

.hint-box .code-sep {
    margin: 0 2px;
    color: #d62828;
}

.code-pre {
    white-space: pre;
    background: #f0f0f0;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    font-size: 0.9em;
}

/* Мобильная адаптация */
@media (max-width: 768px) {
    .table-wrapper {
        padding: 0 12px;
    }

    .aggregate-filter-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    #aggregateFiltersBadge {
        margin-left: 0;
    }
}

/* ==== ПЕРЕКЛЮЧАТЕЛЬ ТОЧНОГО ПОИСКА ==== */
.exact-search-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px 0;
    font-size: 0.95rem;
    color: #555;
}

.toggle-label {
    font-weight: 500;
    white-space: nowrap;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:checked+.slider {
    background-color: #7b2dff;
}

input:checked+.slider:before {
    transform: translateX(20px);
}

.slider {
    transition: .4s cubic-bezier(0.2, 0, 0.2, 1);
}

.slider:before {
    transition: .4s cubic-bezier(0.2, 0, 0.2, 1);
}

/* ==== РЕЖИМ ПОДСВЕТКИ ==== */
.highlight-mode-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px 0;
    font-size: 0.95rem;
    color: #555;
}

.highlight-mode-toggle .toggle-label {
    font-weight: 500;
    white-space: nowrap;
}

/* Подсветка в коде: без padding, включает пробелы */
.virtual-cell .highlight.code-inline {
    background-color: currentColor;
    color: white;
    font-weight: 600;
    line-height: 1.4;
    display: inline;
    padding: 0;
    margin: 0;
    border-radius: 3px;
    box-shadow: none;
    text-shadow: 0 0 1px rgba(0, 0, 0, 0.4);
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}