/* /opt/steuerapp/static/css/sections/team_table.css
   DATEV-like visible borders, чистый CSS для section-team
*/

/* Базовые правила для секции (перенято из вашего стиля) */
#section-team,
#section-team * { font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }

#section-team .overview-grid { max-width:1200px; margin:0 auto; padding:0 1.5rem; display:grid; grid-template-columns:1fr; gap:18px; }

/* HERO */
#section-team .overview-card--hero { position:relative; background:#fff; border-radius:18px; border:1px solid rgba(15,23,42,.06); box-shadow:0 8px 24px rgba(15,23,42,.06); padding:18px 20px; min-height:110px; display:flex; align-items:center; justify-content:center; text-align:center; overflow:hidden; }
#section-team .overview-card--hero::before { content:""; position:absolute; inset:0 0 auto 0; height:4px; background:linear-gradient(90deg,#4f46e5,#22c55e,#0ea5e9); }
#section-team .overview-title { margin:0; font-size:1.25rem; font-weight:800; color:#0f172a; }
#section-team .overview-subtitle { margin:.25rem 0 0; font-size:.9rem; color:#6b7280; }

/* MAIN CARD base */
#section-team .overview-card--full { position:relative; background:#fff; border-radius:18px; border:1px solid rgba(15,23,42,.06); box-shadow:0 8px 24px rgba(15,23,42,.06); padding:18px 20px; display:flex; flex-direction:column; min-height:170px; overflow:hidden; }
#section-team .overview-card--full::before { content:""; position:absolute; inset:0 0 auto 0; height:4px; background:linear-gradient(90deg,#4f46e5,#22c55e,#0ea5e9); }

