/* ============================================================
   ERS Admin — планшетный фикс таблиц (2026-09-08 v3)
   Подключается ПОСЛЕ index-dev6o3DD.css (см. index.html).
   Работает для ЛЮБЫХ antd-таблиц (Каналы, Сервисы и т.д.)
   ============================================================ */

/* 1. Автолэйаут: браузер сам распределяет ширину */
.ant-table-content > table {
  table-layout: auto !important;
  width: 100% !important;
}
.ant-table-content colgroup {
  display: none !important;
}
.ant-table-thead > tr > th {
  white-space: nowrap !important;
}

/* 2. Длинный текст переносится */
.ant-table-cell {
  white-space: normal !important;
  overflow-wrap: break-word;
}
.ant-table-cell:first-child,
.ant-table-cell:last-child {
  white-space: nowrap !important;
}
.ant-table-cell a {
  word-break: break-all;
}

/* 3. Кнопки действий */
.ant-table-cell:last-child .ant-space {
  flex-wrap: nowrap !important;
}
.ant-table-cell:last-child * {
  flex-wrap: nowrap !important;
}
.ant-table-cell:last-child {
  min-width: 112px;
}
.ant-table-cell-ellipsis,
.ant-table-cell-ellipsis > * {
  white-space: normal !important;
}
.ant-table-thead > tr > th:nth-child(n+4),
.ant-table-tbody > tr > td:nth-child(n+4) {
  overflow-wrap: anywhere;
}
.ant-table-thead > tr > th:nth-child(7),
.ant-table-tbody > tr > td:nth-child(7) {
  min-width: 48px;
}

/* 4. Landscape / узкие ноутбуки: компактная плотность */
@media (min-width: 1025px) and (max-width: 1440px) {
  .ant-table { font-size: 13px !important; }
  .ant-table-thead > tr > th,
  .ant-table-tbody > tr > td { padding: 9px 10px !important; }
  .ant-table-cell:last-child .ant-btn { padding: 0 8px !important; }
  .ant-table-cell:last-child .ant-space-item { margin-inline-end: 2px !important; }
}

/* 5. Portrait (≤800px): карточки вместо таблицы — УНИВЕРСАЛЬНЫЙ */
@media (max-width: 800px) {
  /* Скрываем шапку таблицы */
  .ant-table-thead { display: none !important; }

  /* Таблица → вертикальный список карточек */
  .ant-table-content > table,
  .ant-table-content > table > tbody {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    padding: 0 !important;
  }

  /* Каждая строка — карточка */
  .ant-table-tbody > tr {
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
    background: #fff !important;
    border: 1px solid #f0f0f0 !important;
    border-radius: 8px !important;
    padding: 12px !important;
  }

  /* Все ячейки — на всю ширину */
  .ant-table-tbody > tr > td {
    width: 100% !important;
    padding: 2px 0 !important;
    border: none !important;
  }

  /* первая ячейка — заголовок карточки (название или handle+иконка) */
  .ant-table-tbody > tr > td:first-child {
    font-weight: 600 !important;
    font-size: 15px !important;
    padding-bottom: 4px !important;
  }

  /* Вторая ячейка — описание (если есть длинный текст) */
  .ant-table-tbody > tr > td:nth-child(2) {
    font-size: 13px !important;
    color: #555 !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 3 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
  }

  /* Ссылки — компактно */
  .ant-table-tbody > tr > td a {
    font-size: 13px !important;
    word-break: break-all !important;
  }

  /* Бейджи тегов/категорий — в строку */
  .ant-table-tbody > tr > td .ant-tag {
    font-size: 11px !important;
    margin-bottom: 2px !important;
  }

  /* Кнопки действий — внизу, горизонтально, справа */
  .ant-table-tbody > tr > td:last-child {
    display: flex !important;
    justify-content: flex-end !important;
    gap: 8px !important;
    padding-top: 6px !important;
    border-top: 1px solid #f5f5f5 !important;
  }
  .ant-table-tbody > tr > td:last-child .ant-btn {
    padding: 4px 10px !important;
    font-size: 13px !important;
  }

  /* Тоглы (Популярный) — по центру */
  .ant-table-tbody > tr > td .ant-switch {
    margin: 0 auto !important;
    display: flex !important;
  }
}
