@import 'src/styles/variables';

.table_wrapper {
  display: block;
}

.table {
  display: block;
  width: fit-content;
  break-inside: auto;
  --table-cell-height: 48px;
  --table-bar-width: 350px;

  &_tree {
    --table-cell-height: 22px;
    --table-bar-width: 200px;
  }

  &_row {
    position: relative;
    font-weight: 100;
    display: block;
    white-space: nowrap;
    border-bottom: 1px solid #EEEEEE;
    break-inside: auto;

    &:last-child {
      border-bottom: none;
    }

    &_hide {
      opacity: 0.2;
    }

    &_selected {
      background-color: #FFFAF0;
    }
  }

  &_sub_row {
    position: relative;
    font-weight: 100;
    display: block;
    padding: 0 var(--space-m) var(--space-xxl) 42px;

    white-space: nowrap;
    break-inside: auto;

    border-bottom: 1px solid #EEEEEE;
    border-radius: var(--border-radius-m);
  }

  &_cell,
  &_header_cell {
    font-size: var(--font-xs);
    z-index: 0;

    display: inline-block;
    height: var(--table-cell-height);
    line-height: var(--table-cell-height);

    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: top;

    background-color: var(--color-white);
  }

  &_fixed {
    position: sticky;
    top: 0;
    left: 0;
    z-index: 1;
    background-color: rgba(255, 255, 255, 0.9);
  }

  &_cell {
    padding: 0 4px;
  }

  &_header_cell {
    font-weight: bold;
    height: var(--table-cell-height);
    padding: 0 4px;
    line-height: var(--table-cell-height);
    background-color: var(--color-white);
  }

  &_cell_number {
    text-align: right;
  }

  &_cell_icon {
    &_open,
    &_close {
      display: inline-block;
      width: 32px;
      height: 32px;
      margin-top: 8px;
      cursor: pointer;
      transition: transform 0.5s;
      transform: rotate(-90deg);
    }

    &_open {
      transform: rotate(0);
    }
  }
}

.disabled {
  opacity: 0.4;
  filter: grayscale(0.6);
}

@media (max-width: 800px) {
  .table_cell:first-child,
  .table_header_cell:first-child {
    position: static;
  }
}

@media print {
  .table_cell:first-child {
    background-color: transparent;
  }
}
