/* ============================================================
   SDP tables and lists redesigned
   Scope: body.sdp-redesigned. CSS-only foundation for data-heavy screens.
   ============================================================ */

body.sdp-redesigned {
  --sdp-table-surface: var(--sdp-preview-panel, #FFFEFA);
  --sdp-table-ink: var(--sdp-preview-ink, #172033);
  --sdp-table-muted: var(--sdp-preview-muted, #697386);
  --sdp-table-line: var(--sdp-preview-line, rgba(31, 45, 74, 0.12));
  --sdp-table-navy: var(--sdp-preview-navy, #17243C);
  --sdp-table-teal: var(--sdp-preview-teal, #1D766F);
  --sdp-table-gold: var(--sdp-preview-gold, #B5904A);
}

body.sdp-redesigned .table-container,
body.sdp-redesigned .table-container-premium,
body.sdp-redesigned .data-table-container,
body.sdp-redesigned .list-container {
  box-sizing: border-box;
  width: 100%;
  margin: 0 0 18px !important;
  overflow: hidden;
  border-radius: 8px !important;
  background: var(--sdp-table-surface) !important;
  border: 1px solid rgba(31, 45, 74, 0.10) !important;
  box-shadow: 0 1px 1px rgba(31, 45, 74, 0.04), 0 12px 28px rgba(31, 45, 74, 0.08) !important;
}

body.sdp-redesigned .table-header-premium,
body.sdp-redesigned .table-toolbar,
body.sdp-redesigned .list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(31, 45, 74, 0.09);
  background: linear-gradient(180deg, rgba(255, 254, 250, 0.96), rgba(244, 241, 232, 0.42));
}

body.sdp-redesigned .table-header-premium h2,
body.sdp-redesigned .table-toolbar h2,
body.sdp-redesigned .list-header h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  margin: 0;
  color: var(--sdp-table-ink) !important;
  font-family: var(--font-family-base);
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0;
}

body.sdp-redesigned .table-header-premium h2 svg,
body.sdp-redesigned .table-toolbar h2 svg,
body.sdp-redesigned .list-header h2 svg {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  color: var(--sdp-table-gold);
}

body.sdp-redesigned .table-actions,
body.sdp-redesigned .list-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

body.sdp-redesigned .table-container > table,
body.sdp-redesigned .table-container-premium > table,
body.sdp-redesigned .data-table,
body.sdp-redesigned .table-premium {
  width: 100%;
  min-width: 720px;
  border-collapse: separate !important;
  border-spacing: 0 !important;
  background: transparent !important;
  color: var(--sdp-table-ink) !important;
  font-family: var(--font-family-base);
}

body.sdp-redesigned .table-container,
body.sdp-redesigned .table-container-premium {
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(181, 144, 74, 0.46) transparent;
}

body.sdp-redesigned .table-container::-webkit-scrollbar,
body.sdp-redesigned .table-container-premium::-webkit-scrollbar {
  height: 9px;
}

body.sdp-redesigned .table-container::-webkit-scrollbar-thumb,
body.sdp-redesigned .table-container-premium::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
  background-color: rgba(181, 144, 74, 0.46);
}

body.sdp-redesigned .data-table thead th,
body.sdp-redesigned .table-premium thead th,
body.sdp-redesigned .table-container table thead th,
body.sdp-redesigned .table-container-premium table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 12px 14px !important;
  border-bottom: 1px solid rgba(31, 45, 74, 0.12) !important;
  background: #F3E6C7 !important;
  color: #17243C !important;
  font-size: 0.74rem;
  font-weight: 900;
  line-height: 1.2;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

body.sdp-redesigned .data-table tbody td,
body.sdp-redesigned .table-premium tbody td,
body.sdp-redesigned .table-container table tbody td,
body.sdp-redesigned .table-container-premium table tbody td {
  padding: 13px 14px !important;
  border-bottom: 1px solid rgba(31, 45, 74, 0.08) !important;
  color: var(--sdp-table-ink) !important;
  font-size: 0.88rem;
  line-height: 1.35;
  vertical-align: middle;
  background: transparent !important;
}

body.sdp-redesigned .data-table tbody tr,
body.sdp-redesigned .table-premium tbody tr,
body.sdp-redesigned .table-container table tbody tr,
body.sdp-redesigned .table-container-premium table tbody tr {
  transition: background-color 140ms ease;
}

body.sdp-redesigned .data-table tbody tr:nth-child(even),
body.sdp-redesigned .table-premium tbody tr:nth-child(even),
body.sdp-redesigned .table-container table tbody tr:nth-child(even),
body.sdp-redesigned .table-container-premium table tbody tr:nth-child(even) {
  background: rgba(31, 45, 74, 0.025) !important;
}

body.sdp-redesigned .data-table tbody tr:hover,
body.sdp-redesigned .table-premium tbody tr:hover,
body.sdp-redesigned .table-container table tbody tr:hover,
body.sdp-redesigned .table-container-premium table tbody tr:hover {
  background: rgba(181, 144, 74, 0.10) !important;
}

body.sdp-redesigned .data-table tbody tr:last-child td,
body.sdp-redesigned .table-premium tbody tr:last-child td,
body.sdp-redesigned .table-container table tbody tr:last-child td,
body.sdp-redesigned .table-container-premium table tbody tr:last-child td {
  border-bottom: 0 !important;
}

body.sdp-redesigned .table-footer-premium,
body.sdp-redesigned .table-footer,
body.sdp-redesigned .pagination,
body.sdp-redesigned .list-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-top: 1px solid rgba(31, 45, 74, 0.09);
  color: var(--sdp-table-muted) !important;
  font-size: 0.82rem;
  background: rgba(244, 241, 232, 0.44);
}

body.sdp-redesigned .table-footer-premium strong,
body.sdp-redesigned .table-footer strong {
  color: var(--sdp-table-ink);
  font-weight: 900;
}

body.sdp-redesigned .list-grid,
body.sdp-redesigned .cards-list,
body.sdp-redesigned .item-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

body.sdp-redesigned .list-item,
body.sdp-redesigned .data-list-item,
body.sdp-redesigned .student-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 58px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--sdp-table-surface);
  border: 1px solid rgba(31, 45, 74, 0.10);
  box-shadow: 0 1px 1px rgba(31, 45, 74, 0.04);
}

