/* ================================================
   КАСТОМНЫЕ СТИЛИ ДЛЯ TABLEPRESS
   Стилизация таблиц TablePress в стиле главной страницы
   ================================================ */

/* Обертка для TablePress таблиц */
.tablepress-wrapper {
  background-color: white;
  border-radius: var(--border-radius-lg, 12px);
  box-shadow: var(--shadow-light, 0 2px 8px rgba(0, 0, 0, 0.08));
  overflow: hidden;
  transition: all var(--transition-fast, 0.3s ease);
  margin-bottom: 3vw;
}

.tablepress-wrapper:hover {
  box-shadow: var(--shadow-medium, 0 4px 16px rgba(0, 0, 0, 0.12));
  transform: translateY(-0.3vw);
}

/* Стили для самой таблицы TablePress */
.tablepress {
  width: 100% !important;
  border-collapse: collapse !important;
  margin: 0 !important;
  border: none !important;
}

/* Заголовки таблицы */
.tablepress thead th {
  background-color: var(--color-primary, #0696ee) !important;
  color: white !important;
  font-size: 1vw !important;
  font-weight: var(--font-weight-semibold, 600) !important;
  padding: 1.2vw 1.5vw !important;
  border-bottom: 2px solid var(--color-border, #e0e0e0) !important;
  text-align: left !important;
}

/* Строки тела таблицы */
.tablepress tbody tr {
  transition: background-color var(--transition-fast, 0.3s ease);
}

.tablepress tbody tr:hover {
  background-color: var(--color-hover, #f0f8ff) !important;
}

.tablepress tbody td {
  padding: 1.2vw 1.5vw !important;
  font-size: 0.9vw !important;
  color: var(--color-text, #333) !important;
  border-bottom: 1px solid var(--color-border-light, #f0f0f0) !important;
  text-align: left !important;
}

.tablepress tbody tr:last-child td {
  border-bottom: none !important;
}

/* Футер таблицы с кнопками */
.tablepress tfoot {
  background-color: var(--color-bg-secondary, #f8f9fa) !important;
}

.tablepress tfoot tr {
  border-top: 2px solid var(--color-border, #e0e0e0) !important;
}

.tablepress tfoot td {
  padding: 1.5vw 2vw !important;
  text-align: center !important;
  border: none !important;
}

/* Кнопки в футере */
.tablepress-actions {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 1vw;
}

.tablepress-download-btn,
.tablepress-print-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3vw;
  height: 3vw;
  padding: 0;
  background: linear-gradient(135deg, var(--color-primary, #0696ee) 0%, var(--color-primary-dark, #0577c9) 100%);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: all var(--transition-fast, 0.3s ease);
  box-shadow: 0 2px 8px rgba(6, 150, 238, 0.2);
}

.tablepress-download-btn:hover,
.tablepress-print-btn:hover {
  background: linear-gradient(135deg, var(--color-primary-dark, #0577c9) 0%, var(--color-primary, #0696ee) 100%);
  box-shadow: 0 4px 12px rgba(6, 150, 238, 0.3);
  transform: translateY(-0.2vw);
}

.tablepress-download-btn svg,
.tablepress-print-btn svg {
  width: 1.5vw;
  height: 1.5vw;
  fill: currentColor;
}

.tablepress-download-btn span,
.tablepress-print-btn span {
  display: none;
}

/* Адаптивность для планшетов */
@media (max-width: 768px) {
  .tablepress-wrapper {
    margin-bottom: 4vw;
  }

  .tablepress thead th {
    padding: 2.5vw 3vw !important;
    font-size: 2.2vw !important;
  }

  .tablepress tbody td {
    padding: 2vw 3vw !important;
    font-size: 2vw !important;
  }

  .tablepress tfoot td {
    padding: 3vw 4vw !important;
  }

  .tablepress-actions {
    gap: 2vw;
  }

  .tablepress-download-btn,
  .tablepress-print-btn {
    width: 6vw;
    height: 6vw;
  }

  .tablepress-download-btn svg,
  .tablepress-print-btn svg {
    width: 3vw;
    height: 3vw;
  }
}

/* Адаптивность для мобильных устройств */
@media (max-width: 480px) {
  .tablepress-wrapper {
    margin-bottom: 6vw;
  }

  /* Мобильная версия: делаем таблицу блочной */
  .tablepress {
    display: block !important;
  }

  .tablepress thead {
    display: none !important;
  }

  .tablepress tbody {
    display: block !important;
  }

  .tablepress tbody tr {
    display: flex !important;
    flex-direction: column !important;
    margin-bottom: 4vw !important;
    border: 1px solid var(--border-light, #f0f0f0) !important;
    border-radius: var(--border-radius-sm, 6px) !important;
    overflow: hidden !important;
  }

  .tablepress tbody td {
    display: flex !important;
    justify-content: space-between !important;
    padding: 3vw 4vw !important;
    border: none !important;
    border-bottom: 1px solid var(--border-light, #f0f0f0) !important;
    font-size: 3.5vw !important;
  }

  .tablepress tbody td:last-child {
    border-bottom: none !important;
  }

  .tablepress tbody td::before {
    content: attr(data-label);
    font-weight: var(--font-weight-bold, 700);
    color: var(--color-text-secondary, #666);
    min-width: 40%;
  }

  /* Футер с кнопками на мобильных */
  .tablepress tfoot {
    display: block !important;
  }

  .tablepress tfoot tr {
    display: block !important;
  }

  .tablepress tfoot td {
    display: block !important;
    padding: 4vw !important;
  }

  .tablepress-actions {
    flex-direction: row;
    justify-content: center;
    gap: 3vw;
  }

  .tablepress-download-btn,
  .tablepress-print-btn {
    width: 12vw;
    height: 12vw;
    flex-shrink: 0;
  }

  .tablepress-download-btn svg,
  .tablepress-print-btn svg {
    width: 6vw;
    height: 6vw;
  }
}

/* ================================================
   СТИЛИ ДЛЯ ПЕЧАТИ И PDF
   Обеспечивают корректное отображение при печати
   ================================================ */
@media print {
  /* Обертка для печати */
  .tablepress-wrapper {
    box-shadow: none !important;
    border: 1px solid #ddd !important;
    transform: none !important;
    margin-bottom: 20px !important;
    page-break-inside: avoid !important;
  }

  .tablepress-wrapper:hover {
    box-shadow: none !important;
    transform: none !important;
  }

  /* Таблица для печати */
  .tablepress {
    width: 100% !important;
    border-collapse: collapse !important;
    display: table !important;
    font-size: 10pt !important;
  }

  /* Заголовки для печати */
  .tablepress thead {
    display: table-header-group !important;
  }

  .tablepress thead th {
    background-color: #0696ee !important;
    color: white !important;
    font-size: 11pt !important;
    font-weight: 600 !important;
    padding: 10px 12px !important;
    border: 1px solid #ddd !important;
    text-align: left !important;
    page-break-after: avoid !important;
    page-break-inside: avoid !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Тело таблицы для печати */
  .tablepress tbody {
    display: table-row-group !important;
  }

  .tablepress tbody tr {
    display: table-row !important;
    page-break-inside: avoid !important;
    page-break-after: auto !important;
    flex-direction: initial !important;
    margin-bottom: 0 !important;
    border: none !important;
    border-radius: 0 !important;
  }

  .tablepress tbody tr:hover {
    background-color: transparent !important;
  }

  .tablepress tbody td {
    display: table-cell !important;
    padding: 8px 12px !important;
    font-size: 10pt !important;
    color: #333 !important;
    border: 1px solid #ddd !important;
    text-align: left !important;
    page-break-inside: avoid !important;
    justify-content: initial !important;
    flex-direction: initial !important;
  }

  .tablepress tbody td::before {
    display: none !important;
    content: none !important;
  }

  .tablepress tbody td:last-child {
    border-bottom: 1px solid #ddd !important;
  }

  /* Изображения и иконки в ячейках */
  .tablepress tbody td img,
  .tablepress thead th img {
    max-width: 10px !important;
    max-height: 10px !important;
    width: auto !important;
    height: auto !important;
    display: inline-block !important;
    vertical-align: middle !important;
  }

  /* Стили для SVG иконок */
  .tablepress tbody td svg,
  .tablepress thead th svg {
    max-width: 10px !important;
    max-height: 10px !important;
    width: 10px !important;
    height: 10px !important;
    display: inline-block !important;
    vertical-align: middle !important;
  }

  /* Специальные символы (галочки, крестики и т.д.) */
  .tablepress tbody td:has(img),
  .tablepress tbody td:has(svg) {
    text-align: center !important;
    vertical-align: middle !important;
  }

  /* Футер таблицы для печати */
  .tablepress tfoot {
    display: none !important;
  }

  .tablepress tfoot tr {
    display: none !important;
  }

  .tablepress tfoot td {
    display: none !important;
  }

  /* Скрываем кнопки действий при печати */
  .tablepress-actions,
  .tablepress-download-btn,
  .tablepress-print-btn {
    display: none !important;
  }

  /* Убираем анимации и трансформации */
  .tablepress *,
  .tablepress-wrapper * {
    transition: none !important;
    transform: none !important;
    animation: none !important;
  }

  /* Обеспечиваем правильное разделение страниц */
  .tablepress tbody tr {
    page-break-inside: avoid;
  }

  /* Оптимизация для длинных таблиц */
  .tablepress {
    page-break-after: auto;
  }

  .tablepress thead {
    display: table-header-group;
  }

  .tablepress tfoot {
    display: table-footer-group;
  }
}
