/* css/v5-tables.css */

/* ============================================================
   TABLES — таблицы (обычные + edit-path)
   ============================================================ */

/* ============================================================
   ОБЫЧНЫЕ ТАБЛИЦЫ
   ============================================================ */

.v5-table-wrapper {
    overflow-x: auto;
    border-radius: var(--v5-radius);
    border: var(--v5-border-width) solid var(--v5-primary-base);
}

.v5-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--v5-font-normal);
    background: var(--v5-primary-light);
}

.v5-table th,
.v5-table td {
    border: var(--v5-border-width) solid var(--v5-primary-base);
    padding: var(--v5-padding);
    vertical-align: middle;
}

.v5-table th {
    background: var(--v5-primary-bg);
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
}

.v5-sticky-header th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--v5-primary-bg);
}

.v5-table-wrapper::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.v5-table-wrapper::-webkit-scrollbar-track {
    background: var(--v5-primary-light);
    border-radius: 3px;
}

.v5-table-wrapper::-webkit-scrollbar-thumb {
    background: var(--v5-primary-secondary);
    border-radius: 3px;
}

.v5-table-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--v5-primary-base);
}

/* ============================================================
   EDIT-PATH-TABLE — таблица редактирования трассы
   ============================================================ */

.v5-edit-path-table-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.v5-edit-path-table-wrapper {
    flex: 1;
    overflow: auto;
    position: relative;
    scrollbar-gutter: stable;
}

.v5-edit-path-table {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;      /* ← Решение 2: separate вместо collapse */
    border-spacing: 0;              /* ← Решение 2: нулевой spacing */
    font-size: var(--v5-font-normal);
    background: var(--v5-primary-light);
}

.v5-edit-path-table th,
.v5-edit-path-table td {
    border: var(--v5-border-width) solid var(--v5-primary-base);
    padding: var(--v5-padding);
    vertical-align: middle;
    background: var(--v5-primary-light);
}

.v5-edit-path-table thead {
    transform: translateZ(0);       /* ← аппаратное ускорение оставлено */
}

.v5-edit-path-table thead th {
    background: var(--v5-primary-secondary);
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    position: sticky;
    z-index: 10;
    height: 32px;                   /* ← было 42px */
    box-sizing: border-box;
    border: var(--v5-border-width) solid var(--v5-primary-base);
}

.v5-edit-path-table thead tr:first-child th {
    top: 0;
    z-index: 21;
}

.v5-edit-path-table thead tr:nth-child(2) th {
    top: 32px;                      /* ← было 42px */
    z-index: 20;
}

.v5-edit-path-table thead tr:nth-child(3) th {
    top: 64px;                      /* ← было 84px */
    z-index: 19;
}

/* ---- ИТОГО ПО СЕКЦИИ ---- */
.v5-edit-path-table .v5-section-total-row td {
    background: var(--v5-primary-light);
    font-weight: bold;
    border-top: 2px solid var(--v5-primary-base);
}

/* ---- ОБЩИЙ ИТОГО (ФУТТЕР) ---- */
.v5-edit-path-table tfoot tr.v5-total-row td {
    background: var(--v5-primary-secondary);
    font-weight: bold;
    border-top: 3px solid var(--v5-primary-base);
}

/* ---- РЕДАКТИРУЕМЫЕ ЯЧЕЙКИ (объединено) ---- */
.v5-edit-path-table .v5-editable-cell .v5-editable-value,
.v5-edit-path-table .v5-editable-total-cell .v5-editable-value,
.v5-edit-path-table .v5-editable-field-cell .v5-editable-value {
    display: inline-block;
}

.v5-edit-path-table .v5-editable-cell .v5-edit-icon,
.v5-edit-path-table .v5-editable-total-cell .v5-edit-icon,
.v5-edit-path-table .v5-editable-field-cell .v5-edit-icon {
    width: 20px;
    height: 20px;
    margin-left: 4px;
    vertical-align: middle;
    opacity: 0.4;
}

.v5-edit-path-table .v5-editable-cell:hover .v5-edit-icon,
.v5-edit-path-table .v5-editable-total-cell:hover .v5-edit-icon,
.v5-edit-path-table .v5-editable-field-cell:hover .v5-edit-icon {
    opacity: 1;
}

/* ---- ЦЕНТРИРОВАНИЕ (для editable-field-cell) ---- */
.v5-edit-path-table .v5-editable-field-cell {
    text-align: center;
}

/* ---- ОШИБКА (фон) ---- */
.v5-edit-path-table .v5-section-total-row td.v5-error-value,
.v5-edit-path-table .v5-editable-total-cell.v5-error-value {
    background-color: var(--v5-error-bg);
}

/* ---- SCROLLBAR ---- */
.v5-edit-path-table-wrapper::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.v5-edit-path-table-wrapper::-webkit-scrollbar-track {
    background: var(--v5-primary-light);
    border-radius: 4px;
}

.v5-edit-path-table-wrapper::-webkit-scrollbar-thumb {
    background: var(--v5-primary-secondary);
    border-radius: 4px;
}

.v5-edit-path-table-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--v5-primary-base);
}

/* ============================================================
   VISUAL REPORT — цветовые строки
   ============================================================ */

.v5-total-row-base      { background: var(--v5-primary-base); }
.v5-total-row-dark      { background: var(--v5-primary-dark); }
.v5-total-row-primary   { background: var(--v5-primary-primary); }
.v5-total-row-hover     { background: var(--v5-primary-hover); }
.v5-total-row-secondary { background: var(--v5-primary-secondary); }
.v5-total-row-light     { background: var(--v5-primary-light); }
.v5-total-row-bg        { background: var(--v5-primary-bg); }