body.sdp-redesigned .list-item:hover,
body.sdp-redesigned .data-list-item:hover,
body.sdp-redesigned .student-row:hover {
  border-color: rgba(181, 144, 74, 0.28);
  box-shadow: 0 10px 22px rgba(31, 45, 74, 0.08);
}

/* Avatares pequenos APENAS dentro de linhas/itens de lista — escopo restrito.
   Sem o escopo, esse seletor encolhia a foto grande da ficha em /pages/consulta-ficha. */
body.sdp-redesigned .list-item .avatar,
body.sdp-redesigned .list-item .student-photo,
body.sdp-redesigned .list-item .foto-aluno,
body.sdp-redesigned .data-list-item .avatar,
body.sdp-redesigned .data-list-item .student-photo,
body.sdp-redesigned .data-list-item .foto-aluno,
body.sdp-redesigned .student-row .avatar,
body.sdp-redesigned .student-row .student-photo,
body.sdp-redesigned .student-row .foto-aluno {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  object-fit: cover;
  background: rgba(31, 45, 74, 0.08);
  border: 1px solid rgba(31, 45, 74, 0.08);
}

body.sdp-redesigned .row-actions,
body.sdp-redesigned .action-buttons {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

body.sdp-redesigned .row-actions .btn,
body.sdp-redesigned .action-buttons .btn,
body.sdp-redesigned .table-actions .btn,
body.sdp-redesigned .table-actions .btn-premium {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 0.78rem;
}

[data-theme="dark"] body.sdp-redesigned .table-header-premium,
[data-theme="dark"] body.sdp-redesigned .table-toolbar,
[data-theme="dark"] body.sdp-redesigned .list-header {
  background: linear-gradient(180deg, rgba(18, 29, 46, 0.96), rgba(13, 21, 35, 0.72));
  border-bottom-color: rgba(255, 255, 255, 0.10);
}

[data-theme="dark"] body.sdp-redesigned .table-container,
[data-theme="dark"] body.sdp-redesigned .table-container-premium,
[data-theme="dark"] body.sdp-redesigned .data-table-container,
[data-theme="dark"] body.sdp-redesigned .list-container,
[data-theme="dark"] body.sdp-redesigned .list-item,
[data-theme="dark"] body.sdp-redesigned .data-list-item,
[data-theme="dark"] body.sdp-redesigned .student-row {
  border-color: var(--sdp-table-line) !important;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04), 0 18px 42px rgba(0, 0, 0, 0.30) !important;
}