/* Контролы (поиск + кнопки) */
.team-control-row { display:flex; gap:12px; align-items:center; margin:12px 0 8px; flex-wrap:wrap; }
.team-search { padding:10px 12px; border:1px solid #e6eef6; border-radius:10px; min-width:260px; width:320px; }
.team-control-actions { margin-left:auto; display:flex; gap:8px; align-items:center; }

/* TABLE WRAP */
.team-table-wrap { overflow:auto; margin-top:8px; border-radius:10px; background:#fff; }

/* DATEV-like table: видимые границы, четкие линии */
.team-table { width:100%; border-collapse:separate; border-spacing:0; font-size:0.95rem; color:#0f172a; box-shadow:0 0 0 1px rgba(226,232,240,1) inset; }
.team-table thead th {
  background:#f8fafc; color:#0f172a; font-weight:700; padding:2px 14px; text-align:left; border-bottom:2px solid #e6eef6; position:relative;
}
.team-table tbody td {
  padding:1px 14px; border-bottom:1px solid #eef2f5; vertical-align:middle; background:#fff;
}

/* Вертикальные линии между колонками — реализованы с помощью правой границы */
.team-table thead th:not(:last-child),
.team-table tbody td:not(:last-child) { border-right:1px solid #eef2f5; }

/* Zebra rows subtle */
.team-table tbody tr:nth-child(even) td { background:#fbfcfe; }

/* Small utility */
.text-center { text-align:center; }
.no-records { text-align:center; color:#6b7280; padding:18px 0; }

/* Бейджи и статусы */
.badge { display:inline-block; padding:4px 8px; border-radius:999px; font-weight:600; font-size:0.82rem; }
.badge-active { background:#ecfdf5; color:#065f46; }
.badge-blocked { background:#f3f4f6; color:#6b7280; }
.badge-inactive { background:#fef9c3; color:#92400e; }

/* Онлайн/оффлайн */
.online { color:#10b981; font-weight:600; }
.offline { color:#9ca3af; }

/* Actions cell */
.team-actions-cell .btn { margin-right:6px; border-radius:8px; padding:6px 10px; font-size:0.85rem; }

/* Footer actions */
.team-actions { display:flex; justify-content:space-between; align-items:center; margin-top:12px; padding-top:8px; border-top:1px solid #eef2f5; }
.team-load-status { color:#6b7280; }
.team-no-more { color:#6b7280; }

/* Responsive */




/* 
   DATEV-like table: чёткие линии, контрастный заголов, компактная типографика,
   лёгкая зебра, вертикальные разделители, responsive-скролл.
*/

/* Баз */
.team-table-card {
  padding: 0.75rem;
  background: #fff;
  border-radius: 10px;
}

/* Обёртка с горизонт. скроллом */
.team-table-wrap {
  overflow-x: auto;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 0 0 1px rgba(226,232,240,1) inset;
  margin-top: 0.5rem;
}

/* Таблица */
.team-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  font-size: 0.95rem;
  color: #0f172a;
  min-width: 900px;
}

/* Заголовок столбцов */
.team-table thead th {
  background: #f8fafc;
  color: #0f172a;
  font-weight: 700;
  text-align: left;
  padding: 1px 14px;
  border-bottom: 2px solid #e6eef6;
  vertical-align: middle;
  white-space: nowrap;
}

/* Ячейки тела */
.team-table tbody td {
  padding: 1px 14px;
  vertical-align: middle;
  background: #fff;
  border-bottom: 1px solid #eef2f5;
  white-space: nowrap;
}

/* Вертикальные разделители */
.team-table thead th:not(:last-child),
.team-table tbody td:not(:last-child) {
  border-right: 1px solid #eef2f5;
}

/* Zebra (тонкая) */
.team-table tbody tr:nth-child(even) td {
  background: #fbfcfe;
}

/* Аккуратные границы вокруг таблицы */
.team-table-wrap .team-table {
  box-shadow: none;
}

/* Классы колонок */
.team-name {
  font-weight: 600;
  color: #0b1220;
}
.team-email {
  color: #6b7280;
  font-size: 0.9rem;
  margin-top: 3px;
}
.team-phone {
  color: #0f172a;
}
.team-account .badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
}
.badge-active {
  background: #e6f4ea;
  color: #0b6b2f;
  border: 1px solid rgba(11,107,47,0.08);
}
.badge-blocked {
  background: #fff0f0;
  color: #8b1e1e;
  border: 1px solid rgba(139,30,30,0.08);
}
.team-online .online {
  color: #0b6b2f;
  font-weight: 600;
}
.team-online .offline {
  color: #6b7280;
}

/* Числовые колонки */
.team-number {
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: #0f172a;
}

/* Действия (кнопки) */
.team-actions-cell .btn {
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-right: 6px;
}
.team-actions-cell .btn:last-child {
  margin-right: 0;
}

/* Footer controls */
.team-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 4px 0 4px;
}
.team-load-status {
  color: #6b7280;
  font-size: 0.9rem;
}
.team-load-controls {}

/* Search / controls row */
.team-control-row {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 4px 0 4px;
}
.team-search {
  flex: 1 1 420px;
  max-width: 720px;
  padding: 10px 12px;
  border: 1px solid #e6eef6;
  border-radius: 8px;
  background: #fff;
  color: #0f172a;
}
.team-control-actions { display: flex; gap: 8px; align-items: center; }

/* Нет записей */
.no-records {
  padding: 20px;
  text-align: center;
  color: #6b7280;
  background: transparent;
}

/* Вспомогательные: скрытие колонок на мобильных */
@media (max-width: 900px) {
  .team-table { min-width: 780px; }
  .team-control-row { flex-direction: column; align-items: stretch; gap: 8px; }
  .team-search { width:100% !important; max-width:100% !important; min-width:0 !important; box-sizing:border-box !important; }
}
@media (max-width: 700px) {
  .team-table { min-width: 640px; font-size: 0.9rem; }
  .col-hide-sm { display: none; } /* при необходимости назначайте класс колонкам */
  .team-card-title { font-size: 1rem; }
}

/* Utilities */
.visually-hidden {
  position: absolute !important;
  height: 1px; width: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap; /* added line */
}




/* Уточнённые границы и фон заголовка */
.team-table thead th {
  background: #eef3f7;               /* светло‑серый фон заголовка */
  color: #0f172a;
  font-weight: 700;
  text-align: left;
  padding: 1px 14px;
  border-bottom: 2px solid #cfdbe6; /* более выраженная нижняя граница */
  vertical-align: middle;
  white-space: nowrap;
}

/* Более выраженные вертикальные линии и нижняя граница ячеек */
.team-table thead th:not(:last-child),
.team-table tbody td:not(:last-child) {
  border-right: 1px solid #d7e2ea;   /* немного темнее */
}
.team-table tbody td {
  padding: 1px 14px;
  vertical-align: middle;
  background: #fff;
  border-bottom: 1.5px solid #e6eef6; /* утолщённая нижняя граница */
  white-space: nowrap;
}

/* Немного подчёркивающая рамка всей таблицы */
.team-table {
  box-shadow: 0 0 0 1px rgba(189, 209, 221, 0.8) inset;
}
/* Уточнение: более заметное поле поиска, короче, и убрать горизонт. скролл на ПК */

/* Поиск: более контрастная рамка и меньшая ширина */
.team-search {
  max-width: 360px;                 /* короче, чем было */
  padding: 10px 12px;
  border: 1.5px solid #c7d7e3;     /* темнее и толще граница */
  border-radius: 10px;
  background: #fff;
  box-shadow: none;
  transition: border-color .15s, box-shadow .15s;
}
.team-search:focus {
  outline: none;
  border-color: #7aa7d0;
  box-shadow: 0 0 0 4px rgba(122,167,208,0.08);
}

/* Сделать рамки ячеек ещё заметнее (альтернатива, если нужно сильнее) */
.team-table thead th,
.team-table tbody td {
  border-color: #d0dbe4;
}
.team-table thead th {
  border-bottom: 2px solid #bfcfd9; /* ещё более выраженная линия под заголовком */
}

/* На больших экранах убираем горизонт. скролл: таблица подгибается под контейнер.
   При необходимости горизонт. скролл останется на узких экранах. */
@media (min-width: 1100px) {
  .team-table-wrap {
    overflow-x: visible;           /* убираем скролл на ПК */
  }
  .team-table {
    table-layout: fixed;           /* равномерное распределение колонок */
    width: 100% !important;
    min-width: 0;                  /* чтобы не форсить скролл */
  }
  /* Подгоняем поведение колонок — текст переносится внутри ячеек */
  .team-table thead th,
  .team-table tbody td {
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* На планшетах/мобильных оставляем скролл, чтобы таблица не ломалась */
@media (max-width: 1099px) {
  .team-table { min-width: 780px; } /* оставляем горизонт. скролл для узких экранов */
}

/* ===== Empty State ===== */
.team-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 72px 32px;
  text-align: center;
}
.team-empty-icon { font-size: 52px; margin-bottom: 16px; opacity: 0.5; }
.team-empty-title { font-size: 1.2rem; font-weight: 600; margin-bottom: 8px; color: #1a1a2e; }
.team-empty-text { color: #6b7280; max-width: 400px; margin: 0 auto 24px; line-height: 1.6; }
.team-empty-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

/* ===== STICKY COLUMNS + HORIZONTAL SCROLL ===== */
/* Убираем override overflow-x: visible на десктопе — нам нужен скролл */
@media (min-width: 1100px) {
  .team-table-wrap {
    overflow-x: auto !important;
  }
  .team-table {
    table-layout: auto !important;
    min-width: 1200px !important;
    width: max-content !important;
  }
  .team-table thead th,
  .team-table tbody td {
    white-space: nowrap !important;
  }
}

/* Sticky левая колонка (имя) */
.col-sticky-left {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff;
  min-width: 180px;
  box-shadow: 2px 0 6px rgba(0,0,0,0.07);
}

/* Sticky правая колонка (действия) */
.col-sticky-right {
  position: sticky;
  right: 0;
  z-index: 1;
  background: #fff;
  min-width: 100px;
  text-align: center;
  box-shadow: -2px 0 6px rgba(0,0,0,0.07);
}

/* Заголовки sticky колонок */
thead .col-sticky-left,
thead .col-sticky-right {
  background: #eef3f7;
  z-index: 3;
}

/* Hover для sticky ячеек */
.team-row:hover .col-sticky-left,
.team-row:hover .col-sticky-right {
  background: #f0f4ff;
}
.team-table tbody tr:nth-child(even):hover .col-sticky-left,
.team-table tbody tr:nth-child(even):hover .col-sticky-right {
  background: #f0f4ff;
}

/* Кнопки действий в одну строку */

/* ===== ACTION BUTTONS ===== */
.actions-cell {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 5px !important;
  padding: 8px 10px !important;
  overflow: visible !important;
}
.col-sticky-right {
  overflow: visible !important;
}
.btn-icon {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 30px !important;
  height: 30px !important;
  border-radius: 8px !important;
  border: 1.5px solid transparent !important;
  background: transparent !important;
  cursor: pointer !important;
  transition: all .15s !important;
  font-size: 0.95rem !important;
  padding: 0 !important;
  text-decoration: none !important;
  position: relative !important;
}
.btn-icon--profile { color: #3b82f6 !important; border-color: #bfdbfe !important; background: #eff6ff !important; }
.btn-icon--profile:hover { background: #3b82f6 !important; color: #fff !important; border-color: #3b82f6 !important; box-shadow: 0 2px 8px rgba(59,130,246,.35) !important; transform: translateY(-1px) !important; }

.btn-icon--edit { color: #6366f1 !important; border-color: #c7d2fe !important; background: #eef2ff !important; }
.btn-icon--edit:hover { background: #6366f1 !important; color: #fff !important; border-color: #6366f1 !important; box-shadow: 0 2px 8px rgba(99,102,241,.35) !important; transform: translateY(-1px) !important; }

.btn-icon--block { color: #f97316 !important; border-color: #fed7aa !important; background: #fff7ed !important; }
.btn-icon--block:hover { background: #f97316 !important; color: #fff !important; border-color: #f97316 !important; box-shadow: 0 2px 8px rgba(249,115,22,.35) !important; transform: translateY(-1px) !important; }

.btn-icon--unblock { color: #22c55e !important; border-color: #bbf7d0 !important; background: #f0fdf4 !important; }
.btn-icon--unblock:hover { background: #22c55e !important; color: #fff !important; border-color: #22c55e !important; box-shadow: 0 2px 8px rgba(34,197,94,.35) !important; transform: translateY(-1px) !important; }



/* ===== STICKY FIX + SCROLL ===== */
.team-table-wrap {
  overflow: visible !important;
}
.team-table-scroll {
  overflow-x: auto !important;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
}
.team-table-scroll::-webkit-scrollbar { height: 8px; }
.team-table-scroll::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 4px; }
.team-table-scroll::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 4px; }
.team-table-scroll::-webkit-scrollbar-thumb:hover { background: #64748b; }

/* Sticky thead */
.team-table thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  background: #eef3f7;
}
thead th.col-sticky-left  { z-index: 5; }
thead th.col-sticky-right { z-index: 5; }

/* Верхний скроллбар */
.team-table-top-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  margin-bottom: 2px;
  border-radius: 6px 6px 0 0;
}
.team-table-top-scroll::-webkit-scrollbar { height: 8px; }
.team-table-top-scroll::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 4px; }
.team-table-top-scroll::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 4px; }

/* Profile page */
.ep-card--full { grid-column: 1 / -1; }
.ep-card--full .ep-fields { grid-template-columns: repeat(4, 1fr); }

/* Export dropdown */
.export-dropdown { position: relative; display: inline-block; }
.export-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.1);
  min-width: 160px;
  z-index: 999;
  overflow: hidden;
}
.export-menu.show { display: block; }
.export-item {
  display: flex; align-items: center;
  padding: 10px 16px;
  color: #374151;
  text-decoration: none;
  font-size: 0.875rem;
  transition: background .15s;
}
.export-item:hover { background: #f8fafc; color: #4f46e5; }

/* =====================================================================
   MOBILE CARDS — таблица превращается в карточки на мобильном
   ===================================================================== */

/* =====================================================================
   MOBILE — единственный медиазапрос
   ===================================================================== */
@media (max-width: 768px) {

  /* Кнопки и контролы — столбиком */
  .team-control-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }
  .team-search {
    width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }
  .team-control-actions {
    margin-left: 0 !important;
    flex-direction: column !important;
    width: 100% !important;
    gap: 8px !important;
  }
  .team-control-actions > *,
  .team-control-actions button,
  .team-control-actions .export-dropdown,
  #export-toggle {
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Шапка страницы — столбиком */
  .team-page-controls {
    flex-direction: column !important;
    gap: 10px !important;
  }
  .team-page-controls > div {
    width: 100% !important;
    flex-direction: column !important;
    gap: 8px !important;
  }
  .team-page-controls button {
    width: 100% !important;
  }

  /* Таблица → карточки */
  .team-table-wrap,
  .team-table-scroll {
    overflow: visible !important;
    width: 100% !important;
  }

  .team-table {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  .team-table thead { display: none !important; }
  .team-table tbody { display: block !important; }

  /* Каждая строка = карточка */
  .team-table tbody tr {
    display: block !important;
    background: #fff;
    border-radius: 14px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    margin-bottom: 12px;
    overflow: hidden;
  }

  /* Шапка карточки — имя/email, всегда видна */
  .team-table tbody tr td.col-sticky-left {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 14px 16px !important;
    border: none !important;
    border-bottom: 2px solid #e2e8f0 !important;
    background: #fff !important;
    position: static !important;
    cursor: pointer;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .team-table tbody tr td.col-sticky-left .team-name,
  .team-table tbody tr td.col-sticky-left .team-email {
    white-space: normal !important;
    word-break: break-word !important;
  }

  /* Стрелка-индикатор */
  .team-table tbody tr td.col-sticky-left::after {
    content: "▾";
    font-size: 1.5rem;
    color: #94a3b8;
    transition: transform 0.2s;
    margin-left: 8px;
    flex-shrink: 0;
  }
  .team-table tbody tr.mob-expanded td.col-sticky-left::after {
    transform: rotate(180deg);
  }

  /* Скрытые поля */
  .team-table tbody tr td:not(.col-sticky-left):not(.col-sticky-right) {
    display: none !important;
  }
  .team-table tbody tr.mob-expanded td:not(.col-sticky-left):not(.col-sticky-right) {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 8px 16px !important;
    border: none !important;
    border-bottom: 1px solid #f1f5f9 !important;
    border-right: none !important;
    background: #fafbff !important;
    font-size: 0.875rem;
    box-sizing: border-box !important;
  }
  .team-table tbody tr.mob-expanded td:not(.col-sticky-left):not(.col-sticky-right)::before {
    content: attr(data-label);
    font-weight: 700;
    color: #64748b;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex: 0 0 45%;
  }

  /* Кнопки действий */
  .team-table tbody tr td.col-sticky-right {
    display: none !important;
  }
  .team-table tbody tr.mob-expanded td.col-sticky-right {
    display: flex !important;
    justify-content: flex-end !important;
    padding: 12px 16px !important;
    border: none !important;
    border-top: 2px solid #e2e8f0 !important;
    background: #fff !important;
    position: static !important;
  }
}