[data-theme="dark"] body.sdp-redesigned .data-table thead th,
[data-theme="dark"] body.sdp-redesigned .table-premium thead th,
[data-theme="dark"] body.sdp-redesigned .table-container table thead th,
[data-theme="dark"] body.sdp-redesigned .table-container-premium table thead th {
  background: #1D2B43 !important;
  color: #F5F7FA !important;
  border-bottom-color: rgba(255, 255, 255, 0.12) !important;
}

[data-theme="dark"] body.sdp-redesigned .data-table tbody td,
[data-theme="dark"] body.sdp-redesigned .table-premium tbody td,
[data-theme="dark"] body.sdp-redesigned .table-container table tbody td,
[data-theme="dark"] body.sdp-redesigned .table-container-premium table tbody td {
  border-bottom-color: rgba(255, 255, 255, 0.08) !important;
}

[data-theme="dark"] body.sdp-redesigned .data-table tbody tr:nth-child(even),
[data-theme="dark"] body.sdp-redesigned .table-premium tbody tr:nth-child(even),
[data-theme="dark"] body.sdp-redesigned .table-container table tbody tr:nth-child(even),
[data-theme="dark"] body.sdp-redesigned .table-container-premium table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.025) !important;
}

[data-theme="dark"] body.sdp-redesigned .data-table tbody tr:hover,
[data-theme="dark"] body.sdp-redesigned .table-premium tbody tr:hover,
[data-theme="dark"] body.sdp-redesigned .table-container table tbody tr:hover,
[data-theme="dark"] body.sdp-redesigned .table-container-premium table tbody tr:hover,
[data-theme="dark"] body.sdp-redesigned .list-item:hover,
[data-theme="dark"] body.sdp-redesigned .data-list-item:hover,
[data-theme="dark"] body.sdp-redesigned .student-row:hover {
  background: rgba(181, 144, 74, 0.14) !important;
}

[data-theme="dark"] body.sdp-redesigned .table-footer-premium,
[data-theme="dark"] body.sdp-redesigned .table-footer,
[data-theme="dark"] body.sdp-redesigned .pagination,
[data-theme="dark"] body.sdp-redesigned .list-footer {
  background: rgba(13, 21, 35, 0.64);
  border-top-color: rgba(255, 255, 255, 0.10);
}

@media (max-width: 768px) {
  body.sdp-redesigned .table-header-premium,
  body.sdp-redesigned .table-toolbar,
  body.sdp-redesigned .list-header,
  body.sdp-redesigned .table-footer-premium,
  body.sdp-redesigned .table-footer,
  body.sdp-redesigned .pagination,
  body.sdp-redesigned .list-footer {
    align-items: stretch;
    flex-direction: column;
    padding: 14px;
  }

  body.sdp-redesigned .table-actions,
  body.sdp-redesigned .list-actions {
    justify-content: stretch;
  }

  body.sdp-redesigned .table-actions > *,
  body.sdp-redesigned .list-actions > * {
    flex: 1 1 140px;
  }

  body.sdp-redesigned .data-table tbody td,
  body.sdp-redesigned .table-premium tbody td,
  body.sdp-redesigned .table-container table tbody td,
  body.sdp-redesigned .table-container-premium table tbody td {
    padding: 11px 12px !important;
  }

  body.sdp-redesigned .list-item,
  body.sdp-redesigned .data-list-item,
  body.sdp-redesigned .student-row {
    grid-template-columns: auto 1fr;
  }

  body.sdp-redesigned .row-actions,
  body.sdp-redesigned .action-buttons {
    grid-column: 1 / -1;
    justify-content: stretch;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.sdp-redesigned .data-table tbody tr,
  body.sdp-redesigned .table-premium tbody tr,
  body.sdp-redesigned .table-container table tbody tr,
  body.sdp-redesigned .table-container-premium table tbody tr {
    transition: none;
  }
}
